babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344
  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. fullscreen: boolean;
  262. mozFullScreen: boolean;
  263. msIsFullScreen: boolean;
  264. readonly webkitIsFullScreen: boolean;
  265. readonly pointerLockElement: Element;
  266. mozPointerLockElement: HTMLElement;
  267. msPointerLockElement: HTMLElement;
  268. webkitPointerLockElement: HTMLElement;
  269. }
  270. interface HTMLCanvasElement {
  271. requestPointerLock(): void;
  272. msRequestPointerLock?(): void;
  273. mozRequestPointerLock?(): void;
  274. webkitRequestPointerLock?(): void;
  275. }
  276. interface CanvasRenderingContext2D {
  277. msImageSmoothingEnabled: boolean;
  278. }
  279. interface WebGLBuffer {
  280. references: number;
  281. capacity: number;
  282. is32Bits: boolean;
  283. }
  284. interface WebGLProgram {
  285. transformFeedback?: WebGLTransformFeedback | null;
  286. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  287. }
  288. interface MouseEvent {
  289. mozMovementX: number;
  290. mozMovementY: number;
  291. webkitMovementX: number;
  292. webkitMovementY: number;
  293. msMovementX: number;
  294. msMovementY: number;
  295. }
  296. interface Navigator {
  297. mozGetVRDevices: (any: any) => any;
  298. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  301. webkitGetGamepads(): Gamepad[];
  302. msGetGamepads(): Gamepad[];
  303. webkitGamepads(): Gamepad[];
  304. }
  305. interface HTMLVideoElement {
  306. mozSrcObject: any;
  307. }
  308. interface Screen {
  309. readonly orientation: string;
  310. readonly mozOrientation: string;
  311. }
  312. interface Math {
  313. fround(x: number): number;
  314. imul(a: number, b: number): number;
  315. }
  316. interface EXT_disjoint_timer_query {
  317. QUERY_COUNTER_BITS_EXT: number;
  318. TIME_ELAPSED_EXT: number;
  319. TIMESTAMP_EXT: number;
  320. GPU_DISJOINT_EXT: number;
  321. QUERY_RESULT_EXT: number;
  322. QUERY_RESULT_AVAILABLE_EXT: number;
  323. queryCounterEXT(query: WebGLQuery, target: number): void;
  324. createQueryEXT(): WebGLQuery;
  325. beginQueryEXT(target: number, query: WebGLQuery): void;
  326. endQueryEXT(target: number): void;
  327. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  328. deleteQueryEXT(query: WebGLQuery): void;
  329. }
  330. interface WebGLUniformLocation {
  331. _currentState: any;
  332. }
  333. declare module BABYLON {
  334. /**
  335. * Defines how a node can be built from a string name.
  336. */
  337. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  338. /**
  339. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  340. */
  341. class Node implements IBehaviorAware<Node> {
  342. private static _NodeConstructors;
  343. /**
  344. * Add a new node constructor
  345. * @param type defines the type name of the node to construct
  346. * @param constructorFunc defines the constructor function
  347. */
  348. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  349. /**
  350. * Returns a node constructor based on type name
  351. * @param type defines the type name
  352. * @param name defines the new node name
  353. * @param scene defines the hosting scene
  354. * @param options defines optional options to transmit to constructors
  355. * @returns the new constructor or null
  356. */
  357. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  358. /**
  359. * Gets or sets the name of the node
  360. */
  361. name: string;
  362. /**
  363. * Gets or sets the id of the node
  364. */
  365. id: string;
  366. /**
  367. * Gets or sets the unique id of the node
  368. */
  369. uniqueId: number;
  370. /**
  371. * Gets or sets a string used to store user defined state for the node
  372. */
  373. state: string;
  374. /**
  375. * Gets or sets an object used to store user defined information for the node
  376. */
  377. metadata: any;
  378. /**
  379. * Gets or sets a boolean used to define if the node must be serialized
  380. */
  381. doNotSerialize: boolean;
  382. /** @hidden */
  383. _isDisposed: boolean;
  384. /**
  385. * Gets a list of Animations associated with the node
  386. */
  387. animations: Animation[];
  388. protected _ranges: {
  389. [name: string]: Nullable<AnimationRange>;
  390. };
  391. /**
  392. * Callback raised when the node is ready to be used
  393. */
  394. onReady: (node: Node) => void;
  395. private _isEnabled;
  396. private _isParentEnabled;
  397. private _isReady;
  398. /** @hidden */
  399. _currentRenderId: number;
  400. private _parentRenderId;
  401. protected _childRenderId: number;
  402. /** @hidden */
  403. _waitingParentId: Nullable<string>;
  404. /** @hidden */
  405. _scene: Scene;
  406. /** @hidden */
  407. _cache: any;
  408. private _parentNode;
  409. private _children;
  410. /** @hidden */
  411. _worldMatrix: Matrix;
  412. /** @hidden */
  413. _worldMatrixDeterminant: number;
  414. /** @hidden */
  415. private _sceneRootNodesIndex;
  416. /**
  417. * Gets a boolean indicating if the node has been disposed
  418. * @returns true if the node was disposed
  419. */
  420. isDisposed(): boolean;
  421. /**
  422. * Gets or sets the parent of the node
  423. */
  424. parent: Nullable<Node>;
  425. private addToSceneRootNodes;
  426. private removeFromSceneRootNodes;
  427. private _animationPropertiesOverride;
  428. /**
  429. * Gets or sets the animation properties override
  430. */
  431. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  432. /**
  433. * Gets a string idenfifying the name of the class
  434. * @returns "Node" string
  435. */
  436. getClassName(): string;
  437. /**
  438. * An event triggered when the mesh is disposed
  439. */
  440. onDisposeObservable: Observable<Node>;
  441. private _onDisposeObserver;
  442. /**
  443. * Sets a callback that will be raised when the node will be disposed
  444. */
  445. onDispose: () => void;
  446. /**
  447. * Creates a new Node
  448. * @param name the name and id to be given to this node
  449. * @param scene the scene this node will be added to
  450. */
  451. constructor(name: string, scene?: Nullable<Scene>);
  452. /**
  453. * Gets the scene of the node
  454. * @returns a scene
  455. */
  456. getScene(): Scene;
  457. /**
  458. * Gets the engine of the node
  459. * @returns a Engine
  460. */
  461. getEngine(): Engine;
  462. private _behaviors;
  463. /**
  464. * Attach a behavior to the node
  465. * @see http://doc.babylonjs.com/features/behaviour
  466. * @param behavior defines the behavior to attach
  467. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  468. * @returns the current Node
  469. */
  470. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  471. /**
  472. * Remove an attached behavior
  473. * @see http://doc.babylonjs.com/features/behaviour
  474. * @param behavior defines the behavior to attach
  475. * @returns the current Node
  476. */
  477. removeBehavior(behavior: Behavior<Node>): Node;
  478. /**
  479. * Gets the list of attached behaviors
  480. * @see http://doc.babylonjs.com/features/behaviour
  481. */
  482. readonly behaviors: Behavior<Node>[];
  483. /**
  484. * Gets an attached behavior by name
  485. * @param name defines the name of the behavior to look for
  486. * @see http://doc.babylonjs.com/features/behaviour
  487. * @returns null if behavior was not found else the requested behavior
  488. */
  489. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  490. /**
  491. * Returns the latest update of the World matrix
  492. * @returns a Matrix
  493. */
  494. getWorldMatrix(): Matrix;
  495. /** @hidden */
  496. _getWorldMatrixDeterminant(): number;
  497. /**
  498. * Returns directly the latest state of the mesh World matrix.
  499. * A Matrix is returned.
  500. */
  501. readonly worldMatrixFromCache: Matrix;
  502. /** @hidden */
  503. _initCache(): void;
  504. /** @hidden */
  505. updateCache(force?: boolean): void;
  506. /** @hidden */
  507. _updateCache(ignoreParentClass?: boolean): void;
  508. /** @hidden */
  509. _isSynchronized(): boolean;
  510. /** @hidden */
  511. _markSyncedWithParent(): void;
  512. /** @hidden */
  513. isSynchronizedWithParent(): boolean;
  514. /** @hidden */
  515. isSynchronized(): boolean;
  516. /**
  517. * Is this node ready to be used/rendered
  518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  519. * @return true if the node is ready
  520. */
  521. isReady(completeCheck?: boolean): boolean;
  522. /**
  523. * Is this node enabled?
  524. * 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
  525. * @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
  526. * @return whether this node (and its parent) is enabled
  527. */
  528. isEnabled(checkAncestors?: boolean): boolean;
  529. /** @hidden */
  530. protected _syncParentEnabledState(): void;
  531. /**
  532. * Set the enabled state of this node
  533. * @param value defines the new enabled state
  534. */
  535. setEnabled(value: boolean): void;
  536. /**
  537. * Is this node a descendant of the given node?
  538. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  539. * @param ancestor defines the parent node to inspect
  540. * @returns a boolean indicating if this node is a descendant of the given node
  541. */
  542. isDescendantOf(ancestor: Node): boolean;
  543. /** @hidden */
  544. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  545. /**
  546. * Will return all nodes that have this node as ascendant
  547. * @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
  548. * @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
  549. * @return all children nodes of all types
  550. */
  551. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  552. /**
  553. * Get all child-meshes of this node
  554. * @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
  555. * @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
  556. * @returns an array of AbstractMesh
  557. */
  558. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  559. /**
  560. * Get all child-transformNodes of this node
  561. * @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
  562. * @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
  563. * @returns an array of TransformNode
  564. */
  565. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  566. /**
  567. * Get all direct children of this node
  568. * @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
  569. * @returns an array of Node
  570. */
  571. getChildren(predicate?: (node: Node) => boolean): Node[];
  572. /** @hidden */
  573. _setReady(state: boolean): void;
  574. /**
  575. * Get an animation by name
  576. * @param name defines the name of the animation to look for
  577. * @returns null if not found else the requested animation
  578. */
  579. getAnimationByName(name: string): Nullable<Animation>;
  580. /**
  581. * Creates an animation range for this node
  582. * @param name defines the name of the range
  583. * @param from defines the starting key
  584. * @param to defines the end key
  585. */
  586. createAnimationRange(name: string, from: number, to: number): void;
  587. /**
  588. * Delete a specific animation range
  589. * @param name defines the name of the range to delete
  590. * @param deleteFrames defines if animation frames from the range must be deleted as well
  591. */
  592. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  593. /**
  594. * Get an animation range by name
  595. * @param name defines the name of the animation range to look for
  596. * @returns null if not found else the requested animation range
  597. */
  598. getAnimationRange(name: string): Nullable<AnimationRange>;
  599. /**
  600. * Will start the animation sequence
  601. * @param name defines the range frames for animation sequence
  602. * @param loop defines if the animation should loop (false by default)
  603. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  604. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  605. * @returns the object created for this animation. If range does not exist, it will return null
  606. */
  607. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  608. /**
  609. * Serialize animation ranges into a JSON compatible object
  610. * @returns serialization object
  611. */
  612. serializeAnimationRanges(): any;
  613. /**
  614. * Computes the world matrix of the node
  615. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  616. * @returns the world matrix
  617. */
  618. computeWorldMatrix(force?: boolean): Matrix;
  619. /**
  620. * Releases resources associated with this node.
  621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  623. */
  624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  625. /**
  626. * Parse animation range data from a serialization object and store them into a given node
  627. * @param node defines where to store the animation ranges
  628. * @param parsedNode defines the serialization object to read data from
  629. * @param scene defines the hosting scene
  630. */
  631. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  632. }
  633. }
  634. declare module BABYLON {
  635. /**
  636. * Define an interface for all classes that will hold resources
  637. */
  638. interface IDisposable {
  639. /**
  640. * Releases all held resources
  641. */
  642. dispose(): void;
  643. }
  644. /**
  645. * This class is used by the onRenderingGroupObservable
  646. */
  647. class RenderingGroupInfo {
  648. /**
  649. * The Scene that being rendered
  650. */
  651. scene: Scene;
  652. /**
  653. * The camera currently used for the rendering pass
  654. */
  655. camera: Nullable<Camera>;
  656. /**
  657. * The ID of the renderingGroup being processed
  658. */
  659. renderingGroupId: number;
  660. }
  661. /** Interface defining initialization parameters for Scene class */
  662. interface SceneOptions {
  663. /**
  664. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  665. * It will improve performance when the number of geometries becomes important.
  666. */
  667. useGeometryIdsMap?: boolean;
  668. /**
  669. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  670. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  671. */
  672. useMaterialMeshMap?: boolean;
  673. /**
  674. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  675. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  676. */
  677. useClonedMeshhMap?: boolean;
  678. }
  679. /**
  680. * Represents a scene to be rendered by the engine.
  681. * @see http://doc.babylonjs.com/features/scene
  682. */
  683. class Scene extends AbstractScene implements IAnimatable {
  684. private static _uniqueIdCounter;
  685. /** The fog is deactivated */
  686. static readonly FOGMODE_NONE: number;
  687. /** The fog density is following an exponential function */
  688. static readonly FOGMODE_EXP: number;
  689. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  690. static readonly FOGMODE_EXP2: number;
  691. /** The fog density is following a linear function. */
  692. static readonly FOGMODE_LINEAR: number;
  693. /**
  694. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  696. */
  697. static MinDeltaTime: number;
  698. /**
  699. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  701. */
  702. static MaxDeltaTime: number;
  703. /**
  704. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  705. */
  706. autoClear: boolean;
  707. /**
  708. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  709. */
  710. autoClearDepthAndStencil: boolean;
  711. /**
  712. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  713. */
  714. clearColor: Color4;
  715. /**
  716. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  717. */
  718. ambientColor: Color3;
  719. /** @hidden */
  720. _environmentBRDFTexture: BaseTexture;
  721. /** @hidden */
  722. protected _environmentTexture: BaseTexture;
  723. /**
  724. * Texture used in all pbr material as the reflection texture.
  725. * As in the majority of the scene they are the same (exception for multi room and so on),
  726. * this is easier to reference from here than from all the materials.
  727. */
  728. /**
  729. * Texture used in all pbr material as the reflection texture.
  730. * As in the majority of the scene they are the same (exception for multi room and so on),
  731. * this is easier to set here than in all the materials.
  732. */
  733. environmentTexture: BaseTexture;
  734. /** @hidden */
  735. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  736. /**
  737. * Default image processing configuration used either in the rendering
  738. * Forward main pass or through the imageProcessingPostProcess if present.
  739. * As in the majority of the scene they are the same (exception for multi camera),
  740. * this is easier to reference from here than from all the materials and post process.
  741. *
  742. * No setter as we it is a shared configuration, you can set the values instead.
  743. */
  744. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  745. private _forceWireframe;
  746. /**
  747. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  748. */
  749. forceWireframe: boolean;
  750. private _forcePointsCloud;
  751. /**
  752. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  753. */
  754. forcePointsCloud: boolean;
  755. /**
  756. * Gets or sets the active clipplane 1
  757. */
  758. clipPlane: Nullable<Plane>;
  759. /**
  760. * Gets or sets the active clipplane 2
  761. */
  762. clipPlane2: Nullable<Plane>;
  763. /**
  764. * Gets or sets the active clipplane 3
  765. */
  766. clipPlane3: Nullable<Plane>;
  767. /**
  768. * Gets or sets the active clipplane 4
  769. */
  770. clipPlane4: Nullable<Plane>;
  771. /**
  772. * Gets or sets a boolean indicating if animations are enabled
  773. */
  774. animationsEnabled: boolean;
  775. private _animationPropertiesOverride;
  776. /**
  777. * Gets or sets the animation properties override
  778. */
  779. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  780. /**
  781. * Gets or sets a boolean indicating if a constant deltatime has to be used
  782. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  783. */
  784. useConstantAnimationDeltaTime: boolean;
  785. /**
  786. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  787. * Please note that it requires to run a ray cast through the scene on every frame
  788. */
  789. constantlyUpdateMeshUnderPointer: boolean;
  790. /**
  791. * Defines the HTML cursor to use when hovering over interactive elements
  792. */
  793. hoverCursor: string;
  794. /**
  795. * Defines the HTML default cursor to use (empty by default)
  796. */
  797. defaultCursor: string;
  798. /**
  799. * This is used to call preventDefault() on pointer down
  800. * in order to block unwanted artifacts like system double clicks
  801. */
  802. preventDefaultOnPointerDown: boolean;
  803. /**
  804. * This is used to call preventDefault() on pointer up
  805. * in order to block unwanted artifacts like system double clicks
  806. */
  807. preventDefaultOnPointerUp: boolean;
  808. /**
  809. * Gets or sets user defined metadata
  810. */
  811. metadata: any;
  812. /**
  813. * Gets the name of the plugin used to load this scene (null by default)
  814. */
  815. loadingPluginName: string;
  816. /**
  817. * Use this array to add regular expressions used to disable offline support for specific urls
  818. */
  819. disableOfflineSupportExceptionRules: RegExp[];
  820. /**
  821. * An event triggered when the scene is disposed.
  822. */
  823. onDisposeObservable: Observable<Scene>;
  824. private _onDisposeObserver;
  825. /** Sets a function to be executed when this scene is disposed. */
  826. onDispose: () => void;
  827. /**
  828. * An event triggered before rendering the scene (right after animations and physics)
  829. */
  830. onBeforeRenderObservable: Observable<Scene>;
  831. private _onBeforeRenderObserver;
  832. /** Sets a function to be executed before rendering this scene */
  833. beforeRender: Nullable<() => void>;
  834. /**
  835. * An event triggered after rendering the scene
  836. */
  837. onAfterRenderObservable: Observable<Scene>;
  838. private _onAfterRenderObserver;
  839. /** Sets a function to be executed after rendering this scene */
  840. afterRender: Nullable<() => void>;
  841. /**
  842. * An event triggered before animating the scene
  843. */
  844. onBeforeAnimationsObservable: Observable<Scene>;
  845. /**
  846. * An event triggered after animations processing
  847. */
  848. onAfterAnimationsObservable: Observable<Scene>;
  849. /**
  850. * An event triggered before draw calls are ready to be sent
  851. */
  852. onBeforeDrawPhaseObservable: Observable<Scene>;
  853. /**
  854. * An event triggered after draw calls have been sent
  855. */
  856. onAfterDrawPhaseObservable: Observable<Scene>;
  857. /**
  858. * An event triggered when the scene is ready
  859. */
  860. onReadyObservable: Observable<Scene>;
  861. /**
  862. * An event triggered before rendering a camera
  863. */
  864. onBeforeCameraRenderObservable: Observable<Camera>;
  865. private _onBeforeCameraRenderObserver;
  866. /** Sets a function to be executed before rendering a camera*/
  867. beforeCameraRender: () => void;
  868. /**
  869. * An event triggered after rendering a camera
  870. */
  871. onAfterCameraRenderObservable: Observable<Camera>;
  872. private _onAfterCameraRenderObserver;
  873. /** Sets a function to be executed after rendering a camera*/
  874. afterCameraRender: () => void;
  875. /**
  876. * An event triggered when active meshes evaluation is about to start
  877. */
  878. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  879. /**
  880. * An event triggered when active meshes evaluation is done
  881. */
  882. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when particles rendering is about to start
  885. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  886. */
  887. onBeforeParticlesRenderingObservable: Observable<Scene>;
  888. /**
  889. * An event triggered when particles rendering is done
  890. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  891. */
  892. onAfterParticlesRenderingObservable: Observable<Scene>;
  893. /**
  894. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  895. */
  896. onDataLoadedObservable: Observable<Scene>;
  897. /**
  898. * An event triggered when a camera is created
  899. */
  900. onNewCameraAddedObservable: Observable<Camera>;
  901. /**
  902. * An event triggered when a camera is removed
  903. */
  904. onCameraRemovedObservable: Observable<Camera>;
  905. /**
  906. * An event triggered when a light is created
  907. */
  908. onNewLightAddedObservable: Observable<Light>;
  909. /**
  910. * An event triggered when a light is removed
  911. */
  912. onLightRemovedObservable: Observable<Light>;
  913. /**
  914. * An event triggered when a geometry is created
  915. */
  916. onNewGeometryAddedObservable: Observable<Geometry>;
  917. /**
  918. * An event triggered when a geometry is removed
  919. */
  920. onGeometryRemovedObservable: Observable<Geometry>;
  921. /**
  922. * An event triggered when a transform node is created
  923. */
  924. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  925. /**
  926. * An event triggered when a transform node is removed
  927. */
  928. onTransformNodeRemovedObservable: Observable<TransformNode>;
  929. /**
  930. * An event triggered when a mesh is created
  931. */
  932. onNewMeshAddedObservable: Observable<AbstractMesh>;
  933. /**
  934. * An event triggered when a mesh is removed
  935. */
  936. onMeshRemovedObservable: Observable<AbstractMesh>;
  937. /**
  938. * An event triggered when a material is created
  939. */
  940. onNewMaterialAddedObservable: Observable<Material>;
  941. /**
  942. * An event triggered when a material is removed
  943. */
  944. onMaterialRemovedObservable: Observable<Material>;
  945. /**
  946. * An event triggered when a texture is created
  947. */
  948. onNewTextureAddedObservable: Observable<BaseTexture>;
  949. /**
  950. * An event triggered when a texture is removed
  951. */
  952. onTextureRemovedObservable: Observable<BaseTexture>;
  953. /**
  954. * An event triggered when render targets are about to be rendered
  955. * Can happen multiple times per frame.
  956. */
  957. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  958. /**
  959. * An event triggered when render targets were rendered.
  960. * Can happen multiple times per frame.
  961. */
  962. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  963. /**
  964. * An event triggered before calculating deterministic simulation step
  965. */
  966. onBeforeStepObservable: Observable<Scene>;
  967. /**
  968. * An event triggered after calculating deterministic simulation step
  969. */
  970. onAfterStepObservable: Observable<Scene>;
  971. /**
  972. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  973. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  974. * 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)
  975. */
  976. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  977. /**
  978. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  979. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  980. * 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)
  981. */
  982. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  983. /**
  984. * This Observable will when a mesh has been imported into the scene.
  985. */
  986. onMeshImportedObservable: Observable<AbstractMesh>;
  987. private _registeredForLateAnimationBindings;
  988. /**
  989. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  990. */
  991. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  992. /**
  993. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  994. */
  995. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  996. /**
  997. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  998. */
  999. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1000. private _onPointerMove;
  1001. private _onPointerDown;
  1002. private _onPointerUp;
  1003. /** Deprecated. Use onPointerObservable instead */
  1004. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1005. /** Deprecated. Use onPointerObservable instead */
  1006. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1007. /** Deprecated. Use onPointerObservable instead */
  1008. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1009. /** Deprecated. Use onPointerObservable instead */
  1010. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1011. /**
  1012. * 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).
  1013. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1014. */
  1015. onPrePointerObservable: Observable<PointerInfoPre>;
  1016. /**
  1017. * Observable event triggered each time an input event is received from the rendering canvas
  1018. */
  1019. onPointerObservable: Observable<PointerInfo>;
  1020. /**
  1021. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1022. */
  1023. readonly unTranslatedPointer: Vector2;
  1024. /** The distance in pixel that you have to move to prevent some events */
  1025. static DragMovementThreshold: number;
  1026. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1027. static LongPressDelay: number;
  1028. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1029. static DoubleClickDelay: number;
  1030. /** If you need to check double click without raising a single click at first click, enable this flag */
  1031. static ExclusiveDoubleClickMode: boolean;
  1032. private _initClickEvent;
  1033. private _initActionManager;
  1034. private _delayedSimpleClick;
  1035. private _delayedSimpleClickTimeout;
  1036. private _previousDelayedSimpleClickTimeout;
  1037. private _meshPickProceed;
  1038. private _previousButtonPressed;
  1039. private _currentPickResult;
  1040. private _previousPickResult;
  1041. private _totalPointersPressed;
  1042. private _doubleClickOccured;
  1043. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1044. cameraToUseForPointers: Nullable<Camera>;
  1045. private _pointerX;
  1046. private _pointerY;
  1047. private _unTranslatedPointerX;
  1048. private _unTranslatedPointerY;
  1049. private _startingPointerPosition;
  1050. private _previousStartingPointerPosition;
  1051. private _startingPointerTime;
  1052. private _previousStartingPointerTime;
  1053. private _pointerCaptures;
  1054. private _timeAccumulator;
  1055. private _currentStepId;
  1056. private _currentInternalStep;
  1057. /** @hidden */
  1058. _mirroredCameraPosition: Nullable<Vector3>;
  1059. /**
  1060. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1061. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1062. */
  1063. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1064. /**
  1065. * Observable event triggered each time an keyboard event is received from the hosting window
  1066. */
  1067. onKeyboardObservable: Observable<KeyboardInfo>;
  1068. private _onKeyDown;
  1069. private _onKeyUp;
  1070. private _onCanvasFocusObserver;
  1071. private _onCanvasBlurObserver;
  1072. private _useRightHandedSystem;
  1073. /**
  1074. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1075. */
  1076. useRightHandedSystem: boolean;
  1077. /**
  1078. * Sets the step Id used by deterministic lock step
  1079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1080. * @param newStepId defines the step Id
  1081. */
  1082. setStepId(newStepId: number): void;
  1083. /**
  1084. * Gets the step Id used by deterministic lock step
  1085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1086. * @returns the step Id
  1087. */
  1088. getStepId(): number;
  1089. /**
  1090. * Gets the internal step used by deterministic lock step
  1091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1092. * @returns the internal step
  1093. */
  1094. getInternalStep(): number;
  1095. private _fogEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if fog is enabled on this scene
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. * (Default is true)
  1100. */
  1101. fogEnabled: boolean;
  1102. private _fogMode;
  1103. /**
  1104. * Gets or sets the fog mode to use
  1105. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1106. * | mode | value |
  1107. * | --- | --- |
  1108. * | FOGMODE_NONE | 0 |
  1109. * | FOGMODE_EXP | 1 |
  1110. * | FOGMODE_EXP2 | 2 |
  1111. * | FOGMODE_LINEAR | 3 |
  1112. */
  1113. fogMode: number;
  1114. /**
  1115. * Gets or sets the fog color to use
  1116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1117. * (Default is Color3(0.2, 0.2, 0.3))
  1118. */
  1119. fogColor: Color3;
  1120. /**
  1121. * Gets or sets the fog density to use
  1122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1123. * (Default is 0.1)
  1124. */
  1125. fogDensity: number;
  1126. /**
  1127. * Gets or sets the fog start distance to use
  1128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1129. * (Default is 0)
  1130. */
  1131. fogStart: number;
  1132. /**
  1133. * Gets or sets the fog end distance to use
  1134. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1135. * (Default is 1000)
  1136. */
  1137. fogEnd: number;
  1138. private _shadowsEnabled;
  1139. /**
  1140. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1141. */
  1142. shadowsEnabled: boolean;
  1143. private _lightsEnabled;
  1144. /**
  1145. * Gets or sets a boolean indicating if lights are enabled on this scene
  1146. */
  1147. lightsEnabled: boolean;
  1148. /** All of the active cameras added to this scene. */
  1149. activeCameras: Camera[];
  1150. /** The current active camera */
  1151. activeCamera: Nullable<Camera>;
  1152. private _defaultMaterial;
  1153. /** The default material used on meshes when no material is affected */
  1154. /** The default material used on meshes when no material is affected */
  1155. defaultMaterial: Material;
  1156. private _texturesEnabled;
  1157. /**
  1158. * Gets or sets a boolean indicating if textures are enabled on this scene
  1159. */
  1160. texturesEnabled: boolean;
  1161. /**
  1162. * Gets or sets a boolean indicating if particles are enabled on this scene
  1163. */
  1164. particlesEnabled: boolean;
  1165. /**
  1166. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1167. */
  1168. spritesEnabled: boolean;
  1169. private _skeletonsEnabled;
  1170. /**
  1171. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1172. */
  1173. skeletonsEnabled: boolean;
  1174. /**
  1175. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1176. */
  1177. lensFlaresEnabled: boolean;
  1178. /**
  1179. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1181. */
  1182. collisionsEnabled: boolean;
  1183. private _workerCollisions;
  1184. /** @hidden */
  1185. collisionCoordinator: ICollisionCoordinator;
  1186. /**
  1187. * Defines the gravity applied to this scene (used only for collisions)
  1188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1189. */
  1190. gravity: Vector3;
  1191. /**
  1192. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1193. */
  1194. postProcessesEnabled: boolean;
  1195. /**
  1196. * The list of postprocesses added to the scene
  1197. */
  1198. postProcesses: PostProcess[];
  1199. /**
  1200. * Gets the current postprocess manager
  1201. */
  1202. postProcessManager: PostProcessManager;
  1203. /**
  1204. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1205. */
  1206. renderTargetsEnabled: boolean;
  1207. /**
  1208. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1209. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1210. */
  1211. dumpNextRenderTargets: boolean;
  1212. /**
  1213. * The list of user defined render targets added to the scene
  1214. */
  1215. customRenderTargets: RenderTargetTexture[];
  1216. /**
  1217. * Defines if texture loading must be delayed
  1218. * If true, textures will only be loaded when they need to be rendered
  1219. */
  1220. useDelayedTextureLoading: boolean;
  1221. /**
  1222. * Gets the list of meshes imported to the scene through SceneLoader
  1223. */
  1224. importedMeshesFiles: String[];
  1225. /**
  1226. * Gets or sets a boolean indicating if probes are enabled on this scene
  1227. */
  1228. probesEnabled: boolean;
  1229. /**
  1230. * Gets or sets the current offline provider to use to store scene data
  1231. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1232. */
  1233. offlineProvider: IOfflineProvider;
  1234. /**
  1235. * Gets or sets the action manager associated with the scene
  1236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1237. */
  1238. actionManager: ActionManager;
  1239. private _meshesForIntersections;
  1240. /**
  1241. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1242. */
  1243. proceduralTexturesEnabled: boolean;
  1244. private _engine;
  1245. private _totalVertices;
  1246. /** @hidden */
  1247. _activeIndices: PerfCounter;
  1248. /** @hidden */
  1249. _activeParticles: PerfCounter;
  1250. /** @hidden */
  1251. _activeBones: PerfCounter;
  1252. private _animationRatio;
  1253. private _animationTimeLast;
  1254. private _animationTime;
  1255. /**
  1256. * Gets or sets a general scale for animation speed
  1257. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1258. */
  1259. animationTimeScale: number;
  1260. /** @hidden */
  1261. _cachedMaterial: Nullable<Material>;
  1262. /** @hidden */
  1263. _cachedEffect: Nullable<Effect>;
  1264. /** @hidden */
  1265. _cachedVisibility: Nullable<number>;
  1266. private _renderId;
  1267. private _frameId;
  1268. private _executeWhenReadyTimeoutId;
  1269. private _intermediateRendering;
  1270. private _viewUpdateFlag;
  1271. private _projectionUpdateFlag;
  1272. private _alternateViewUpdateFlag;
  1273. private _alternateProjectionUpdateFlag;
  1274. /** @hidden */
  1275. _toBeDisposed: Nullable<IDisposable>[];
  1276. private _activeRequests;
  1277. private _pendingData;
  1278. private _isDisposed;
  1279. /**
  1280. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1281. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1282. */
  1283. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1284. private _activeMeshes;
  1285. private _processedMaterials;
  1286. private _renderTargets;
  1287. /** @hidden */
  1288. _activeParticleSystems: SmartArray<IParticleSystem>;
  1289. private _activeSkeletons;
  1290. private _softwareSkinnedMeshes;
  1291. private _renderingManager;
  1292. /** @hidden */
  1293. _activeAnimatables: Animatable[];
  1294. private _transformMatrix;
  1295. private _sceneUbo;
  1296. private _alternateSceneUbo;
  1297. private _pickWithRayInverseMatrix;
  1298. private _viewMatrix;
  1299. private _projectionMatrix;
  1300. private _alternateViewMatrix;
  1301. private _alternateProjectionMatrix;
  1302. private _alternateTransformMatrix;
  1303. private _useAlternateCameraConfiguration;
  1304. private _alternateRendering;
  1305. /** @hidden */
  1306. _forcedViewPosition: Nullable<Vector3>;
  1307. /** @hidden */
  1308. readonly _isAlternateRenderingEnabled: boolean;
  1309. private _frustumPlanes;
  1310. /**
  1311. * Gets the list of frustum planes (built from the active camera)
  1312. */
  1313. readonly frustumPlanes: Plane[];
  1314. /**
  1315. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1316. * This is useful if there are more lights that the maximum simulteanous authorized
  1317. */
  1318. requireLightSorting: boolean;
  1319. /** @hidden */
  1320. readonly useMaterialMeshMap: boolean;
  1321. /** @hidden */
  1322. readonly useClonedMeshhMap: boolean;
  1323. private _pointerOverMesh;
  1324. private _pickedDownMesh;
  1325. private _pickedUpMesh;
  1326. private _externalData;
  1327. private _uid;
  1328. /**
  1329. * @hidden
  1330. * Backing store of defined scene components.
  1331. */
  1332. _components: ISceneComponent[];
  1333. /**
  1334. * @hidden
  1335. * Backing store of defined scene components.
  1336. */
  1337. _serializableComponents: ISceneSerializableComponent[];
  1338. /**
  1339. * List of components to register on the next registration step.
  1340. */
  1341. private _transientComponents;
  1342. /**
  1343. * Registers the transient components if needed.
  1344. */
  1345. private _registerTransientComponents;
  1346. /**
  1347. * @hidden
  1348. * Add a component to the scene.
  1349. * Note that the ccomponent could be registered on th next frame if this is called after
  1350. * the register component stage.
  1351. * @param component Defines the component to add to the scene
  1352. */
  1353. _addComponent(component: ISceneComponent): void;
  1354. /**
  1355. * @hidden
  1356. * Gets a component from the scene.
  1357. * @param name defines the name of the component to retrieve
  1358. * @returns the component or null if not present
  1359. */
  1360. _getComponent(name: string): Nullable<ISceneComponent>;
  1361. /**
  1362. * @hidden
  1363. * Defines the actions happening before camera updates.
  1364. */
  1365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1366. /**
  1367. * @hidden
  1368. * Defines the actions happening before clear the canvas.
  1369. */
  1370. _beforeClearStage: Stage<SimpleStageAction>;
  1371. /**
  1372. * @hidden
  1373. * Defines the actions when collecting render targets for the frame.
  1374. */
  1375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1376. /**
  1377. * @hidden
  1378. * Defines the actions happening for one camera in the frame.
  1379. */
  1380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1381. /**
  1382. * @hidden
  1383. * Defines the actions happening during the per mesh ready checks.
  1384. */
  1385. _isReadyForMeshStage: Stage<MeshStageAction>;
  1386. /**
  1387. * @hidden
  1388. * Defines the actions happening before evaluate active mesh checks.
  1389. */
  1390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1391. /**
  1392. * @hidden
  1393. * Defines the actions happening during the evaluate sub mesh checks.
  1394. */
  1395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1396. /**
  1397. * @hidden
  1398. * Defines the actions happening during the active mesh stage.
  1399. */
  1400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1401. /**
  1402. * @hidden
  1403. * Defines the actions happening during the per camera render target step.
  1404. */
  1405. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1406. /**
  1407. * @hidden
  1408. * Defines the actions happening just before the active camera is drawing.
  1409. */
  1410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1411. /**
  1412. * @hidden
  1413. * Defines the actions happening just before a rendering group is drawing.
  1414. */
  1415. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1416. /**
  1417. * @hidden
  1418. * Defines the actions happening just before a mesh is drawing.
  1419. */
  1420. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1421. /**
  1422. * @hidden
  1423. * Defines the actions happening just after a mesh has been drawn.
  1424. */
  1425. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1426. /**
  1427. * @hidden
  1428. * Defines the actions happening just after a rendering group has been drawn.
  1429. */
  1430. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1431. /**
  1432. * @hidden
  1433. * Defines the actions happening just after the active camera has been drawn.
  1434. */
  1435. _afterCameraDrawStage: Stage<CameraStageAction>;
  1436. /**
  1437. * @hidden
  1438. * Defines the actions happening just after rendering all cameras and computing intersections.
  1439. */
  1440. _afterRenderStage: Stage<SimpleStageAction>;
  1441. /**
  1442. * @hidden
  1443. * Defines the actions happening when a pointer move event happens.
  1444. */
  1445. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1446. /**
  1447. * @hidden
  1448. * Defines the actions happening when a pointer down event happens.
  1449. */
  1450. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1451. /**
  1452. * @hidden
  1453. * Defines the actions happening when a pointer up event happens.
  1454. */
  1455. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1456. /**
  1457. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1458. */
  1459. private geometriesById;
  1460. /**
  1461. * Creates a new Scene
  1462. * @param engine defines the engine to use to render this scene
  1463. */
  1464. constructor(engine: Engine, options?: SceneOptions);
  1465. private _defaultMeshCandidates;
  1466. /**
  1467. * @hidden
  1468. */
  1469. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1470. private _defaultSubMeshCandidates;
  1471. /**
  1472. * @hidden
  1473. */
  1474. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1475. /**
  1476. * Sets the default candidate providers for the scene.
  1477. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1478. * and getCollidingSubMeshCandidates to their default function
  1479. */
  1480. setDefaultCandidateProviders(): void;
  1481. /**
  1482. * Gets a boolean indicating if collisions are processed on a web worker
  1483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1484. */
  1485. workerCollisions: boolean;
  1486. /**
  1487. * Gets the mesh that is currently under the pointer
  1488. */
  1489. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1490. /**
  1491. * Gets the current on-screen X position of the pointer
  1492. */
  1493. readonly pointerX: number;
  1494. /**
  1495. * Gets the current on-screen Y position of the pointer
  1496. */
  1497. readonly pointerY: number;
  1498. /**
  1499. * Gets the cached material (ie. the latest rendered one)
  1500. * @returns the cached material
  1501. */
  1502. getCachedMaterial(): Nullable<Material>;
  1503. /**
  1504. * Gets the cached effect (ie. the latest rendered one)
  1505. * @returns the cached effect
  1506. */
  1507. getCachedEffect(): Nullable<Effect>;
  1508. /**
  1509. * Gets the cached visibility state (ie. the latest rendered one)
  1510. * @returns the cached visibility state
  1511. */
  1512. getCachedVisibility(): Nullable<number>;
  1513. /**
  1514. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1515. * @param material defines the current material
  1516. * @param effect defines the current effect
  1517. * @param visibility defines the current visibility state
  1518. * @returns true if one parameter is not cached
  1519. */
  1520. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1521. /**
  1522. * Gets the engine associated with the scene
  1523. * @returns an Engine
  1524. */
  1525. getEngine(): Engine;
  1526. /**
  1527. * Gets the total number of vertices rendered per frame
  1528. * @returns the total number of vertices rendered per frame
  1529. */
  1530. getTotalVertices(): number;
  1531. /**
  1532. * Gets the performance counter for total vertices
  1533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1534. */
  1535. readonly totalVerticesPerfCounter: PerfCounter;
  1536. /**
  1537. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1538. * @returns the total number of active indices rendered per frame
  1539. */
  1540. getActiveIndices(): number;
  1541. /**
  1542. * Gets the performance counter for active indices
  1543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1544. */
  1545. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1546. /**
  1547. * Gets the total number of active particles rendered per frame
  1548. * @returns the total number of active particles rendered per frame
  1549. */
  1550. getActiveParticles(): number;
  1551. /**
  1552. * Gets the performance counter for active particles
  1553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1554. */
  1555. readonly activeParticlesPerfCounter: PerfCounter;
  1556. /**
  1557. * Gets the total number of active bones rendered per frame
  1558. * @returns the total number of active bones rendered per frame
  1559. */
  1560. getActiveBones(): number;
  1561. /**
  1562. * Gets the performance counter for active bones
  1563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1564. */
  1565. readonly activeBonesPerfCounter: PerfCounter;
  1566. /** @hidden */
  1567. getInterFramePerfCounter(): number;
  1568. /** @hidden */
  1569. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1570. /** @hidden */
  1571. getLastFrameDuration(): number;
  1572. /** @hidden */
  1573. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1574. /** @hidden */
  1575. getEvaluateActiveMeshesDuration(): number;
  1576. /** @hidden */
  1577. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1578. /**
  1579. * Gets the array of active meshes
  1580. * @returns an array of AbstractMesh
  1581. */
  1582. getActiveMeshes(): SmartArray<AbstractMesh>;
  1583. /** @hidden */
  1584. getRenderTargetsDuration(): number;
  1585. /** @hidden */
  1586. getRenderDuration(): number;
  1587. /** @hidden */
  1588. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1589. /** @hidden */
  1590. getParticlesDuration(): number;
  1591. /** @hidden */
  1592. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1593. /** @hidden */
  1594. getSpritesDuration(): number;
  1595. /** @hidden */
  1596. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1597. /**
  1598. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1599. * @returns a number
  1600. */
  1601. getAnimationRatio(): number;
  1602. /**
  1603. * Gets an unique Id for the current render phase
  1604. * @returns a number
  1605. */
  1606. getRenderId(): number;
  1607. /**
  1608. * Gets an unique Id for the current frame
  1609. * @returns a number
  1610. */
  1611. getFrameId(): number;
  1612. /** Call this function if you want to manually increment the render Id*/
  1613. incrementRenderId(): void;
  1614. private _updatePointerPosition;
  1615. private _createUbo;
  1616. private _createAlternateUbo;
  1617. private _setRayOnPointerInfo;
  1618. /**
  1619. * Use this method to simulate a pointer move on a mesh
  1620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1623. * @returns the current scene
  1624. */
  1625. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1626. private _processPointerMove;
  1627. private _checkPrePointerObservable;
  1628. /**
  1629. * Use this method to simulate a pointer down on a mesh
  1630. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1631. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1632. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1633. * @returns the current scene
  1634. */
  1635. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1636. private _processPointerDown;
  1637. /**
  1638. * Use this method to simulate a pointer up on a mesh
  1639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1642. * @returns the current scene
  1643. */
  1644. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1645. private _processPointerUp;
  1646. /**
  1647. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1648. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1649. * @returns true if the pointer was captured
  1650. */
  1651. isPointerCaptured(pointerId?: number): boolean;
  1652. /** @hidden */
  1653. _isPointerSwiping(): boolean;
  1654. /**
  1655. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1656. * @param attachUp defines if you want to attach events to pointerup
  1657. * @param attachDown defines if you want to attach events to pointerdown
  1658. * @param attachMove defines if you want to attach events to pointermove
  1659. */
  1660. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1661. /** Detaches all event handlers*/
  1662. detachControl(): void;
  1663. /**
  1664. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1665. * Delay loaded resources are not taking in account
  1666. * @return true if all required resources are ready
  1667. */
  1668. isReady(): boolean;
  1669. /** Resets all cached information relative to material (including effect and visibility) */
  1670. resetCachedMaterial(): void;
  1671. /**
  1672. * Registers a function to be called before every frame render
  1673. * @param func defines the function to register
  1674. */
  1675. registerBeforeRender(func: () => void): void;
  1676. /**
  1677. * Unregisters a function called before every frame render
  1678. * @param func defines the function to unregister
  1679. */
  1680. unregisterBeforeRender(func: () => void): void;
  1681. /**
  1682. * Registers a function to be called after every frame render
  1683. * @param func defines the function to register
  1684. */
  1685. registerAfterRender(func: () => void): void;
  1686. /**
  1687. * Unregisters a function called after every frame render
  1688. * @param func defines the function to unregister
  1689. */
  1690. unregisterAfterRender(func: () => void): void;
  1691. private _executeOnceBeforeRender;
  1692. /**
  1693. * The provided function will run before render once and will be disposed afterwards.
  1694. * A timeout delay can be provided so that the function will be executed in N ms.
  1695. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1696. * @param func The function to be executed.
  1697. * @param timeout optional delay in ms
  1698. */
  1699. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1700. /** @hidden */
  1701. _addPendingData(data: any): void;
  1702. /** @hidden */
  1703. _removePendingData(data: any): void;
  1704. /**
  1705. * Returns the number of items waiting to be loaded
  1706. * @returns the number of items waiting to be loaded
  1707. */
  1708. getWaitingItemsCount(): number;
  1709. /**
  1710. * Returns a boolean indicating if the scene is still loading data
  1711. */
  1712. readonly isLoading: boolean;
  1713. /**
  1714. * Registers a function to be executed when the scene is ready
  1715. * @param {Function} func - the function to be executed
  1716. */
  1717. executeWhenReady(func: () => void): void;
  1718. /**
  1719. * Returns a promise that resolves when the scene is ready
  1720. * @returns A promise that resolves when the scene is ready
  1721. */
  1722. whenReadyAsync(): Promise<void>;
  1723. /** @hidden */
  1724. _checkIsReady(): void;
  1725. /**
  1726. * Will start the animation sequence of a given target
  1727. * @param target defines the target
  1728. * @param from defines from which frame should animation start
  1729. * @param to defines until which frame should animation run.
  1730. * @param weight defines the weight to apply to the animation (1.0 by default)
  1731. * @param loop defines if the animation loops
  1732. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1733. * @param onAnimationEnd defines the function to be executed when the animation ends
  1734. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1736. * @returns the animatable object created for this animation
  1737. */
  1738. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1739. /**
  1740. * Will start the animation sequence of a given target
  1741. * @param target defines the target
  1742. * @param from defines from which frame should animation start
  1743. * @param to defines until which frame should animation run.
  1744. * @param loop defines if the animation loops
  1745. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1746. * @param onAnimationEnd defines the function to be executed when the animation ends
  1747. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1748. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1749. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1750. * @returns the animatable object created for this animation
  1751. */
  1752. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1753. /**
  1754. * Begin a new animation on a given node
  1755. * @param target defines the target where the animation will take place
  1756. * @param animations defines the list of animations to start
  1757. * @param from defines the initial value
  1758. * @param to defines the final value
  1759. * @param loop defines if you want animation to loop (off by default)
  1760. * @param speedRatio defines the speed ratio to apply to all animations
  1761. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1762. * @returns the list of created animatables
  1763. */
  1764. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1765. /**
  1766. * Begin a new animation on a given node and its hierarchy
  1767. * @param target defines the root node where the animation will take place
  1768. * @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.
  1769. * @param animations defines the list of animations to start
  1770. * @param from defines the initial value
  1771. * @param to defines the final value
  1772. * @param loop defines if you want animation to loop (off by default)
  1773. * @param speedRatio defines the speed ratio to apply to all animations
  1774. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1775. * @returns the list of animatables created for all nodes
  1776. */
  1777. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1778. /**
  1779. * Gets the animatable associated with a specific target
  1780. * @param target defines the target of the animatable
  1781. * @returns the required animatable if found
  1782. */
  1783. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1784. /**
  1785. * Gets all animatables associated with a given target
  1786. * @param target defines the target to look animatables for
  1787. * @returns an array of Animatables
  1788. */
  1789. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1790. /**
  1791. * Gets all animatable attached to the scene
  1792. */
  1793. readonly animatables: Animatable[];
  1794. /**
  1795. * Will stop the animation of the given target
  1796. * @param target - the target
  1797. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1798. * @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)
  1799. */
  1800. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1801. /**
  1802. * Stops and removes all animations that have been applied to the scene
  1803. */
  1804. stopAllAnimations(): void;
  1805. private _animate;
  1806. /** @hidden */
  1807. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1808. private _processLateAnimationBindingsForMatrices;
  1809. private _processLateAnimationBindingsForQuaternions;
  1810. private _processLateAnimationBindings;
  1811. /** @hidden */
  1812. _switchToAlternateCameraConfiguration(active: boolean): void;
  1813. /**
  1814. * Gets the current view matrix
  1815. * @returns a Matrix
  1816. */
  1817. getViewMatrix(): Matrix;
  1818. /**
  1819. * Gets the current projection matrix
  1820. * @returns a Matrix
  1821. */
  1822. getProjectionMatrix(): Matrix;
  1823. /**
  1824. * Gets the current transform matrix
  1825. * @returns a Matrix made of View * Projection
  1826. */
  1827. getTransformMatrix(): Matrix;
  1828. /**
  1829. * Sets the current transform matrix
  1830. * @param view defines the View matrix to use
  1831. * @param projection defines the Projection matrix to use
  1832. */
  1833. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1834. /** @hidden */
  1835. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1836. /**
  1837. * Gets the uniform buffer used to store scene data
  1838. * @returns a UniformBuffer
  1839. */
  1840. getSceneUniformBuffer(): UniformBuffer;
  1841. /**
  1842. * Gets an unique (relatively to the current scene) Id
  1843. * @returns an unique number for the scene
  1844. */
  1845. getUniqueId(): number;
  1846. /**
  1847. * Add a mesh to the list of scene's meshes
  1848. * @param newMesh defines the mesh to add
  1849. * @param recursive if all child meshes should also be added to the scene
  1850. */
  1851. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1852. /**
  1853. * Remove a mesh for the list of scene's meshes
  1854. * @param toRemove defines the mesh to remove
  1855. * @param recursive if all child meshes should also be removed from the scene
  1856. * @returns the index where the mesh was in the mesh list
  1857. */
  1858. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1859. /**
  1860. * Add a transform node to the list of scene's transform nodes
  1861. * @param newTransformNode defines the transform node to add
  1862. */
  1863. addTransformNode(newTransformNode: TransformNode): void;
  1864. /**
  1865. * Remove a transform node for the list of scene's transform nodes
  1866. * @param toRemove defines the transform node to remove
  1867. * @returns the index where the transform node was in the transform node list
  1868. */
  1869. removeTransformNode(toRemove: TransformNode): number;
  1870. /**
  1871. * Remove a skeleton for the list of scene's skeletons
  1872. * @param toRemove defines the skeleton to remove
  1873. * @returns the index where the skeleton was in the skeleton list
  1874. */
  1875. removeSkeleton(toRemove: Skeleton): number;
  1876. /**
  1877. * Remove a morph target for the list of scene's morph targets
  1878. * @param toRemove defines the morph target to remove
  1879. * @returns the index where the morph target was in the morph target list
  1880. */
  1881. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1882. /**
  1883. * Remove a light for the list of scene's lights
  1884. * @param toRemove defines the light to remove
  1885. * @returns the index where the light was in the light list
  1886. */
  1887. removeLight(toRemove: Light): number;
  1888. /**
  1889. * Remove a camera for the list of scene's cameras
  1890. * @param toRemove defines the camera to remove
  1891. * @returns the index where the camera was in the camera list
  1892. */
  1893. removeCamera(toRemove: Camera): number;
  1894. /**
  1895. * Remove a particle system for the list of scene's particle systems
  1896. * @param toRemove defines the particle system to remove
  1897. * @returns the index where the particle system was in the particle system list
  1898. */
  1899. removeParticleSystem(toRemove: IParticleSystem): number;
  1900. /**
  1901. * Remove a animation for the list of scene's animations
  1902. * @param toRemove defines the animation to remove
  1903. * @returns the index where the animation was in the animation list
  1904. */
  1905. removeAnimation(toRemove: Animation): number;
  1906. /**
  1907. * Removes the given animation group from this scene.
  1908. * @param toRemove The animation group to remove
  1909. * @returns The index of the removed animation group
  1910. */
  1911. removeAnimationGroup(toRemove: AnimationGroup): number;
  1912. /**
  1913. * Removes the given multi-material from this scene.
  1914. * @param toRemove The multi-material to remove
  1915. * @returns The index of the removed multi-material
  1916. */
  1917. removeMultiMaterial(toRemove: MultiMaterial): number;
  1918. /**
  1919. * Removes the given material from this scene.
  1920. * @param toRemove The material to remove
  1921. * @returns The index of the removed material
  1922. */
  1923. removeMaterial(toRemove: Material): number;
  1924. /**
  1925. * Removes the given action manager from this scene.
  1926. * @param toRemove The action manager to remove
  1927. * @returns The index of the removed action manager
  1928. */
  1929. removeActionManager(toRemove: ActionManager): number;
  1930. /**
  1931. * Removes the given texture from this scene.
  1932. * @param toRemove The texture to remove
  1933. * @returns The index of the removed texture
  1934. */
  1935. removeTexture(toRemove: BaseTexture): number;
  1936. /**
  1937. * Adds the given light to this scene
  1938. * @param newLight The light to add
  1939. */
  1940. addLight(newLight: Light): void;
  1941. /**
  1942. * Sorts the list list based on light priorities
  1943. */
  1944. sortLightsByPriority(): void;
  1945. /**
  1946. * Adds the given camera to this scene
  1947. * @param newCamera The camera to add
  1948. */
  1949. addCamera(newCamera: Camera): void;
  1950. /**
  1951. * Adds the given skeleton to this scene
  1952. * @param newSkeleton The skeleton to add
  1953. */
  1954. addSkeleton(newSkeleton: Skeleton): void;
  1955. /**
  1956. * Adds the given particle system to this scene
  1957. * @param newParticleSystem The particle system to add
  1958. */
  1959. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1960. /**
  1961. * Adds the given animation to this scene
  1962. * @param newAnimation The animation to add
  1963. */
  1964. addAnimation(newAnimation: Animation): void;
  1965. /**
  1966. * Adds the given animation group to this scene.
  1967. * @param newAnimationGroup The animation group to add
  1968. */
  1969. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1970. /**
  1971. * Adds the given multi-material to this scene
  1972. * @param newMultiMaterial The multi-material to add
  1973. */
  1974. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1975. /**
  1976. * Adds the given material to this scene
  1977. * @param newMaterial The material to add
  1978. */
  1979. addMaterial(newMaterial: Material): void;
  1980. /**
  1981. * Adds the given morph target to this scene
  1982. * @param newMorphTargetManager The morph target to add
  1983. */
  1984. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1985. /**
  1986. * Adds the given geometry to this scene
  1987. * @param newGeometry The geometry to add
  1988. */
  1989. addGeometry(newGeometry: Geometry): void;
  1990. /**
  1991. * Adds the given action manager to this scene
  1992. * @param newActionManager The action manager to add
  1993. */
  1994. addActionManager(newActionManager: ActionManager): void;
  1995. /**
  1996. * Adds the given texture to this scene.
  1997. * @param newTexture The texture to add
  1998. */
  1999. addTexture(newTexture: BaseTexture): void;
  2000. /**
  2001. * Switch active camera
  2002. * @param newCamera defines the new active camera
  2003. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2004. */
  2005. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2006. /**
  2007. * sets the active camera of the scene using its ID
  2008. * @param id defines the camera's ID
  2009. * @return the new active camera or null if none found.
  2010. */
  2011. setActiveCameraByID(id: string): Nullable<Camera>;
  2012. /**
  2013. * sets the active camera of the scene using its name
  2014. * @param name defines the camera's name
  2015. * @returns the new active camera or null if none found.
  2016. */
  2017. setActiveCameraByName(name: string): Nullable<Camera>;
  2018. /**
  2019. * get an animation group using its name
  2020. * @param name defines the material's name
  2021. * @return the animation group or null if none found.
  2022. */
  2023. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2024. /**
  2025. * get a material using its id
  2026. * @param id defines the material's ID
  2027. * @return the material or null if none found.
  2028. */
  2029. getMaterialByID(id: string): Nullable<Material>;
  2030. /**
  2031. * Gets a material using its name
  2032. * @param name defines the material's name
  2033. * @return the material or null if none found.
  2034. */
  2035. getMaterialByName(name: string): Nullable<Material>;
  2036. /**
  2037. * Gets a camera using its id
  2038. * @param id defines the id to look for
  2039. * @returns the camera or null if not found
  2040. */
  2041. getCameraByID(id: string): Nullable<Camera>;
  2042. /**
  2043. * Gets a camera using its unique id
  2044. * @param uniqueId defines the unique id to look for
  2045. * @returns the camera or null if not found
  2046. */
  2047. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2048. /**
  2049. * Gets a camera using its name
  2050. * @param name defines the camera's name
  2051. * @return the camera or null if none found.
  2052. */
  2053. getCameraByName(name: string): Nullable<Camera>;
  2054. /**
  2055. * Gets a bone using its id
  2056. * @param id defines the bone's id
  2057. * @return the bone or null if not found
  2058. */
  2059. getBoneByID(id: string): Nullable<Bone>;
  2060. /**
  2061. * Gets a bone using its id
  2062. * @param name defines the bone's name
  2063. * @return the bone or null if not found
  2064. */
  2065. getBoneByName(name: string): Nullable<Bone>;
  2066. /**
  2067. * Gets a light node using its name
  2068. * @param name defines the the light's name
  2069. * @return the light or null if none found.
  2070. */
  2071. getLightByName(name: string): Nullable<Light>;
  2072. /**
  2073. * Gets a light node using its id
  2074. * @param id defines the light's id
  2075. * @return the light or null if none found.
  2076. */
  2077. getLightByID(id: string): Nullable<Light>;
  2078. /**
  2079. * Gets a light node using its scene-generated unique ID
  2080. * @param uniqueId defines the light's unique id
  2081. * @return the light or null if none found.
  2082. */
  2083. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2084. /**
  2085. * Gets a particle system by id
  2086. * @param id defines the particle system id
  2087. * @return the corresponding system or null if none found
  2088. */
  2089. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2090. /**
  2091. * Gets a geometry using its ID
  2092. * @param id defines the geometry's id
  2093. * @return the geometry or null if none found.
  2094. */
  2095. getGeometryByID(id: string): Nullable<Geometry>;
  2096. /**
  2097. * Add a new geometry to this scene
  2098. * @param geometry defines the geometry to be added to the scene.
  2099. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2100. * @return a boolean defining if the geometry was added or not
  2101. */
  2102. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2103. /**
  2104. * Removes an existing geometry
  2105. * @param geometry defines the geometry to be removed from the scene
  2106. * @return a boolean defining if the geometry was removed or not
  2107. */
  2108. removeGeometry(geometry: Geometry): boolean;
  2109. /**
  2110. * Gets the list of geometries attached to the scene
  2111. * @returns an array of Geometry
  2112. */
  2113. getGeometries(): Geometry[];
  2114. /**
  2115. * Gets the first added mesh found of a given ID
  2116. * @param id defines the id to search for
  2117. * @return the mesh found or null if not found at all
  2118. */
  2119. getMeshByID(id: string): Nullable<AbstractMesh>;
  2120. /**
  2121. * Gets a list of meshes using their id
  2122. * @param id defines the id to search for
  2123. * @returns a list of meshes
  2124. */
  2125. getMeshesByID(id: string): Array<AbstractMesh>;
  2126. /**
  2127. * Gets the first added transform node found of a given ID
  2128. * @param id defines the id to search for
  2129. * @return the found transform node or null if not found at all.
  2130. */
  2131. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2132. /**
  2133. * Gets a list of transform nodes using their id
  2134. * @param id defines the id to search for
  2135. * @returns a list of transform nodes
  2136. */
  2137. getTransformNodesByID(id: string): Array<TransformNode>;
  2138. /**
  2139. * Gets a mesh with its auto-generated unique id
  2140. * @param uniqueId defines the unique id to search for
  2141. * @return the found mesh or null if not found at all.
  2142. */
  2143. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2144. /**
  2145. * Gets a the last added mesh using a given id
  2146. * @param id defines the id to search for
  2147. * @return the found mesh or null if not found at all.
  2148. */
  2149. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2150. /**
  2151. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2152. * @param id defines the id to search for
  2153. * @return the found node or null if not found at all
  2154. */
  2155. getLastEntryByID(id: string): Nullable<Node>;
  2156. /**
  2157. * Gets a node (Mesh, Camera, Light) using a given id
  2158. * @param id defines the id to search for
  2159. * @return the found node or null if not found at all
  2160. */
  2161. getNodeByID(id: string): Nullable<Node>;
  2162. /**
  2163. * Gets a node (Mesh, Camera, Light) using a given name
  2164. * @param name defines the name to search for
  2165. * @return the found node or null if not found at all.
  2166. */
  2167. getNodeByName(name: string): Nullable<Node>;
  2168. /**
  2169. * Gets a mesh using a given name
  2170. * @param name defines the name to search for
  2171. * @return the found mesh or null if not found at all.
  2172. */
  2173. getMeshByName(name: string): Nullable<AbstractMesh>;
  2174. /**
  2175. * Gets a transform node using a given name
  2176. * @param name defines the name to search for
  2177. * @return the found transform node or null if not found at all.
  2178. */
  2179. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2180. /**
  2181. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2182. * @param id defines the id to search for
  2183. * @return the found skeleton or null if not found at all.
  2184. */
  2185. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2186. /**
  2187. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2188. * @param id defines the id to search for
  2189. * @return the found skeleton or null if not found at all.
  2190. */
  2191. getSkeletonById(id: string): Nullable<Skeleton>;
  2192. /**
  2193. * Gets a skeleton using a given name
  2194. * @param name defines the name to search for
  2195. * @return the found skeleton or null if not found at all.
  2196. */
  2197. getSkeletonByName(name: string): Nullable<Skeleton>;
  2198. /**
  2199. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2200. * @param id defines the id to search for
  2201. * @return the found morph target manager or null if not found at all.
  2202. */
  2203. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2204. /**
  2205. * Gets a boolean indicating if the given mesh is active
  2206. * @param mesh defines the mesh to look for
  2207. * @returns true if the mesh is in the active list
  2208. */
  2209. isActiveMesh(mesh: AbstractMesh): boolean;
  2210. /**
  2211. * Return a unique id as a string which can serve as an identifier for the scene
  2212. */
  2213. readonly uid: string;
  2214. /**
  2215. * Add an externaly attached data from its key.
  2216. * This method call will fail and return false, if such key already exists.
  2217. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2218. * @param key the unique key that identifies the data
  2219. * @param data the data object to associate to the key for this Engine instance
  2220. * @return true if no such key were already present and the data was added successfully, false otherwise
  2221. */
  2222. addExternalData<T>(key: string, data: T): boolean;
  2223. /**
  2224. * Get an externaly attached data from its key
  2225. * @param key the unique key that identifies the data
  2226. * @return the associated data, if present (can be null), or undefined if not present
  2227. */
  2228. getExternalData<T>(key: string): Nullable<T>;
  2229. /**
  2230. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2231. * @param key the unique key that identifies the data
  2232. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2233. * @return the associated data, can be null if the factory returned null.
  2234. */
  2235. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2236. /**
  2237. * Remove an externaly attached data from the Engine instance
  2238. * @param key the unique key that identifies the data
  2239. * @return true if the data was successfully removed, false if it doesn't exist
  2240. */
  2241. removeExternalData(key: string): boolean;
  2242. private _evaluateSubMesh;
  2243. /**
  2244. * Clear the processed materials smart array preventing retention point in material dispose.
  2245. */
  2246. freeProcessedMaterials(): void;
  2247. private _preventFreeActiveMeshesAndRenderingGroups;
  2248. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2249. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2250. * when disposing several meshes in a row or a hierarchy of meshes.
  2251. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2252. */
  2253. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2254. /**
  2255. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2256. */
  2257. freeActiveMeshes(): void;
  2258. /**
  2259. * Clear the info related to rendering groups preventing retention points during dispose.
  2260. */
  2261. freeRenderingGroups(): void;
  2262. /** @hidden */
  2263. _isInIntermediateRendering(): boolean;
  2264. /**
  2265. * Lambda returning the list of potentially active meshes.
  2266. */
  2267. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2268. /**
  2269. * Lambda returning the list of potentially active sub meshes.
  2270. */
  2271. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2272. /**
  2273. * Lambda returning the list of potentially intersecting sub meshes.
  2274. */
  2275. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2276. /**
  2277. * Lambda returning the list of potentially colliding sub meshes.
  2278. */
  2279. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2280. private _activeMeshesFrozen;
  2281. /**
  2282. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2283. * @returns the current scene
  2284. */
  2285. freezeActiveMeshes(): Scene;
  2286. /**
  2287. * Use this function to restart evaluating active meshes on every frame
  2288. * @returns the current scene
  2289. */
  2290. unfreezeActiveMeshes(): Scene;
  2291. private _evaluateActiveMeshes;
  2292. private _activeMesh;
  2293. /**
  2294. * Update the transform matrix to update from the current active camera
  2295. * @param force defines a boolean used to force the update even if cache is up to date
  2296. */
  2297. updateTransformMatrix(force?: boolean): void;
  2298. /**
  2299. * 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)
  2300. * @param alternateCamera defines the camera to use
  2301. */
  2302. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2303. /** @hidden */
  2304. _allowPostProcessClearColor: boolean;
  2305. private _renderForCamera;
  2306. private _processSubCameras;
  2307. private _checkIntersections;
  2308. /** @hidden */
  2309. _advancePhysicsEngineStep(step: number): void;
  2310. /**
  2311. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2312. */
  2313. getDeterministicFrameTime: () => number;
  2314. /**
  2315. * Render the scene
  2316. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2317. */
  2318. render(updateCameras?: boolean): void;
  2319. /**
  2320. * Freeze all materials
  2321. * A frozen material will not be updatable but should be faster to render
  2322. */
  2323. freezeMaterials(): void;
  2324. /**
  2325. * Unfreeze all materials
  2326. * A frozen material will not be updatable but should be faster to render
  2327. */
  2328. unfreezeMaterials(): void;
  2329. /**
  2330. * Releases all held ressources
  2331. */
  2332. dispose(): void;
  2333. /**
  2334. * Gets if the scene is already disposed
  2335. */
  2336. readonly isDisposed: boolean;
  2337. /**
  2338. * Call this function to reduce memory footprint of the scene.
  2339. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2340. */
  2341. clearCachedVertexData(): void;
  2342. /**
  2343. * This function will remove the local cached buffer data from texture.
  2344. * It will save memory but will prevent the texture from being rebuilt
  2345. */
  2346. cleanCachedTextureBuffer(): void;
  2347. /**
  2348. * Get the world extend vectors with an optional filter
  2349. *
  2350. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2351. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2352. */
  2353. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2354. min: Vector3;
  2355. max: Vector3;
  2356. };
  2357. /**
  2358. * Creates a ray that can be used to pick in the scene
  2359. * @param x defines the x coordinate of the origin (on-screen)
  2360. * @param y defines the y coordinate of the origin (on-screen)
  2361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2362. * @param camera defines the camera to use for the picking
  2363. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2364. * @returns a Ray
  2365. */
  2366. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2367. /**
  2368. * Creates a ray that can be used to pick in the scene
  2369. * @param x defines the x coordinate of the origin (on-screen)
  2370. * @param y defines the y coordinate of the origin (on-screen)
  2371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2372. * @param result defines the ray where to store the picking ray
  2373. * @param camera defines the camera to use for the picking
  2374. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2375. * @returns the current scene
  2376. */
  2377. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2378. /**
  2379. * Creates a ray that can be used to pick in the scene
  2380. * @param x defines the x coordinate of the origin (on-screen)
  2381. * @param y defines the y coordinate of the origin (on-screen)
  2382. * @param camera defines the camera to use for the picking
  2383. * @returns a Ray
  2384. */
  2385. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2386. /**
  2387. * Creates a ray that can be used to pick in the scene
  2388. * @param x defines the x coordinate of the origin (on-screen)
  2389. * @param y defines the y coordinate of the origin (on-screen)
  2390. * @param result defines the ray where to store the picking ray
  2391. * @param camera defines the camera to use for the picking
  2392. * @returns the current scene
  2393. */
  2394. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2395. private _internalPick;
  2396. private _internalMultiPick;
  2397. private _tempPickingRay;
  2398. /** Launch a ray to try to pick a mesh in the scene
  2399. * @param x position on screen
  2400. * @param y position on screen
  2401. * @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
  2402. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2403. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2404. * @returns a PickingInfo
  2405. */
  2406. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2407. private _cachedRayForTransform;
  2408. /** Use the given ray to pick a mesh in the scene
  2409. * @param ray The ray to use to pick meshes
  2410. * @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
  2411. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2412. * @returns a PickingInfo
  2413. */
  2414. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2415. /**
  2416. * Launch a ray to try to pick a mesh in the scene
  2417. * @param x X position on screen
  2418. * @param y Y position on screen
  2419. * @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
  2420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2421. * @returns an array of PickingInfo
  2422. */
  2423. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2424. /**
  2425. * Launch a ray to try to pick a mesh in the scene
  2426. * @param ray Ray to use
  2427. * @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
  2428. * @returns an array of PickingInfo
  2429. */
  2430. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2431. /**
  2432. * Force the value of meshUnderPointer
  2433. * @param mesh defines the mesh to use
  2434. */
  2435. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2436. /**
  2437. * Gets the mesh under the pointer
  2438. * @returns a Mesh or null if no mesh is under the pointer
  2439. */
  2440. getPointerOverMesh(): Nullable<AbstractMesh>;
  2441. /** @hidden */
  2442. _rebuildGeometries(): void;
  2443. /** @hidden */
  2444. _rebuildTextures(): void;
  2445. private _getByTags;
  2446. /**
  2447. * Get a list of meshes by tags
  2448. * @param tagsQuery defines the tags query to use
  2449. * @param forEach defines a predicate used to filter results
  2450. * @returns an array of Mesh
  2451. */
  2452. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2453. /**
  2454. * Get a list of cameras by tags
  2455. * @param tagsQuery defines the tags query to use
  2456. * @param forEach defines a predicate used to filter results
  2457. * @returns an array of Camera
  2458. */
  2459. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2460. /**
  2461. * Get a list of lights by tags
  2462. * @param tagsQuery defines the tags query to use
  2463. * @param forEach defines a predicate used to filter results
  2464. * @returns an array of Light
  2465. */
  2466. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2467. /**
  2468. * Get a list of materials by tags
  2469. * @param tagsQuery defines the tags query to use
  2470. * @param forEach defines a predicate used to filter results
  2471. * @returns an array of Material
  2472. */
  2473. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2474. /**
  2475. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2476. * This allowed control for front to back rendering or reversly depending of the special needs.
  2477. *
  2478. * @param renderingGroupId The rendering group id corresponding to its index
  2479. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2480. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2481. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2482. */
  2483. 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;
  2484. /**
  2485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2486. *
  2487. * @param renderingGroupId The rendering group id corresponding to its index
  2488. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2489. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2490. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2491. */
  2492. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2493. /**
  2494. * Gets the current auto clear configuration for one rendering group of the rendering
  2495. * manager.
  2496. * @param index the rendering group index to get the information for
  2497. * @returns The auto clear setup for the requested rendering group
  2498. */
  2499. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2500. private _blockMaterialDirtyMechanism;
  2501. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2502. blockMaterialDirtyMechanism: boolean;
  2503. /**
  2504. * Will flag all materials as dirty to trigger new shader compilation
  2505. * @param flag defines the flag used to specify which material part must be marked as dirty
  2506. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2507. */
  2508. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2509. /** @hidden */
  2510. _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;
  2511. /** @hidden */
  2512. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2513. }
  2514. }
  2515. declare module BABYLON {
  2516. /**
  2517. * Groups all the scene component constants in one place to ease maintenance.
  2518. * @hidden
  2519. */
  2520. class SceneComponentConstants {
  2521. static readonly NAME_EFFECTLAYER: string;
  2522. static readonly NAME_LAYER: string;
  2523. static readonly NAME_LENSFLARESYSTEM: string;
  2524. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2525. static readonly NAME_PARTICLESYSTEM: string;
  2526. static readonly NAME_GAMEPAD: string;
  2527. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2528. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2529. static readonly NAME_DEPTHRENDERER: string;
  2530. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2531. static readonly NAME_SPRITE: string;
  2532. static readonly NAME_OUTLINERENDERER: string;
  2533. static readonly NAME_PROCEDURALTEXTURE: string;
  2534. static readonly NAME_SHADOWGENERATOR: string;
  2535. static readonly NAME_OCTREE: string;
  2536. static readonly NAME_PHYSICSENGINE: string;
  2537. static readonly NAME_AUDIO: string;
  2538. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2539. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2540. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2541. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2542. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2543. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2544. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2545. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2546. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2547. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2548. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2549. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2550. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2551. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2553. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2554. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2555. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2556. static readonly STEP_AFTERRENDER_AUDIO: number;
  2557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2558. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2559. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2560. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2561. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2562. static readonly STEP_POINTERMOVE_SPRITE: number;
  2563. static readonly STEP_POINTERDOWN_SPRITE: number;
  2564. static readonly STEP_POINTERUP_SPRITE: number;
  2565. }
  2566. /**
  2567. * This represents a scene component.
  2568. *
  2569. * This is used to decouple the dependency the scene is having on the different workloads like
  2570. * layers, post processes...
  2571. */
  2572. interface ISceneComponent {
  2573. /**
  2574. * The name of the component. Each component must have a unique name.
  2575. */
  2576. name: string;
  2577. /**
  2578. * The scene the component belongs to.
  2579. */
  2580. scene: Scene;
  2581. /**
  2582. * Register the component to one instance of a scene.
  2583. */
  2584. register(): void;
  2585. /**
  2586. * Rebuilds the elements related to this component in case of
  2587. * context lost for instance.
  2588. */
  2589. rebuild(): void;
  2590. /**
  2591. * Disposes the component and the associated ressources.
  2592. */
  2593. dispose(): void;
  2594. }
  2595. /**
  2596. * This represents a SERIALIZABLE scene component.
  2597. *
  2598. * This extends Scene Component to add Serialization methods on top.
  2599. */
  2600. interface ISceneSerializableComponent extends ISceneComponent {
  2601. /**
  2602. * Adds all the element from the container to the scene
  2603. * @param container the container holding the elements
  2604. */
  2605. addFromContainer(container: AbstractScene): void;
  2606. /**
  2607. * Removes all the elements in the container from the scene
  2608. * @param container contains the elements to remove
  2609. */
  2610. removeFromContainer(container: AbstractScene): void;
  2611. /**
  2612. * Serializes the component data to the specified json object
  2613. * @param serializationObject The object to serialize to
  2614. */
  2615. serialize(serializationObject: any): void;
  2616. }
  2617. /**
  2618. * Strong typing of a Mesh related stage step action
  2619. */
  2620. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2621. /**
  2622. * Strong typing of a Evaluate Sub Mesh related stage step action
  2623. */
  2624. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2625. /**
  2626. * Strong typing of a Active Mesh related stage step action
  2627. */
  2628. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2629. /**
  2630. * Strong typing of a Camera related stage step action
  2631. */
  2632. type CameraStageAction = (camera: Camera) => void;
  2633. /**
  2634. * Strong typing of a RenderingGroup related stage step action
  2635. */
  2636. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2637. /**
  2638. * Strong typing of a Mesh Render related stage step action
  2639. */
  2640. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2641. /**
  2642. * Strong typing of a simple stage step action
  2643. */
  2644. type SimpleStageAction = () => void;
  2645. /**
  2646. * Strong typing of a render target action.
  2647. */
  2648. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2649. /**
  2650. * Strong typing of a pointer move action.
  2651. */
  2652. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2653. /**
  2654. * Strong typing of a pointer up/down action.
  2655. */
  2656. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2657. /**
  2658. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2659. * @hidden
  2660. */
  2661. class Stage<T extends Function> extends Array<{
  2662. index: number;
  2663. component: ISceneComponent;
  2664. action: T;
  2665. }> {
  2666. /**
  2667. * Hide ctor from the rest of the world.
  2668. * @param items The items to add.
  2669. */
  2670. private constructor();
  2671. /**
  2672. * Creates a new Stage.
  2673. * @returns A new instance of a Stage
  2674. */
  2675. static Create<T extends Function>(): Stage<T>;
  2676. /**
  2677. * Registers a step in an ordered way in the targeted stage.
  2678. * @param index Defines the position to register the step in
  2679. * @param component Defines the component attached to the step
  2680. * @param action Defines the action to launch during the step
  2681. */
  2682. registerStep(index: number, component: ISceneComponent, action: T): void;
  2683. /**
  2684. * Clears all the steps from the stage.
  2685. */
  2686. clear(): void;
  2687. }
  2688. }
  2689. declare module BABYLON {
  2690. /** Alias type for value that can be null */
  2691. type Nullable<T> = T | null;
  2692. /**
  2693. * Alias type for number that are floats
  2694. * @ignorenaming
  2695. */
  2696. type float = number;
  2697. /**
  2698. * Alias type for number that are doubles.
  2699. * @ignorenaming
  2700. */
  2701. type double = number;
  2702. /**
  2703. * Alias type for number that are integer
  2704. * @ignorenaming
  2705. */
  2706. type int = number;
  2707. /** Alias type for number array or Float32Array */
  2708. type FloatArray = number[] | Float32Array;
  2709. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2710. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2711. /**
  2712. * Alias for types that can be used by a Buffer or VertexBuffer.
  2713. */
  2714. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2715. }
  2716. declare module BABYLON {
  2717. /**
  2718. * The action to be carried out following a trigger
  2719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2720. */
  2721. class Action {
  2722. /** the trigger, with or without parameters, for the action */
  2723. triggerOptions: any;
  2724. /**
  2725. * Trigger for the action
  2726. */
  2727. trigger: number;
  2728. /**
  2729. * Internal only - manager for action
  2730. * @hidden
  2731. */
  2732. _actionManager: ActionManager;
  2733. private _nextActiveAction;
  2734. private _child;
  2735. private _condition?;
  2736. private _triggerParameter;
  2737. /**
  2738. * An event triggered prior to action being executed.
  2739. */
  2740. onBeforeExecuteObservable: Observable<Action>;
  2741. /**
  2742. * Creates a new Action
  2743. * @param triggerOptions the trigger, with or without parameters, for the action
  2744. * @param condition an optional determinant of action
  2745. */
  2746. constructor(
  2747. /** the trigger, with or without parameters, for the action */
  2748. triggerOptions: any, condition?: Condition);
  2749. /**
  2750. * Internal only
  2751. * @hidden
  2752. */
  2753. _prepare(): void;
  2754. /**
  2755. * Gets the trigger parameters
  2756. * @returns the trigger parameters
  2757. */
  2758. getTriggerParameter(): any;
  2759. /**
  2760. * Internal only - executes current action event
  2761. * @hidden
  2762. */
  2763. _executeCurrent(evt?: ActionEvent): void;
  2764. /**
  2765. * Execute placeholder for child classes
  2766. * @param evt optional action event
  2767. */
  2768. execute(evt?: ActionEvent): void;
  2769. /**
  2770. * Skips to next active action
  2771. */
  2772. skipToNextActiveAction(): void;
  2773. /**
  2774. * Adds action to chain of actions, may be a DoNothingAction
  2775. * @param action defines the next action to execute
  2776. * @returns The action passed in
  2777. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2778. */
  2779. then(action: Action): Action;
  2780. /**
  2781. * Internal only
  2782. * @hidden
  2783. */
  2784. _getProperty(propertyPath: string): string;
  2785. /**
  2786. * Internal only
  2787. * @hidden
  2788. */
  2789. _getEffectiveTarget(target: any, propertyPath: string): any;
  2790. /**
  2791. * Serialize placeholder for child classes
  2792. * @param parent of child
  2793. * @returns the serialized object
  2794. */
  2795. serialize(parent: any): any;
  2796. /**
  2797. * Internal only called by serialize
  2798. * @hidden
  2799. */
  2800. protected _serialize(serializedAction: any, parent?: any): any;
  2801. /**
  2802. * Internal only
  2803. * @hidden
  2804. */
  2805. static _SerializeValueAsString: (value: any) => string;
  2806. /**
  2807. * Internal only
  2808. * @hidden
  2809. */
  2810. static _GetTargetProperty: (target: Scene | Node) => {
  2811. name: string;
  2812. targetType: string;
  2813. value: string;
  2814. };
  2815. }
  2816. }
  2817. declare module BABYLON {
  2818. /**
  2819. * ActionEvent is the event being sent when an action is triggered.
  2820. */
  2821. class ActionEvent {
  2822. /** The mesh or sprite that triggered the action */
  2823. source: any;
  2824. /** The X mouse cursor position at the time of the event */
  2825. pointerX: number;
  2826. /** The Y mouse cursor position at the time of the event */
  2827. pointerY: number;
  2828. /** The mesh that is currently pointed at (can be null) */
  2829. meshUnderPointer: Nullable<AbstractMesh>;
  2830. /** the original (browser) event that triggered the ActionEvent */
  2831. sourceEvent?: any;
  2832. /** additional data for the event */
  2833. additionalData?: any;
  2834. /**
  2835. * Creates a new ActionEvent
  2836. * @param source The mesh or sprite that triggered the action
  2837. * @param pointerX The X mouse cursor position at the time of the event
  2838. * @param pointerY The Y mouse cursor position at the time of the event
  2839. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2840. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2841. * @param additionalData additional data for the event
  2842. */
  2843. constructor(
  2844. /** The mesh or sprite that triggered the action */
  2845. source: any,
  2846. /** The X mouse cursor position at the time of the event */
  2847. pointerX: number,
  2848. /** The Y mouse cursor position at the time of the event */
  2849. pointerY: number,
  2850. /** The mesh that is currently pointed at (can be null) */
  2851. meshUnderPointer: Nullable<AbstractMesh>,
  2852. /** the original (browser) event that triggered the ActionEvent */
  2853. sourceEvent?: any,
  2854. /** additional data for the event */
  2855. additionalData?: any);
  2856. /**
  2857. * Helper function to auto-create an ActionEvent from a source mesh.
  2858. * @param source The source mesh that triggered the event
  2859. * @param evt The original (browser) event
  2860. * @param additionalData additional data for the event
  2861. * @returns the new ActionEvent
  2862. */
  2863. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2864. /**
  2865. * Helper function to auto-create an ActionEvent from a source sprite
  2866. * @param source The source sprite that triggered the event
  2867. * @param scene Scene associated with the sprite
  2868. * @param evt The original (browser) event
  2869. * @param additionalData additional data for the event
  2870. * @returns the new ActionEvent
  2871. */
  2872. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2873. /**
  2874. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2875. * @param scene the scene where the event occurred
  2876. * @param evt The original (browser) event
  2877. * @returns the new ActionEvent
  2878. */
  2879. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2880. /**
  2881. * Helper function to auto-create an ActionEvent from a primitive
  2882. * @param prim defines the target primitive
  2883. * @param pointerPos defines the pointer position
  2884. * @param evt The original (browser) event
  2885. * @param additionalData additional data for the event
  2886. * @returns the new ActionEvent
  2887. */
  2888. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2889. }
  2890. /**
  2891. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2892. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2894. */
  2895. class ActionManager {
  2896. /**
  2897. * Nothing
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly NothingTrigger: number;
  2901. /**
  2902. * On pick
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnPickTrigger: number;
  2906. /**
  2907. * On left pick
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnLeftPickTrigger: number;
  2911. /**
  2912. * On right pick
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnRightPickTrigger: number;
  2916. /**
  2917. * On center pick
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnCenterPickTrigger: number;
  2921. /**
  2922. * On pick down
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnPickDownTrigger: number;
  2926. /**
  2927. * On double pick
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnDoublePickTrigger: number;
  2931. /**
  2932. * On pick up
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnPickUpTrigger: number;
  2936. /**
  2937. * On pick out.
  2938. * This trigger will only be raised if you also declared a OnPickDown
  2939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2940. */
  2941. static readonly OnPickOutTrigger: number;
  2942. /**
  2943. * On long press
  2944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2945. */
  2946. static readonly OnLongPressTrigger: number;
  2947. /**
  2948. * On pointer over
  2949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2950. */
  2951. static readonly OnPointerOverTrigger: number;
  2952. /**
  2953. * On pointer out
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2955. */
  2956. static readonly OnPointerOutTrigger: number;
  2957. /**
  2958. * On every frame
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnEveryFrameTrigger: number;
  2962. /**
  2963. * On intersection enter
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnIntersectionEnterTrigger: number;
  2967. /**
  2968. * On intersection exit
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnIntersectionExitTrigger: number;
  2972. /**
  2973. * On key down
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnKeyDownTrigger: number;
  2977. /**
  2978. * On key up
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnKeyUpTrigger: number;
  2982. /** Gets the list of active triggers */
  2983. static Triggers: {
  2984. [key: string]: number;
  2985. };
  2986. /** Gets the list of actions */
  2987. actions: Action[];
  2988. /** Gets the cursor to use when hovering items */
  2989. hoverCursor: string;
  2990. private _scene;
  2991. /**
  2992. * Creates a new action manager
  2993. * @param scene defines the hosting scene
  2994. */
  2995. constructor(scene: Scene);
  2996. /**
  2997. * Releases all associated resources
  2998. */
  2999. dispose(): void;
  3000. /**
  3001. * Gets hosting scene
  3002. * @returns the hosting scene
  3003. */
  3004. getScene(): Scene;
  3005. /**
  3006. * Does this action manager handles actions of any of the given triggers
  3007. * @param triggers defines the triggers to be tested
  3008. * @return a boolean indicating whether one (or more) of the triggers is handled
  3009. */
  3010. hasSpecificTriggers(triggers: number[]): boolean;
  3011. /**
  3012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3013. * speed.
  3014. * @param triggerA defines the trigger to be tested
  3015. * @param triggerB defines the trigger to be tested
  3016. * @return a boolean indicating whether one (or more) of the triggers is handled
  3017. */
  3018. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3019. /**
  3020. * Does this action manager handles actions of a given trigger
  3021. * @param trigger defines the trigger to be tested
  3022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3023. * @return whether the trigger is handled
  3024. */
  3025. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3026. /**
  3027. * Does this action manager has pointer triggers
  3028. */
  3029. readonly hasPointerTriggers: boolean;
  3030. /**
  3031. * Does this action manager has pick triggers
  3032. */
  3033. readonly hasPickTriggers: boolean;
  3034. /**
  3035. * Does exist one action manager with at least one trigger
  3036. **/
  3037. static readonly HasTriggers: boolean;
  3038. /**
  3039. * Does exist one action manager with at least one pick trigger
  3040. **/
  3041. static readonly HasPickTriggers: boolean;
  3042. /**
  3043. * Does exist one action manager that handles actions of a given trigger
  3044. * @param trigger defines the trigger to be tested
  3045. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3046. **/
  3047. static HasSpecificTrigger(trigger: number): boolean;
  3048. /**
  3049. * Registers an action to this action manager
  3050. * @param action defines the action to be registered
  3051. * @return the action amended (prepared) after registration
  3052. */
  3053. registerAction(action: Action): Nullable<Action>;
  3054. /**
  3055. * Unregisters an action to this action manager
  3056. * @param action defines the action to be unregistered
  3057. * @return a boolean indicating whether the action has been unregistered
  3058. */
  3059. unregisterAction(action: Action): Boolean;
  3060. /**
  3061. * Process a specific trigger
  3062. * @param trigger defines the trigger to process
  3063. * @param evt defines the event details to be processed
  3064. */
  3065. processTrigger(trigger: number, evt?: ActionEvent): void;
  3066. /** @hidden */
  3067. _getEffectiveTarget(target: any, propertyPath: string): any;
  3068. /** @hidden */
  3069. _getProperty(propertyPath: string): string;
  3070. /**
  3071. * Serialize this manager to a JSON object
  3072. * @param name defines the property name to store this manager
  3073. * @returns a JSON representation of this manager
  3074. */
  3075. serialize(name: string): any;
  3076. /**
  3077. * Creates a new ActionManager from a JSON data
  3078. * @param parsedActions defines the JSON data to read from
  3079. * @param object defines the hosting mesh
  3080. * @param scene defines the hosting scene
  3081. */
  3082. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3083. /**
  3084. * Get a trigger name by index
  3085. * @param trigger defines the trigger index
  3086. * @returns a trigger name
  3087. */
  3088. static GetTriggerName(trigger: number): string;
  3089. }
  3090. }
  3091. declare module BABYLON {
  3092. /**
  3093. * A Condition applied to an Action
  3094. */
  3095. class Condition {
  3096. /**
  3097. * Internal only - manager for action
  3098. * @hidden
  3099. */
  3100. _actionManager: ActionManager;
  3101. /**
  3102. * Internal only
  3103. * @hidden
  3104. */
  3105. _evaluationId: number;
  3106. /**
  3107. * Internal only
  3108. * @hidden
  3109. */
  3110. _currentResult: boolean;
  3111. /**
  3112. * Creates a new Condition
  3113. * @param actionManager the manager of the action the condition is applied to
  3114. */
  3115. constructor(actionManager: ActionManager);
  3116. /**
  3117. * Check if the current condition is valid
  3118. * @returns a boolean
  3119. */
  3120. isValid(): boolean;
  3121. /**
  3122. * Internal only
  3123. * @hidden
  3124. */
  3125. _getProperty(propertyPath: string): string;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. _getEffectiveTarget(target: any, propertyPath: string): any;
  3131. /**
  3132. * Serialize placeholder for child classes
  3133. * @returns the serialized object
  3134. */
  3135. serialize(): any;
  3136. /**
  3137. * Internal only
  3138. * @hidden
  3139. */
  3140. protected _serialize(serializedCondition: any): any;
  3141. }
  3142. /**
  3143. * Defines specific conditional operators as extensions of Condition
  3144. */
  3145. class ValueCondition extends Condition {
  3146. /** path to specify the property of the target the conditional operator uses */
  3147. propertyPath: string;
  3148. /** the value compared by the conditional operator against the current value of the property */
  3149. value: any;
  3150. /** the conditional operator, default ValueCondition.IsEqual */
  3151. operator: number;
  3152. /**
  3153. * Internal only
  3154. * @hidden
  3155. */
  3156. private static _IsEqual;
  3157. /**
  3158. * Internal only
  3159. * @hidden
  3160. */
  3161. private static _IsDifferent;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private static _IsGreater;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private static _IsLesser;
  3172. /**
  3173. * returns the number for IsEqual
  3174. */
  3175. static readonly IsEqual: number;
  3176. /**
  3177. * Returns the number for IsDifferent
  3178. */
  3179. static readonly IsDifferent: number;
  3180. /**
  3181. * Returns the number for IsGreater
  3182. */
  3183. static readonly IsGreater: number;
  3184. /**
  3185. * Returns the number for IsLesser
  3186. */
  3187. static readonly IsLesser: number;
  3188. /**
  3189. * Internal only The action manager for the condition
  3190. * @hidden
  3191. */
  3192. _actionManager: ActionManager;
  3193. /**
  3194. * Internal only
  3195. * @hidden
  3196. */
  3197. private _target;
  3198. /**
  3199. * Internal only
  3200. * @hidden
  3201. */
  3202. private _effectiveTarget;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. private _property;
  3208. /**
  3209. * Creates a new ValueCondition
  3210. * @param actionManager manager for the action the condition applies to
  3211. * @param target for the action
  3212. * @param propertyPath path to specify the property of the target the conditional operator uses
  3213. * @param value the value compared by the conditional operator against the current value of the property
  3214. * @param operator the conditional operator, default ValueCondition.IsEqual
  3215. */
  3216. constructor(actionManager: ActionManager, target: any,
  3217. /** path to specify the property of the target the conditional operator uses */
  3218. propertyPath: string,
  3219. /** the value compared by the conditional operator against the current value of the property */
  3220. value: any,
  3221. /** the conditional operator, default ValueCondition.IsEqual */
  3222. operator?: number);
  3223. /**
  3224. * Compares the given value with the property value for the specified conditional operator
  3225. * @returns the result of the comparison
  3226. */
  3227. isValid(): boolean;
  3228. /**
  3229. * Serialize the ValueCondition into a JSON compatible object
  3230. * @returns serialization object
  3231. */
  3232. serialize(): any;
  3233. /**
  3234. * Gets the name of the conditional operator for the ValueCondition
  3235. * @param operator the conditional operator
  3236. * @returns the name
  3237. */
  3238. static GetOperatorName(operator: number): string;
  3239. }
  3240. /**
  3241. * Defines a predicate condition as an extension of Condition
  3242. */
  3243. class PredicateCondition extends Condition {
  3244. /** defines the predicate function used to validate the condition */
  3245. predicate: () => boolean;
  3246. /**
  3247. * Internal only - manager for action
  3248. * @hidden
  3249. */
  3250. _actionManager: ActionManager;
  3251. /**
  3252. * Creates a new PredicateCondition
  3253. * @param actionManager manager for the action the condition applies to
  3254. * @param predicate defines the predicate function used to validate the condition
  3255. */
  3256. constructor(actionManager: ActionManager,
  3257. /** defines the predicate function used to validate the condition */
  3258. predicate: () => boolean);
  3259. /**
  3260. * @returns the validity of the predicate condition
  3261. */
  3262. isValid(): boolean;
  3263. }
  3264. /**
  3265. * Defines a state condition as an extension of Condition
  3266. */
  3267. class StateCondition extends Condition {
  3268. /** Value to compare with target state */
  3269. value: string;
  3270. /**
  3271. * Internal only - manager for action
  3272. * @hidden
  3273. */
  3274. _actionManager: ActionManager;
  3275. /**
  3276. * Internal only
  3277. * @hidden
  3278. */
  3279. private _target;
  3280. /**
  3281. * Creates a new StateCondition
  3282. * @param actionManager manager for the action the condition applies to
  3283. * @param target of the condition
  3284. * @param value to compare with target state
  3285. */
  3286. constructor(actionManager: ActionManager, target: any,
  3287. /** Value to compare with target state */
  3288. value: string);
  3289. /**
  3290. * Gets a boolean indicating if the current condition is met
  3291. * @returns the validity of the state
  3292. */
  3293. isValid(): boolean;
  3294. /**
  3295. * Serialize the StateCondition into a JSON compatible object
  3296. * @returns serialization object
  3297. */
  3298. serialize(): any;
  3299. }
  3300. }
  3301. declare module BABYLON {
  3302. /**
  3303. * This defines an action responsible to toggle a boolean once triggered.
  3304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3305. */
  3306. class SwitchBooleanAction extends Action {
  3307. /**
  3308. * The path to the boolean property in the target object
  3309. */
  3310. propertyPath: string;
  3311. private _target;
  3312. private _effectiveTarget;
  3313. private _property;
  3314. /**
  3315. * Instantiate the action
  3316. * @param triggerOptions defines the trigger options
  3317. * @param target defines the object containing the boolean
  3318. * @param propertyPath defines the path to the boolean property in the target object
  3319. * @param condition defines the trigger related conditions
  3320. */
  3321. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3322. /** @hidden */
  3323. _prepare(): void;
  3324. /**
  3325. * Execute the action toggle the boolean value.
  3326. */
  3327. execute(): void;
  3328. /**
  3329. * Serializes the actions and its related information.
  3330. * @param parent defines the object to serialize in
  3331. * @returns the serialized object
  3332. */
  3333. serialize(parent: any): any;
  3334. }
  3335. /**
  3336. * This defines an action responsible to set a the state field of the target
  3337. * to a desired value once triggered.
  3338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3339. */
  3340. class SetStateAction extends Action {
  3341. /**
  3342. * The value to store in the state field.
  3343. */
  3344. value: string;
  3345. private _target;
  3346. /**
  3347. * Instantiate the action
  3348. * @param triggerOptions defines the trigger options
  3349. * @param target defines the object containing the state property
  3350. * @param value defines the value to store in the state field
  3351. * @param condition defines the trigger related conditions
  3352. */
  3353. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3354. /**
  3355. * Execute the action and store the value on the target state property.
  3356. */
  3357. execute(): void;
  3358. /**
  3359. * Serializes the actions and its related information.
  3360. * @param parent defines the object to serialize in
  3361. * @returns the serialized object
  3362. */
  3363. serialize(parent: any): any;
  3364. }
  3365. /**
  3366. * This defines an action responsible to set a property of the target
  3367. * to a desired value once triggered.
  3368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3369. */
  3370. class SetValueAction extends Action {
  3371. /**
  3372. * The path of the property to set in the target.
  3373. */
  3374. propertyPath: string;
  3375. /**
  3376. * The value to set in the property
  3377. */
  3378. value: any;
  3379. private _target;
  3380. private _effectiveTarget;
  3381. private _property;
  3382. /**
  3383. * Instantiate the action
  3384. * @param triggerOptions defines the trigger options
  3385. * @param target defines the object containing the property
  3386. * @param propertyPath defines the path of the property to set in the target
  3387. * @param value defines the value to set in the property
  3388. * @param condition defines the trigger related conditions
  3389. */
  3390. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3391. /** @hidden */
  3392. _prepare(): void;
  3393. /**
  3394. * Execute the action and set the targetted property to the desired value.
  3395. */
  3396. execute(): void;
  3397. /**
  3398. * Serializes the actions and its related information.
  3399. * @param parent defines the object to serialize in
  3400. * @returns the serialized object
  3401. */
  3402. serialize(parent: any): any;
  3403. }
  3404. /**
  3405. * This defines an action responsible to increment the target value
  3406. * to a desired value once triggered.
  3407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3408. */
  3409. class IncrementValueAction extends Action {
  3410. /**
  3411. * The path of the property to increment in the target.
  3412. */
  3413. propertyPath: string;
  3414. /**
  3415. * The value we should increment the property by.
  3416. */
  3417. value: any;
  3418. private _target;
  3419. private _effectiveTarget;
  3420. private _property;
  3421. /**
  3422. * Instantiate the action
  3423. * @param triggerOptions defines the trigger options
  3424. * @param target defines the object containing the property
  3425. * @param propertyPath defines the path of the property to increment in the target
  3426. * @param value defines the value value we should increment the property by
  3427. * @param condition defines the trigger related conditions
  3428. */
  3429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3430. /** @hidden */
  3431. _prepare(): void;
  3432. /**
  3433. * Execute the action and increment the target of the value amount.
  3434. */
  3435. execute(): void;
  3436. /**
  3437. * Serializes the actions and its related information.
  3438. * @param parent defines the object to serialize in
  3439. * @returns the serialized object
  3440. */
  3441. serialize(parent: any): any;
  3442. }
  3443. /**
  3444. * This defines an action responsible to start an animation once triggered.
  3445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3446. */
  3447. class PlayAnimationAction extends Action {
  3448. /**
  3449. * Where the animation should start (animation frame)
  3450. */
  3451. from: number;
  3452. /**
  3453. * Where the animation should stop (animation frame)
  3454. */
  3455. to: number;
  3456. /**
  3457. * Define if the animation should loop or stop after the first play.
  3458. */
  3459. loop?: boolean;
  3460. private _target;
  3461. /**
  3462. * Instantiate the action
  3463. * @param triggerOptions defines the trigger options
  3464. * @param target defines the target animation or animation name
  3465. * @param from defines from where the animation should start (animation frame)
  3466. * @param end defines where the animation should stop (animation frame)
  3467. * @param loop defines if the animation should loop or stop after the first play
  3468. * @param condition defines the trigger related conditions
  3469. */
  3470. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3471. /** @hidden */
  3472. _prepare(): void;
  3473. /**
  3474. * Execute the action and play the animation.
  3475. */
  3476. execute(): void;
  3477. /**
  3478. * Serializes the actions and its related information.
  3479. * @param parent defines the object to serialize in
  3480. * @returns the serialized object
  3481. */
  3482. serialize(parent: any): any;
  3483. }
  3484. /**
  3485. * This defines an action responsible to stop an animation once triggered.
  3486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3487. */
  3488. class StopAnimationAction extends Action {
  3489. private _target;
  3490. /**
  3491. * Instantiate the action
  3492. * @param triggerOptions defines the trigger options
  3493. * @param target defines the target animation or animation name
  3494. * @param condition defines the trigger related conditions
  3495. */
  3496. constructor(triggerOptions: any, target: any, condition?: Condition);
  3497. /** @hidden */
  3498. _prepare(): void;
  3499. /**
  3500. * Execute the action and stop the animation.
  3501. */
  3502. execute(): void;
  3503. /**
  3504. * Serializes the actions and its related information.
  3505. * @param parent defines the object to serialize in
  3506. * @returns the serialized object
  3507. */
  3508. serialize(parent: any): any;
  3509. }
  3510. /**
  3511. * This defines an action responsible that does nothing once triggered.
  3512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3513. */
  3514. class DoNothingAction extends Action {
  3515. /**
  3516. * Instantiate the action
  3517. * @param triggerOptions defines the trigger options
  3518. * @param condition defines the trigger related conditions
  3519. */
  3520. constructor(triggerOptions?: any, condition?: Condition);
  3521. /**
  3522. * Execute the action and do nothing.
  3523. */
  3524. execute(): void;
  3525. /**
  3526. * Serializes the actions and its related information.
  3527. * @param parent defines the object to serialize in
  3528. * @returns the serialized object
  3529. */
  3530. serialize(parent: any): any;
  3531. }
  3532. /**
  3533. * This defines an action responsible to trigger several actions once triggered.
  3534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3535. */
  3536. class CombineAction extends Action {
  3537. /**
  3538. * The list of aggregated animations to run.
  3539. */
  3540. children: Action[];
  3541. /**
  3542. * Instantiate the action
  3543. * @param triggerOptions defines the trigger options
  3544. * @param children defines the list of aggregated animations to run
  3545. * @param condition defines the trigger related conditions
  3546. */
  3547. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3548. /** @hidden */
  3549. _prepare(): void;
  3550. /**
  3551. * Execute the action and executes all the aggregated actions.
  3552. */
  3553. execute(evt: ActionEvent): void;
  3554. /**
  3555. * Serializes the actions and its related information.
  3556. * @param parent defines the object to serialize in
  3557. * @returns the serialized object
  3558. */
  3559. serialize(parent: any): any;
  3560. }
  3561. /**
  3562. * This defines an action responsible to run code (external event) once triggered.
  3563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3564. */
  3565. class ExecuteCodeAction extends Action {
  3566. /**
  3567. * The callback function to run.
  3568. */
  3569. func: (evt: ActionEvent) => void;
  3570. /**
  3571. * Instantiate the action
  3572. * @param triggerOptions defines the trigger options
  3573. * @param func defines the callback function to run
  3574. * @param condition defines the trigger related conditions
  3575. */
  3576. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3577. /**
  3578. * Execute the action and run the attached code.
  3579. */
  3580. execute(evt: ActionEvent): void;
  3581. }
  3582. /**
  3583. * This defines an action responsible to set the parent property of the target once triggered.
  3584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3585. */
  3586. class SetParentAction extends Action {
  3587. private _parent;
  3588. private _target;
  3589. /**
  3590. * Instantiate the action
  3591. * @param triggerOptions defines the trigger options
  3592. * @param target defines the target containing the parent property
  3593. * @param parent defines from where the animation should start (animation frame)
  3594. * @param condition defines the trigger related conditions
  3595. */
  3596. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3597. /** @hidden */
  3598. _prepare(): void;
  3599. /**
  3600. * Execute the action and set the parent property.
  3601. */
  3602. execute(): void;
  3603. /**
  3604. * Serializes the actions and its related information.
  3605. * @param parent defines the object to serialize in
  3606. * @returns the serialized object
  3607. */
  3608. serialize(parent: any): any;
  3609. }
  3610. }
  3611. declare module BABYLON {
  3612. /**
  3613. * This defines an action helpful to play a defined sound on a triggered action.
  3614. */
  3615. class PlaySoundAction extends Action {
  3616. private _sound;
  3617. /**
  3618. * Instantiate the action
  3619. * @param triggerOptions defines the trigger options
  3620. * @param sound defines the sound to play
  3621. * @param condition defines the trigger related conditions
  3622. */
  3623. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3624. /** @hidden */
  3625. _prepare(): void;
  3626. /**
  3627. * Execute the action and play the sound.
  3628. */
  3629. execute(): void;
  3630. /**
  3631. * Serializes the actions and its related information.
  3632. * @param parent defines the object to serialize in
  3633. * @returns the serialized object
  3634. */
  3635. serialize(parent: any): any;
  3636. }
  3637. /**
  3638. * This defines an action helpful to stop a defined sound on a triggered action.
  3639. */
  3640. class StopSoundAction extends Action {
  3641. private _sound;
  3642. /**
  3643. * Instantiate the action
  3644. * @param triggerOptions defines the trigger options
  3645. * @param sound defines the sound to stop
  3646. * @param condition defines the trigger related conditions
  3647. */
  3648. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3649. /** @hidden */
  3650. _prepare(): void;
  3651. /**
  3652. * Execute the action and stop the sound.
  3653. */
  3654. execute(): void;
  3655. /**
  3656. * Serializes the actions and its related information.
  3657. * @param parent defines the object to serialize in
  3658. * @returns the serialized object
  3659. */
  3660. serialize(parent: any): any;
  3661. }
  3662. }
  3663. declare module BABYLON {
  3664. /**
  3665. * This defines an action responsible to change the value of a property
  3666. * by interpolating between its current value and the newly set one once triggered.
  3667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3668. */
  3669. class InterpolateValueAction extends Action {
  3670. /**
  3671. * Defines the path of the property where the value should be interpolated
  3672. */
  3673. propertyPath: string;
  3674. /**
  3675. * Defines the target value at the end of the interpolation.
  3676. */
  3677. value: any;
  3678. /**
  3679. * Defines the time it will take for the property to interpolate to the value.
  3680. */
  3681. duration: number;
  3682. /**
  3683. * Defines if the other scene animations should be stopped when the action has been triggered
  3684. */
  3685. stopOtherAnimations?: boolean;
  3686. /**
  3687. * Defines a callback raised once the interpolation animation has been done.
  3688. */
  3689. onInterpolationDone?: () => void;
  3690. /**
  3691. * Observable triggered once the interpolation animation has been done.
  3692. */
  3693. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3694. private _target;
  3695. private _effectiveTarget;
  3696. private _property;
  3697. /**
  3698. * Instantiate the action
  3699. * @param triggerOptions defines the trigger options
  3700. * @param target defines the object containing the value to interpolate
  3701. * @param propertyPath defines the path to the property in the target object
  3702. * @param value defines the target value at the end of the interpolation
  3703. * @param duration deines the time it will take for the property to interpolate to the value.
  3704. * @param condition defines the trigger related conditions
  3705. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3706. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3707. */
  3708. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3709. /** @hidden */
  3710. _prepare(): void;
  3711. /**
  3712. * Execute the action starts the value interpolation.
  3713. */
  3714. execute(): void;
  3715. /**
  3716. * Serializes the actions and its related information.
  3717. * @param parent defines the object to serialize in
  3718. * @returns the serialized object
  3719. */
  3720. serialize(parent: any): any;
  3721. }
  3722. }
  3723. declare module BABYLON {
  3724. /**
  3725. * Class used to store an actual running animation
  3726. */
  3727. class Animatable {
  3728. /** defines the target object */
  3729. target: any;
  3730. /** defines the starting frame number (default is 0) */
  3731. fromFrame: number;
  3732. /** defines the ending frame number (default is 100) */
  3733. toFrame: number;
  3734. /** defines if the animation must loop (default is false) */
  3735. loopAnimation: boolean;
  3736. /** defines a callback to call when animation ends if it is not looping */
  3737. onAnimationEnd?: (() => void) | null | undefined;
  3738. private _localDelayOffset;
  3739. private _pausedDelay;
  3740. private _runtimeAnimations;
  3741. private _paused;
  3742. private _scene;
  3743. private _speedRatio;
  3744. private _weight;
  3745. private _syncRoot;
  3746. /**
  3747. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3748. * This will only apply for non looping animation (default is true)
  3749. */
  3750. disposeOnEnd: boolean;
  3751. /**
  3752. * Gets a boolean indicating if the animation has started
  3753. */
  3754. animationStarted: boolean;
  3755. /**
  3756. * Observer raised when the animation ends
  3757. */
  3758. onAnimationEndObservable: Observable<Animatable>;
  3759. /**
  3760. * Gets the root Animatable used to synchronize and normalize animations
  3761. */
  3762. readonly syncRoot: Animatable;
  3763. /**
  3764. * Gets the current frame of the first RuntimeAnimation
  3765. * Used to synchronize Animatables
  3766. */
  3767. readonly masterFrame: number;
  3768. /**
  3769. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3770. */
  3771. weight: number;
  3772. /**
  3773. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3774. */
  3775. speedRatio: number;
  3776. /**
  3777. * Creates a new Animatable
  3778. * @param scene defines the hosting scene
  3779. * @param target defines the target object
  3780. * @param fromFrame defines the starting frame number (default is 0)
  3781. * @param toFrame defines the ending frame number (default is 100)
  3782. * @param loopAnimation defines if the animation must loop (default is false)
  3783. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3784. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3785. * @param animations defines a group of animation to add to the new Animatable
  3786. */
  3787. constructor(scene: Scene,
  3788. /** defines the target object */
  3789. target: any,
  3790. /** defines the starting frame number (default is 0) */
  3791. fromFrame?: number,
  3792. /** defines the ending frame number (default is 100) */
  3793. toFrame?: number,
  3794. /** defines if the animation must loop (default is false) */
  3795. loopAnimation?: boolean, speedRatio?: number,
  3796. /** defines a callback to call when animation ends if it is not looping */
  3797. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3798. /**
  3799. * Synchronize and normalize current Animatable with a source Animatable
  3800. * This is useful when using animation weights and when animations are not of the same length
  3801. * @param root defines the root Animatable to synchronize with
  3802. * @returns the current Animatable
  3803. */
  3804. syncWith(root: Animatable): Animatable;
  3805. /**
  3806. * Gets the list of runtime animations
  3807. * @returns an array of RuntimeAnimation
  3808. */
  3809. getAnimations(): RuntimeAnimation[];
  3810. /**
  3811. * Adds more animations to the current animatable
  3812. * @param target defines the target of the animations
  3813. * @param animations defines the new animations to add
  3814. */
  3815. appendAnimations(target: any, animations: Animation[]): void;
  3816. /**
  3817. * Gets the source animation for a specific property
  3818. * @param property defines the propertyu to look for
  3819. * @returns null or the source animation for the given property
  3820. */
  3821. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3822. /**
  3823. * Gets the runtime animation for a specific property
  3824. * @param property defines the propertyu to look for
  3825. * @returns null or the runtime animation for the given property
  3826. */
  3827. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3828. /**
  3829. * Resets the animatable to its original state
  3830. */
  3831. reset(): void;
  3832. /**
  3833. * Allows the animatable to blend with current running animations
  3834. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3835. * @param blendingSpeed defines the blending speed to use
  3836. */
  3837. enableBlending(blendingSpeed: number): void;
  3838. /**
  3839. * Disable animation blending
  3840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3841. */
  3842. disableBlending(): void;
  3843. /**
  3844. * Jump directly to a given frame
  3845. * @param frame defines the frame to jump to
  3846. */
  3847. goToFrame(frame: number): void;
  3848. /**
  3849. * Pause the animation
  3850. */
  3851. pause(): void;
  3852. /**
  3853. * Restart the animation
  3854. */
  3855. restart(): void;
  3856. private _raiseOnAnimationEnd;
  3857. /**
  3858. * Stop and delete the current animation
  3859. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3860. * @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)
  3861. */
  3862. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3863. /**
  3864. * Wait asynchronously for the animation to end
  3865. * @returns a promise which will be fullfilled when the animation ends
  3866. */
  3867. waitAsync(): Promise<Animatable>;
  3868. /** @hidden */
  3869. _animate(delay: number): boolean;
  3870. }
  3871. }
  3872. declare module BABYLON {
  3873. /**
  3874. * Represents the range of an animation
  3875. */
  3876. class AnimationRange {
  3877. /**The name of the animation range**/
  3878. name: string;
  3879. /**The starting frame of the animation */
  3880. from: number;
  3881. /**The ending frame of the animation*/
  3882. to: number;
  3883. /**
  3884. * Initializes the range of an animation
  3885. * @param name The name of the animation range
  3886. * @param from The starting frame of the animation
  3887. * @param to The ending frame of the animation
  3888. */
  3889. constructor(
  3890. /**The name of the animation range**/
  3891. name: string,
  3892. /**The starting frame of the animation */
  3893. from: number,
  3894. /**The ending frame of the animation*/
  3895. to: number);
  3896. /**
  3897. * Makes a copy of the animation range
  3898. * @returns A copy of the animation range
  3899. */
  3900. clone(): AnimationRange;
  3901. }
  3902. /**
  3903. * Composed of a frame, and an action function
  3904. */
  3905. class AnimationEvent {
  3906. /** The frame for which the event is triggered **/
  3907. frame: number;
  3908. /** The event to perform when triggered **/
  3909. action: (currentFrame: number) => void;
  3910. /** Specifies if the event should be triggered only once**/
  3911. onlyOnce?: boolean | undefined;
  3912. /**
  3913. * Specifies if the animation event is done
  3914. */
  3915. isDone: boolean;
  3916. /**
  3917. * Initializes the animation event
  3918. * @param frame The frame for which the event is triggered
  3919. * @param action The event to perform when triggered
  3920. * @param onlyOnce Specifies if the event should be triggered only once
  3921. */
  3922. constructor(
  3923. /** The frame for which the event is triggered **/
  3924. frame: number,
  3925. /** The event to perform when triggered **/
  3926. action: (currentFrame: number) => void,
  3927. /** Specifies if the event should be triggered only once**/
  3928. onlyOnce?: boolean | undefined);
  3929. /** @hidden */
  3930. _clone(): AnimationEvent;
  3931. }
  3932. /**
  3933. * A cursor which tracks a point on a path
  3934. */
  3935. class PathCursor {
  3936. private path;
  3937. /**
  3938. * Stores path cursor callbacks for when an onchange event is triggered
  3939. */
  3940. private _onchange;
  3941. /**
  3942. * The value of the path cursor
  3943. */
  3944. value: number;
  3945. /**
  3946. * The animation array of the path cursor
  3947. */
  3948. animations: Animation[];
  3949. /**
  3950. * Initializes the path cursor
  3951. * @param path The path to track
  3952. */
  3953. constructor(path: Path2);
  3954. /**
  3955. * Gets the cursor point on the path
  3956. * @returns A point on the path cursor at the cursor location
  3957. */
  3958. getPoint(): Vector3;
  3959. /**
  3960. * Moves the cursor ahead by the step amount
  3961. * @param step The amount to move the cursor forward
  3962. * @returns This path cursor
  3963. */
  3964. moveAhead(step?: number): PathCursor;
  3965. /**
  3966. * Moves the cursor behind by the step amount
  3967. * @param step The amount to move the cursor back
  3968. * @returns This path cursor
  3969. */
  3970. moveBack(step?: number): PathCursor;
  3971. /**
  3972. * Moves the cursor by the step amount
  3973. * If the step amount is greater than one, an exception is thrown
  3974. * @param step The amount to move the cursor
  3975. * @returns This path cursor
  3976. */
  3977. move(step: number): PathCursor;
  3978. /**
  3979. * Ensures that the value is limited between zero and one
  3980. * @returns This path cursor
  3981. */
  3982. private ensureLimits;
  3983. /**
  3984. * Runs onchange callbacks on change (used by the animation engine)
  3985. * @returns This path cursor
  3986. */
  3987. private raiseOnChange;
  3988. /**
  3989. * Executes a function on change
  3990. * @param f A path cursor onchange callback
  3991. * @returns This path cursor
  3992. */
  3993. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3994. }
  3995. /**
  3996. * Defines an interface which represents an animation key frame
  3997. */
  3998. interface IAnimationKey {
  3999. /**
  4000. * Frame of the key frame
  4001. */
  4002. frame: number;
  4003. /**
  4004. * Value at the specifies key frame
  4005. */
  4006. value: any;
  4007. /**
  4008. * The input tangent for the cubic hermite spline
  4009. */
  4010. inTangent?: any;
  4011. /**
  4012. * The output tangent for the cubic hermite spline
  4013. */
  4014. outTangent?: any;
  4015. /**
  4016. * The animation interpolation type
  4017. */
  4018. interpolation?: AnimationKeyInterpolation;
  4019. }
  4020. /**
  4021. * Enum for the animation key frame interpolation type
  4022. */
  4023. enum AnimationKeyInterpolation {
  4024. /**
  4025. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4026. */
  4027. STEP = 1
  4028. }
  4029. /**
  4030. * Class used to store any kind of animation
  4031. */
  4032. class Animation {
  4033. /**Name of the animation */
  4034. name: string;
  4035. /**Property to animate */
  4036. targetProperty: string;
  4037. /**The frames per second of the animation */
  4038. framePerSecond: number;
  4039. /**The data type of the animation */
  4040. dataType: number;
  4041. /**The loop mode of the animation */
  4042. loopMode?: number | undefined;
  4043. /**Specifies if blending should be enabled */
  4044. enableBlending?: boolean | undefined;
  4045. /**
  4046. * Use matrix interpolation instead of using direct key value when animating matrices
  4047. */
  4048. static AllowMatricesInterpolation: boolean;
  4049. /**
  4050. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4051. */
  4052. static AllowMatrixDecomposeForInterpolation: boolean;
  4053. /**
  4054. * Stores the key frames of the animation
  4055. */
  4056. private _keys;
  4057. /**
  4058. * Stores the easing function of the animation
  4059. */
  4060. private _easingFunction;
  4061. /**
  4062. * @hidden Internal use only
  4063. */
  4064. _runtimeAnimations: RuntimeAnimation[];
  4065. /**
  4066. * The set of event that will be linked to this animation
  4067. */
  4068. private _events;
  4069. /**
  4070. * Stores an array of target property paths
  4071. */
  4072. targetPropertyPath: string[];
  4073. /**
  4074. * Stores the blending speed of the animation
  4075. */
  4076. blendingSpeed: number;
  4077. /**
  4078. * Stores the animation ranges for the animation
  4079. */
  4080. private _ranges;
  4081. /**
  4082. * @hidden Internal use
  4083. */
  4084. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4085. /**
  4086. * Sets up an animation
  4087. * @param property The property to animate
  4088. * @param animationType The animation type to apply
  4089. * @param framePerSecond The frames per second of the animation
  4090. * @param easingFunction The easing function used in the animation
  4091. * @returns The created animation
  4092. */
  4093. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4094. /**
  4095. * Create and start an animation on a node
  4096. * @param name defines the name of the global animation that will be run on all nodes
  4097. * @param node defines the root node where the animation will take place
  4098. * @param targetProperty defines property to animate
  4099. * @param framePerSecond defines the number of frame per second yo use
  4100. * @param totalFrame defines the number of frames in total
  4101. * @param from defines the initial value
  4102. * @param to defines the final value
  4103. * @param loopMode defines which loop mode you want to use (off by default)
  4104. * @param easingFunction defines the easing function to use (linear by default)
  4105. * @param onAnimationEnd defines the callback to call when animation end
  4106. * @returns the animatable created for this animation
  4107. */
  4108. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4109. /**
  4110. * Create and start an animation on a node and its descendants
  4111. * @param name defines the name of the global animation that will be run on all nodes
  4112. * @param node defines the root node where the animation will take place
  4113. * @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
  4114. * @param targetProperty defines property to animate
  4115. * @param framePerSecond defines the number of frame per second to use
  4116. * @param totalFrame defines the number of frames in total
  4117. * @param from defines the initial value
  4118. * @param to defines the final value
  4119. * @param loopMode defines which loop mode you want to use (off by default)
  4120. * @param easingFunction defines the easing function to use (linear by default)
  4121. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4122. * @returns the list of animatables created for all nodes
  4123. * @example https://www.babylonjs-playground.com/#MH0VLI
  4124. */
  4125. 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[]>;
  4126. /**
  4127. * Creates a new animation, merges it with the existing animations and starts it
  4128. * @param name Name of the animation
  4129. * @param node Node which contains the scene that begins the animations
  4130. * @param targetProperty Specifies which property to animate
  4131. * @param framePerSecond The frames per second of the animation
  4132. * @param totalFrame The total number of frames
  4133. * @param from The frame at the beginning of the animation
  4134. * @param to The frame at the end of the animation
  4135. * @param loopMode Specifies the loop mode of the animation
  4136. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4137. * @param onAnimationEnd Callback to run once the animation is complete
  4138. * @returns Nullable animation
  4139. */
  4140. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4141. /**
  4142. * Transition property of an host to the target Value
  4143. * @param property The property to transition
  4144. * @param targetValue The target Value of the property
  4145. * @param host The object where the property to animate belongs
  4146. * @param scene Scene used to run the animation
  4147. * @param frameRate Framerate (in frame/s) to use
  4148. * @param transition The transition type we want to use
  4149. * @param duration The duration of the animation, in milliseconds
  4150. * @param onAnimationEnd Callback trigger at the end of the animation
  4151. * @returns Nullable animation
  4152. */
  4153. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4154. /**
  4155. * Return the array of runtime animations currently using this animation
  4156. */
  4157. readonly runtimeAnimations: RuntimeAnimation[];
  4158. /**
  4159. * Specifies if any of the runtime animations are currently running
  4160. */
  4161. readonly hasRunningRuntimeAnimations: boolean;
  4162. /**
  4163. * Initializes the animation
  4164. * @param name Name of the animation
  4165. * @param targetProperty Property to animate
  4166. * @param framePerSecond The frames per second of the animation
  4167. * @param dataType The data type of the animation
  4168. * @param loopMode The loop mode of the animation
  4169. * @param enableBlendings Specifies if blending should be enabled
  4170. */
  4171. constructor(
  4172. /**Name of the animation */
  4173. name: string,
  4174. /**Property to animate */
  4175. targetProperty: string,
  4176. /**The frames per second of the animation */
  4177. framePerSecond: number,
  4178. /**The data type of the animation */
  4179. dataType: number,
  4180. /**The loop mode of the animation */
  4181. loopMode?: number | undefined,
  4182. /**Specifies if blending should be enabled */
  4183. enableBlending?: boolean | undefined);
  4184. /**
  4185. * Converts the animation to a string
  4186. * @param fullDetails support for multiple levels of logging within scene loading
  4187. * @returns String form of the animation
  4188. */
  4189. toString(fullDetails?: boolean): string;
  4190. /**
  4191. * Add an event to this animation
  4192. * @param event Event to add
  4193. */
  4194. addEvent(event: AnimationEvent): void;
  4195. /**
  4196. * Remove all events found at the given frame
  4197. * @param frame The frame to remove events from
  4198. */
  4199. removeEvents(frame: number): void;
  4200. /**
  4201. * Retrieves all the events from the animation
  4202. * @returns Events from the animation
  4203. */
  4204. getEvents(): AnimationEvent[];
  4205. /**
  4206. * Creates an animation range
  4207. * @param name Name of the animation range
  4208. * @param from Starting frame of the animation range
  4209. * @param to Ending frame of the animation
  4210. */
  4211. createRange(name: string, from: number, to: number): void;
  4212. /**
  4213. * Deletes an animation range by name
  4214. * @param name Name of the animation range to delete
  4215. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4216. */
  4217. deleteRange(name: string, deleteFrames?: boolean): void;
  4218. /**
  4219. * Gets the animation range by name, or null if not defined
  4220. * @param name Name of the animation range
  4221. * @returns Nullable animation range
  4222. */
  4223. getRange(name: string): Nullable<AnimationRange>;
  4224. /**
  4225. * Gets the key frames from the animation
  4226. * @returns The key frames of the animation
  4227. */
  4228. getKeys(): Array<IAnimationKey>;
  4229. /**
  4230. * Gets the highest frame rate of the animation
  4231. * @returns Highest frame rate of the animation
  4232. */
  4233. getHighestFrame(): number;
  4234. /**
  4235. * Gets the easing function of the animation
  4236. * @returns Easing function of the animation
  4237. */
  4238. getEasingFunction(): IEasingFunction;
  4239. /**
  4240. * Sets the easing function of the animation
  4241. * @param easingFunction A custom mathematical formula for animation
  4242. */
  4243. setEasingFunction(easingFunction: EasingFunction): void;
  4244. /**
  4245. * Interpolates a scalar linearly
  4246. * @param startValue Start value of the animation curve
  4247. * @param endValue End value of the animation curve
  4248. * @param gradient Scalar amount to interpolate
  4249. * @returns Interpolated scalar value
  4250. */
  4251. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4252. /**
  4253. * Interpolates a scalar cubically
  4254. * @param startValue Start value of the animation curve
  4255. * @param outTangent End tangent of the animation
  4256. * @param endValue End value of the animation curve
  4257. * @param inTangent Start tangent of the animation curve
  4258. * @param gradient Scalar amount to interpolate
  4259. * @returns Interpolated scalar value
  4260. */
  4261. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4262. /**
  4263. * Interpolates a quaternion using a spherical linear interpolation
  4264. * @param startValue Start value of the animation curve
  4265. * @param endValue End value of the animation curve
  4266. * @param gradient Scalar amount to interpolate
  4267. * @returns Interpolated quaternion value
  4268. */
  4269. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4270. /**
  4271. * Interpolates a quaternion cubically
  4272. * @param startValue Start value of the animation curve
  4273. * @param outTangent End tangent of the animation curve
  4274. * @param endValue End value of the animation curve
  4275. * @param inTangent Start tangent of the animation curve
  4276. * @param gradient Scalar amount to interpolate
  4277. * @returns Interpolated quaternion value
  4278. */
  4279. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4280. /**
  4281. * Interpolates a Vector3 linearl
  4282. * @param startValue Start value of the animation curve
  4283. * @param endValue End value of the animation curve
  4284. * @param gradient Scalar amount to interpolate
  4285. * @returns Interpolated scalar value
  4286. */
  4287. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4288. /**
  4289. * Interpolates a Vector3 cubically
  4290. * @param startValue Start value of the animation curve
  4291. * @param outTangent End tangent of the animation
  4292. * @param endValue End value of the animation curve
  4293. * @param inTangent Start tangent of the animation curve
  4294. * @param gradient Scalar amount to interpolate
  4295. * @returns InterpolatedVector3 value
  4296. */
  4297. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4298. /**
  4299. * Interpolates a Vector2 linearly
  4300. * @param startValue Start value of the animation curve
  4301. * @param endValue End value of the animation curve
  4302. * @param gradient Scalar amount to interpolate
  4303. * @returns Interpolated Vector2 value
  4304. */
  4305. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4306. /**
  4307. * Interpolates a Vector2 cubically
  4308. * @param startValue Start value of the animation curve
  4309. * @param outTangent End tangent of the animation
  4310. * @param endValue End value of the animation curve
  4311. * @param inTangent Start tangent of the animation curve
  4312. * @param gradient Scalar amount to interpolate
  4313. * @returns Interpolated Vector2 value
  4314. */
  4315. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4316. /**
  4317. * Interpolates a size linearly
  4318. * @param startValue Start value of the animation curve
  4319. * @param endValue End value of the animation curve
  4320. * @param gradient Scalar amount to interpolate
  4321. * @returns Interpolated Size value
  4322. */
  4323. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4324. /**
  4325. * Interpolates a Color3 linearly
  4326. * @param startValue Start value of the animation curve
  4327. * @param endValue End value of the animation curve
  4328. * @param gradient Scalar amount to interpolate
  4329. * @returns Interpolated Color3 value
  4330. */
  4331. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4332. /**
  4333. * @hidden Internal use only
  4334. */
  4335. _getKeyValue(value: any): any;
  4336. /**
  4337. * @hidden Internal use only
  4338. */
  4339. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4340. /**
  4341. * Defines the function to use to interpolate matrices
  4342. * @param startValue defines the start matrix
  4343. * @param endValue defines the end matrix
  4344. * @param gradient defines the gradient between both matrices
  4345. * @param result defines an optional target matrix where to store the interpolation
  4346. * @returns the interpolated matrix
  4347. */
  4348. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4349. /**
  4350. * Makes a copy of the animation
  4351. * @returns Cloned animation
  4352. */
  4353. clone(): Animation;
  4354. /**
  4355. * Sets the key frames of the animation
  4356. * @param values The animation key frames to set
  4357. */
  4358. setKeys(values: Array<IAnimationKey>): void;
  4359. /**
  4360. * Serializes the animation to an object
  4361. * @returns Serialized object
  4362. */
  4363. serialize(): any;
  4364. /**
  4365. * Float animation type
  4366. */
  4367. private static _ANIMATIONTYPE_FLOAT;
  4368. /**
  4369. * Vector3 animation type
  4370. */
  4371. private static _ANIMATIONTYPE_VECTOR3;
  4372. /**
  4373. * Quaternion animation type
  4374. */
  4375. private static _ANIMATIONTYPE_QUATERNION;
  4376. /**
  4377. * Matrix animation type
  4378. */
  4379. private static _ANIMATIONTYPE_MATRIX;
  4380. /**
  4381. * Color3 animation type
  4382. */
  4383. private static _ANIMATIONTYPE_COLOR3;
  4384. /**
  4385. * Vector2 animation type
  4386. */
  4387. private static _ANIMATIONTYPE_VECTOR2;
  4388. /**
  4389. * Size animation type
  4390. */
  4391. private static _ANIMATIONTYPE_SIZE;
  4392. /**
  4393. * Relative Loop Mode
  4394. */
  4395. private static _ANIMATIONLOOPMODE_RELATIVE;
  4396. /**
  4397. * Cycle Loop Mode
  4398. */
  4399. private static _ANIMATIONLOOPMODE_CYCLE;
  4400. /**
  4401. * Constant Loop Mode
  4402. */
  4403. private static _ANIMATIONLOOPMODE_CONSTANT;
  4404. /**
  4405. * Get the float animation type
  4406. */
  4407. static readonly ANIMATIONTYPE_FLOAT: number;
  4408. /**
  4409. * Get the Vector3 animation type
  4410. */
  4411. static readonly ANIMATIONTYPE_VECTOR3: number;
  4412. /**
  4413. * Get the Vector2 animation type
  4414. */
  4415. static readonly ANIMATIONTYPE_VECTOR2: number;
  4416. /**
  4417. * Get the Size animation type
  4418. */
  4419. static readonly ANIMATIONTYPE_SIZE: number;
  4420. /**
  4421. * Get the Quaternion animation type
  4422. */
  4423. static readonly ANIMATIONTYPE_QUATERNION: number;
  4424. /**
  4425. * Get the Matrix animation type
  4426. */
  4427. static readonly ANIMATIONTYPE_MATRIX: number;
  4428. /**
  4429. * Get the Color3 animation type
  4430. */
  4431. static readonly ANIMATIONTYPE_COLOR3: number;
  4432. /**
  4433. * Get the Relative Loop Mode
  4434. */
  4435. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4436. /**
  4437. * Get the Cycle Loop Mode
  4438. */
  4439. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4440. /**
  4441. * Get the Constant Loop Mode
  4442. */
  4443. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4444. /** @hidden */
  4445. static _UniversalLerp(left: any, right: any, amount: number): any;
  4446. /**
  4447. * Parses an animation object and creates an animation
  4448. * @param parsedAnimation Parsed animation object
  4449. * @returns Animation object
  4450. */
  4451. static Parse(parsedAnimation: any): Animation;
  4452. /**
  4453. * Appends the serialized animations from the source animations
  4454. * @param source Source containing the animations
  4455. * @param destination Target to store the animations
  4456. */
  4457. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /**
  4462. * This class defines the direct association between an animation and a target
  4463. */
  4464. class TargetedAnimation {
  4465. /**
  4466. * Animation to perform
  4467. */
  4468. animation: Animation;
  4469. /**
  4470. * Target to animate
  4471. */
  4472. target: any;
  4473. }
  4474. /**
  4475. * Use this class to create coordinated animations on multiple targets
  4476. */
  4477. class AnimationGroup implements IDisposable {
  4478. /** The name of the animation group */
  4479. name: string;
  4480. private _scene;
  4481. private _targetedAnimations;
  4482. private _animatables;
  4483. private _from;
  4484. private _to;
  4485. private _isStarted;
  4486. private _speedRatio;
  4487. /**
  4488. * This observable will notify when one animation have ended.
  4489. */
  4490. onAnimationEndObservable: Observable<TargetedAnimation>;
  4491. /**
  4492. * This observable will notify when all animations have ended.
  4493. */
  4494. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4495. /**
  4496. * This observable will notify when all animations have paused.
  4497. */
  4498. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4499. /**
  4500. * Gets the first frame
  4501. */
  4502. readonly from: number;
  4503. /**
  4504. * Gets the last frame
  4505. */
  4506. readonly to: number;
  4507. /**
  4508. * Define if the animations are started
  4509. */
  4510. readonly isStarted: boolean;
  4511. /**
  4512. * Gets or sets the speed ratio to use for all animations
  4513. */
  4514. /**
  4515. * Gets or sets the speed ratio to use for all animations
  4516. */
  4517. speedRatio: number;
  4518. /**
  4519. * Gets the targeted animations for this animation group
  4520. */
  4521. readonly targetedAnimations: Array<TargetedAnimation>;
  4522. /**
  4523. * returning the list of animatables controlled by this animation group.
  4524. */
  4525. readonly animatables: Array<Animatable>;
  4526. /**
  4527. * Instantiates a new Animation Group.
  4528. * This helps managing several animations at once.
  4529. * @see http://doc.babylonjs.com/how_to/group
  4530. * @param name Defines the name of the group
  4531. * @param scene Defines the scene the group belongs to
  4532. */
  4533. constructor(
  4534. /** The name of the animation group */
  4535. name: string, scene?: Nullable<Scene>);
  4536. /**
  4537. * Add an animation (with its target) in the group
  4538. * @param animation defines the animation we want to add
  4539. * @param target defines the target of the animation
  4540. * @returns the TargetedAnimation object
  4541. */
  4542. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4543. /**
  4544. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4545. * It can add constant keys at begin or end
  4546. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4547. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4548. * @returns the animation group
  4549. */
  4550. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4551. /**
  4552. * Start all animations on given targets
  4553. * @param loop defines if animations must loop
  4554. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4555. * @param from defines the from key (optional)
  4556. * @param to defines the to key (optional)
  4557. * @returns the current animation group
  4558. */
  4559. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4560. /**
  4561. * Pause all animations
  4562. * @returns the animation group
  4563. */
  4564. pause(): AnimationGroup;
  4565. /**
  4566. * Play all animations to initial state
  4567. * This function will start() the animations if they were not started or will restart() them if they were paused
  4568. * @param loop defines if animations must loop
  4569. * @returns the animation group
  4570. */
  4571. play(loop?: boolean): AnimationGroup;
  4572. /**
  4573. * Reset all animations to initial state
  4574. * @returns the animation group
  4575. */
  4576. reset(): AnimationGroup;
  4577. /**
  4578. * Restart animations from key 0
  4579. * @returns the animation group
  4580. */
  4581. restart(): AnimationGroup;
  4582. /**
  4583. * Stop all animations
  4584. * @returns the animation group
  4585. */
  4586. stop(): AnimationGroup;
  4587. /**
  4588. * Set animation weight for all animatables
  4589. * @param weight defines the weight to use
  4590. * @return the animationGroup
  4591. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4592. */
  4593. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4594. /**
  4595. * Synchronize and normalize all animatables with a source animatable
  4596. * @param root defines the root animatable to synchronize with
  4597. * @return the animationGroup
  4598. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4599. */
  4600. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4601. /**
  4602. * Goes to a specific frame in this animation group
  4603. * @param frame the frame number to go to
  4604. * @return the animationGroup
  4605. */
  4606. goToFrame(frame: number): AnimationGroup;
  4607. /**
  4608. * Dispose all associated resources
  4609. */
  4610. dispose(): void;
  4611. private _checkAnimationGroupEnded;
  4612. /**
  4613. * Returns a new AnimationGroup object parsed from the source provided.
  4614. * @param parsedAnimationGroup defines the source
  4615. * @param scene defines the scene that will receive the animationGroup
  4616. * @returns a new AnimationGroup
  4617. */
  4618. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4619. /**
  4620. * Returns the string "AnimationGroup"
  4621. * @returns "AnimationGroup"
  4622. */
  4623. getClassName(): string;
  4624. /**
  4625. * Creates a detailled string about the object
  4626. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4627. * @returns a string representing the object
  4628. */
  4629. toString(fullDetails?: boolean): string;
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to override all child animations of a given target
  4635. */
  4636. class AnimationPropertiesOverride {
  4637. /**
  4638. * Gets or sets a value indicating if animation blending must be used
  4639. */
  4640. enableBlending: boolean;
  4641. /**
  4642. * Gets or sets the blending speed to use when enableBlending is true
  4643. */
  4644. blendingSpeed: number;
  4645. /**
  4646. * Gets or sets the default loop mode to use
  4647. */
  4648. loopMode: number;
  4649. }
  4650. }
  4651. declare module BABYLON {
  4652. /**
  4653. * This represents the main contract an easing function should follow.
  4654. * Easing functions are used throughout the animation system.
  4655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4656. */
  4657. interface IEasingFunction {
  4658. /**
  4659. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4660. * of the easing function.
  4661. * The link below provides some of the most common examples of easing functions.
  4662. * @see https://easings.net/
  4663. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4664. * @returns the corresponding value on the curve defined by the easing function
  4665. */
  4666. ease(gradient: number): number;
  4667. }
  4668. /**
  4669. * Base class used for every default easing function.
  4670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4671. */
  4672. class EasingFunction implements IEasingFunction {
  4673. /**
  4674. * Interpolation follows the mathematical formula associated with the easing function.
  4675. */
  4676. static readonly EASINGMODE_EASEIN: number;
  4677. /**
  4678. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4679. */
  4680. static readonly EASINGMODE_EASEOUT: number;
  4681. /**
  4682. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4683. */
  4684. static readonly EASINGMODE_EASEINOUT: number;
  4685. private _easingMode;
  4686. /**
  4687. * Sets the easing mode of the current function.
  4688. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4689. */
  4690. setEasingMode(easingMode: number): void;
  4691. /**
  4692. * Gets the current easing mode.
  4693. * @returns the easing mode
  4694. */
  4695. getEasingMode(): number;
  4696. /**
  4697. * @hidden
  4698. */
  4699. easeInCore(gradient: number): number;
  4700. /**
  4701. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4702. * of the easing function.
  4703. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4704. * @returns the corresponding value on the curve defined by the easing function
  4705. */
  4706. ease(gradient: number): number;
  4707. }
  4708. /**
  4709. * Easing function with a circle shape (see link below).
  4710. * @see https://easings.net/#easeInCirc
  4711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4712. */
  4713. class CircleEase extends EasingFunction implements IEasingFunction {
  4714. /** @hidden */
  4715. easeInCore(gradient: number): number;
  4716. }
  4717. /**
  4718. * Easing function with a ease back shape (see link below).
  4719. * @see https://easings.net/#easeInBack
  4720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4721. */
  4722. class BackEase extends EasingFunction implements IEasingFunction {
  4723. /** Defines the amplitude of the function */
  4724. amplitude: number;
  4725. /**
  4726. * Instantiates a back ease easing
  4727. * @see https://easings.net/#easeInBack
  4728. * @param amplitude Defines the amplitude of the function
  4729. */
  4730. constructor(
  4731. /** Defines the amplitude of the function */
  4732. amplitude?: number);
  4733. /** @hidden */
  4734. easeInCore(gradient: number): number;
  4735. }
  4736. /**
  4737. * Easing function with a bouncing shape (see link below).
  4738. * @see https://easings.net/#easeInBounce
  4739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4740. */
  4741. class BounceEase extends EasingFunction implements IEasingFunction {
  4742. /** Defines the number of bounces */
  4743. bounces: number;
  4744. /** Defines the amplitude of the bounce */
  4745. bounciness: number;
  4746. /**
  4747. * Instantiates a bounce easing
  4748. * @see https://easings.net/#easeInBounce
  4749. * @param bounces Defines the number of bounces
  4750. * @param bounciness Defines the amplitude of the bounce
  4751. */
  4752. constructor(
  4753. /** Defines the number of bounces */
  4754. bounces?: number,
  4755. /** Defines the amplitude of the bounce */
  4756. bounciness?: number);
  4757. /** @hidden */
  4758. easeInCore(gradient: number): number;
  4759. }
  4760. /**
  4761. * Easing function with a power of 3 shape (see link below).
  4762. * @see https://easings.net/#easeInCubic
  4763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4764. */
  4765. class CubicEase extends EasingFunction implements IEasingFunction {
  4766. /** @hidden */
  4767. easeInCore(gradient: number): number;
  4768. }
  4769. /**
  4770. * Easing function with an elastic shape (see link below).
  4771. * @see https://easings.net/#easeInElastic
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. class ElasticEase extends EasingFunction implements IEasingFunction {
  4775. /** Defines the number of oscillations*/
  4776. oscillations: number;
  4777. /** Defines the amplitude of the oscillations*/
  4778. springiness: number;
  4779. /**
  4780. * Instantiates an elastic easing function
  4781. * @see https://easings.net/#easeInElastic
  4782. * @param oscillations Defines the number of oscillations
  4783. * @param springiness Defines the amplitude of the oscillations
  4784. */
  4785. constructor(
  4786. /** Defines the number of oscillations*/
  4787. oscillations?: number,
  4788. /** Defines the amplitude of the oscillations*/
  4789. springiness?: number);
  4790. /** @hidden */
  4791. easeInCore(gradient: number): number;
  4792. }
  4793. /**
  4794. * Easing function with an exponential shape (see link below).
  4795. * @see https://easings.net/#easeInExpo
  4796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4797. */
  4798. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4799. /** Defines the exponent of the function */
  4800. exponent: number;
  4801. /**
  4802. * Instantiates an exponential easing function
  4803. * @see https://easings.net/#easeInExpo
  4804. * @param exponent Defines the exponent of the function
  4805. */
  4806. constructor(
  4807. /** Defines the exponent of the function */
  4808. exponent?: number);
  4809. /** @hidden */
  4810. easeInCore(gradient: number): number;
  4811. }
  4812. /**
  4813. * Easing function with a power shape (see link below).
  4814. * @see https://easings.net/#easeInQuad
  4815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4816. */
  4817. class PowerEase extends EasingFunction implements IEasingFunction {
  4818. /** Defines the power of the function */
  4819. power: number;
  4820. /**
  4821. * Instantiates an power base easing function
  4822. * @see https://easings.net/#easeInQuad
  4823. * @param power Defines the power of the function
  4824. */
  4825. constructor(
  4826. /** Defines the power of the function */
  4827. power?: number);
  4828. /** @hidden */
  4829. easeInCore(gradient: number): number;
  4830. }
  4831. /**
  4832. * Easing function with a power of 2 shape (see link below).
  4833. * @see https://easings.net/#easeInQuad
  4834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4835. */
  4836. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4837. /** @hidden */
  4838. easeInCore(gradient: number): number;
  4839. }
  4840. /**
  4841. * Easing function with a power of 4 shape (see link below).
  4842. * @see https://easings.net/#easeInQuart
  4843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4844. */
  4845. class QuarticEase extends EasingFunction implements IEasingFunction {
  4846. /** @hidden */
  4847. easeInCore(gradient: number): number;
  4848. }
  4849. /**
  4850. * Easing function with a power of 5 shape (see link below).
  4851. * @see https://easings.net/#easeInQuint
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. class QuinticEase extends EasingFunction implements IEasingFunction {
  4855. /** @hidden */
  4856. easeInCore(gradient: number): number;
  4857. }
  4858. /**
  4859. * Easing function with a sin shape (see link below).
  4860. * @see https://easings.net/#easeInSine
  4861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4862. */
  4863. class SineEase extends EasingFunction implements IEasingFunction {
  4864. /** @hidden */
  4865. easeInCore(gradient: number): number;
  4866. }
  4867. /**
  4868. * Easing function with a bezier shape (see link below).
  4869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4871. */
  4872. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4873. /** Defines the x component of the start tangent in the bezier curve */
  4874. x1: number;
  4875. /** Defines the y component of the start tangent in the bezier curve */
  4876. y1: number;
  4877. /** Defines the x component of the end tangent in the bezier curve */
  4878. x2: number;
  4879. /** Defines the y component of the end tangent in the bezier curve */
  4880. y2: number;
  4881. /**
  4882. * Instantiates a bezier function
  4883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4884. * @param x1 Defines the x component of the start tangent in the bezier curve
  4885. * @param y1 Defines the y component of the start tangent in the bezier curve
  4886. * @param x2 Defines the x component of the end tangent in the bezier curve
  4887. * @param y2 Defines the y component of the end tangent in the bezier curve
  4888. */
  4889. constructor(
  4890. /** Defines the x component of the start tangent in the bezier curve */
  4891. x1?: number,
  4892. /** Defines the y component of the start tangent in the bezier curve */
  4893. y1?: number,
  4894. /** Defines the x component of the end tangent in the bezier curve */
  4895. x2?: number,
  4896. /** Defines the y component of the end tangent in the bezier curve */
  4897. y2?: number);
  4898. /** @hidden */
  4899. easeInCore(gradient: number): number;
  4900. }
  4901. }
  4902. declare module BABYLON {
  4903. /**
  4904. * Defines a runtime animation
  4905. */
  4906. class RuntimeAnimation {
  4907. private _events;
  4908. /**
  4909. * The current frame of the runtime animation
  4910. */
  4911. private _currentFrame;
  4912. /**
  4913. * The animation used by the runtime animation
  4914. */
  4915. private _animation;
  4916. /**
  4917. * The target of the runtime animation
  4918. */
  4919. private _target;
  4920. /**
  4921. * The initiating animatable
  4922. */
  4923. private _host;
  4924. /**
  4925. * The original value of the runtime animation
  4926. */
  4927. private _originalValue;
  4928. /**
  4929. * The original blend value of the runtime animation
  4930. */
  4931. private _originalBlendValue;
  4932. /**
  4933. * The offsets cache of the runtime animation
  4934. */
  4935. private _offsetsCache;
  4936. /**
  4937. * The high limits cache of the runtime animation
  4938. */
  4939. private _highLimitsCache;
  4940. /**
  4941. * Specifies if the runtime animation has been stopped
  4942. */
  4943. private _stopped;
  4944. /**
  4945. * The blending factor of the runtime animation
  4946. */
  4947. private _blendingFactor;
  4948. /**
  4949. * The BabylonJS scene
  4950. */
  4951. private _scene;
  4952. /**
  4953. * The current value of the runtime animation
  4954. */
  4955. private _currentValue;
  4956. /** @hidden */
  4957. _workValue: any;
  4958. /**
  4959. * The active target of the runtime animation
  4960. */
  4961. private _activeTarget;
  4962. /**
  4963. * The target path of the runtime animation
  4964. */
  4965. private _targetPath;
  4966. /**
  4967. * The weight of the runtime animation
  4968. */
  4969. private _weight;
  4970. /**
  4971. * The ratio offset of the runtime animation
  4972. */
  4973. private _ratioOffset;
  4974. /**
  4975. * The previous delay of the runtime animation
  4976. */
  4977. private _previousDelay;
  4978. /**
  4979. * The previous ratio of the runtime animation
  4980. */
  4981. private _previousRatio;
  4982. /**
  4983. * Gets the current frame of the runtime animation
  4984. */
  4985. readonly currentFrame: number;
  4986. /**
  4987. * Gets the weight of the runtime animation
  4988. */
  4989. readonly weight: number;
  4990. /**
  4991. * Gets the current value of the runtime animation
  4992. */
  4993. readonly currentValue: any;
  4994. /**
  4995. * Gets the target path of the runtime animation
  4996. */
  4997. readonly targetPath: string;
  4998. /**
  4999. * Gets the actual target of the runtime animation
  5000. */
  5001. readonly target: any;
  5002. /**
  5003. * Create a new RuntimeAnimation object
  5004. * @param target defines the target of the animation
  5005. * @param animation defines the source animation object
  5006. * @param scene defines the hosting scene
  5007. * @param host defines the initiating Animatable
  5008. */
  5009. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5010. /**
  5011. * Gets the animation from the runtime animation
  5012. */
  5013. readonly animation: Animation;
  5014. /**
  5015. * Resets the runtime animation to the beginning
  5016. * @param restoreOriginal defines whether to restore the target property to the original value
  5017. */
  5018. reset(restoreOriginal?: boolean): void;
  5019. /**
  5020. * Specifies if the runtime animation is stopped
  5021. * @returns Boolean specifying if the runtime animation is stopped
  5022. */
  5023. isStopped(): boolean;
  5024. /**
  5025. * Disposes of the runtime animation
  5026. */
  5027. dispose(): void;
  5028. /**
  5029. * Interpolates the animation from the current frame
  5030. * @param currentFrame The frame to interpolate the animation to
  5031. * @param repeatCount The number of times that the animation should loop
  5032. * @param loopMode The type of looping mode to use
  5033. * @param offsetValue Animation offset value
  5034. * @param highLimitValue The high limit value
  5035. * @returns The interpolated value
  5036. */
  5037. private _interpolate;
  5038. /**
  5039. * Apply the interpolated value to the target
  5040. * @param currentValue defines the value computed by the animation
  5041. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5042. */
  5043. setValue(currentValue: any, weight?: number): void;
  5044. private _setValue;
  5045. /**
  5046. * Gets the loop pmode of the runtime animation
  5047. * @returns Loop Mode
  5048. */
  5049. private _getCorrectLoopMode;
  5050. /**
  5051. * Move the current animation to a given frame
  5052. * @param frame defines the frame to move to
  5053. */
  5054. goToFrame(frame: number): void;
  5055. /**
  5056. * @hidden Internal use only
  5057. */
  5058. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5059. /**
  5060. * Execute the current animation
  5061. * @param delay defines the delay to add to the current frame
  5062. * @param from defines the lower bound of the animation range
  5063. * @param to defines the upper bound of the animation range
  5064. * @param loop defines if the current animation must loop
  5065. * @param speedRatio defines the current speed ratio
  5066. * @param weight defines the weight of the animation (default is -1 so no weight)
  5067. * @returns a boolean indicating if the animation is running
  5068. */
  5069. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5070. }
  5071. }
  5072. declare module BABYLON {
  5073. /**
  5074. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5076. */
  5077. class Analyser {
  5078. /**
  5079. * Gets or sets the smoothing
  5080. * @ignorenaming
  5081. */
  5082. SMOOTHING: number;
  5083. /**
  5084. * Gets or sets the FFT table size
  5085. * @ignorenaming
  5086. */
  5087. FFT_SIZE: number;
  5088. /**
  5089. * Gets or sets the bar graph amplitude
  5090. * @ignorenaming
  5091. */
  5092. BARGRAPHAMPLITUDE: number;
  5093. /**
  5094. * Gets or sets the position of the debug canvas
  5095. * @ignorenaming
  5096. */
  5097. DEBUGCANVASPOS: {
  5098. x: number;
  5099. y: number;
  5100. };
  5101. /**
  5102. * Gets or sets the debug canvas size
  5103. * @ignorenaming
  5104. */
  5105. DEBUGCANVASSIZE: {
  5106. width: number;
  5107. height: number;
  5108. };
  5109. private _byteFreqs;
  5110. private _byteTime;
  5111. private _floatFreqs;
  5112. private _webAudioAnalyser;
  5113. private _debugCanvas;
  5114. private _debugCanvasContext;
  5115. private _scene;
  5116. private _registerFunc;
  5117. private _audioEngine;
  5118. /**
  5119. * Creates a new analyser
  5120. * @param scene defines hosting scene
  5121. */
  5122. constructor(scene: Scene);
  5123. /**
  5124. * Get the number of data values you will have to play with for the visualization
  5125. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5126. * @returns a number
  5127. */
  5128. getFrequencyBinCount(): number;
  5129. /**
  5130. * Gets the current frequency data as a byte array
  5131. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5132. * @returns a Uint8Array
  5133. */
  5134. getByteFrequencyData(): Uint8Array;
  5135. /**
  5136. * Gets the current waveform as a byte array
  5137. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5138. * @returns a Uint8Array
  5139. */
  5140. getByteTimeDomainData(): Uint8Array;
  5141. /**
  5142. * Gets the current frequency data as a float array
  5143. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5144. * @returns a Float32Array
  5145. */
  5146. getFloatFrequencyData(): Float32Array;
  5147. /**
  5148. * Renders the debug canvas
  5149. */
  5150. drawDebugCanvas(): void;
  5151. /**
  5152. * Stops rendering the debug canvas and removes it
  5153. */
  5154. stopDebugCanvas(): void;
  5155. /**
  5156. * Connects two audio nodes
  5157. * @param inputAudioNode defines first node to connect
  5158. * @param outputAudioNode defines second node to connect
  5159. */
  5160. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5161. /**
  5162. * Releases all associated resources
  5163. */
  5164. dispose(): void;
  5165. }
  5166. }
  5167. declare module BABYLON {
  5168. /**
  5169. * This represents an audio engine and it is responsible
  5170. * to play, synchronize and analyse sounds throughout the application.
  5171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5172. */
  5173. interface IAudioEngine extends IDisposable {
  5174. /**
  5175. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5176. */
  5177. readonly canUseWebAudio: boolean;
  5178. /**
  5179. * Gets the current AudioContext if available.
  5180. */
  5181. readonly audioContext: Nullable<AudioContext>;
  5182. /**
  5183. * The master gain node defines the global audio volume of your audio engine.
  5184. */
  5185. readonly masterGain: GainNode;
  5186. /**
  5187. * Gets whether or not mp3 are supported by your browser.
  5188. */
  5189. readonly isMP3supported: boolean;
  5190. /**
  5191. * Gets whether or not ogg are supported by your browser.
  5192. */
  5193. readonly isOGGsupported: boolean;
  5194. /**
  5195. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5196. * @ignoreNaming
  5197. */
  5198. WarnedWebAudioUnsupported: boolean;
  5199. /**
  5200. * Defines if the audio engine relies on a custom unlocked button.
  5201. * In this case, the embedded button will not be displayed.
  5202. */
  5203. useCustomUnlockedButton: boolean;
  5204. /**
  5205. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5206. */
  5207. readonly unlocked: boolean;
  5208. /**
  5209. * Event raised when audio has been unlocked on the browser.
  5210. */
  5211. onAudioUnlockedObservable: Observable<AudioEngine>;
  5212. /**
  5213. * Event raised when audio has been locked on the browser.
  5214. */
  5215. onAudioLockedObservable: Observable<AudioEngine>;
  5216. /**
  5217. * Flags the audio engine in Locked state.
  5218. * This happens due to new browser policies preventing audio to autoplay.
  5219. */
  5220. lock(): void;
  5221. /**
  5222. * Unlocks the audio engine once a user action has been done on the dom.
  5223. * This is helpful to resume play once browser policies have been satisfied.
  5224. */
  5225. unlock(): void;
  5226. }
  5227. /**
  5228. * This represents the default audio engine used in babylon.
  5229. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5231. */
  5232. class AudioEngine implements IAudioEngine {
  5233. private _audioContext;
  5234. private _audioContextInitialized;
  5235. private _muteButton;
  5236. private _hostElement;
  5237. /**
  5238. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5239. */
  5240. canUseWebAudio: boolean;
  5241. /**
  5242. * The master gain node defines the global audio volume of your audio engine.
  5243. */
  5244. masterGain: GainNode;
  5245. /**
  5246. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5247. * @ignoreNaming
  5248. */
  5249. WarnedWebAudioUnsupported: boolean;
  5250. /**
  5251. * Gets whether or not mp3 are supported by your browser.
  5252. */
  5253. isMP3supported: boolean;
  5254. /**
  5255. * Gets whether or not ogg are supported by your browser.
  5256. */
  5257. isOGGsupported: boolean;
  5258. /**
  5259. * Gets whether audio has been unlocked on the device.
  5260. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5261. * a user interaction has happened.
  5262. */
  5263. unlocked: boolean;
  5264. /**
  5265. * Defines if the audio engine relies on a custom unlocked button.
  5266. * In this case, the embedded button will not be displayed.
  5267. */
  5268. useCustomUnlockedButton: boolean;
  5269. /**
  5270. * Event raised when audio has been unlocked on the browser.
  5271. */
  5272. onAudioUnlockedObservable: Observable<AudioEngine>;
  5273. /**
  5274. * Event raised when audio has been locked on the browser.
  5275. */
  5276. onAudioLockedObservable: Observable<AudioEngine>;
  5277. /**
  5278. * Gets the current AudioContext if available.
  5279. */
  5280. readonly audioContext: Nullable<AudioContext>;
  5281. private _connectedAnalyser;
  5282. /**
  5283. * Instantiates a new audio engine.
  5284. *
  5285. * There should be only one per page as some browsers restrict the number
  5286. * of audio contexts you can create.
  5287. * @param hostElement defines the host element where to display the mute icon if necessary
  5288. */
  5289. constructor(hostElement?: Nullable<HTMLElement>);
  5290. /**
  5291. * Flags the audio engine in Locked state.
  5292. * This happens due to new browser policies preventing audio to autoplay.
  5293. */
  5294. lock(): void;
  5295. /**
  5296. * Unlocks the audio engine once a user action has been done on the dom.
  5297. * This is helpful to resume play once browser policies have been satisfied.
  5298. */
  5299. unlock(): void;
  5300. private _resumeAudioContext;
  5301. private _initializeAudioContext;
  5302. private _tryToRun;
  5303. private _triggerRunningState;
  5304. private _triggerSuspendedState;
  5305. private _displayMuteButton;
  5306. private _moveButtonToTopLeft;
  5307. private _onResize;
  5308. private _hideMuteButton;
  5309. /**
  5310. * Destroy and release the resources associated with the audio ccontext.
  5311. */
  5312. dispose(): void;
  5313. /**
  5314. * Gets the global volume sets on the master gain.
  5315. * @returns the global volume if set or -1 otherwise
  5316. */
  5317. getGlobalVolume(): number;
  5318. /**
  5319. * Sets the global volume of your experience (sets on the master gain).
  5320. * @param newVolume Defines the new global volume of the application
  5321. */
  5322. setGlobalVolume(newVolume: number): void;
  5323. /**
  5324. * Connect the audio engine to an audio analyser allowing some amazing
  5325. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5327. * @param analyser The analyser to connect to the engine
  5328. */
  5329. connectToAnalyser(analyser: Analyser): void;
  5330. }
  5331. }
  5332. declare module BABYLON {
  5333. interface AbstractScene {
  5334. /**
  5335. * The list of sounds used in the scene.
  5336. */
  5337. sounds: Nullable<Array<Sound>>;
  5338. }
  5339. interface Scene {
  5340. /**
  5341. * @hidden
  5342. * Backing field
  5343. */
  5344. _mainSoundTrack: SoundTrack;
  5345. /**
  5346. * The main sound track played by the scene.
  5347. * It cotains your primary collection of sounds.
  5348. */
  5349. mainSoundTrack: SoundTrack;
  5350. /**
  5351. * The list of sound tracks added to the scene
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. soundTracks: Nullable<Array<SoundTrack>>;
  5355. /**
  5356. * Gets a sound using a given name
  5357. * @param name defines the name to search for
  5358. * @return the found sound or null if not found at all.
  5359. */
  5360. getSoundByName(name: string): Nullable<Sound>;
  5361. /**
  5362. * Gets or sets if audio support is enabled
  5363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5364. */
  5365. audioEnabled: boolean;
  5366. /**
  5367. * Gets or sets if audio will be output to headphones
  5368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5369. */
  5370. headphone: boolean;
  5371. }
  5372. /**
  5373. * Defines the sound scene component responsible to manage any sounds
  5374. * in a given scene.
  5375. */
  5376. class AudioSceneComponent implements ISceneSerializableComponent {
  5377. /**
  5378. * The component name helpfull to identify the component in the list of scene components.
  5379. */
  5380. readonly name: string;
  5381. /**
  5382. * The scene the component belongs to.
  5383. */
  5384. scene: Scene;
  5385. private _audioEnabled;
  5386. /**
  5387. * Gets whether audio is enabled or not.
  5388. * Please use related enable/disable method to switch state.
  5389. */
  5390. readonly audioEnabled: boolean;
  5391. private _headphone;
  5392. /**
  5393. * Gets whether audio is outputing to headphone or not.
  5394. * Please use the according Switch methods to change output.
  5395. */
  5396. readonly headphone: boolean;
  5397. /**
  5398. * Creates a new instance of the component for the given scene
  5399. * @param scene Defines the scene to register the component in
  5400. */
  5401. constructor(scene: Scene);
  5402. /**
  5403. * Registers the component in a given scene
  5404. */
  5405. register(): void;
  5406. /**
  5407. * Rebuilds the elements related to this component in case of
  5408. * context lost for instance.
  5409. */
  5410. rebuild(): void;
  5411. /**
  5412. * Serializes the component data to the specified json object
  5413. * @param serializationObject The object to serialize to
  5414. */
  5415. serialize(serializationObject: any): void;
  5416. /**
  5417. * Adds all the element from the container to the scene
  5418. * @param container the container holding the elements
  5419. */
  5420. addFromContainer(container: AbstractScene): void;
  5421. /**
  5422. * Removes all the elements in the container from the scene
  5423. * @param container contains the elements to remove
  5424. */
  5425. removeFromContainer(container: AbstractScene): void;
  5426. /**
  5427. * Disposes the component and the associated ressources.
  5428. */
  5429. dispose(): void;
  5430. /**
  5431. * Disables audio in the associated scene.
  5432. */
  5433. disableAudio(): void;
  5434. /**
  5435. * Enables audio in the associated scene.
  5436. */
  5437. enableAudio(): void;
  5438. /**
  5439. * Switch audio to headphone output.
  5440. */
  5441. switchAudioModeForHeadphones(): void;
  5442. /**
  5443. * Switch audio to normal speakers.
  5444. */
  5445. switchAudioModeForNormalSpeakers(): void;
  5446. private _afterRender;
  5447. }
  5448. }
  5449. declare module BABYLON {
  5450. /**
  5451. * Defines a sound that can be played in the application.
  5452. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5454. */
  5455. class Sound {
  5456. /**
  5457. * The name of the sound in the scene.
  5458. */
  5459. name: string;
  5460. /**
  5461. * Does the sound autoplay once loaded.
  5462. */
  5463. autoplay: boolean;
  5464. /**
  5465. * Does the sound loop after it finishes playing once.
  5466. */
  5467. loop: boolean;
  5468. /**
  5469. * Does the sound use a custom attenuation curve to simulate the falloff
  5470. * happening when the source gets further away from the camera.
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5472. */
  5473. useCustomAttenuation: boolean;
  5474. /**
  5475. * The sound track id this sound belongs to.
  5476. */
  5477. soundTrackId: number;
  5478. /**
  5479. * Is this sound currently played.
  5480. */
  5481. isPlaying: boolean;
  5482. /**
  5483. * Is this sound currently paused.
  5484. */
  5485. isPaused: boolean;
  5486. /**
  5487. * Does this sound enables spatial sound.
  5488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5489. */
  5490. spatialSound: boolean;
  5491. /**
  5492. * Define the reference distance the sound should be heard perfectly.
  5493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5494. */
  5495. refDistance: number;
  5496. /**
  5497. * Define the roll off factor of spatial sounds.
  5498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5499. */
  5500. rolloffFactor: number;
  5501. /**
  5502. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5504. */
  5505. maxDistance: number;
  5506. /**
  5507. * Define the distance attenuation model the sound will follow.
  5508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5509. */
  5510. distanceModel: string;
  5511. /**
  5512. * @hidden
  5513. * Back Compat
  5514. **/
  5515. onended: () => any;
  5516. /**
  5517. * Observable event when the current playing sound finishes.
  5518. */
  5519. onEndedObservable: Observable<Sound>;
  5520. private _panningModel;
  5521. private _playbackRate;
  5522. private _streaming;
  5523. private _startTime;
  5524. private _startOffset;
  5525. private _position;
  5526. /** @hidden */
  5527. _positionInEmitterSpace: boolean;
  5528. private _localDirection;
  5529. private _volume;
  5530. private _isReadyToPlay;
  5531. private _isDirectional;
  5532. private _readyToPlayCallback;
  5533. private _audioBuffer;
  5534. private _soundSource;
  5535. private _streamingSource;
  5536. private _soundPanner;
  5537. private _soundGain;
  5538. private _inputAudioNode;
  5539. private _outputAudioNode;
  5540. private _coneInnerAngle;
  5541. private _coneOuterAngle;
  5542. private _coneOuterGain;
  5543. private _scene;
  5544. private _connectedMesh;
  5545. private _customAttenuationFunction;
  5546. private _registerFunc;
  5547. private _isOutputConnected;
  5548. private _htmlAudioElement;
  5549. private _urlType;
  5550. /**
  5551. * Create a sound and attach it to a scene
  5552. * @param name Name of your sound
  5553. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5554. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5555. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5556. */
  5557. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5558. /**
  5559. * Release the sound and its associated resources
  5560. */
  5561. dispose(): void;
  5562. /**
  5563. * Gets if the sounds is ready to be played or not.
  5564. * @returns true if ready, otherwise false
  5565. */
  5566. isReady(): boolean;
  5567. private _soundLoaded;
  5568. /**
  5569. * Sets the data of the sound from an audiobuffer
  5570. * @param audioBuffer The audioBuffer containing the data
  5571. */
  5572. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5573. /**
  5574. * Updates the current sounds options such as maxdistance, loop...
  5575. * @param options A JSON object containing values named as the object properties
  5576. */
  5577. updateOptions(options: any): void;
  5578. private _createSpatialParameters;
  5579. private _updateSpatialParameters;
  5580. /**
  5581. * Switch the panning model to HRTF:
  5582. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5584. */
  5585. switchPanningModelToHRTF(): void;
  5586. /**
  5587. * Switch the panning model to Equal Power:
  5588. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5590. */
  5591. switchPanningModelToEqualPower(): void;
  5592. private _switchPanningModel;
  5593. /**
  5594. * Connect this sound to a sound track audio node like gain...
  5595. * @param soundTrackAudioNode the sound track audio node to connect to
  5596. */
  5597. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5598. /**
  5599. * Transform this sound into a directional source
  5600. * @param coneInnerAngle Size of the inner cone in degree
  5601. * @param coneOuterAngle Size of the outer cone in degree
  5602. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5603. */
  5604. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5605. /**
  5606. * Gets or sets the inner angle for the directional cone.
  5607. */
  5608. /**
  5609. * Gets or sets the inner angle for the directional cone.
  5610. */
  5611. directionalConeInnerAngle: number;
  5612. /**
  5613. * Gets or sets the outer angle for the directional cone.
  5614. */
  5615. /**
  5616. * Gets or sets the outer angle for the directional cone.
  5617. */
  5618. directionalConeOuterAngle: number;
  5619. /**
  5620. * Sets the position of the emitter if spatial sound is enabled
  5621. * @param newPosition Defines the new posisiton
  5622. */
  5623. setPosition(newPosition: Vector3): void;
  5624. /**
  5625. * Sets the local direction of the emitter if spatial sound is enabled
  5626. * @param newLocalDirection Defines the new local direction
  5627. */
  5628. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5629. private _updateDirection;
  5630. /** @hidden */
  5631. updateDistanceFromListener(): void;
  5632. /**
  5633. * Sets a new custom attenuation function for the sound.
  5634. * @param callback Defines the function used for the attenuation
  5635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5636. */
  5637. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5638. /**
  5639. * Play the sound
  5640. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5641. * @param offset (optional) Start the sound setting it at a specific time
  5642. */
  5643. play(time?: number, offset?: number): void;
  5644. private _onended;
  5645. /**
  5646. * Stop the sound
  5647. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5648. */
  5649. stop(time?: number): void;
  5650. /**
  5651. * Put the sound in pause
  5652. */
  5653. pause(): void;
  5654. /**
  5655. * Sets a dedicated volume for this sounds
  5656. * @param newVolume Define the new volume of the sound
  5657. * @param time Define in how long the sound should be at this value
  5658. */
  5659. setVolume(newVolume: number, time?: number): void;
  5660. /**
  5661. * Set the sound play back rate
  5662. * @param newPlaybackRate Define the playback rate the sound should be played at
  5663. */
  5664. setPlaybackRate(newPlaybackRate: number): void;
  5665. /**
  5666. * Gets the volume of the sound.
  5667. * @returns the volume of the sound
  5668. */
  5669. getVolume(): number;
  5670. /**
  5671. * Attach the sound to a dedicated mesh
  5672. * @param meshToConnectTo The mesh to connect the sound with
  5673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5674. */
  5675. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5676. /**
  5677. * Detach the sound from the previously attached mesh
  5678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5679. */
  5680. detachFromMesh(): void;
  5681. private _onRegisterAfterWorldMatrixUpdate;
  5682. /**
  5683. * Clone the current sound in the scene.
  5684. * @returns the new sound clone
  5685. */
  5686. clone(): Nullable<Sound>;
  5687. /**
  5688. * Gets the current underlying audio buffer containing the data
  5689. * @returns the audio buffer
  5690. */
  5691. getAudioBuffer(): Nullable<AudioBuffer>;
  5692. /**
  5693. * Serializes the Sound in a JSON representation
  5694. * @returns the JSON representation of the sound
  5695. */
  5696. serialize(): any;
  5697. /**
  5698. * Parse a JSON representation of a sound to innstantiate in a given scene
  5699. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5700. * @param scene Define the scene the new parsed sound should be created in
  5701. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5702. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5703. * @returns the newly parsed sound
  5704. */
  5705. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5706. }
  5707. }
  5708. declare module BABYLON {
  5709. /**
  5710. * Options allowed during the creation of a sound track.
  5711. */
  5712. interface ISoundTrackOptions {
  5713. /**
  5714. * The volume the sound track should take during creation
  5715. */
  5716. volume?: number;
  5717. /**
  5718. * Define if the sound track is the main sound track of the scene
  5719. */
  5720. mainTrack?: boolean;
  5721. }
  5722. /**
  5723. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5724. * It will be also used in a future release to apply effects on a specific track.
  5725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5726. */
  5727. class SoundTrack {
  5728. /**
  5729. * The unique identifier of the sound track in the scene.
  5730. */
  5731. id: number;
  5732. /**
  5733. * The list of sounds included in the sound track.
  5734. */
  5735. soundCollection: Array<Sound>;
  5736. private _outputAudioNode;
  5737. private _scene;
  5738. private _isMainTrack;
  5739. private _connectedAnalyser;
  5740. private _options;
  5741. private _isInitialized;
  5742. /**
  5743. * Creates a new sound track.
  5744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5745. * @param scene Define the scene the sound track belongs to
  5746. * @param options
  5747. */
  5748. constructor(scene: Scene, options?: ISoundTrackOptions);
  5749. private _initializeSoundTrackAudioGraph;
  5750. /**
  5751. * Release the sound track and its associated resources
  5752. */
  5753. dispose(): void;
  5754. /**
  5755. * Adds a sound to this sound track
  5756. * @param sound define the cound to add
  5757. * @ignoreNaming
  5758. */
  5759. AddSound(sound: Sound): void;
  5760. /**
  5761. * Removes a sound to this sound track
  5762. * @param sound define the cound to remove
  5763. * @ignoreNaming
  5764. */
  5765. RemoveSound(sound: Sound): void;
  5766. /**
  5767. * Set a global volume for the full sound track.
  5768. * @param newVolume Define the new volume of the sound track
  5769. */
  5770. setVolume(newVolume: number): void;
  5771. /**
  5772. * Switch the panning model to HRTF:
  5773. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5775. */
  5776. switchPanningModelToHRTF(): void;
  5777. /**
  5778. * Switch the panning model to Equal Power:
  5779. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5781. */
  5782. switchPanningModelToEqualPower(): void;
  5783. /**
  5784. * Connect the sound track to an audio analyser allowing some amazing
  5785. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5787. * @param analyser The analyser to connect to the engine
  5788. */
  5789. connectToAnalyser(analyser: Analyser): void;
  5790. }
  5791. }
  5792. declare module BABYLON {
  5793. /**
  5794. * Wraps one or more Sound objects and selects one with random weight for playback.
  5795. */
  5796. class WeightedSound {
  5797. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5798. loop: boolean;
  5799. private _coneInnerAngle;
  5800. private _coneOuterAngle;
  5801. private _volume;
  5802. /** A Sound is currently playing. */
  5803. isPlaying: boolean;
  5804. /** A Sound is currently paused. */
  5805. isPaused: boolean;
  5806. private _sounds;
  5807. private _weights;
  5808. private _currentIndex?;
  5809. /**
  5810. * Creates a new WeightedSound from the list of sounds given.
  5811. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5812. * @param sounds Array of Sounds that will be selected from.
  5813. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5814. */
  5815. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5816. /**
  5817. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5818. */
  5819. /**
  5820. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5821. */
  5822. directionalConeInnerAngle: number;
  5823. /**
  5824. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5825. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5826. */
  5827. /**
  5828. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5829. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5830. */
  5831. directionalConeOuterAngle: number;
  5832. /**
  5833. * Playback volume.
  5834. */
  5835. /**
  5836. * Playback volume.
  5837. */
  5838. volume: number;
  5839. private _onended;
  5840. /**
  5841. * Suspend playback
  5842. */
  5843. pause(): void;
  5844. /**
  5845. * Stop playback
  5846. */
  5847. stop(): void;
  5848. /**
  5849. * Start playback.
  5850. * @param startOffset Position the clip head at a specific time in seconds.
  5851. */
  5852. play(startOffset?: number): void;
  5853. }
  5854. }
  5855. declare module BABYLON {
  5856. /**
  5857. * Interface used to define a behavior
  5858. */
  5859. interface Behavior<T> {
  5860. /** gets or sets behavior's name */
  5861. name: string;
  5862. /**
  5863. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5864. */
  5865. init(): void;
  5866. /**
  5867. * Called when the behavior is attached to a target
  5868. * @param target defines the target where the behavior is attached to
  5869. */
  5870. attach(target: T): void;
  5871. /**
  5872. * Called when the behavior is detached from its target
  5873. */
  5874. detach(): void;
  5875. }
  5876. /**
  5877. * Interface implemented by classes supporting behaviors
  5878. */
  5879. interface IBehaviorAware<T> {
  5880. /**
  5881. * Attach a behavior
  5882. * @param behavior defines the behavior to attach
  5883. * @returns the current host
  5884. */
  5885. addBehavior(behavior: Behavior<T>): T;
  5886. /**
  5887. * Remove a behavior from the current object
  5888. * @param behavior defines the behavior to detach
  5889. * @returns the current host
  5890. */
  5891. removeBehavior(behavior: Behavior<T>): T;
  5892. /**
  5893. * Gets a behavior using its name to search
  5894. * @param name defines the name to search
  5895. * @returns the behavior or null if not found
  5896. */
  5897. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5898. }
  5899. }
  5900. declare module BABYLON {
  5901. /**
  5902. * Class used to store bone information
  5903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5904. */
  5905. class Bone extends Node {
  5906. /**
  5907. * defines the bone name
  5908. */
  5909. name: string;
  5910. private static _tmpVecs;
  5911. private static _tmpQuat;
  5912. private static _tmpMats;
  5913. /**
  5914. * Gets the list of child bones
  5915. */
  5916. children: Bone[];
  5917. /** Gets the animations associated with this bone */
  5918. animations: Animation[];
  5919. /**
  5920. * Gets or sets bone length
  5921. */
  5922. length: number;
  5923. /**
  5924. * @hidden Internal only
  5925. * Set this value to map this bone to a different index in the transform matrices
  5926. * Set this value to -1 to exclude the bone from the transform matrices
  5927. */
  5928. _index: Nullable<number>;
  5929. private _skeleton;
  5930. private _localMatrix;
  5931. private _restPose;
  5932. private _baseMatrix;
  5933. private _absoluteTransform;
  5934. private _invertedAbsoluteTransform;
  5935. private _parent;
  5936. private _scalingDeterminant;
  5937. private _worldTransform;
  5938. private _localScaling;
  5939. private _localRotation;
  5940. private _localPosition;
  5941. private _needToDecompose;
  5942. private _needToCompose;
  5943. /** @hidden */
  5944. /** @hidden */
  5945. _matrix: Matrix;
  5946. /**
  5947. * Create a new bone
  5948. * @param name defines the bone name
  5949. * @param skeleton defines the parent skeleton
  5950. * @param parentBone defines the parent (can be null if the bone is the root)
  5951. * @param localMatrix defines the local matrix
  5952. * @param restPose defines the rest pose matrix
  5953. * @param baseMatrix defines the base matrix
  5954. * @param index defines index of the bone in the hiearchy
  5955. */
  5956. constructor(
  5957. /**
  5958. * defines the bone name
  5959. */
  5960. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5961. /**
  5962. * Gets the parent skeleton
  5963. * @returns a skeleton
  5964. */
  5965. getSkeleton(): Skeleton;
  5966. /**
  5967. * Gets parent bone
  5968. * @returns a bone or null if the bone is the root of the bone hierarchy
  5969. */
  5970. getParent(): Nullable<Bone>;
  5971. /**
  5972. * Sets the parent bone
  5973. * @param parent defines the parent (can be null if the bone is the root)
  5974. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5975. */
  5976. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5977. /**
  5978. * Gets the local matrix
  5979. * @returns a matrix
  5980. */
  5981. getLocalMatrix(): Matrix;
  5982. /**
  5983. * Gets the base matrix (initial matrix which remains unchanged)
  5984. * @returns a matrix
  5985. */
  5986. getBaseMatrix(): Matrix;
  5987. /**
  5988. * Gets the rest pose matrix
  5989. * @returns a matrix
  5990. */
  5991. getRestPose(): Matrix;
  5992. /**
  5993. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5994. */
  5995. getWorldMatrix(): Matrix;
  5996. /**
  5997. * Sets the local matrix to rest pose matrix
  5998. */
  5999. returnToRest(): void;
  6000. /**
  6001. * Gets the inverse of the absolute transform matrix.
  6002. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6003. * @returns a matrix
  6004. */
  6005. getInvertedAbsoluteTransform(): Matrix;
  6006. /**
  6007. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6008. * @returns a matrix
  6009. */
  6010. getAbsoluteTransform(): Matrix;
  6011. /** Gets or sets current position (in local space) */
  6012. position: Vector3;
  6013. /** Gets or sets current rotation (in local space) */
  6014. rotation: Vector3;
  6015. /** Gets or sets current rotation quaternion (in local space) */
  6016. rotationQuaternion: Quaternion;
  6017. /** Gets or sets current scaling (in local space) */
  6018. scaling: Vector3;
  6019. /**
  6020. * Gets the animation properties override
  6021. */
  6022. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6023. private _decompose;
  6024. private _compose;
  6025. /**
  6026. * Update the base and local matrices
  6027. * @param matrix defines the new base or local matrix
  6028. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6029. * @param updateLocalMatrix defines if the local matrix should be updated
  6030. */
  6031. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6032. /** @hidden */
  6033. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6034. /**
  6035. * Flag the bone as dirty (Forcing it to update everything)
  6036. */
  6037. markAsDirty(): void;
  6038. private _markAsDirtyAndCompose;
  6039. private _markAsDirtyAndDecompose;
  6040. /**
  6041. * Copy an animation range from another bone
  6042. * @param source defines the source bone
  6043. * @param rangeName defines the range name to copy
  6044. * @param frameOffset defines the frame offset
  6045. * @param rescaleAsRequired defines if rescaling must be applied if required
  6046. * @param skelDimensionsRatio defines the scaling ratio
  6047. * @returns true if operation was successful
  6048. */
  6049. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6050. /**
  6051. * Translate the bone in local or world space
  6052. * @param vec The amount to translate the bone
  6053. * @param space The space that the translation is in
  6054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6055. */
  6056. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6057. /**
  6058. * Set the postion of the bone in local or world space
  6059. * @param position The position to set the bone
  6060. * @param space The space that the position is in
  6061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6062. */
  6063. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6064. /**
  6065. * Set the absolute position of the bone (world space)
  6066. * @param position The position to set the bone
  6067. * @param mesh The mesh that this bone is attached to
  6068. */
  6069. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6070. /**
  6071. * Scale the bone on the x, y and z axes (in local space)
  6072. * @param x The amount to scale the bone on the x axis
  6073. * @param y The amount to scale the bone on the y axis
  6074. * @param z The amount to scale the bone on the z axis
  6075. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6076. */
  6077. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6078. /**
  6079. * Set the bone scaling in local space
  6080. * @param scale defines the scaling vector
  6081. */
  6082. setScale(scale: Vector3): void;
  6083. /**
  6084. * Gets the current scaling in local space
  6085. * @returns the current scaling vector
  6086. */
  6087. getScale(): Vector3;
  6088. /**
  6089. * Gets the current scaling in local space and stores it in a target vector
  6090. * @param result defines the target vector
  6091. */
  6092. getScaleToRef(result: Vector3): void;
  6093. /**
  6094. * Set the yaw, pitch, and roll of the bone in local or world space
  6095. * @param yaw The rotation of the bone on the y axis
  6096. * @param pitch The rotation of the bone on the x axis
  6097. * @param roll The rotation of the bone on the z axis
  6098. * @param space The space that the axes of rotation are in
  6099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6100. */
  6101. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6102. /**
  6103. * Add a rotation to the bone on an axis in local or world space
  6104. * @param axis The axis to rotate the bone on
  6105. * @param amount The amount to rotate the bone
  6106. * @param space The space that the axis is in
  6107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6108. */
  6109. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6110. /**
  6111. * Set the rotation of the bone to a particular axis angle in local or world space
  6112. * @param axis The axis to rotate the bone on
  6113. * @param angle The angle that the bone should be rotated to
  6114. * @param space The space that the axis is in
  6115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6116. */
  6117. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6118. /**
  6119. * Set the euler rotation of the bone in local of world space
  6120. * @param rotation The euler rotation that the bone should be set to
  6121. * @param space The space that the rotation is in
  6122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6123. */
  6124. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6125. /**
  6126. * Set the quaternion rotation of the bone in local of world space
  6127. * @param quat The quaternion rotation that the bone should be set to
  6128. * @param space The space that the rotation is in
  6129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6130. */
  6131. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6132. /**
  6133. * Set the rotation matrix of the bone in local of world space
  6134. * @param rotMat The rotation matrix that the bone should be set to
  6135. * @param space The space that the rotation is in
  6136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6137. */
  6138. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6139. private _rotateWithMatrix;
  6140. private _getNegativeRotationToRef;
  6141. /**
  6142. * Get the position of the bone in local or world space
  6143. * @param space The space that the returned position is in
  6144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6145. * @returns The position of the bone
  6146. */
  6147. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6148. /**
  6149. * Copy the position of the bone to a vector3 in local or world space
  6150. * @param space The space that the returned position is in
  6151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6152. * @param result The vector3 to copy the position to
  6153. */
  6154. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6155. /**
  6156. * Get the absolute position of the bone (world space)
  6157. * @param mesh The mesh that this bone is attached to
  6158. * @returns The absolute position of the bone
  6159. */
  6160. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6161. /**
  6162. * Copy the absolute position of the bone (world space) to the result param
  6163. * @param mesh The mesh that this bone is attached to
  6164. * @param result The vector3 to copy the absolute position to
  6165. */
  6166. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6167. /**
  6168. * Compute the absolute transforms of this bone and its children
  6169. */
  6170. computeAbsoluteTransforms(): void;
  6171. /**
  6172. * Get the world direction from an axis that is in the local space of the bone
  6173. * @param localAxis The local direction that is used to compute the world direction
  6174. * @param mesh The mesh that this bone is attached to
  6175. * @returns The world direction
  6176. */
  6177. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6178. /**
  6179. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6180. * @param localAxis The local direction that is used to compute the world direction
  6181. * @param mesh The mesh that this bone is attached to
  6182. * @param result The vector3 that the world direction will be copied to
  6183. */
  6184. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6185. /**
  6186. * Get the euler rotation of the bone in local or world space
  6187. * @param space The space that the rotation should be in
  6188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6189. * @returns The euler rotation
  6190. */
  6191. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6192. /**
  6193. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6194. * @param space The space that the rotation should be in
  6195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6196. * @param result The vector3 that the rotation should be copied to
  6197. */
  6198. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6199. /**
  6200. * Get the quaternion rotation of the bone in either local or world space
  6201. * @param space The space that the rotation should be in
  6202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6203. * @returns The quaternion rotation
  6204. */
  6205. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6206. /**
  6207. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6208. * @param space The space that the rotation should be in
  6209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6210. * @param result The quaternion that the rotation should be copied to
  6211. */
  6212. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6213. /**
  6214. * Get the rotation matrix of the bone in local or world space
  6215. * @param space The space that the rotation should be in
  6216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6217. * @returns The rotation matrix
  6218. */
  6219. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6220. /**
  6221. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6222. * @param space The space that the rotation should be in
  6223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6224. * @param result The quaternion that the rotation should be copied to
  6225. */
  6226. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6227. /**
  6228. * Get the world position of a point that is in the local space of the bone
  6229. * @param position The local position
  6230. * @param mesh The mesh that this bone is attached to
  6231. * @returns The world position
  6232. */
  6233. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6234. /**
  6235. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6236. * @param position The local position
  6237. * @param mesh The mesh that this bone is attached to
  6238. * @param result The vector3 that the world position should be copied to
  6239. */
  6240. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6241. /**
  6242. * Get the local position of a point that is in world space
  6243. * @param position The world position
  6244. * @param mesh The mesh that this bone is attached to
  6245. * @returns The local position
  6246. */
  6247. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6248. /**
  6249. * Get the local position of a point that is in world space and copy it to the result param
  6250. * @param position The world position
  6251. * @param mesh The mesh that this bone is attached to
  6252. * @param result The vector3 that the local position should be copied to
  6253. */
  6254. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * Class used to apply inverse kinematics to bones
  6260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6261. */
  6262. class BoneIKController {
  6263. private static _tmpVecs;
  6264. private static _tmpQuat;
  6265. private static _tmpMats;
  6266. /**
  6267. * Gets or sets the target mesh
  6268. */
  6269. targetMesh: AbstractMesh;
  6270. /** Gets or sets the mesh used as pole */
  6271. poleTargetMesh: AbstractMesh;
  6272. /**
  6273. * Gets or sets the bone used as pole
  6274. */
  6275. poleTargetBone: Nullable<Bone>;
  6276. /**
  6277. * Gets or sets the target position
  6278. */
  6279. targetPosition: Vector3;
  6280. /**
  6281. * Gets or sets the pole target position
  6282. */
  6283. poleTargetPosition: Vector3;
  6284. /**
  6285. * Gets or sets the pole target local offset
  6286. */
  6287. poleTargetLocalOffset: Vector3;
  6288. /**
  6289. * Gets or sets the pole angle
  6290. */
  6291. poleAngle: number;
  6292. /**
  6293. * Gets or sets the mesh associated with the controller
  6294. */
  6295. mesh: AbstractMesh;
  6296. /**
  6297. * 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)
  6298. */
  6299. slerpAmount: number;
  6300. private _bone1Quat;
  6301. private _bone1Mat;
  6302. private _bone2Ang;
  6303. private _bone1;
  6304. private _bone2;
  6305. private _bone1Length;
  6306. private _bone2Length;
  6307. private _maxAngle;
  6308. private _maxReach;
  6309. private _rightHandedSystem;
  6310. private _bendAxis;
  6311. private _slerping;
  6312. private _adjustRoll;
  6313. /**
  6314. * Gets or sets maximum allowed angle
  6315. */
  6316. maxAngle: number;
  6317. /**
  6318. * Creates a new BoneIKController
  6319. * @param mesh defines the mesh to control
  6320. * @param bone defines the bone to control
  6321. * @param options defines options to set up the controller
  6322. */
  6323. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6324. targetMesh?: AbstractMesh;
  6325. poleTargetMesh?: AbstractMesh;
  6326. poleTargetBone?: Bone;
  6327. poleTargetLocalOffset?: Vector3;
  6328. poleAngle?: number;
  6329. bendAxis?: Vector3;
  6330. maxAngle?: number;
  6331. slerpAmount?: number;
  6332. });
  6333. private _setMaxAngle;
  6334. /**
  6335. * Force the controller to update the bones
  6336. */
  6337. update(): void;
  6338. }
  6339. }
  6340. declare module BABYLON {
  6341. /**
  6342. * Class used to make a bone look toward a point in space
  6343. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6344. */
  6345. class BoneLookController {
  6346. private static _tmpVecs;
  6347. private static _tmpQuat;
  6348. private static _tmpMats;
  6349. /**
  6350. * The target Vector3 that the bone will look at
  6351. */
  6352. target: Vector3;
  6353. /**
  6354. * The mesh that the bone is attached to
  6355. */
  6356. mesh: AbstractMesh;
  6357. /**
  6358. * The bone that will be looking to the target
  6359. */
  6360. bone: Bone;
  6361. /**
  6362. * The up axis of the coordinate system that is used when the bone is rotated
  6363. */
  6364. upAxis: Vector3;
  6365. /**
  6366. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6367. */
  6368. upAxisSpace: Space;
  6369. /**
  6370. * Used to make an adjustment to the yaw of the bone
  6371. */
  6372. adjustYaw: number;
  6373. /**
  6374. * Used to make an adjustment to the pitch of the bone
  6375. */
  6376. adjustPitch: number;
  6377. /**
  6378. * Used to make an adjustment to the roll of the bone
  6379. */
  6380. adjustRoll: number;
  6381. /**
  6382. * 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)
  6383. */
  6384. slerpAmount: number;
  6385. private _minYaw;
  6386. private _maxYaw;
  6387. private _minPitch;
  6388. private _maxPitch;
  6389. private _minYawSin;
  6390. private _minYawCos;
  6391. private _maxYawSin;
  6392. private _maxYawCos;
  6393. private _midYawConstraint;
  6394. private _minPitchTan;
  6395. private _maxPitchTan;
  6396. private _boneQuat;
  6397. private _slerping;
  6398. private _transformYawPitch;
  6399. private _transformYawPitchInv;
  6400. private _firstFrameSkipped;
  6401. private _yawRange;
  6402. private _fowardAxis;
  6403. /**
  6404. * Gets or sets the minimum yaw angle that the bone can look to
  6405. */
  6406. minYaw: number;
  6407. /**
  6408. * Gets or sets the maximum yaw angle that the bone can look to
  6409. */
  6410. maxYaw: number;
  6411. /**
  6412. * Gets or sets the minimum pitch angle that the bone can look to
  6413. */
  6414. minPitch: number;
  6415. /**
  6416. * Gets or sets the maximum pitch angle that the bone can look to
  6417. */
  6418. maxPitch: number;
  6419. /**
  6420. * Create a BoneLookController
  6421. * @param mesh the mesh that the bone belongs to
  6422. * @param bone the bone that will be looking to the target
  6423. * @param target the target Vector3 to look at
  6424. * @param settings optional settings:
  6425. * * maxYaw: the maximum angle the bone will yaw to
  6426. * * minYaw: the minimum angle the bone will yaw to
  6427. * * maxPitch: the maximum angle the bone will pitch to
  6428. * * minPitch: the minimum angle the bone will yaw to
  6429. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6430. * * upAxis: the up axis of the coordinate system
  6431. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6432. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6433. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6434. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6435. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6436. * * adjustRoll: used to make an adjustment to the roll of the bone
  6437. **/
  6438. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6439. maxYaw?: number;
  6440. minYaw?: number;
  6441. maxPitch?: number;
  6442. minPitch?: number;
  6443. slerpAmount?: number;
  6444. upAxis?: Vector3;
  6445. upAxisSpace?: Space;
  6446. yawAxis?: Vector3;
  6447. pitchAxis?: Vector3;
  6448. adjustYaw?: number;
  6449. adjustPitch?: number;
  6450. adjustRoll?: number;
  6451. });
  6452. /**
  6453. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6454. */
  6455. update(): void;
  6456. private _getAngleDiff;
  6457. private _getAngleBetween;
  6458. private _isAngleBetween;
  6459. }
  6460. }
  6461. declare module BABYLON {
  6462. /**
  6463. * Class used to handle skinning animations
  6464. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6465. */
  6466. class Skeleton implements IAnimatable {
  6467. /** defines the skeleton name */
  6468. name: string;
  6469. /** defines the skeleton Id */
  6470. id: string;
  6471. /**
  6472. * Gets the list of child bones
  6473. */
  6474. bones: Bone[];
  6475. /**
  6476. * Gets an estimate of the dimension of the skeleton at rest
  6477. */
  6478. dimensionsAtRest: Vector3;
  6479. /**
  6480. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6481. */
  6482. needInitialSkinMatrix: boolean;
  6483. /**
  6484. * Gets the list of animations attached to this skeleton
  6485. */
  6486. animations: Array<Animation>;
  6487. private _scene;
  6488. private _isDirty;
  6489. private _transformMatrices;
  6490. private _meshesWithPoseMatrix;
  6491. private _animatables;
  6492. private _identity;
  6493. private _synchronizedWithMesh;
  6494. private _ranges;
  6495. private _lastAbsoluteTransformsUpdateId;
  6496. /**
  6497. * Specifies if the skeleton should be serialized
  6498. */
  6499. doNotSerialize: boolean;
  6500. private _animationPropertiesOverride;
  6501. /**
  6502. * Gets or sets the animation properties override
  6503. */
  6504. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6505. /**
  6506. * An observable triggered before computing the skeleton's matrices
  6507. */
  6508. onBeforeComputeObservable: Observable<Skeleton>;
  6509. /**
  6510. * Creates a new skeleton
  6511. * @param name defines the skeleton name
  6512. * @param id defines the skeleton Id
  6513. * @param scene defines the hosting scene
  6514. */
  6515. constructor(
  6516. /** defines the skeleton name */
  6517. name: string,
  6518. /** defines the skeleton Id */
  6519. id: string, scene: Scene);
  6520. /**
  6521. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6522. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6523. * @returns a Float32Array containing matrices data
  6524. */
  6525. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6526. /**
  6527. * Gets the current hosting scene
  6528. * @returns a scene object
  6529. */
  6530. getScene(): Scene;
  6531. /**
  6532. * Gets a string representing the current skeleton data
  6533. * @param fullDetails defines a boolean indicating if we want a verbose version
  6534. * @returns a string representing the current skeleton data
  6535. */
  6536. toString(fullDetails?: boolean): string;
  6537. /**
  6538. * Get bone's index searching by name
  6539. * @param name defines bone's name to search for
  6540. * @return the indice of the bone. Returns -1 if not found
  6541. */
  6542. getBoneIndexByName(name: string): number;
  6543. /**
  6544. * Creater a new animation range
  6545. * @param name defines the name of the range
  6546. * @param from defines the start key
  6547. * @param to defines the end key
  6548. */
  6549. createAnimationRange(name: string, from: number, to: number): void;
  6550. /**
  6551. * Delete a specific animation range
  6552. * @param name defines the name of the range
  6553. * @param deleteFrames defines if frames must be removed as well
  6554. */
  6555. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6556. /**
  6557. * Gets a specific animation range
  6558. * @param name defines the name of the range to look for
  6559. * @returns the requested animation range or null if not found
  6560. */
  6561. getAnimationRange(name: string): Nullable<AnimationRange>;
  6562. /**
  6563. * Gets the list of all animation ranges defined on this skeleton
  6564. * @returns an array
  6565. */
  6566. getAnimationRanges(): Nullable<AnimationRange>[];
  6567. /**
  6568. * Copy animation range from a source skeleton.
  6569. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6570. * @param source defines the source skeleton
  6571. * @param name defines the name of the range to copy
  6572. * @param rescaleAsRequired defines if rescaling must be applied if required
  6573. * @returns true if operation was successful
  6574. */
  6575. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6576. /**
  6577. * Forces the skeleton to go to rest pose
  6578. */
  6579. returnToRest(): void;
  6580. private _getHighestAnimationFrame;
  6581. /**
  6582. * Begin a specific animation range
  6583. * @param name defines the name of the range to start
  6584. * @param loop defines if looping must be turned on (false by default)
  6585. * @param speedRatio defines the speed ratio to apply (1 by default)
  6586. * @param onAnimationEnd defines a callback which will be called when animation will end
  6587. * @returns a new animatable
  6588. */
  6589. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6590. /** @hidden */
  6591. _markAsDirty(): void;
  6592. /** @hidden */
  6593. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6594. /** @hidden */
  6595. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6596. /** @hidden */
  6597. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6598. /**
  6599. * Build all resources required to render a skeleton
  6600. */
  6601. prepare(): void;
  6602. /**
  6603. * Gets the list of animatables currently running for this skeleton
  6604. * @returns an array of animatables
  6605. */
  6606. getAnimatables(): IAnimatable[];
  6607. /**
  6608. * Clone the current skeleton
  6609. * @param name defines the name of the new skeleton
  6610. * @param id defines the id of the enw skeleton
  6611. * @returns the new skeleton
  6612. */
  6613. clone(name: string, id: string): Skeleton;
  6614. /**
  6615. * Enable animation blending for this skeleton
  6616. * @param blendingSpeed defines the blending speed to apply
  6617. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6618. */
  6619. enableBlending(blendingSpeed?: number): void;
  6620. /**
  6621. * Releases all resources associated with the current skeleton
  6622. */
  6623. dispose(): void;
  6624. /**
  6625. * Serialize the skeleton in a JSON object
  6626. * @returns a JSON object
  6627. */
  6628. serialize(): any;
  6629. /**
  6630. * Creates a new skeleton from serialized data
  6631. * @param parsedSkeleton defines the serialized data
  6632. * @param scene defines the hosting scene
  6633. * @returns a new skeleton
  6634. */
  6635. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6636. /**
  6637. * Compute all node absolute transforms
  6638. * @param forceUpdate defines if computation must be done even if cache is up to date
  6639. */
  6640. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6641. /**
  6642. * Gets the root pose matrix
  6643. * @returns a matrix
  6644. */
  6645. getPoseMatrix(): Nullable<Matrix>;
  6646. /**
  6647. * Sorts bones per internal index
  6648. */
  6649. sortBones(): void;
  6650. private _sortBones;
  6651. }
  6652. }
  6653. declare module BABYLON {
  6654. /** @hidden */
  6655. class Collider {
  6656. /** Define if a collision was found */
  6657. collisionFound: boolean;
  6658. /**
  6659. * Define last intersection point in local space
  6660. */
  6661. intersectionPoint: Vector3;
  6662. /**
  6663. * Define last collided mesh
  6664. */
  6665. collidedMesh: Nullable<AbstractMesh>;
  6666. private _collisionPoint;
  6667. private _planeIntersectionPoint;
  6668. private _tempVector;
  6669. private _tempVector2;
  6670. private _tempVector3;
  6671. private _tempVector4;
  6672. private _edge;
  6673. private _baseToVertex;
  6674. private _destinationPoint;
  6675. private _slidePlaneNormal;
  6676. private _displacementVector;
  6677. /** @hidden */
  6678. _radius: Vector3;
  6679. /** @hidden */
  6680. _retry: number;
  6681. private _velocity;
  6682. private _basePoint;
  6683. private _epsilon;
  6684. /** @hidden */
  6685. _velocityWorldLength: number;
  6686. /** @hidden */
  6687. _basePointWorld: Vector3;
  6688. private _velocityWorld;
  6689. private _normalizedVelocity;
  6690. /** @hidden */
  6691. _initialVelocity: Vector3;
  6692. /** @hidden */
  6693. _initialPosition: Vector3;
  6694. private _nearestDistance;
  6695. private _collisionMask;
  6696. collisionMask: number;
  6697. /**
  6698. * Gets the plane normal used to compute the sliding response (in local space)
  6699. */
  6700. readonly slidePlaneNormal: Vector3;
  6701. /** @hidden */
  6702. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6703. /** @hidden */
  6704. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6705. /** @hidden */
  6706. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6707. /** @hidden */
  6708. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6709. /** @hidden */
  6710. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6711. /** @hidden */
  6712. _getResponse(pos: Vector3, vel: Vector3): void;
  6713. }
  6714. }
  6715. declare module BABYLON {
  6716. /** @hidden */
  6717. var CollisionWorker: string;
  6718. /** @hidden */
  6719. interface ICollisionCoordinator {
  6720. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6721. init(scene: Scene): void;
  6722. destroy(): void;
  6723. onMeshAdded(mesh: AbstractMesh): void;
  6724. onMeshUpdated(mesh: AbstractMesh): void;
  6725. onMeshRemoved(mesh: AbstractMesh): void;
  6726. onGeometryAdded(geometry: Geometry): void;
  6727. onGeometryUpdated(geometry: Geometry): void;
  6728. onGeometryDeleted(geometry: Geometry): void;
  6729. }
  6730. /** @hidden */
  6731. interface SerializedMesh {
  6732. id: string;
  6733. name: string;
  6734. uniqueId: number;
  6735. geometryId: Nullable<string>;
  6736. sphereCenter: Array<number>;
  6737. sphereRadius: number;
  6738. boxMinimum: Array<number>;
  6739. boxMaximum: Array<number>;
  6740. worldMatrixFromCache: any;
  6741. subMeshes: Array<SerializedSubMesh>;
  6742. checkCollisions: boolean;
  6743. }
  6744. /** @hidden */
  6745. interface SerializedSubMesh {
  6746. position: number;
  6747. verticesStart: number;
  6748. verticesCount: number;
  6749. indexStart: number;
  6750. indexCount: number;
  6751. hasMaterial: boolean;
  6752. sphereCenter: Array<number>;
  6753. sphereRadius: number;
  6754. boxMinimum: Array<number>;
  6755. boxMaximum: Array<number>;
  6756. }
  6757. /**
  6758. * Interface describing the value associated with a geometry.
  6759. * @hidden
  6760. */
  6761. interface SerializedGeometry {
  6762. /**
  6763. * Defines the unique ID of the geometry
  6764. */
  6765. id: string;
  6766. /**
  6767. * Defines the array containing the positions
  6768. */
  6769. positions: Float32Array;
  6770. /**
  6771. * Defines the array containing the indices
  6772. */
  6773. indices: Uint32Array;
  6774. /**
  6775. * Defines the array containing the normals
  6776. */
  6777. normals: Float32Array;
  6778. }
  6779. /** @hidden */
  6780. interface BabylonMessage {
  6781. taskType: WorkerTaskType;
  6782. payload: InitPayload | CollidePayload | UpdatePayload;
  6783. }
  6784. /** @hidden */
  6785. interface SerializedColliderToWorker {
  6786. position: Array<number>;
  6787. velocity: Array<number>;
  6788. radius: Array<number>;
  6789. }
  6790. /** Defines supported task for worker process */
  6791. enum WorkerTaskType {
  6792. /** Initialization */
  6793. INIT = 0,
  6794. /** Update of geometry */
  6795. UPDATE = 1,
  6796. /** Evaluate collision */
  6797. COLLIDE = 2
  6798. }
  6799. /** @hidden */
  6800. interface WorkerReply {
  6801. error: WorkerReplyType;
  6802. taskType: WorkerTaskType;
  6803. payload?: any;
  6804. }
  6805. /** @hidden */
  6806. interface CollisionReplyPayload {
  6807. newPosition: Array<number>;
  6808. collisionId: number;
  6809. collidedMeshUniqueId: number;
  6810. }
  6811. /** @hidden */
  6812. interface InitPayload {
  6813. }
  6814. /** @hidden */
  6815. interface CollidePayload {
  6816. collisionId: number;
  6817. collider: SerializedColliderToWorker;
  6818. maximumRetry: number;
  6819. excludedMeshUniqueId: Nullable<number>;
  6820. }
  6821. /** @hidden */
  6822. interface UpdatePayload {
  6823. updatedMeshes: {
  6824. [n: number]: SerializedMesh;
  6825. };
  6826. updatedGeometries: {
  6827. [s: string]: SerializedGeometry;
  6828. };
  6829. removedMeshes: Array<number>;
  6830. removedGeometries: Array<string>;
  6831. }
  6832. /** Defines kind of replies returned by worker */
  6833. enum WorkerReplyType {
  6834. /** Success */
  6835. SUCCESS = 0,
  6836. /** Unkown error */
  6837. UNKNOWN_ERROR = 1
  6838. }
  6839. /** @hidden */
  6840. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6841. private _scene;
  6842. private _scaledPosition;
  6843. private _scaledVelocity;
  6844. private _collisionsCallbackArray;
  6845. private _init;
  6846. private _runningUpdated;
  6847. private _worker;
  6848. private _addUpdateMeshesList;
  6849. private _addUpdateGeometriesList;
  6850. private _toRemoveMeshesArray;
  6851. private _toRemoveGeometryArray;
  6852. constructor();
  6853. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6854. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6855. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6856. init(scene: Scene): void;
  6857. destroy(): void;
  6858. onMeshAdded(mesh: AbstractMesh): void;
  6859. onMeshUpdated: (transformNode: TransformNode) => void;
  6860. onMeshRemoved(mesh: AbstractMesh): void;
  6861. onGeometryAdded(geometry: Geometry): void;
  6862. onGeometryUpdated: (geometry: Geometry) => void;
  6863. onGeometryDeleted(geometry: Geometry): void;
  6864. private _afterRender;
  6865. private _onMessageFromWorker;
  6866. }
  6867. /** @hidden */
  6868. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6869. private _scene;
  6870. private _scaledPosition;
  6871. private _scaledVelocity;
  6872. private _finalPosition;
  6873. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6874. init(scene: Scene): void;
  6875. destroy(): void;
  6876. onMeshAdded(mesh: AbstractMesh): void;
  6877. onMeshUpdated(mesh: AbstractMesh): void;
  6878. onMeshRemoved(mesh: AbstractMesh): void;
  6879. onGeometryAdded(geometry: Geometry): void;
  6880. onGeometryUpdated(geometry: Geometry): void;
  6881. onGeometryDeleted(geometry: Geometry): void;
  6882. private _collideWithWorld;
  6883. }
  6884. }
  6885. declare function importScripts(...urls: string[]): void;
  6886. declare const safePostMessage: any;
  6887. declare module BABYLON {
  6888. /** @hidden */
  6889. var WorkerIncluded: boolean;
  6890. /** @hidden */
  6891. class CollisionCache {
  6892. private _meshes;
  6893. private _geometries;
  6894. getMeshes(): {
  6895. [n: number]: SerializedMesh;
  6896. };
  6897. getGeometries(): {
  6898. [s: number]: SerializedGeometry;
  6899. };
  6900. getMesh(id: any): SerializedMesh;
  6901. addMesh(mesh: SerializedMesh): void;
  6902. removeMesh(uniqueId: number): void;
  6903. getGeometry(id: string): SerializedGeometry;
  6904. addGeometry(geometry: SerializedGeometry): void;
  6905. removeGeometry(id: string): void;
  6906. }
  6907. /** @hidden */
  6908. class CollideWorker {
  6909. collider: Collider;
  6910. private _collisionCache;
  6911. private finalPosition;
  6912. private collisionsScalingMatrix;
  6913. private collisionTranformationMatrix;
  6914. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6915. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6916. private checkCollision;
  6917. private processCollisionsForSubMeshes;
  6918. private collideForSubMesh;
  6919. private checkSubmeshCollision;
  6920. }
  6921. /** @hidden */
  6922. interface ICollisionDetector {
  6923. onInit(payload: InitPayload): void;
  6924. onUpdate(payload: UpdatePayload): void;
  6925. onCollision(payload: CollidePayload): void;
  6926. }
  6927. /** @hidden */
  6928. class CollisionDetectorTransferable implements ICollisionDetector {
  6929. private _collisionCache;
  6930. onInit(payload: InitPayload): void;
  6931. onUpdate(payload: UpdatePayload): void;
  6932. onCollision(payload: CollidePayload): void;
  6933. }
  6934. }
  6935. declare module BABYLON {
  6936. /**
  6937. * @hidden
  6938. */
  6939. class IntersectionInfo {
  6940. bu: Nullable<number>;
  6941. bv: Nullable<number>;
  6942. distance: number;
  6943. faceId: number;
  6944. subMeshId: number;
  6945. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6946. }
  6947. /**
  6948. * Information about the result of picking within a scene
  6949. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6950. */
  6951. class PickingInfo {
  6952. /**
  6953. * If the pick collided with an object
  6954. */
  6955. hit: boolean;
  6956. /**
  6957. * Distance away where the pick collided
  6958. */
  6959. distance: number;
  6960. /**
  6961. * The location of pick collision
  6962. */
  6963. pickedPoint: Nullable<Vector3>;
  6964. /**
  6965. * The mesh corresponding the the pick collision
  6966. */
  6967. pickedMesh: Nullable<AbstractMesh>;
  6968. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6969. bu: number;
  6970. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6971. bv: number;
  6972. /** The id of the face on the mesh that was picked */
  6973. faceId: number;
  6974. /** Id of the the submesh that was picked */
  6975. subMeshId: number;
  6976. /** If a sprite was picked, this will be the sprite the pick collided with */
  6977. pickedSprite: Nullable<Sprite>;
  6978. /**
  6979. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6980. */
  6981. originMesh: Nullable<AbstractMesh>;
  6982. /**
  6983. * The ray that was used to perform the picking.
  6984. */
  6985. ray: Nullable<Ray>;
  6986. /**
  6987. * Gets the normal correspodning to the face the pick collided with
  6988. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6989. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6990. * @returns The normal correspodning to the face the pick collided with
  6991. */
  6992. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6993. /**
  6994. * Gets the texture coordinates of where the pick occured
  6995. * @returns the vector containing the coordnates of the texture
  6996. */
  6997. getTextureCoordinates(): Nullable<Vector2>;
  6998. }
  6999. }
  7000. declare module BABYLON {
  7001. /**
  7002. * Class used to store bounding box information
  7003. */
  7004. class BoundingBox implements ICullable {
  7005. /**
  7006. * Gets the 8 vectors representing the bounding box in local space
  7007. */
  7008. vectors: Vector3[];
  7009. /**
  7010. * Gets the center of the bounding box in local space
  7011. */
  7012. center: Vector3;
  7013. /**
  7014. * Gets the center of the bounding box in world space
  7015. */
  7016. centerWorld: Vector3;
  7017. /**
  7018. * Gets the extend size in local space
  7019. */
  7020. extendSize: Vector3;
  7021. /**
  7022. * Gets the extend size in world space
  7023. */
  7024. extendSizeWorld: Vector3;
  7025. /**
  7026. * Gets the OBB (object bounding box) directions
  7027. */
  7028. directions: Vector3[];
  7029. /**
  7030. * Gets the 8 vectors representing the bounding box in world space
  7031. */
  7032. vectorsWorld: Vector3[];
  7033. /**
  7034. * Gets the minimum vector in world space
  7035. */
  7036. minimumWorld: Vector3;
  7037. /**
  7038. * Gets the maximum vector in world space
  7039. */
  7040. maximumWorld: Vector3;
  7041. /**
  7042. * Gets the minimum vector in local space
  7043. */
  7044. minimum: Vector3;
  7045. /**
  7046. * Gets the maximum vector in local space
  7047. */
  7048. maximum: Vector3;
  7049. private _worldMatrix;
  7050. private static TmpVector3;
  7051. /**
  7052. * @hidden
  7053. */
  7054. _tag: number;
  7055. /**
  7056. * Creates a new bounding box
  7057. * @param min defines the minimum vector (in local space)
  7058. * @param max defines the maximum vector (in local space)
  7059. * @param worldMatrix defines the new world matrix
  7060. */
  7061. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  7062. /**
  7063. * Recreates the entire bounding box from scratch
  7064. * @param min defines the new minimum vector (in local space)
  7065. * @param max defines the new maximum vector (in local space)
  7066. * @param worldMatrix defines the new world matrix
  7067. */
  7068. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7069. /**
  7070. * Scale the current bounding box by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding box
  7073. */
  7074. scale(factor: number): BoundingBox;
  7075. /**
  7076. * Gets the world matrix of the bounding box
  7077. * @returns a matrix
  7078. */
  7079. getWorldMatrix(): Matrix;
  7080. /**
  7081. * Sets the world matrix stored in the bounding box
  7082. * @param matrix defines the matrix to store
  7083. * @returns current bounding box
  7084. */
  7085. setWorldMatrix(matrix: Matrix): BoundingBox;
  7086. /** @hidden */
  7087. _update(world: Matrix): void;
  7088. /**
  7089. * Tests if the bounding box is intersecting the frustum planes
  7090. * @param frustumPlanes defines the frustum planes to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. isInFrustum(frustumPlanes: Plane[]): boolean;
  7094. /**
  7095. * Tests if the bounding box is entirely inside the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an inclusion
  7098. */
  7099. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7100. /**
  7101. * Tests if a point is inside the bounding box
  7102. * @param point defines the point to test
  7103. * @returns true if the point is inside the bounding box
  7104. */
  7105. intersectsPoint(point: Vector3): boolean;
  7106. /**
  7107. * Tests if the bounding box intersects with a bounding sphere
  7108. * @param sphere defines the sphere to test
  7109. * @returns true if there is an intersection
  7110. */
  7111. intersectsSphere(sphere: BoundingSphere): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7114. * @param min defines the min vector to use
  7115. * @param max defines the max vector to use
  7116. * @returns true if there is an intersection
  7117. */
  7118. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  7119. /**
  7120. * Tests if two bounding boxes are intersections
  7121. * @param box0 defines the first box to test
  7122. * @param box1 defines the second box to test
  7123. * @returns true if there is an intersection
  7124. */
  7125. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  7126. /**
  7127. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7128. * @param minPoint defines the minimum vector of the bounding box
  7129. * @param maxPoint defines the maximum vector of the bounding box
  7130. * @param sphereCenter defines the sphere center
  7131. * @param sphereRadius defines the sphere radius
  7132. * @returns true if there is an intersection
  7133. */
  7134. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  7135. /**
  7136. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7137. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7138. * @param frustumPlanes defines the frustum planes to test
  7139. * @return true if there is an inclusion
  7140. */
  7141. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7142. /**
  7143. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7144. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7145. * @param frustumPlanes defines the frustum planes to test
  7146. * @return true if there is an intersection
  7147. */
  7148. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7149. }
  7150. }
  7151. declare module BABYLON {
  7152. /**
  7153. * Interface for cullable objects
  7154. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7155. */
  7156. interface ICullable {
  7157. /**
  7158. * Checks if the object or part of the object is in the frustum
  7159. * @param frustumPlanes Camera near/planes
  7160. * @returns true if the object is in frustum otherwise false
  7161. */
  7162. isInFrustum(frustumPlanes: Plane[]): boolean;
  7163. /**
  7164. * Checks if a cullable object (mesh...) is in the camera frustum
  7165. * Unlike isInFrustum this cheks the full bounding box
  7166. * @param frustumPlanes Camera near/planes
  7167. * @returns true if the object is in frustum otherwise false
  7168. */
  7169. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7170. }
  7171. /**
  7172. * Info for a bounding data of a mesh
  7173. */
  7174. class BoundingInfo implements ICullable {
  7175. /**
  7176. * Bounding box for the mesh
  7177. */
  7178. boundingBox: BoundingBox;
  7179. /**
  7180. * Bounding sphere for the mesh
  7181. */
  7182. boundingSphere: BoundingSphere;
  7183. private _isLocked;
  7184. /**
  7185. * Constructs bounding info
  7186. * @param minimum min vector of the bounding box/sphere
  7187. * @param maximum max vector of the bounding box/sphere
  7188. * @param worldMatrix defines the new world matrix
  7189. */
  7190. constructor(minimum: Vector3, maximum: Vector3, worldMatrix?: Matrix);
  7191. /**
  7192. * Recreates the entire bounding info from scratch
  7193. * @param min defines the new minimum vector (in local space)
  7194. * @param max defines the new maximum vector (in local space)
  7195. * @param worldMatrix defines the new world matrix
  7196. */
  7197. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7198. /**
  7199. * min vector of the bounding box/sphere
  7200. */
  7201. readonly minimum: Vector3;
  7202. /**
  7203. * max vector of the bounding box/sphere
  7204. */
  7205. readonly maximum: Vector3;
  7206. /**
  7207. * If the info is locked and won't be updated to avoid perf overhead
  7208. */
  7209. isLocked: boolean;
  7210. /**
  7211. * Updates the boudning sphere and box
  7212. * @param world world matrix to be used to update
  7213. */
  7214. update(world: Matrix): void;
  7215. /**
  7216. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7217. * @param center New center of the bounding info
  7218. * @param extend New extend of the bounding info
  7219. * @returns the current bounding info
  7220. */
  7221. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  7222. /**
  7223. * Scale the current bounding info by applying a scale factor
  7224. * @param factor defines the scale factor to apply
  7225. * @returns the current bounding info
  7226. */
  7227. scale(factor: number): BoundingInfo;
  7228. /**
  7229. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7230. * @param frustumPlanes defines the frustum to test
  7231. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7232. * @returns true if the bounding info is in the frustum planes
  7233. */
  7234. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  7235. /**
  7236. * Gets the world distance between the min and max points of the bounding box
  7237. */
  7238. readonly diagonalLength: number;
  7239. /**
  7240. * Checks if a cullable object (mesh...) is in the camera frustum
  7241. * Unlike isInFrustum this cheks the full bounding box
  7242. * @param frustumPlanes Camera near/planes
  7243. * @returns true if the object is in frustum otherwise false
  7244. */
  7245. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7246. /** @hidden */
  7247. _checkCollision(collider: Collider): boolean;
  7248. /**
  7249. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7250. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7251. * @param point the point to check intersection with
  7252. * @returns if the point intersects
  7253. */
  7254. intersectsPoint(point: Vector3): boolean;
  7255. /**
  7256. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7257. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7258. * @param boundingInfo the bounding info to check intersection with
  7259. * @param precise if the intersection should be done using OBB
  7260. * @returns if the bounding info intersects
  7261. */
  7262. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  7263. }
  7264. }
  7265. declare module BABYLON {
  7266. /**
  7267. * Class used to store bounding sphere information
  7268. */
  7269. class BoundingSphere {
  7270. /**
  7271. * Gets the center of the bounding sphere in local space
  7272. */
  7273. center: Vector3;
  7274. /**
  7275. * Radius of the bounding sphere in local space
  7276. */
  7277. radius: number;
  7278. /**
  7279. * Gets the center of the bounding sphere in world space
  7280. */
  7281. centerWorld: Vector3;
  7282. /**
  7283. * Radius of the bounding sphere in world space
  7284. */
  7285. radiusWorld: number;
  7286. /**
  7287. * Gets the minimum vector in local space
  7288. */
  7289. minimum: Vector3;
  7290. /**
  7291. * Gets the maximum vector in local space
  7292. */
  7293. maximum: Vector3;
  7294. private static TmpVector3;
  7295. /**
  7296. * Creates a new bounding sphere
  7297. * @param min defines the minimum vector (in local space)
  7298. * @param max defines the maximum vector (in local space)
  7299. * @param worldMatrix defines the new world matrix
  7300. */
  7301. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  7302. /**
  7303. * Recreates the entire bounding sphere from scratch
  7304. * @param min defines the new minimum vector (in local space)
  7305. * @param max defines the new maximum vector (in local space)
  7306. * @param worldMatrix defines the new world matrix
  7307. */
  7308. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7309. /**
  7310. * Scale the current bounding sphere by applying a scale factor
  7311. * @param factor defines the scale factor to apply
  7312. * @returns the current bounding box
  7313. */
  7314. scale(factor: number): BoundingSphere;
  7315. /** @hidden */
  7316. _update(world: Matrix): void;
  7317. /**
  7318. * Tests if the bounding sphere is intersecting the frustum planes
  7319. * @param frustumPlanes defines the frustum planes to test
  7320. * @returns true if there is an intersection
  7321. */
  7322. isInFrustum(frustumPlanes: Plane[]): boolean;
  7323. /**
  7324. * Tests if a point is inside the bounding sphere
  7325. * @param point defines the point to test
  7326. * @returns true if the point is inside the bounding sphere
  7327. */
  7328. intersectsPoint(point: Vector3): boolean;
  7329. /**
  7330. * Checks if two sphere intersct
  7331. * @param sphere0 sphere 0
  7332. * @param sphere1 sphere 1
  7333. * @returns true if the speres intersect
  7334. */
  7335. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. /**
  7340. * Class representing a ray with position and direction
  7341. */
  7342. class Ray {
  7343. /** origin point */
  7344. origin: Vector3;
  7345. /** direction */
  7346. direction: Vector3;
  7347. /** length of the ray */
  7348. length: number;
  7349. private _edge1;
  7350. private _edge2;
  7351. private _pvec;
  7352. private _tvec;
  7353. private _qvec;
  7354. private _tmpRay;
  7355. /**
  7356. * Creates a new ray
  7357. * @param origin origin point
  7358. * @param direction direction
  7359. * @param length length of the ray
  7360. */
  7361. constructor(
  7362. /** origin point */
  7363. origin: Vector3,
  7364. /** direction */
  7365. direction: Vector3,
  7366. /** length of the ray */
  7367. length?: number);
  7368. /**
  7369. * Checks if the ray intersects a box
  7370. * @param minimum bound of the box
  7371. * @param maximum bound of the box
  7372. * @returns if the box was hit
  7373. */
  7374. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  7375. /**
  7376. * Checks if the ray intersects a box
  7377. * @param box the bounding box to check
  7378. * @returns if the box was hit
  7379. */
  7380. intersectsBox(box: BoundingBox): boolean;
  7381. /**
  7382. * If the ray hits a sphere
  7383. * @param sphere the bounding sphere to check
  7384. * @returns true if it hits the sphere
  7385. */
  7386. intersectsSphere(sphere: BoundingSphere): boolean;
  7387. /**
  7388. * If the ray hits a triange
  7389. * @param vertex0 triangle vertex
  7390. * @param vertex1 triangle vertex
  7391. * @param vertex2 triangle vertex
  7392. * @returns intersection information if hit
  7393. */
  7394. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  7395. /**
  7396. * Checks if ray intersects a plane
  7397. * @param plane the plane to check
  7398. * @returns the distance away it was hit
  7399. */
  7400. intersectsPlane(plane: Plane): Nullable<number>;
  7401. /**
  7402. * Checks if ray intersects a mesh
  7403. * @param mesh the mesh to check
  7404. * @param fastCheck if only the bounding box should checked
  7405. * @returns picking info of the intersecton
  7406. */
  7407. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  7408. /**
  7409. * Checks if ray intersects a mesh
  7410. * @param meshes the meshes to check
  7411. * @param fastCheck if only the bounding box should checked
  7412. * @param results array to store result in
  7413. * @returns Array of picking infos
  7414. */
  7415. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7416. private _comparePickingInfo;
  7417. private static smallnum;
  7418. private static rayl;
  7419. /**
  7420. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7421. * @param sega the first point of the segment to test the intersection against
  7422. * @param segb the second point of the segment to test the intersection against
  7423. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7424. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7425. */
  7426. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  7427. /**
  7428. * Update the ray from viewport position
  7429. * @param x position
  7430. * @param y y position
  7431. * @param viewportWidth viewport width
  7432. * @param viewportHeight viewport height
  7433. * @param world world matrix
  7434. * @param view view matrix
  7435. * @param projection projection matrix
  7436. * @returns this ray updated
  7437. */
  7438. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7439. /**
  7440. * Creates a ray with origin and direction of 0,0,0
  7441. * @returns the new ray
  7442. */
  7443. static Zero(): Ray;
  7444. /**
  7445. * Creates a new ray from screen space and viewport
  7446. * @param x position
  7447. * @param y y position
  7448. * @param viewportWidth viewport width
  7449. * @param viewportHeight viewport height
  7450. * @param world world matrix
  7451. * @param view view matrix
  7452. * @param projection projection matrix
  7453. * @returns new ray
  7454. */
  7455. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7456. /**
  7457. * 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
  7458. * transformed to the given world matrix.
  7459. * @param origin The origin point
  7460. * @param end The end point
  7461. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7462. * @returns the new ray
  7463. */
  7464. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  7465. /**
  7466. * Transforms a ray by a matrix
  7467. * @param ray ray to transform
  7468. * @param matrix matrix to apply
  7469. * @returns the resulting new ray
  7470. */
  7471. static Transform(ray: Ray, matrix: Matrix): Ray;
  7472. /**
  7473. * Transforms a ray by a matrix
  7474. * @param ray ray to transform
  7475. * @param matrix matrix to apply
  7476. * @param result ray to store result in
  7477. */
  7478. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * This represents an orbital type of camera.
  7484. *
  7485. * 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.
  7486. * 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.
  7487. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7488. */
  7489. class ArcRotateCamera extends TargetCamera {
  7490. /**
  7491. * Defines the rotation angle of the camera along the longitudinal axis.
  7492. */
  7493. alpha: number;
  7494. /**
  7495. * Defines the rotation angle of the camera along the latitudinal axis.
  7496. */
  7497. beta: number;
  7498. /**
  7499. * Defines the radius of the camera from it s target point.
  7500. */
  7501. radius: number;
  7502. protected _target: Vector3;
  7503. protected _targetHost: Nullable<AbstractMesh>;
  7504. /**
  7505. * Defines the target point of the camera.
  7506. * The camera looks towards it form the radius distance.
  7507. */
  7508. target: Vector3;
  7509. /**
  7510. * Current inertia value on the longitudinal axis.
  7511. * The bigger this number the longer it will take for the camera to stop.
  7512. */
  7513. inertialAlphaOffset: number;
  7514. /**
  7515. * Current inertia value on the latitudinal axis.
  7516. * The bigger this number the longer it will take for the camera to stop.
  7517. */
  7518. inertialBetaOffset: number;
  7519. /**
  7520. * Current inertia value on the radius axis.
  7521. * The bigger this number the longer it will take for the camera to stop.
  7522. */
  7523. inertialRadiusOffset: number;
  7524. /**
  7525. * Minimum allowed angle on the longitudinal axis.
  7526. * This can help limiting how the Camera is able to move in the scene.
  7527. */
  7528. lowerAlphaLimit: Nullable<number>;
  7529. /**
  7530. * Maximum allowed angle on the longitudinal axis.
  7531. * This can help limiting how the Camera is able to move in the scene.
  7532. */
  7533. upperAlphaLimit: Nullable<number>;
  7534. /**
  7535. * Minimum allowed angle on the latitudinal axis.
  7536. * This can help limiting how the Camera is able to move in the scene.
  7537. */
  7538. lowerBetaLimit: number;
  7539. /**
  7540. * Maximum allowed angle on the latitudinal axis.
  7541. * This can help limiting how the Camera is able to move in the scene.
  7542. */
  7543. upperBetaLimit: number;
  7544. /**
  7545. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7546. * This can help limiting how the Camera is able to move in the scene.
  7547. */
  7548. lowerRadiusLimit: Nullable<number>;
  7549. /**
  7550. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7551. * This can help limiting how the Camera is able to move in the scene.
  7552. */
  7553. upperRadiusLimit: Nullable<number>;
  7554. /**
  7555. * Defines the current inertia value used during panning of the camera along the X axis.
  7556. */
  7557. inertialPanningX: number;
  7558. /**
  7559. * Defines the current inertia value used during panning of the camera along the Y axis.
  7560. */
  7561. inertialPanningY: number;
  7562. /**
  7563. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7564. * Basically if your fingers moves away from more than this distance you will be considered
  7565. * in pinch mode.
  7566. */
  7567. pinchToPanMaxDistance: number;
  7568. /**
  7569. * Defines the maximum distance the camera can pan.
  7570. * This could help keeping the cammera always in your scene.
  7571. */
  7572. panningDistanceLimit: Nullable<number>;
  7573. /**
  7574. * Defines the target of the camera before paning.
  7575. */
  7576. panningOriginTarget: Vector3;
  7577. /**
  7578. * Defines the value of the inertia used during panning.
  7579. * 0 would mean stop inertia and one would mean no decelleration at all.
  7580. */
  7581. panningInertia: number;
  7582. /**
  7583. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7584. */
  7585. angularSensibilityX: number;
  7586. /**
  7587. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7588. */
  7589. angularSensibilityY: number;
  7590. /**
  7591. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7592. */
  7593. pinchPrecision: number;
  7594. /**
  7595. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7596. * It will be used instead of pinchDeltaPrecision if different from 0.
  7597. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7598. */
  7599. pinchDeltaPercentage: number;
  7600. /**
  7601. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7602. */
  7603. panningSensibility: number;
  7604. /**
  7605. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7606. */
  7607. keysUp: number[];
  7608. /**
  7609. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7610. */
  7611. keysDown: number[];
  7612. /**
  7613. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7614. */
  7615. keysLeft: number[];
  7616. /**
  7617. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7618. */
  7619. keysRight: number[];
  7620. /**
  7621. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7622. */
  7623. wheelPrecision: number;
  7624. /**
  7625. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7626. * It will be used instead of pinchDeltaPrecision if different from 0.
  7627. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7628. */
  7629. wheelDeltaPercentage: number;
  7630. /**
  7631. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7632. */
  7633. zoomOnFactor: number;
  7634. /**
  7635. * Defines a screen offset for the camera position.
  7636. */
  7637. targetScreenOffset: Vector2;
  7638. /**
  7639. * Allows the camera to be completely reversed.
  7640. * If false the camera can not arrive upside down.
  7641. */
  7642. allowUpsideDown: boolean;
  7643. /**
  7644. * Define if double tap/click is used to restore the previously saved state of the camera.
  7645. */
  7646. useInputToRestoreState: boolean;
  7647. /** @hidden */
  7648. _viewMatrix: Matrix;
  7649. /** @hidden */
  7650. _useCtrlForPanning: boolean;
  7651. /** @hidden */
  7652. _panningMouseButton: number;
  7653. /**
  7654. * Defines the inpute associated to the camera.
  7655. */
  7656. inputs: ArcRotateCameraInputsManager;
  7657. /** @hidden */
  7658. _reset: () => void;
  7659. /**
  7660. * Defines the allowed panning axis.
  7661. */
  7662. panningAxis: Vector3;
  7663. protected _localDirection: Vector3;
  7664. protected _transformedDirection: Vector3;
  7665. private _bouncingBehavior;
  7666. /**
  7667. * Gets the bouncing behavior of the camera if it has been enabled.
  7668. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7669. */
  7670. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7671. /**
  7672. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7673. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7674. */
  7675. useBouncingBehavior: boolean;
  7676. private _framingBehavior;
  7677. /**
  7678. * Gets the framing behavior of the camera if it has been enabled.
  7679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7680. */
  7681. readonly framingBehavior: Nullable<FramingBehavior>;
  7682. /**
  7683. * Defines if the framing behavior of the camera is enabled on the camera.
  7684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7685. */
  7686. useFramingBehavior: boolean;
  7687. private _autoRotationBehavior;
  7688. /**
  7689. * Gets the auto rotation behavior of the camera if it has been enabled.
  7690. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7691. */
  7692. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7693. /**
  7694. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7695. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7696. */
  7697. useAutoRotationBehavior: boolean;
  7698. /**
  7699. * Observable triggered when the mesh target has been changed on the camera.
  7700. */
  7701. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7702. /**
  7703. * Event raised when the camera is colliding with a mesh.
  7704. */
  7705. onCollide: (collidedMesh: AbstractMesh) => void;
  7706. /**
  7707. * Defines whether the camera should check collision with the objects oh the scene.
  7708. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7709. */
  7710. checkCollisions: boolean;
  7711. /**
  7712. * Defines the collision radius of the camera.
  7713. * This simulates a sphere around the camera.
  7714. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7715. */
  7716. collisionRadius: Vector3;
  7717. protected _collider: Collider;
  7718. protected _previousPosition: Vector3;
  7719. protected _collisionVelocity: Vector3;
  7720. protected _newPosition: Vector3;
  7721. protected _previousAlpha: number;
  7722. protected _previousBeta: number;
  7723. protected _previousRadius: number;
  7724. protected _collisionTriggered: boolean;
  7725. protected _targetBoundingCenter: Nullable<Vector3>;
  7726. private _computationVector;
  7727. /**
  7728. * Instantiates a new ArcRotateCamera in a given scene
  7729. * @param name Defines the name of the camera
  7730. * @param alpha Defines the camera rotation along the logitudinal axis
  7731. * @param beta Defines the camera rotation along the latitudinal axis
  7732. * @param radius Defines the camera distance from its target
  7733. * @param target Defines the camera target
  7734. * @param scene Defines the scene the camera belongs to
  7735. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7736. */
  7737. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7738. /** @hidden */
  7739. _initCache(): void;
  7740. /** @hidden */
  7741. _updateCache(ignoreParentClass?: boolean): void;
  7742. protected _getTargetPosition(): Vector3;
  7743. private _storedAlpha;
  7744. private _storedBeta;
  7745. private _storedRadius;
  7746. private _storedTarget;
  7747. /**
  7748. * Stores the current state of the camera (alpha, beta, radius and target)
  7749. * @returns the camera itself
  7750. */
  7751. storeState(): Camera;
  7752. /**
  7753. * @hidden
  7754. * Restored camera state. You must call storeState() first
  7755. */
  7756. _restoreStateValues(): boolean;
  7757. /** @hidden */
  7758. _isSynchronizedViewMatrix(): boolean;
  7759. /**
  7760. * Attached controls to the current camera.
  7761. * @param element Defines the element the controls should be listened from
  7762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7763. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7764. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7765. */
  7766. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7767. /**
  7768. * Detach the current controls from the camera.
  7769. * The camera will stop reacting to inputs.
  7770. * @param element Defines the element to stop listening the inputs from
  7771. */
  7772. detachControl(element: HTMLElement): void;
  7773. /** @hidden */
  7774. _checkInputs(): void;
  7775. protected _checkLimits(): void;
  7776. /**
  7777. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7778. */
  7779. rebuildAnglesAndRadius(): void;
  7780. /**
  7781. * Use a position to define the current camera related information like aplha, beta and radius
  7782. * @param position Defines the position to set the camera at
  7783. */
  7784. setPosition(position: Vector3): void;
  7785. /**
  7786. * Defines the target the camera should look at.
  7787. * This will automatically adapt alpha beta and radius to fit within the new target.
  7788. * @param target Defines the new target as a Vector or a mesh
  7789. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7790. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7791. */
  7792. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7793. /** @hidden */
  7794. _getViewMatrix(): Matrix;
  7795. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7796. /**
  7797. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7798. * @param meshes Defines the mesh to zoom on
  7799. * @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)
  7800. */
  7801. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7802. /**
  7803. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7804. * The target will be changed but the radius
  7805. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7806. * @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)
  7807. */
  7808. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7809. min: Vector3;
  7810. max: Vector3;
  7811. distance: number;
  7812. }, doNotUpdateMaxZ?: boolean): void;
  7813. /**
  7814. * @override
  7815. * Override Camera.createRigCamera
  7816. */
  7817. createRigCamera(name: string, cameraIndex: number): Camera;
  7818. /**
  7819. * @hidden
  7820. * @override
  7821. * Override Camera._updateRigCameras
  7822. */
  7823. _updateRigCameras(): void;
  7824. /**
  7825. * Destroy the camera and release the current resources hold by it.
  7826. */
  7827. dispose(): void;
  7828. /**
  7829. * Gets the current object class name.
  7830. * @return the class name
  7831. */
  7832. getClassName(): string;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Default Inputs manager for the ArcRotateCamera.
  7838. * It groups all the default supported inputs for ease of use.
  7839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7840. */
  7841. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7842. /**
  7843. * Instantiates a new ArcRotateCameraInputsManager.
  7844. * @param camera Defines the camera the inputs belong to
  7845. */
  7846. constructor(camera: ArcRotateCamera);
  7847. /**
  7848. * Add mouse wheel input support to the input manager.
  7849. * @returns the current input manager
  7850. */
  7851. addMouseWheel(): ArcRotateCameraInputsManager;
  7852. /**
  7853. * Add pointers input support to the input manager.
  7854. * @returns the current input manager
  7855. */
  7856. addPointers(): ArcRotateCameraInputsManager;
  7857. /**
  7858. * Add keyboard input support to the input manager.
  7859. * @returns the current input manager
  7860. */
  7861. addKeyboard(): ArcRotateCameraInputsManager;
  7862. /**
  7863. * Add orientation input support to the input manager.
  7864. * @returns the current input manager
  7865. */
  7866. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7867. }
  7868. }
  7869. declare module BABYLON {
  7870. /**
  7871. * This is the base class of all the camera used in the application.
  7872. * @see http://doc.babylonjs.com/features/cameras
  7873. */
  7874. class Camera extends Node {
  7875. /**
  7876. * This is the default projection mode used by the cameras.
  7877. * It helps recreating a feeling of perspective and better appreciate depth.
  7878. * This is the best way to simulate real life cameras.
  7879. */
  7880. static readonly PERSPECTIVE_CAMERA: number;
  7881. /**
  7882. * This helps creating camera with an orthographic mode.
  7883. * 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.
  7884. */
  7885. static readonly ORTHOGRAPHIC_CAMERA: number;
  7886. /**
  7887. * This is the default FOV mode for perspective cameras.
  7888. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7889. */
  7890. static readonly FOVMODE_VERTICAL_FIXED: number;
  7891. /**
  7892. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7893. */
  7894. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7895. /**
  7896. * This specifies ther is no need for a camera rig.
  7897. * Basically only one eye is rendered corresponding to the camera.
  7898. */
  7899. static readonly RIG_MODE_NONE: number;
  7900. /**
  7901. * Simulates a camera Rig with one blue eye and one red eye.
  7902. * This can be use with 3d blue and red glasses.
  7903. */
  7904. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7905. /**
  7906. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7907. */
  7908. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7909. /**
  7910. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7911. */
  7912. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7913. /**
  7914. * Defines that both eyes of the camera will be rendered over under each other.
  7915. */
  7916. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7917. /**
  7918. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7919. */
  7920. static readonly RIG_MODE_VR: number;
  7921. /**
  7922. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7923. */
  7924. static readonly RIG_MODE_WEBVR: number;
  7925. /**
  7926. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7927. */
  7928. static readonly RIG_MODE_CUSTOM: number;
  7929. /**
  7930. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7931. */
  7932. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7933. /**
  7934. * @hidden
  7935. * Might be removed once multiview will be a thing
  7936. */
  7937. static UseAlternateWebVRRendering: boolean;
  7938. /**
  7939. * Define the input manager associated with the camera.
  7940. */
  7941. inputs: CameraInputsManager<Camera>;
  7942. /**
  7943. * Define the current local position of the camera in the scene
  7944. */
  7945. position: Vector3;
  7946. /**
  7947. * The vector the camera should consider as up.
  7948. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7949. */
  7950. upVector: Vector3;
  7951. /**
  7952. * Define the current limit on the left side for an orthographic camera
  7953. * In scene unit
  7954. */
  7955. orthoLeft: Nullable<number>;
  7956. /**
  7957. * Define the current limit on the right side for an orthographic camera
  7958. * In scene unit
  7959. */
  7960. orthoRight: Nullable<number>;
  7961. /**
  7962. * Define the current limit on the bottom side for an orthographic camera
  7963. * In scene unit
  7964. */
  7965. orthoBottom: Nullable<number>;
  7966. /**
  7967. * Define the current limit on the top side for an orthographic camera
  7968. * In scene unit
  7969. */
  7970. orthoTop: Nullable<number>;
  7971. /**
  7972. * Field Of View is set in Radians. (default is 0.8)
  7973. */
  7974. fov: number;
  7975. /**
  7976. * Define the minimum distance the camera can see from.
  7977. * This is important to note that the depth buffer are not infinite and the closer it starts
  7978. * the more your scene might encounter depth fighting issue.
  7979. */
  7980. minZ: number;
  7981. /**
  7982. * Define the maximum distance the camera can see to.
  7983. * This is important to note that the depth buffer are not infinite and the further it end
  7984. * the more your scene might encounter depth fighting issue.
  7985. */
  7986. maxZ: number;
  7987. /**
  7988. * Define the default inertia of the camera.
  7989. * This helps giving a smooth feeling to the camera movement.
  7990. */
  7991. inertia: number;
  7992. /**
  7993. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7994. */
  7995. mode: number;
  7996. /**
  7997. * Define wether the camera is intermediate.
  7998. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7999. */
  8000. isIntermediate: boolean;
  8001. /**
  8002. * Define the viewport of the camera.
  8003. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8004. */
  8005. viewport: Viewport;
  8006. /**
  8007. * Restricts the camera to viewing objects with the same layerMask.
  8008. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8009. */
  8010. layerMask: number;
  8011. /**
  8012. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8013. */
  8014. fovMode: number;
  8015. /**
  8016. * Rig mode of the camera.
  8017. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8018. * This is normally controlled byt the camera themselves as internal use.
  8019. */
  8020. cameraRigMode: number;
  8021. /**
  8022. * Defines the distance between both "eyes" in case of a RIG
  8023. */
  8024. interaxialDistance: number;
  8025. /**
  8026. * Defines if stereoscopic rendering is done side by side or over under.
  8027. */
  8028. isStereoscopicSideBySide: boolean;
  8029. /**
  8030. * Defines the list of custom render target the camera should render to.
  8031. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8032. * else in the scene.
  8033. */
  8034. customRenderTargets: RenderTargetTexture[];
  8035. /**
  8036. * When set, the camera will render to this render target instead of the default canvas
  8037. */
  8038. customDefaultRenderTarget: Nullable<RenderTargetTexture>;
  8039. /**
  8040. * Observable triggered when the camera view matrix has changed.
  8041. */
  8042. onViewMatrixChangedObservable: Observable<Camera>;
  8043. /**
  8044. * Observable triggered when the camera Projection matrix has changed.
  8045. */
  8046. onProjectionMatrixChangedObservable: Observable<Camera>;
  8047. /**
  8048. * Observable triggered when the inputs have been processed.
  8049. */
  8050. onAfterCheckInputsObservable: Observable<Camera>;
  8051. /**
  8052. * Observable triggered when reset has been called and applied to the camera.
  8053. */
  8054. onRestoreStateObservable: Observable<Camera>;
  8055. /** @hidden */
  8056. _cameraRigParams: any;
  8057. /** @hidden */
  8058. _rigCameras: Camera[];
  8059. /** @hidden */
  8060. _rigPostProcess: Nullable<PostProcess>;
  8061. protected _webvrViewMatrix: Matrix;
  8062. /** @hidden */
  8063. _skipRendering: boolean;
  8064. /** @hidden */
  8065. _alternateCamera: Camera;
  8066. /** @hidden */
  8067. _projectionMatrix: Matrix;
  8068. /** @hidden */
  8069. _postProcesses: Nullable<PostProcess>[];
  8070. /** @hidden */
  8071. _activeMeshes: SmartArray<AbstractMesh>;
  8072. protected _globalPosition: Vector3;
  8073. private _computedViewMatrix;
  8074. private _doNotComputeProjectionMatrix;
  8075. private _transformMatrix;
  8076. private _frustumPlanes;
  8077. private _refreshFrustumPlanes;
  8078. private _storedFov;
  8079. private _stateStored;
  8080. /**
  8081. * Instantiates a new camera object.
  8082. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8083. * @see http://doc.babylonjs.com/features/cameras
  8084. * @param name Defines the name of the camera in the scene
  8085. * @param position Defines the position of the camera
  8086. * @param scene Defines the scene the camera belongs too
  8087. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8088. */
  8089. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8090. /**
  8091. * Store current camera state (fov, position, etc..)
  8092. * @returns the camera
  8093. */
  8094. storeState(): Camera;
  8095. /**
  8096. * Restores the camera state values if it has been stored. You must call storeState() first
  8097. */
  8098. protected _restoreStateValues(): boolean;
  8099. /**
  8100. * Restored camera state. You must call storeState() first.
  8101. * @returns true if restored and false otherwise
  8102. */
  8103. restoreState(): boolean;
  8104. /**
  8105. * Gets the class name of the camera.
  8106. * @returns the class name
  8107. */
  8108. getClassName(): string;
  8109. /**
  8110. * Gets a string representation of the camera usefull for debug purpose.
  8111. * @param fullDetails Defines that a more verboe level of logging is required
  8112. * @returns the string representation
  8113. */
  8114. toString(fullDetails?: boolean): string;
  8115. /**
  8116. * Gets the current world space position of the camera.
  8117. */
  8118. readonly globalPosition: Vector3;
  8119. /**
  8120. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8121. * @returns the active meshe list
  8122. */
  8123. getActiveMeshes(): SmartArray<AbstractMesh>;
  8124. /**
  8125. * Check wether a mesh is part of the current active mesh list of the camera
  8126. * @param mesh Defines the mesh to check
  8127. * @returns true if active, false otherwise
  8128. */
  8129. isActiveMesh(mesh: Mesh): boolean;
  8130. /**
  8131. * Is this camera ready to be used/rendered
  8132. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8133. * @return true if the camera is ready
  8134. */
  8135. isReady(completeCheck?: boolean): boolean;
  8136. /** @hidden */
  8137. _initCache(): void;
  8138. /** @hidden */
  8139. _updateCache(ignoreParentClass?: boolean): void;
  8140. /** @hidden */
  8141. _isSynchronized(): boolean;
  8142. /** @hidden */
  8143. _isSynchronizedViewMatrix(): boolean;
  8144. /** @hidden */
  8145. _isSynchronizedProjectionMatrix(): boolean;
  8146. /**
  8147. * Attach the input controls to a specific dom element to get the input from.
  8148. * @param element Defines the element the controls should be listened from
  8149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8150. */
  8151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8152. /**
  8153. * Detach the current controls from the specified dom element.
  8154. * @param element Defines the element to stop listening the inputs from
  8155. */
  8156. detachControl(element: HTMLElement): void;
  8157. /**
  8158. * Update the camera state according to the different inputs gathered during the frame.
  8159. */
  8160. update(): void;
  8161. /** @hidden */
  8162. _checkInputs(): void;
  8163. /** @hidden */
  8164. readonly rigCameras: Camera[];
  8165. /**
  8166. * Gets the post process used by the rig cameras
  8167. */
  8168. readonly rigPostProcess: Nullable<PostProcess>;
  8169. /**
  8170. * Internal, gets the first post proces.
  8171. * @returns the first post process to be run on this camera.
  8172. */
  8173. _getFirstPostProcess(): Nullable<PostProcess>;
  8174. private _cascadePostProcessesToRigCams;
  8175. /**
  8176. * Attach a post process to the camera.
  8177. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8178. * @param postProcess The post process to attach to the camera
  8179. * @param insertAt The position of the post process in case several of them are in use in the scene
  8180. * @returns the position the post process has been inserted at
  8181. */
  8182. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8183. /**
  8184. * Detach a post process to the camera.
  8185. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8186. * @param postProcess The post process to detach from the camera
  8187. */
  8188. detachPostProcess(postProcess: PostProcess): void;
  8189. /**
  8190. * Gets the current world matrix of the camera
  8191. */
  8192. getWorldMatrix(): Matrix;
  8193. /** @hidden */
  8194. protected _getViewMatrix(): Matrix;
  8195. /**
  8196. * Gets the current view matrix of the camera.
  8197. * @param force forces the camera to recompute the matrix without looking at the cached state
  8198. * @returns the view matrix
  8199. */
  8200. getViewMatrix(force?: boolean): Matrix;
  8201. /**
  8202. * Freeze the projection matrix.
  8203. * It will prevent the cache check of the camera projection compute and can speed up perf
  8204. * if no parameter of the camera are meant to change
  8205. * @param projection Defines manually a projection if necessary
  8206. */
  8207. freezeProjectionMatrix(projection?: Matrix): void;
  8208. /**
  8209. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8210. */
  8211. unfreezeProjectionMatrix(): void;
  8212. /**
  8213. * Gets the current projection matrix of the camera.
  8214. * @param force forces the camera to recompute the matrix without looking at the cached state
  8215. * @returns the projection matrix
  8216. */
  8217. getProjectionMatrix(force?: boolean): Matrix;
  8218. /**
  8219. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8220. * @returns a Matrix
  8221. */
  8222. getTransformationMatrix(): Matrix;
  8223. private _updateFrustumPlanes;
  8224. /**
  8225. * Checks if a cullable object (mesh...) is in the camera frustum
  8226. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8227. * @param target The object to check
  8228. * @returns true if the object is in frustum otherwise false
  8229. */
  8230. isInFrustum(target: ICullable): boolean;
  8231. /**
  8232. * Checks if a cullable object (mesh...) is in the camera frustum
  8233. * Unlike isInFrustum this cheks the full bounding box
  8234. * @param target The object to check
  8235. * @returns true if the object is in frustum otherwise false
  8236. */
  8237. isCompletelyInFrustum(target: ICullable): boolean;
  8238. /**
  8239. * Gets a ray in the forward direction from the camera.
  8240. * @param length Defines the length of the ray to create
  8241. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8242. * @param origin Defines the start point of the ray which defaults to the camera position
  8243. * @returns the forward ray
  8244. */
  8245. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8246. /**
  8247. * Releases resources associated with this node.
  8248. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8249. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8250. */
  8251. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8252. /**
  8253. * Gets the left camera of a rig setup in case of Rigged Camera
  8254. */
  8255. readonly leftCamera: Nullable<FreeCamera>;
  8256. /**
  8257. * Gets the right camera of a rig setup in case of Rigged Camera
  8258. */
  8259. readonly rightCamera: Nullable<FreeCamera>;
  8260. /**
  8261. * Gets the left camera target of a rig setup in case of Rigged Camera
  8262. * @returns the target position
  8263. */
  8264. getLeftTarget(): Nullable<Vector3>;
  8265. /**
  8266. * Gets the right camera target of a rig setup in case of Rigged Camera
  8267. * @returns the target position
  8268. */
  8269. getRightTarget(): Nullable<Vector3>;
  8270. /**
  8271. * @hidden
  8272. */
  8273. setCameraRigMode(mode: number, rigParams: any): void;
  8274. private _getVRProjectionMatrix;
  8275. protected _updateCameraRotationMatrix(): void;
  8276. protected _updateWebVRCameraRotationMatrix(): void;
  8277. /**
  8278. * This function MUST be overwritten by the different WebVR cameras available.
  8279. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8280. */
  8281. protected _getWebVRProjectionMatrix(): Matrix;
  8282. /**
  8283. * This function MUST be overwritten by the different WebVR cameras available.
  8284. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8285. */
  8286. protected _getWebVRViewMatrix(): Matrix;
  8287. /** @hidden */
  8288. setCameraRigParameter(name: string, value: any): void;
  8289. /**
  8290. * needs to be overridden by children so sub has required properties to be copied
  8291. * @hidden
  8292. */
  8293. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8294. /**
  8295. * May need to be overridden by children
  8296. * @hidden
  8297. */
  8298. _updateRigCameras(): void;
  8299. /** @hidden */
  8300. _setupInputs(): void;
  8301. /**
  8302. * Serialiaze the camera setup to a json represention
  8303. * @returns the JSON representation
  8304. */
  8305. serialize(): any;
  8306. /**
  8307. * Clones the current camera.
  8308. * @param name The cloned camera name
  8309. * @returns the cloned camera
  8310. */
  8311. clone(name: string): Camera;
  8312. /**
  8313. * Gets the direction of the camera relative to a given local axis.
  8314. * @param localAxis Defines the reference axis to provide a relative direction.
  8315. * @return the direction
  8316. */
  8317. getDirection(localAxis: Vector3): Vector3;
  8318. /**
  8319. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8320. * @param localAxis Defines the reference axis to provide a relative direction.
  8321. * @param result Defines the vector to store the result in
  8322. */
  8323. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8324. /**
  8325. * Gets a camera constructor for a given camera type
  8326. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8327. * @param name The name of the camera the result will be able to instantiate
  8328. * @param scene The scene the result will construct the camera in
  8329. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8330. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8331. * @returns a factory method to construc the camera
  8332. */
  8333. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8334. /**
  8335. * Compute the world matrix of the camera.
  8336. * @returns the camera workd matrix
  8337. */
  8338. computeWorldMatrix(): Matrix;
  8339. /**
  8340. * Parse a JSON and creates the camera from the parsed information
  8341. * @param parsedCamera The JSON to parse
  8342. * @param scene The scene to instantiate the camera in
  8343. * @returns the newly constructed camera
  8344. */
  8345. static Parse(parsedCamera: any, scene: Scene): Camera;
  8346. }
  8347. }
  8348. declare module BABYLON {
  8349. /**
  8350. * @ignore
  8351. * This is a list of all the different input types that are available in the application.
  8352. * Fo instance: ArcRotateCameraGamepadInput...
  8353. */
  8354. var CameraInputTypes: {};
  8355. /**
  8356. * This is the contract to implement in order to create a new input class.
  8357. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8358. */
  8359. interface ICameraInput<TCamera extends Camera> {
  8360. /**
  8361. * Defines the camera the input is attached to.
  8362. */
  8363. camera: Nullable<TCamera>;
  8364. /**
  8365. * Gets the class name of the current intput.
  8366. * @returns the class name
  8367. */
  8368. getClassName(): string;
  8369. /**
  8370. * Get the friendly name associated with the input class.
  8371. * @returns the input friendly name
  8372. */
  8373. getSimpleName(): string;
  8374. /**
  8375. * Attach the input controls to a specific dom element to get the input from.
  8376. * @param element Defines the element the controls should be listened from
  8377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8378. */
  8379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8380. /**
  8381. * Detach the current controls from the specified dom element.
  8382. * @param element Defines the element to stop listening the inputs from
  8383. */
  8384. detachControl(element: Nullable<HTMLElement>): void;
  8385. /**
  8386. * Update the current camera state depending on the inputs that have been used this frame.
  8387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8388. */
  8389. checkInputs?: () => void;
  8390. }
  8391. /**
  8392. * Represents a map of input types to input instance or input index to input instance.
  8393. */
  8394. interface CameraInputsMap<TCamera extends Camera> {
  8395. /**
  8396. * Accessor to the input by input type.
  8397. */
  8398. [name: string]: ICameraInput<TCamera>;
  8399. /**
  8400. * Accessor to the input by input index.
  8401. */
  8402. [idx: number]: ICameraInput<TCamera>;
  8403. }
  8404. /**
  8405. * This represents the input manager used within a camera.
  8406. * It helps dealing with all the different kind of input attached to a camera.
  8407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8408. */
  8409. class CameraInputsManager<TCamera extends Camera> {
  8410. /**
  8411. * Defines the list of inputs attahed to the camera.
  8412. */
  8413. attached: CameraInputsMap<TCamera>;
  8414. /**
  8415. * Defines the dom element the camera is collecting inputs from.
  8416. * This is null if the controls have not been attached.
  8417. */
  8418. attachedElement: Nullable<HTMLElement>;
  8419. /**
  8420. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8421. */
  8422. noPreventDefault: boolean;
  8423. /**
  8424. * Defined the camera the input manager belongs to.
  8425. */
  8426. camera: TCamera;
  8427. /**
  8428. * Update the current camera state depending on the inputs that have been used this frame.
  8429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8430. */
  8431. checkInputs: () => void;
  8432. /**
  8433. * Instantiate a new Camera Input Manager.
  8434. * @param camera Defines the camera the input manager blongs to
  8435. */
  8436. constructor(camera: TCamera);
  8437. /**
  8438. * Add an input method to a camera
  8439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8440. * @param input camera input method
  8441. */
  8442. add(input: ICameraInput<TCamera>): void;
  8443. /**
  8444. * Remove a specific input method from a camera
  8445. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8446. * @param inputToRemove camera input method
  8447. */
  8448. remove(inputToRemove: ICameraInput<TCamera>): void;
  8449. /**
  8450. * Remove a specific input type from a camera
  8451. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8452. * @param inputType the type of the input to remove
  8453. */
  8454. removeByType(inputType: string): void;
  8455. private _addCheckInputs;
  8456. /**
  8457. * Attach the input controls to the currently attached dom element to listen the events from.
  8458. * @param input Defines the input to attach
  8459. */
  8460. attachInput(input: ICameraInput<TCamera>): void;
  8461. /**
  8462. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8463. * @param element Defines the dom element to collect the events from
  8464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8465. */
  8466. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8467. /**
  8468. * Detach the current manager inputs controls from a specific dom element.
  8469. * @param element Defines the dom element to collect the events from
  8470. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8471. */
  8472. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8473. /**
  8474. * Rebuild the dynamic inputCheck function from the current list of
  8475. * defined inputs in the manager.
  8476. */
  8477. rebuildInputCheck(): void;
  8478. /**
  8479. * Remove all attached input methods from a camera
  8480. */
  8481. clear(): void;
  8482. /**
  8483. * Serialize the current input manager attached to a camera.
  8484. * This ensures than once parsed,
  8485. * the input associated to the camera will be identical to the current ones
  8486. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8487. */
  8488. serialize(serializedCamera: any): void;
  8489. /**
  8490. * Parses an input manager serialized JSON to restore the previous list of inputs
  8491. * and states associated to a camera.
  8492. * @param parsedCamera Defines the JSON to parse
  8493. */
  8494. parse(parsedCamera: any): void;
  8495. }
  8496. }
  8497. declare module BABYLON {
  8498. /**
  8499. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8500. * being tilted forward or back and left or right.
  8501. */
  8502. class DeviceOrientationCamera extends FreeCamera {
  8503. private _initialQuaternion;
  8504. private _quaternionCache;
  8505. /**
  8506. * Creates a new device orientation camera
  8507. * @param name The name of the camera
  8508. * @param position The start position camera
  8509. * @param scene The scene the camera belongs to
  8510. */
  8511. constructor(name: string, position: Vector3, scene: Scene);
  8512. /**
  8513. * Gets the current instance class name ("DeviceOrientationCamera").
  8514. * This helps avoiding instanceof at run time.
  8515. * @returns the class name
  8516. */
  8517. getClassName(): string;
  8518. /**
  8519. * @hidden
  8520. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8521. */
  8522. _checkInputs(): void;
  8523. /**
  8524. * Reset the camera to its default orientation on the specified axis only.
  8525. * @param axis The axis to reset
  8526. */
  8527. resetToCurrentRotation(axis?: Axis): void;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8533. * such as in a 3D Space Shooter or a Flight Simulator.
  8534. */
  8535. class FlyCamera extends TargetCamera {
  8536. /**
  8537. * Define the collision ellipsoid of the camera.
  8538. * This is helpful for simulating a camera body, like a player's body.
  8539. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8540. */
  8541. ellipsoid: Vector3;
  8542. /**
  8543. * Define an offset for the position of the ellipsoid around the camera.
  8544. * This can be helpful if the camera is attached away from the player's body center,
  8545. * such as at its head.
  8546. */
  8547. ellipsoidOffset: Vector3;
  8548. /**
  8549. * Enable or disable collisions of the camera with the rest of the scene objects.
  8550. */
  8551. checkCollisions: boolean;
  8552. /**
  8553. * Enable or disable gravity on the camera.
  8554. */
  8555. applyGravity: boolean;
  8556. /**
  8557. * Define the current direction the camera is moving to.
  8558. */
  8559. cameraDirection: Vector3;
  8560. /**
  8561. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8562. * This overrides and empties cameraRotation.
  8563. */
  8564. rotationQuaternion: BABYLON.Quaternion;
  8565. /**
  8566. * Track Roll to maintain the wanted Rolling when looking around.
  8567. */
  8568. _trackRoll: number;
  8569. /**
  8570. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8571. */
  8572. rollCorrect: number;
  8573. /**
  8574. * Mimic a banked turn, Rolling the camera when Yawing.
  8575. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8576. */
  8577. bankedTurn: boolean;
  8578. /**
  8579. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8580. */
  8581. bankedTurnLimit: number;
  8582. /**
  8583. * Value of 0 disables the banked Roll.
  8584. * Value of 1 is equal to the Yaw angle in radians.
  8585. */
  8586. bankedTurnMultiplier: number;
  8587. /**
  8588. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8589. */
  8590. inputs: FlyCameraInputsManager;
  8591. /**
  8592. * Gets the input sensibility for mouse input.
  8593. * Higher values reduce sensitivity.
  8594. */
  8595. /**
  8596. * Sets the input sensibility for a mouse input.
  8597. * Higher values reduce sensitivity.
  8598. */
  8599. angularSensibility: number;
  8600. /**
  8601. * Get the keys for camera movement forward.
  8602. */
  8603. /**
  8604. * Set the keys for camera movement forward.
  8605. */
  8606. keysForward: number[];
  8607. /**
  8608. * Get the keys for camera movement backward.
  8609. */
  8610. keysBackward: number[];
  8611. /**
  8612. * Get the keys for camera movement up.
  8613. */
  8614. /**
  8615. * Set the keys for camera movement up.
  8616. */
  8617. keysUp: number[];
  8618. /**
  8619. * Get the keys for camera movement down.
  8620. */
  8621. /**
  8622. * Set the keys for camera movement down.
  8623. */
  8624. keysDown: number[];
  8625. /**
  8626. * Get the keys for camera movement left.
  8627. */
  8628. /**
  8629. * Set the keys for camera movement left.
  8630. */
  8631. keysLeft: number[];
  8632. /**
  8633. * Set the keys for camera movement right.
  8634. */
  8635. /**
  8636. * Set the keys for camera movement right.
  8637. */
  8638. keysRight: number[];
  8639. /**
  8640. * Event raised when the camera collides with a mesh in the scene.
  8641. */
  8642. onCollide: (collidedMesh: AbstractMesh) => void;
  8643. private _collider;
  8644. private _needMoveForGravity;
  8645. private _oldPosition;
  8646. private _diffPosition;
  8647. private _newPosition;
  8648. /** @hidden */
  8649. _localDirection: Vector3;
  8650. /** @hidden */
  8651. _transformedDirection: Vector3;
  8652. /**
  8653. * Instantiates a FlyCamera.
  8654. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8655. * such as in a 3D Space Shooter or a Flight Simulator.
  8656. * @param name Define the name of the camera in the scene.
  8657. * @param position Define the starting position of the camera in the scene.
  8658. * @param scene Define the scene the camera belongs to.
  8659. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8660. */
  8661. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8662. /**
  8663. * Attach a control to the HTML DOM element.
  8664. * @param element Defines the element that listens to the input events.
  8665. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8666. */
  8667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8668. /**
  8669. * Detach a control from the HTML DOM element.
  8670. * The camera will stop reacting to that input.
  8671. * @param element Defines the element that listens to the input events.
  8672. */
  8673. detachControl(element: HTMLElement): void;
  8674. private _collisionMask;
  8675. /**
  8676. * Get the mask that the camera ignores in collision events.
  8677. */
  8678. /**
  8679. * Set the mask that the camera ignores in collision events.
  8680. */
  8681. collisionMask: number;
  8682. /** @hidden */
  8683. _collideWithWorld(displacement: Vector3): void;
  8684. /** @hidden */
  8685. private _onCollisionPositionChange;
  8686. /** @hidden */
  8687. _checkInputs(): void;
  8688. /** @hidden */
  8689. _decideIfNeedsToMove(): boolean;
  8690. /** @hidden */
  8691. _updatePosition(): void;
  8692. /**
  8693. * Restore the Roll to its target value at the rate specified.
  8694. * @param rate - Higher means slower restoring.
  8695. * @hidden
  8696. */
  8697. restoreRoll(rate: number): void;
  8698. /**
  8699. * Destroy the camera and release the current resources held by it.
  8700. */
  8701. dispose(): void;
  8702. /**
  8703. * Get the current object class name.
  8704. * @returns the class name.
  8705. */
  8706. getClassName(): string;
  8707. }
  8708. }
  8709. declare module BABYLON {
  8710. /**
  8711. * Default Inputs manager for the FlyCamera.
  8712. * It groups all the default supported inputs for ease of use.
  8713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8714. */
  8715. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8716. /**
  8717. * Instantiates a new FlyCameraInputsManager.
  8718. * @param camera Defines the camera the inputs belong to.
  8719. */
  8720. constructor(camera: FlyCamera);
  8721. /**
  8722. * Add keyboard input support to the input manager.
  8723. * @returns the new FlyCameraKeyboardMoveInput().
  8724. */
  8725. addKeyboard(): FlyCameraInputsManager;
  8726. /**
  8727. * Add mouse input support to the input manager.
  8728. * @param touchEnabled Enable touch screen support.
  8729. * @returns the new FlyCameraMouseInput().
  8730. */
  8731. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8732. }
  8733. }
  8734. declare module BABYLON {
  8735. /**
  8736. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8737. * an arc rotate version arcFollowCamera are available.
  8738. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8739. */
  8740. class FollowCamera extends TargetCamera {
  8741. /**
  8742. * Distance the follow camera should follow an object at
  8743. */
  8744. radius: number;
  8745. /**
  8746. * Define a rotation offset between the camera and the object it follows
  8747. */
  8748. rotationOffset: number;
  8749. /**
  8750. * Define a height offset between the camera and the object it follows.
  8751. * It can help following an object from the top (like a car chaing a plane)
  8752. */
  8753. heightOffset: number;
  8754. /**
  8755. * Define how fast the camera can accelerate to follow it s target.
  8756. */
  8757. cameraAcceleration: number;
  8758. /**
  8759. * Define the speed limit of the camera following an object.
  8760. */
  8761. maxCameraSpeed: number;
  8762. /**
  8763. * Define the target of the camera.
  8764. */
  8765. lockedTarget: Nullable<AbstractMesh>;
  8766. /**
  8767. * Instantiates the follow camera.
  8768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8769. * @param name Define the name of the camera in the scene
  8770. * @param position Define the position of the camera
  8771. * @param scene Define the scene the camera belong to
  8772. * @param lockedTarget Define the target of the camera
  8773. */
  8774. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8775. private _follow;
  8776. /** @hidden */
  8777. _checkInputs(): void;
  8778. /**
  8779. * Gets the camera class name.
  8780. * @returns the class name
  8781. */
  8782. getClassName(): string;
  8783. }
  8784. /**
  8785. * Arc Rotate version of the follow camera.
  8786. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8787. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8788. */
  8789. class ArcFollowCamera extends TargetCamera {
  8790. /** The longitudinal angle of the camera */
  8791. alpha: number;
  8792. /** The latitudinal angle of the camera */
  8793. beta: number;
  8794. /** The radius of the camera from its target */
  8795. radius: number;
  8796. /** Define the camera target (the messh it should follow) */
  8797. target: Nullable<AbstractMesh>;
  8798. private _cartesianCoordinates;
  8799. /**
  8800. * Instantiates a new ArcFollowCamera
  8801. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8802. * @param name Define the name of the camera
  8803. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8804. * @param beta Define the rotation angle of the camera around the elevation axis
  8805. * @param radius Define the radius of the camera from its target point
  8806. * @param target Define the target of the camera
  8807. * @param scene Define the scene the camera belongs to
  8808. */
  8809. constructor(name: string,
  8810. /** The longitudinal angle of the camera */
  8811. alpha: number,
  8812. /** The latitudinal angle of the camera */
  8813. beta: number,
  8814. /** The radius of the camera from its target */
  8815. radius: number,
  8816. /** Define the camera target (the messh it should follow) */
  8817. target: Nullable<AbstractMesh>, scene: Scene);
  8818. private _follow;
  8819. /** @hidden */
  8820. _checkInputs(): void;
  8821. /**
  8822. * Returns the class name of the object.
  8823. * It is mostly used internally for serialization purposes.
  8824. */
  8825. getClassName(): string;
  8826. }
  8827. }
  8828. declare module BABYLON {
  8829. /**
  8830. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8831. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8832. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8833. */
  8834. class FreeCamera extends TargetCamera {
  8835. /**
  8836. * Define the collision ellipsoid of the camera.
  8837. * This is helpful to simulate a camera body like the player body around the camera
  8838. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8839. */
  8840. ellipsoid: Vector3;
  8841. /**
  8842. * Define an offset for the position of the ellipsoid around the camera.
  8843. * This can be helpful to determine the center of the body near the gravity center of the body
  8844. * instead of its head.
  8845. */
  8846. ellipsoidOffset: Vector3;
  8847. /**
  8848. * Enable or disable collisions of the camera with the rest of the scene objects.
  8849. */
  8850. checkCollisions: boolean;
  8851. /**
  8852. * Enable or disable gravity on the camera.
  8853. */
  8854. applyGravity: boolean;
  8855. /**
  8856. * Define the input manager associated to the camera.
  8857. */
  8858. inputs: FreeCameraInputsManager;
  8859. /**
  8860. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8861. * Higher values reduce sensitivity.
  8862. */
  8863. /**
  8864. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8865. * Higher values reduce sensitivity.
  8866. */
  8867. angularSensibility: number;
  8868. /**
  8869. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8870. */
  8871. keysUp: number[];
  8872. /**
  8873. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8874. */
  8875. keysDown: number[];
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8878. */
  8879. keysLeft: number[];
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8882. */
  8883. keysRight: number[];
  8884. /**
  8885. * Event raised when the camera collide with a mesh in the scene.
  8886. */
  8887. onCollide: (collidedMesh: AbstractMesh) => void;
  8888. private _collider;
  8889. private _needMoveForGravity;
  8890. private _oldPosition;
  8891. private _diffPosition;
  8892. private _newPosition;
  8893. /** @hidden */
  8894. _localDirection: Vector3;
  8895. /** @hidden */
  8896. _transformedDirection: Vector3;
  8897. /**
  8898. * Instantiates a Free Camera.
  8899. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8900. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8901. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8902. * @param name Define the name of the camera in the scene
  8903. * @param position Define the start position of the camera in the scene
  8904. * @param scene Define the scene the camera belongs to
  8905. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8906. */
  8907. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8908. /**
  8909. * Attached controls to the current camera.
  8910. * @param element Defines the element the controls should be listened from
  8911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8912. */
  8913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8914. /**
  8915. * Detach the current controls from the camera.
  8916. * The camera will stop reacting to inputs.
  8917. * @param element Defines the element to stop listening the inputs from
  8918. */
  8919. detachControl(element: HTMLElement): void;
  8920. private _collisionMask;
  8921. /**
  8922. * Define a collision mask to limit the list of object the camera can collide with
  8923. */
  8924. collisionMask: number;
  8925. /** @hidden */
  8926. _collideWithWorld(displacement: Vector3): void;
  8927. private _onCollisionPositionChange;
  8928. /** @hidden */
  8929. _checkInputs(): void;
  8930. /** @hidden */
  8931. _decideIfNeedsToMove(): boolean;
  8932. /** @hidden */
  8933. _updatePosition(): void;
  8934. /**
  8935. * Destroy the camera and release the current resources hold by it.
  8936. */
  8937. dispose(): void;
  8938. /**
  8939. * Gets the current object class name.
  8940. * @return the class name
  8941. */
  8942. getClassName(): string;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. /**
  8947. * Default Inputs manager for the FreeCamera.
  8948. * It groups all the default supported inputs for ease of use.
  8949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8950. */
  8951. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8952. /**
  8953. * Instantiates a new FreeCameraInputsManager.
  8954. * @param camera Defines the camera the inputs belong to
  8955. */
  8956. constructor(camera: FreeCamera);
  8957. /**
  8958. * Add keyboard input support to the input manager.
  8959. * @returns the current input manager
  8960. */
  8961. addKeyboard(): FreeCameraInputsManager;
  8962. /**
  8963. * Add mouse input support to the input manager.
  8964. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8965. * @returns the current input manager
  8966. */
  8967. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8968. /**
  8969. * Add orientation input support to the input manager.
  8970. * @returns the current input manager
  8971. */
  8972. addDeviceOrientation(): FreeCameraInputsManager;
  8973. /**
  8974. * Add touch input support to the input manager.
  8975. * @returns the current input manager
  8976. */
  8977. addTouch(): FreeCameraInputsManager;
  8978. /**
  8979. * Add virtual joystick input support to the input manager.
  8980. * @returns the current input manager
  8981. */
  8982. addVirtualJoystick(): FreeCameraInputsManager;
  8983. }
  8984. }
  8985. declare module BABYLON {
  8986. /**
  8987. * This represents a FPS type of camera. This is only here for back compat purpose.
  8988. * Please use the UniversalCamera instead as both are identical.
  8989. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8990. */
  8991. class GamepadCamera extends UniversalCamera {
  8992. /**
  8993. * Instantiates a new Gamepad Camera
  8994. * This represents a FPS type of camera. This is only here for back compat purpose.
  8995. * Please use the UniversalCamera instead as both are identical.
  8996. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8997. * @param name Define the name of the camera in the scene
  8998. * @param position Define the start position of the camera in the scene
  8999. * @param scene Define the scene the camera belongs to
  9000. */
  9001. constructor(name: string, position: Vector3, scene: Scene);
  9002. /**
  9003. * Gets the current object class name.
  9004. * @return the class name
  9005. */
  9006. getClassName(): string;
  9007. }
  9008. }
  9009. declare module BABYLON {
  9010. /**
  9011. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9012. * This is the base of the follow, arc rotate cameras and Free camera
  9013. * @see http://doc.babylonjs.com/features/cameras
  9014. */
  9015. class TargetCamera extends Camera {
  9016. /**
  9017. * Define the current direction the camera is moving to
  9018. */
  9019. cameraDirection: Vector3;
  9020. /**
  9021. * Define the current rotation the camera is rotating to
  9022. */
  9023. cameraRotation: Vector2;
  9024. /**
  9025. * Define the current rotation of the camera
  9026. */
  9027. rotation: Vector3;
  9028. /**
  9029. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9030. */
  9031. rotationQuaternion: Quaternion;
  9032. /**
  9033. * Define the current speed of the camera
  9034. */
  9035. speed: number;
  9036. /**
  9037. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9038. * around all axis.
  9039. */
  9040. noRotationConstraint: boolean;
  9041. /**
  9042. * Define the current target of the camera as an object or a position.
  9043. */
  9044. lockedTarget: any;
  9045. /** @hidden */
  9046. _currentTarget: Vector3;
  9047. /** @hidden */
  9048. _viewMatrix: Matrix;
  9049. /** @hidden */
  9050. _camMatrix: Matrix;
  9051. /** @hidden */
  9052. _cameraTransformMatrix: Matrix;
  9053. /** @hidden */
  9054. _cameraRotationMatrix: Matrix;
  9055. private _rigCamTransformMatrix;
  9056. /** @hidden */
  9057. _referencePoint: Vector3;
  9058. /** @hidden */
  9059. _transformedReferencePoint: Vector3;
  9060. protected _globalCurrentTarget: Vector3;
  9061. protected _globalCurrentUpVector: Vector3;
  9062. /** @hidden */
  9063. _reset: () => void;
  9064. private _defaultUp;
  9065. /**
  9066. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9067. * This is the base of the follow, arc rotate cameras and Free camera
  9068. * @see http://doc.babylonjs.com/features/cameras
  9069. * @param name Defines the name of the camera in the scene
  9070. * @param position Defines the start position of the camera in the scene
  9071. * @param scene Defines the scene the camera belongs to
  9072. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9073. */
  9074. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9075. /**
  9076. * Gets the position in front of the camera at a given distance.
  9077. * @param distance The distance from the camera we want the position to be
  9078. * @returns the position
  9079. */
  9080. getFrontPosition(distance: number): Vector3;
  9081. /** @hidden */
  9082. _getLockedTargetPosition(): Nullable<Vector3>;
  9083. private _storedPosition;
  9084. private _storedRotation;
  9085. private _storedRotationQuaternion;
  9086. /**
  9087. * Store current camera state of the camera (fov, position, rotation, etc..)
  9088. * @returns the camera
  9089. */
  9090. storeState(): Camera;
  9091. /**
  9092. * Restored camera state. You must call storeState() first
  9093. * @returns whether it was successful or not
  9094. * @hidden
  9095. */
  9096. _restoreStateValues(): boolean;
  9097. /** @hidden */
  9098. _initCache(): void;
  9099. /** @hidden */
  9100. _updateCache(ignoreParentClass?: boolean): void;
  9101. /** @hidden */
  9102. _isSynchronizedViewMatrix(): boolean;
  9103. /** @hidden */
  9104. _computeLocalCameraSpeed(): number;
  9105. /** @hidden */
  9106. setTarget(target: Vector3): void;
  9107. /**
  9108. * Return the current target position of the camera. This value is expressed in local space.
  9109. * @returns the target position
  9110. */
  9111. getTarget(): Vector3;
  9112. /** @hidden */
  9113. _decideIfNeedsToMove(): boolean;
  9114. /** @hidden */
  9115. _updatePosition(): void;
  9116. /** @hidden */
  9117. _checkInputs(): void;
  9118. protected _updateCameraRotationMatrix(): void;
  9119. /**
  9120. * 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)
  9121. * @returns the current camera
  9122. */
  9123. private _rotateUpVectorWithCameraRotationMatrix;
  9124. private _cachedRotationZ;
  9125. private _cachedQuaternionRotationZ;
  9126. /** @hidden */
  9127. _getViewMatrix(): Matrix;
  9128. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9129. /**
  9130. * @hidden
  9131. */
  9132. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9133. /**
  9134. * @hidden
  9135. */
  9136. _updateRigCameras(): void;
  9137. private _getRigCamPosition;
  9138. /**
  9139. * Gets the current object class name.
  9140. * @return the class name
  9141. */
  9142. getClassName(): string;
  9143. }
  9144. }
  9145. declare module BABYLON {
  9146. /**
  9147. * This represents a FPS type of camera controlled by touch.
  9148. * This is like a universal camera minus the Gamepad controls.
  9149. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9150. */
  9151. class TouchCamera extends FreeCamera {
  9152. /**
  9153. * Defines the touch sensibility for rotation.
  9154. * The higher the faster.
  9155. */
  9156. touchAngularSensibility: number;
  9157. /**
  9158. * Defines the touch sensibility for move.
  9159. * The higher the faster.
  9160. */
  9161. touchMoveSensibility: number;
  9162. /**
  9163. * Instantiates a new touch camera.
  9164. * This represents a FPS type of camera controlled by touch.
  9165. * This is like a universal camera minus the Gamepad controls.
  9166. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9167. * @param name Define the name of the camera in the scene
  9168. * @param position Define the start position of the camera in the scene
  9169. * @param scene Define the scene the camera belongs to
  9170. */
  9171. constructor(name: string, position: Vector3, scene: Scene);
  9172. /**
  9173. * Gets the current object class name.
  9174. * @return the class name
  9175. */
  9176. getClassName(): string;
  9177. /** @hidden */
  9178. _setupInputs(): void;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /**
  9183. * 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,
  9184. * which still works and will still be found in many Playgrounds.
  9185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9186. */
  9187. class UniversalCamera extends TouchCamera {
  9188. /**
  9189. * Defines the gamepad rotation sensiblity.
  9190. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9191. */
  9192. gamepadAngularSensibility: number;
  9193. /**
  9194. * Defines the gamepad move sensiblity.
  9195. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9196. */
  9197. gamepadMoveSensibility: number;
  9198. /**
  9199. * 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,
  9200. * which still works and will still be found in many Playgrounds.
  9201. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9202. * @param name Define the name of the camera in the scene
  9203. * @param position Define the start position of the camera in the scene
  9204. * @param scene Define the scene the camera belongs to
  9205. */
  9206. constructor(name: string, position: Vector3, scene: Scene);
  9207. /**
  9208. * Gets the current object class name.
  9209. * @return the class name
  9210. */
  9211. getClassName(): string;
  9212. }
  9213. }
  9214. declare module BABYLON {
  9215. /**
  9216. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  9217. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9218. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9219. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9220. */
  9221. class VirtualJoysticksCamera extends FreeCamera {
  9222. /**
  9223. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  9224. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9225. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9226. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9227. * @param name Define the name of the camera in the scene
  9228. * @param position Define the start position of the camera in the scene
  9229. * @param scene Define the scene the camera belongs to
  9230. */
  9231. constructor(name: string, position: Vector3, scene: Scene);
  9232. /**
  9233. * Gets the current object class name.
  9234. * @return the class name
  9235. */
  9236. getClassName(): string;
  9237. }
  9238. }
  9239. interface VRDisplay extends EventTarget {
  9240. /**
  9241. * Dictionary of capabilities describing the VRDisplay.
  9242. */
  9243. readonly capabilities: VRDisplayCapabilities;
  9244. /**
  9245. * z-depth defining the far plane of the eye view frustum
  9246. * enables mapping of values in the render target depth
  9247. * attachment to scene coordinates. Initially set to 10000.0.
  9248. */
  9249. depthFar: number;
  9250. /**
  9251. * z-depth defining the near plane of the eye view frustum
  9252. * enables mapping of values in the render target depth
  9253. * attachment to scene coordinates. Initially set to 0.01.
  9254. */
  9255. depthNear: number;
  9256. /**
  9257. * An identifier for this distinct VRDisplay. Used as an
  9258. * association point in the Gamepad API.
  9259. */
  9260. readonly displayId: number;
  9261. /**
  9262. * A display name, a user-readable name identifying it.
  9263. */
  9264. readonly displayName: string;
  9265. readonly isConnected: boolean;
  9266. readonly isPresenting: boolean;
  9267. /**
  9268. * If this VRDisplay supports room-scale experiences, the optional
  9269. * stage attribute contains details on the room-scale parameters.
  9270. */
  9271. readonly stageParameters: VRStageParameters | null;
  9272. /**
  9273. * Passing the value returned by `requestAnimationFrame` to
  9274. * `cancelAnimationFrame` will unregister the callback.
  9275. * @param handle Define the hanle of the request to cancel
  9276. */
  9277. cancelAnimationFrame(handle: number): void;
  9278. /**
  9279. * Stops presenting to the VRDisplay.
  9280. * @returns a promise to know when it stopped
  9281. */
  9282. exitPresent(): Promise<void>;
  9283. /**
  9284. * Return the current VREyeParameters for the given eye.
  9285. * @param whichEye Define the eye we want the parameter for
  9286. * @returns the eye parameters
  9287. */
  9288. getEyeParameters(whichEye: string): VREyeParameters;
  9289. /**
  9290. * Populates the passed VRFrameData with the information required to render
  9291. * the current frame.
  9292. * @param frameData Define the data structure to populate
  9293. * @returns true if ok otherwise false
  9294. */
  9295. getFrameData(frameData: VRFrameData): boolean;
  9296. /**
  9297. * Get the layers currently being presented.
  9298. * @returns the list of VR layers
  9299. */
  9300. getLayers(): VRLayer[];
  9301. /**
  9302. * Return a VRPose containing the future predicted pose of the VRDisplay
  9303. * when the current frame will be presented. The value returned will not
  9304. * change until JavaScript has returned control to the browser.
  9305. *
  9306. * The VRPose will contain the position, orientation, velocity,
  9307. * and acceleration of each of these properties.
  9308. * @returns the pose object
  9309. */
  9310. getPose(): VRPose;
  9311. /**
  9312. * Return the current instantaneous pose of the VRDisplay, with no
  9313. * prediction applied.
  9314. * @returns the current instantaneous pose
  9315. */
  9316. getImmediatePose(): VRPose;
  9317. /**
  9318. * The callback passed to `requestAnimationFrame` will be called
  9319. * any time a new frame should be rendered. When the VRDisplay is
  9320. * presenting the callback will be called at the native refresh
  9321. * rate of the HMD. When not presenting this function acts
  9322. * identically to how window.requestAnimationFrame acts. Content should
  9323. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9324. * asynchronously from other displays and at differing refresh rates.
  9325. * @param callback Define the eaction to run next frame
  9326. * @returns the request handle it
  9327. */
  9328. requestAnimationFrame(callback: FrameRequestCallback): number;
  9329. /**
  9330. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9331. * Repeat calls while already presenting will update the VRLayers being displayed.
  9332. * @param layers Define the list of layer to present
  9333. * @returns a promise to know when the request has been fulfilled
  9334. */
  9335. requestPresent(layers: VRLayer[]): Promise<void>;
  9336. /**
  9337. * Reset the pose for this display, treating its current position and
  9338. * orientation as the "origin/zero" values. VRPose.position,
  9339. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9340. * updated when calling resetPose(). This should be called in only
  9341. * sitting-space experiences.
  9342. */
  9343. resetPose(): void;
  9344. /**
  9345. * The VRLayer provided to the VRDisplay will be captured and presented
  9346. * in the HMD. Calling this function has the same effect on the source
  9347. * canvas as any other operation that uses its source image, and canvases
  9348. * created without preserveDrawingBuffer set to true will be cleared.
  9349. * @param pose Define the pose to submit
  9350. */
  9351. submitFrame(pose?: VRPose): void;
  9352. }
  9353. declare var VRDisplay: {
  9354. prototype: VRDisplay;
  9355. new (): VRDisplay;
  9356. };
  9357. interface VRLayer {
  9358. leftBounds?: number[] | Float32Array | null;
  9359. rightBounds?: number[] | Float32Array | null;
  9360. source?: HTMLCanvasElement | null;
  9361. }
  9362. interface VRDisplayCapabilities {
  9363. readonly canPresent: boolean;
  9364. readonly hasExternalDisplay: boolean;
  9365. readonly hasOrientation: boolean;
  9366. readonly hasPosition: boolean;
  9367. readonly maxLayers: number;
  9368. }
  9369. interface VREyeParameters {
  9370. /** @deprecated */
  9371. readonly fieldOfView: VRFieldOfView;
  9372. readonly offset: Float32Array;
  9373. readonly renderHeight: number;
  9374. readonly renderWidth: number;
  9375. }
  9376. interface VRFieldOfView {
  9377. readonly downDegrees: number;
  9378. readonly leftDegrees: number;
  9379. readonly rightDegrees: number;
  9380. readonly upDegrees: number;
  9381. }
  9382. interface VRFrameData {
  9383. readonly leftProjectionMatrix: Float32Array;
  9384. readonly leftViewMatrix: Float32Array;
  9385. readonly pose: VRPose;
  9386. readonly rightProjectionMatrix: Float32Array;
  9387. readonly rightViewMatrix: Float32Array;
  9388. readonly timestamp: number;
  9389. }
  9390. interface VRPose {
  9391. readonly angularAcceleration: Float32Array | null;
  9392. readonly angularVelocity: Float32Array | null;
  9393. readonly linearAcceleration: Float32Array | null;
  9394. readonly linearVelocity: Float32Array | null;
  9395. readonly orientation: Float32Array | null;
  9396. readonly position: Float32Array | null;
  9397. readonly timestamp: number;
  9398. }
  9399. interface VRStageParameters {
  9400. sittingToStandingTransform?: Float32Array;
  9401. sizeX?: number;
  9402. sizeY?: number;
  9403. }
  9404. interface Navigator {
  9405. getVRDisplays(): Promise<VRDisplay[]>;
  9406. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9407. }
  9408. interface Window {
  9409. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9410. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9411. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9412. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9413. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9414. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9415. }
  9416. interface Gamepad {
  9417. readonly displayId: number;
  9418. }
  9419. /**
  9420. * Module Debug contains the (visual) components to debug a scene correctly
  9421. */
  9422. declare module BABYLON.Debug {
  9423. /**
  9424. * The Axes viewer will show 3 axes in a specific point in space
  9425. */
  9426. class AxesViewer {
  9427. private _xline;
  9428. private _yline;
  9429. private _zline;
  9430. private _xmesh;
  9431. private _ymesh;
  9432. private _zmesh;
  9433. /**
  9434. * Gets the hosting scene
  9435. */
  9436. scene: Nullable<Scene>;
  9437. /**
  9438. * Gets or sets a number used to scale line length
  9439. */
  9440. scaleLines: number;
  9441. /**
  9442. * Creates a new AxesViewer
  9443. * @param scene defines the hosting scene
  9444. * @param scaleLines defines a number used to scale line length (1 by default)
  9445. */
  9446. constructor(scene: Scene, scaleLines?: number);
  9447. /**
  9448. * Force the viewer to update
  9449. * @param position defines the position of the viewer
  9450. * @param xaxis defines the x axis of the viewer
  9451. * @param yaxis defines the y axis of the viewer
  9452. * @param zaxis defines the z axis of the viewer
  9453. */
  9454. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9455. /** Releases resources */
  9456. dispose(): void;
  9457. }
  9458. }
  9459. declare module BABYLON.Debug {
  9460. /**
  9461. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9462. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9463. */
  9464. class BoneAxesViewer extends AxesViewer {
  9465. /**
  9466. * Gets or sets the target mesh where to display the axes viewer
  9467. */
  9468. mesh: Nullable<Mesh>;
  9469. /**
  9470. * Gets or sets the target bone where to display the axes viewer
  9471. */
  9472. bone: Nullable<Bone>;
  9473. /** Gets current position */
  9474. pos: Vector3;
  9475. /** Gets direction of X axis */
  9476. xaxis: Vector3;
  9477. /** Gets direction of Y axis */
  9478. yaxis: Vector3;
  9479. /** Gets direction of Z axis */
  9480. zaxis: Vector3;
  9481. /**
  9482. * Creates a new BoneAxesViewer
  9483. * @param scene defines the hosting scene
  9484. * @param bone defines the target bone
  9485. * @param mesh defines the target mesh
  9486. * @param scaleLines defines a scaling factor for line length (1 by default)
  9487. */
  9488. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9489. /**
  9490. * Force the viewer to update
  9491. */
  9492. update(): void;
  9493. /** Releases resources */
  9494. dispose(): void;
  9495. }
  9496. }
  9497. declare module BABYLON {
  9498. interface Scene {
  9499. /**
  9500. * @hidden
  9501. * Backing field
  9502. */
  9503. _debugLayer: DebugLayer;
  9504. /**
  9505. * Gets the debug layer (aka Inspector) associated with the scene
  9506. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9507. */
  9508. debugLayer: DebugLayer;
  9509. }
  9510. /**
  9511. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9512. * what is happening in your scene
  9513. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9514. */
  9515. class DebugLayer {
  9516. /**
  9517. * Define the url to get the inspector script from.
  9518. * By default it uses the babylonjs CDN.
  9519. * @ignoreNaming
  9520. */
  9521. static InspectorURL: string;
  9522. private _scene;
  9523. private _inspector;
  9524. private BJSINSPECTOR;
  9525. /**
  9526. * Observable triggered when a property is changed through the inspector.
  9527. */
  9528. onPropertyChangedObservable: Observable<{
  9529. object: any;
  9530. property: string;
  9531. value: any;
  9532. initialValue: any;
  9533. }>;
  9534. /**
  9535. * Instantiates a new debug layer.
  9536. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9537. * what is happening in your scene
  9538. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9539. * @param scene Defines the scene to inspect
  9540. */
  9541. constructor(scene: Scene);
  9542. /** Creates the inspector window. */
  9543. private _createInspector;
  9544. /**
  9545. * Get if the inspector is visible or not.
  9546. * @returns true if visible otherwise, false
  9547. */
  9548. isVisible(): boolean;
  9549. /**
  9550. * Hide the inspector and close its window.
  9551. */
  9552. hide(): void;
  9553. /**
  9554. *
  9555. * Launch the debugLayer.
  9556. *
  9557. * initialTab:
  9558. * | Value | Tab Name |
  9559. * | --- | --- |
  9560. * | 0 | Scene |
  9561. * | 1 | Console |
  9562. * | 2 | Stats |
  9563. * | 3 | Textures |
  9564. * | 4 | Mesh |
  9565. * | 5 | Light |
  9566. * | 6 | Material |
  9567. * | 7 | GLTF |
  9568. * | 8 | GUI |
  9569. * | 9 | Physics |
  9570. * | 10 | Camera |
  9571. * | 11 | Audio |
  9572. *
  9573. * @param config Define the configuration of the inspector
  9574. */
  9575. show(config?: {
  9576. popup?: boolean;
  9577. initialTab?: number | string;
  9578. parentElement?: HTMLElement;
  9579. newColors?: {
  9580. backgroundColor?: string;
  9581. backgroundColorLighter?: string;
  9582. backgroundColorLighter2?: string;
  9583. backgroundColorLighter3?: string;
  9584. color?: string;
  9585. colorTop?: string;
  9586. colorBot?: string;
  9587. };
  9588. }): void;
  9589. /**
  9590. * Gets the active tab
  9591. * @return the index of the active tab or -1 if the inspector is hidden
  9592. */
  9593. getActiveTab(): number;
  9594. }
  9595. }
  9596. declare module BABYLON.Debug {
  9597. /**
  9598. * Used to show the physics impostor around the specific mesh
  9599. */
  9600. class PhysicsViewer {
  9601. /** @hidden */
  9602. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9603. /** @hidden */
  9604. protected _meshes: Array<Nullable<AbstractMesh>>;
  9605. /** @hidden */
  9606. protected _scene: Nullable<Scene>;
  9607. /** @hidden */
  9608. protected _numMeshes: number;
  9609. /** @hidden */
  9610. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9611. private _renderFunction;
  9612. private _debugBoxMesh;
  9613. private _debugSphereMesh;
  9614. private _debugMaterial;
  9615. /**
  9616. * Creates a new PhysicsViewer
  9617. * @param scene defines the hosting scene
  9618. */
  9619. constructor(scene: Scene);
  9620. /** @hidden */
  9621. protected _updateDebugMeshes(): void;
  9622. /**
  9623. * Renders a specified physic impostor
  9624. * @param impostor defines the impostor to render
  9625. */
  9626. showImpostor(impostor: PhysicsImpostor): void;
  9627. /**
  9628. * Hides a specified physic impostor
  9629. * @param impostor defines the impostor to hide
  9630. */
  9631. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9632. private _getDebugMaterial;
  9633. private _getDebugBoxMesh;
  9634. private _getDebugSphereMesh;
  9635. private _getDebugMesh;
  9636. /** Releases all resources */
  9637. dispose(): void;
  9638. }
  9639. }
  9640. declare module BABYLON {
  9641. /**
  9642. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9643. * in order to better appreciate the issue one might have.
  9644. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9645. */
  9646. class RayHelper {
  9647. /**
  9648. * Defines the ray we are currently tryin to visualize.
  9649. */
  9650. ray: Nullable<Ray>;
  9651. private _renderPoints;
  9652. private _renderLine;
  9653. private _renderFunction;
  9654. private _scene;
  9655. private _updateToMeshFunction;
  9656. private _attachedToMesh;
  9657. private _meshSpaceDirection;
  9658. private _meshSpaceOrigin;
  9659. /**
  9660. * Helper function to create a colored helper in a scene in one line.
  9661. * @param ray Defines the ray we are currently tryin to visualize
  9662. * @param scene Defines the scene the ray is used in
  9663. * @param color Defines the color we want to see the ray in
  9664. * @returns The newly created ray helper.
  9665. */
  9666. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9667. /**
  9668. * Instantiate a new ray helper.
  9669. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9670. * in order to better appreciate the issue one might have.
  9671. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9672. * @param ray Defines the ray we are currently tryin to visualize
  9673. */
  9674. constructor(ray: Ray);
  9675. /**
  9676. * Shows the ray we are willing to debug.
  9677. * @param scene Defines the scene the ray needs to be rendered in
  9678. * @param color Defines the color the ray needs to be rendered in
  9679. */
  9680. show(scene: Scene, color?: Color3): void;
  9681. /**
  9682. * Hides the ray we are debugging.
  9683. */
  9684. hide(): void;
  9685. private _render;
  9686. /**
  9687. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9688. * @param mesh Defines the mesh we want the helper attached to
  9689. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9690. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9691. * @param length Defines the length of the ray
  9692. */
  9693. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9694. /**
  9695. * Detach the ray helper from the mesh it has previously been attached to.
  9696. */
  9697. detachFromMesh(): void;
  9698. private _updateToMesh;
  9699. /**
  9700. * Dispose the helper and release its associated resources.
  9701. */
  9702. dispose(): void;
  9703. }
  9704. }
  9705. declare module BABYLON.Debug {
  9706. /**
  9707. * Class used to render a debug view of a given skeleton
  9708. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9709. */
  9710. class SkeletonViewer {
  9711. /** defines the skeleton to render */
  9712. skeleton: Skeleton;
  9713. /** defines the mesh attached to the skeleton */
  9714. mesh: AbstractMesh;
  9715. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9716. autoUpdateBonesMatrices: boolean;
  9717. /** defines the rendering group id to use with the viewer */
  9718. renderingGroupId: number;
  9719. /** Gets or sets the color used to render the skeleton */
  9720. color: Color3;
  9721. private _scene;
  9722. private _debugLines;
  9723. private _debugMesh;
  9724. private _isEnabled;
  9725. private _renderFunction;
  9726. /**
  9727. * Creates a new SkeletonViewer
  9728. * @param skeleton defines the skeleton to render
  9729. * @param mesh defines the mesh attached to the skeleton
  9730. * @param scene defines the hosting scene
  9731. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9732. * @param renderingGroupId defines the rendering group id to use with the viewer
  9733. */
  9734. constructor(
  9735. /** defines the skeleton to render */
  9736. skeleton: Skeleton,
  9737. /** defines the mesh attached to the skeleton */
  9738. mesh: AbstractMesh, scene: Scene,
  9739. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9740. autoUpdateBonesMatrices?: boolean,
  9741. /** defines the rendering group id to use with the viewer */
  9742. renderingGroupId?: number);
  9743. /** Gets or sets a boolean indicating if the viewer is enabled */
  9744. isEnabled: boolean;
  9745. private _getBonePosition;
  9746. private _getLinesForBonesWithLength;
  9747. private _getLinesForBonesNoLength;
  9748. /** Update the viewer to sync with current skeleton state */
  9749. update(): void;
  9750. /** Release associated resources */
  9751. dispose(): void;
  9752. }
  9753. }
  9754. declare module BABYLON {
  9755. /**
  9756. * Interface for attribute information associated with buffer instanciation
  9757. */
  9758. class InstancingAttributeInfo {
  9759. /**
  9760. * Index/offset of the attribute in the vertex shader
  9761. */
  9762. index: number;
  9763. /**
  9764. * size of the attribute, 1, 2, 3 or 4
  9765. */
  9766. attributeSize: number;
  9767. /**
  9768. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9769. * default is FLOAT
  9770. */
  9771. attribyteType: number;
  9772. /**
  9773. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9774. */
  9775. normalized: boolean;
  9776. /**
  9777. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9778. */
  9779. offset: number;
  9780. /**
  9781. * Name of the GLSL attribute, for debugging purpose only
  9782. */
  9783. attributeName: string;
  9784. }
  9785. /**
  9786. * Define options used to create a render target texture
  9787. */
  9788. class RenderTargetCreationOptions {
  9789. /**
  9790. * Specifies is mipmaps must be generated
  9791. */
  9792. generateMipMaps?: boolean;
  9793. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9794. generateDepthBuffer?: boolean;
  9795. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9796. generateStencilBuffer?: boolean;
  9797. /** Defines texture type (int by default) */
  9798. type?: number;
  9799. /** Defines sampling mode (trilinear by default) */
  9800. samplingMode?: number;
  9801. /** Defines format (RGBA by default) */
  9802. format?: number;
  9803. }
  9804. /**
  9805. * Define options used to create a depth texture
  9806. */
  9807. class DepthTextureCreationOptions {
  9808. /** Specifies whether or not a stencil should be allocated in the texture */
  9809. generateStencil?: boolean;
  9810. /** Specifies whether or not bilinear filtering is enable on the texture */
  9811. bilinearFiltering?: boolean;
  9812. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9813. comparisonFunction?: number;
  9814. /** Specifies if the created texture is a cube texture */
  9815. isCube?: boolean;
  9816. }
  9817. /**
  9818. * Class used to describe the capabilities of the engine relatively to the current browser
  9819. */
  9820. class EngineCapabilities {
  9821. /** Maximum textures units per fragment shader */
  9822. maxTexturesImageUnits: number;
  9823. /** Maximum texture units per vertex shader */
  9824. maxVertexTextureImageUnits: number;
  9825. /** Maximum textures units in the entire pipeline */
  9826. maxCombinedTexturesImageUnits: number;
  9827. /** Maximum texture size */
  9828. maxTextureSize: number;
  9829. /** Maximum cube texture size */
  9830. maxCubemapTextureSize: number;
  9831. /** Maximum render texture size */
  9832. maxRenderTextureSize: number;
  9833. /** Maximum number of vertex attributes */
  9834. maxVertexAttribs: number;
  9835. /** Maximum number of varyings */
  9836. maxVaryingVectors: number;
  9837. /** Maximum number of uniforms per vertex shader */
  9838. maxVertexUniformVectors: number;
  9839. /** Maximum number of uniforms per fragment shader */
  9840. maxFragmentUniformVectors: number;
  9841. /** Defines if standard derivates (dx/dy) are supported */
  9842. standardDerivatives: boolean;
  9843. /** Defines if s3tc texture compression is supported */
  9844. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9845. /** Defines if pvrtc texture compression is supported */
  9846. pvrtc: any;
  9847. /** Defines if etc1 texture compression is supported */
  9848. etc1: any;
  9849. /** Defines if etc2 texture compression is supported */
  9850. etc2: any;
  9851. /** Defines if astc texture compression is supported */
  9852. astc: any;
  9853. /** Defines if float textures are supported */
  9854. textureFloat: boolean;
  9855. /** Defines if vertex array objects are supported */
  9856. vertexArrayObject: boolean;
  9857. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9858. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9859. /** Gets the maximum level of anisotropy supported */
  9860. maxAnisotropy: number;
  9861. /** Defines if instancing is supported */
  9862. instancedArrays: boolean;
  9863. /** Defines if 32 bits indices are supported */
  9864. uintIndices: boolean;
  9865. /** Defines if high precision shaders are supported */
  9866. highPrecisionShaderSupported: boolean;
  9867. /** Defines if depth reading in the fragment shader is supported */
  9868. fragmentDepthSupported: boolean;
  9869. /** Defines if float texture linear filtering is supported*/
  9870. textureFloatLinearFiltering: boolean;
  9871. /** Defines if rendering to float textures is supported */
  9872. textureFloatRender: boolean;
  9873. /** Defines if half float textures are supported*/
  9874. textureHalfFloat: boolean;
  9875. /** Defines if half float texture linear filtering is supported*/
  9876. textureHalfFloatLinearFiltering: boolean;
  9877. /** Defines if rendering to half float textures is supported */
  9878. textureHalfFloatRender: boolean;
  9879. /** Defines if textureLOD shader command is supported */
  9880. textureLOD: boolean;
  9881. /** Defines if draw buffers extension is supported */
  9882. drawBuffersExtension: boolean;
  9883. /** Defines if depth textures are supported */
  9884. depthTextureExtension: boolean;
  9885. /** Defines if float color buffer are supported */
  9886. colorBufferFloat: boolean;
  9887. /** Gets disjoint timer query extension (null if not supported) */
  9888. timerQuery: EXT_disjoint_timer_query;
  9889. /** Defines if timestamp can be used with timer query */
  9890. canUseTimestampForTimerQuery: boolean;
  9891. /** Function used to let the system compiles shaders in background */
  9892. parallelShaderCompile: {
  9893. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9894. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9895. COMPLETION_STATUS_KHR: number;
  9896. };
  9897. }
  9898. /** Interface defining initialization parameters for Engine class */
  9899. interface EngineOptions extends WebGLContextAttributes {
  9900. /**
  9901. * Defines if the engine should no exceed a specified device ratio
  9902. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9903. */
  9904. limitDeviceRatio?: number;
  9905. /**
  9906. * Defines if webvr should be enabled automatically
  9907. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9908. */
  9909. autoEnableWebVR?: boolean;
  9910. /**
  9911. * Defines if webgl2 should be turned off even if supported
  9912. * @see http://doc.babylonjs.com/features/webgl2
  9913. */
  9914. disableWebGL2Support?: boolean;
  9915. /**
  9916. * Defines if webaudio should be initialized as well
  9917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9918. */
  9919. audioEngine?: boolean;
  9920. /**
  9921. * Defines if animations should run using a deterministic lock step
  9922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9923. */
  9924. deterministicLockstep?: boolean;
  9925. /** Defines the maximum steps to use with deterministic lock step mode */
  9926. lockstepMaxSteps?: number;
  9927. /**
  9928. * Defines that engine should ignore context lost events
  9929. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9930. */
  9931. doNotHandleContextLost?: boolean;
  9932. }
  9933. /**
  9934. * Defines the interface used by display changed events
  9935. */
  9936. interface IDisplayChangedEventArgs {
  9937. /** Gets the vrDisplay object (if any) */
  9938. vrDisplay: Nullable<any>;
  9939. /** Gets a boolean indicating if webVR is supported */
  9940. vrSupported: boolean;
  9941. }
  9942. /**
  9943. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9944. */
  9945. class Engine {
  9946. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9947. static ExceptionList: ({
  9948. key: string;
  9949. capture: string;
  9950. captureConstraint: number;
  9951. targets: string[];
  9952. } | {
  9953. key: string;
  9954. capture: null;
  9955. captureConstraint: null;
  9956. targets: string[];
  9957. })[];
  9958. /** Gets the list of created engines */
  9959. static Instances: Engine[];
  9960. /**
  9961. * Gets the latest created engine
  9962. */
  9963. static readonly LastCreatedEngine: Nullable<Engine>;
  9964. /**
  9965. * Gets the latest created scene
  9966. */
  9967. static readonly LastCreatedScene: Nullable<Scene>;
  9968. /**
  9969. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9970. * @param flag defines which part of the materials must be marked as dirty
  9971. * @param predicate defines a predicate used to filter which materials should be affected
  9972. */
  9973. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9974. /**
  9975. * Hidden
  9976. */
  9977. static _TextureLoaders: IInternalTextureLoader[];
  9978. /** Defines that alpha blending is disabled */
  9979. static readonly ALPHA_DISABLE: number;
  9980. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9981. static readonly ALPHA_ADD: number;
  9982. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9983. static readonly ALPHA_COMBINE: number;
  9984. /** Defines that alpha blending to DEST - SRC * DEST */
  9985. static readonly ALPHA_SUBTRACT: number;
  9986. /** Defines that alpha blending to SRC * DEST */
  9987. static readonly ALPHA_MULTIPLY: number;
  9988. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9989. static readonly ALPHA_MAXIMIZED: number;
  9990. /** Defines that alpha blending to SRC + DEST */
  9991. static readonly ALPHA_ONEONE: number;
  9992. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9993. static readonly ALPHA_PREMULTIPLIED: number;
  9994. /**
  9995. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9996. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9997. */
  9998. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9999. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10000. static readonly ALPHA_INTERPOLATE: number;
  10001. /**
  10002. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10003. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10004. */
  10005. static readonly ALPHA_SCREENMODE: number;
  10006. /** Defines that the ressource is not delayed*/
  10007. static readonly DELAYLOADSTATE_NONE: number;
  10008. /** Defines that the ressource was successfully delay loaded */
  10009. static readonly DELAYLOADSTATE_LOADED: number;
  10010. /** Defines that the ressource is currently delay loading */
  10011. static readonly DELAYLOADSTATE_LOADING: number;
  10012. /** Defines that the ressource is delayed and has not started loading */
  10013. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10014. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10015. static readonly NEVER: number;
  10016. /** 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 */
  10017. static readonly ALWAYS: number;
  10018. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10019. static readonly LESS: number;
  10020. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10021. static readonly EQUAL: number;
  10022. /** 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 */
  10023. static readonly LEQUAL: number;
  10024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10025. static readonly GREATER: number;
  10026. /** 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 */
  10027. static readonly GEQUAL: number;
  10028. /** 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 */
  10029. static readonly NOTEQUAL: number;
  10030. /** Passed to stencilOperation to specify that stencil value must be kept */
  10031. static readonly KEEP: number;
  10032. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10033. static readonly REPLACE: number;
  10034. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10035. static readonly INCR: number;
  10036. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10037. static readonly DECR: number;
  10038. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10039. static readonly INVERT: number;
  10040. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10041. static readonly INCR_WRAP: number;
  10042. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10043. static readonly DECR_WRAP: number;
  10044. /** Texture is not repeating outside of 0..1 UVs */
  10045. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10046. /** Texture is repeating outside of 0..1 UVs */
  10047. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10048. /** Texture is repeating and mirrored */
  10049. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10050. /** ALPHA */
  10051. static readonly TEXTUREFORMAT_ALPHA: number;
  10052. /** LUMINANCE */
  10053. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10054. /** LUMINANCE_ALPHA */
  10055. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10056. /** RGB */
  10057. static readonly TEXTUREFORMAT_RGB: number;
  10058. /** RGBA */
  10059. static readonly TEXTUREFORMAT_RGBA: number;
  10060. /** RED */
  10061. static readonly TEXTUREFORMAT_RED: number;
  10062. /** RED (2nd reference) */
  10063. static readonly TEXTUREFORMAT_R: number;
  10064. /** RG */
  10065. static readonly TEXTUREFORMAT_RG: number;
  10066. /** RED_INTEGER */
  10067. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10068. /** RED_INTEGER (2nd reference) */
  10069. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10070. /** RG_INTEGER */
  10071. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10072. /** RGB_INTEGER */
  10073. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10074. /** RGBA_INTEGER */
  10075. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10076. /** UNSIGNED_BYTE */
  10077. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10078. /** UNSIGNED_BYTE (2nd reference) */
  10079. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10080. /** FLOAT */
  10081. static readonly TEXTURETYPE_FLOAT: number;
  10082. /** HALF_FLOAT */
  10083. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10084. /** BYTE */
  10085. static readonly TEXTURETYPE_BYTE: number;
  10086. /** SHORT */
  10087. static readonly TEXTURETYPE_SHORT: number;
  10088. /** UNSIGNED_SHORT */
  10089. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10090. /** INT */
  10091. static readonly TEXTURETYPE_INT: number;
  10092. /** UNSIGNED_INT */
  10093. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10094. /** UNSIGNED_SHORT_4_4_4_4 */
  10095. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10096. /** UNSIGNED_SHORT_5_5_5_1 */
  10097. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10098. /** UNSIGNED_SHORT_5_6_5 */
  10099. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10100. /** UNSIGNED_INT_2_10_10_10_REV */
  10101. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10102. /** UNSIGNED_INT_24_8 */
  10103. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10104. /** UNSIGNED_INT_10F_11F_11F_REV */
  10105. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10106. /** UNSIGNED_INT_5_9_9_9_REV */
  10107. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10108. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10109. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10110. /** nearest is mag = nearest and min = nearest and mip = linear */
  10111. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10112. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10113. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10114. /** Trilinear is mag = linear and min = linear and mip = linear */
  10115. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10116. /** nearest is mag = nearest and min = nearest and mip = linear */
  10117. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10119. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10120. /** Trilinear is mag = linear and min = linear and mip = linear */
  10121. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10122. /** mag = nearest and min = nearest and mip = nearest */
  10123. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10124. /** mag = nearest and min = linear and mip = nearest */
  10125. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10126. /** mag = nearest and min = linear and mip = linear */
  10127. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10128. /** mag = nearest and min = linear and mip = none */
  10129. static readonly TEXTURE_NEAREST_LINEAR: number;
  10130. /** mag = nearest and min = nearest and mip = none */
  10131. static readonly TEXTURE_NEAREST_NEAREST: number;
  10132. /** mag = linear and min = nearest and mip = nearest */
  10133. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10134. /** mag = linear and min = nearest and mip = linear */
  10135. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10136. /** mag = linear and min = linear and mip = none */
  10137. static readonly TEXTURE_LINEAR_LINEAR: number;
  10138. /** mag = linear and min = nearest and mip = none */
  10139. static readonly TEXTURE_LINEAR_NEAREST: number;
  10140. /** Explicit coordinates mode */
  10141. static readonly TEXTURE_EXPLICIT_MODE: number;
  10142. /** Spherical coordinates mode */
  10143. static readonly TEXTURE_SPHERICAL_MODE: number;
  10144. /** Planar coordinates mode */
  10145. static readonly TEXTURE_PLANAR_MODE: number;
  10146. /** Cubic coordinates mode */
  10147. static readonly TEXTURE_CUBIC_MODE: number;
  10148. /** Projection coordinates mode */
  10149. static readonly TEXTURE_PROJECTION_MODE: number;
  10150. /** Skybox coordinates mode */
  10151. static readonly TEXTURE_SKYBOX_MODE: number;
  10152. /** Inverse Cubic coordinates mode */
  10153. static readonly TEXTURE_INVCUBIC_MODE: number;
  10154. /** Equirectangular coordinates mode */
  10155. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10156. /** Equirectangular Fixed coordinates mode */
  10157. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10158. /** Equirectangular Fixed Mirrored coordinates mode */
  10159. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10160. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10161. static readonly SCALEMODE_FLOOR: number;
  10162. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10163. static readonly SCALEMODE_NEAREST: number;
  10164. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10165. static readonly SCALEMODE_CEILING: number;
  10166. /**
  10167. * Returns the current version of the framework
  10168. */
  10169. static readonly Version: string;
  10170. /**
  10171. * Gets or sets the epsilon value used by collision engine
  10172. */
  10173. static CollisionsEpsilon: number;
  10174. /**
  10175. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10176. */
  10177. static CodeRepository: string;
  10178. /**
  10179. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10180. */
  10181. static ShadersRepository: string;
  10182. /**
  10183. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10184. */
  10185. forcePOTTextures: boolean;
  10186. /**
  10187. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10188. */
  10189. isFullscreen: boolean;
  10190. /**
  10191. * Gets a boolean indicating if the pointer is currently locked
  10192. */
  10193. isPointerLock: boolean;
  10194. /**
  10195. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10196. */
  10197. cullBackFaces: boolean;
  10198. /**
  10199. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10200. */
  10201. renderEvenInBackground: boolean;
  10202. /**
  10203. * Gets or sets a boolean indicating that cache can be kept between frames
  10204. */
  10205. preventCacheWipeBetweenFrames: boolean;
  10206. /**
  10207. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10208. **/
  10209. enableOfflineSupport: boolean;
  10210. /**
  10211. * 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)
  10212. **/
  10213. disableManifestCheck: boolean;
  10214. /**
  10215. * Gets the list of created scenes
  10216. */
  10217. scenes: Scene[];
  10218. /**
  10219. * Gets the list of created postprocesses
  10220. */
  10221. postProcesses: PostProcess[];
  10222. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10223. validateShaderPrograms: boolean;
  10224. /**
  10225. * Observable event triggered each time the rendering canvas is resized
  10226. */
  10227. onResizeObservable: Observable<Engine>;
  10228. /**
  10229. * Observable event triggered each time the canvas loses focus
  10230. */
  10231. onCanvasBlurObservable: Observable<Engine>;
  10232. /**
  10233. * Observable event triggered each time the canvas gains focus
  10234. */
  10235. onCanvasFocusObservable: Observable<Engine>;
  10236. /**
  10237. * Observable event triggered each time the canvas receives pointerout event
  10238. */
  10239. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10240. /**
  10241. * Observable event triggered before each texture is initialized
  10242. */
  10243. onBeforeTextureInitObservable: Observable<Texture>;
  10244. private _vrDisplay;
  10245. private _vrSupported;
  10246. private _oldSize;
  10247. private _oldHardwareScaleFactor;
  10248. private _vrExclusivePointerMode;
  10249. private _webVRInitPromise;
  10250. /**
  10251. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10252. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10253. */
  10254. readonly isInVRExclusivePointerMode: boolean;
  10255. /**
  10256. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10257. */
  10258. disableUniformBuffers: boolean;
  10259. /** @hidden */
  10260. _uniformBuffers: UniformBuffer[];
  10261. /**
  10262. * Gets a boolean indicating that the engine supports uniform buffers
  10263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10264. */
  10265. readonly supportsUniformBuffers: boolean;
  10266. /**
  10267. * Observable raised when the engine begins a new frame
  10268. */
  10269. onBeginFrameObservable: Observable<Engine>;
  10270. /**
  10271. * If set, will be used to request the next animation frame for the render loop
  10272. */
  10273. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10274. /**
  10275. * Observable raised when the engine ends the current frame
  10276. */
  10277. onEndFrameObservable: Observable<Engine>;
  10278. /**
  10279. * Observable raised when the engine is about to compile a shader
  10280. */
  10281. onBeforeShaderCompilationObservable: Observable<Engine>;
  10282. /**
  10283. * Observable raised when the engine has jsut compiled a shader
  10284. */
  10285. onAfterShaderCompilationObservable: Observable<Engine>;
  10286. /** @hidden */
  10287. _gl: WebGLRenderingContext;
  10288. private _renderingCanvas;
  10289. private _windowIsBackground;
  10290. private _webGLVersion;
  10291. /**
  10292. * Gets a boolean indicating that only power of 2 textures are supported
  10293. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10294. */
  10295. readonly needPOTTextures: boolean;
  10296. /** @hidden */
  10297. _badOS: boolean;
  10298. /** @hidden */
  10299. _badDesktopOS: boolean;
  10300. /**
  10301. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10302. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10303. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10304. */
  10305. disableTextureBindingOptimization: boolean;
  10306. /**
  10307. * Gets the audio engine
  10308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10309. * @ignorenaming
  10310. */
  10311. static audioEngine: IAudioEngine;
  10312. /**
  10313. * Default AudioEngine factory responsible of creating the Audio Engine.
  10314. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10315. */
  10316. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10317. /**
  10318. * Default offline support factory responsible of creating a tool used to store data locally.
  10319. * By default, this will create a Database object if the workload has been embedded.
  10320. */
  10321. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10322. private _onFocus;
  10323. private _onBlur;
  10324. private _onCanvasPointerOut;
  10325. private _onCanvasBlur;
  10326. private _onCanvasFocus;
  10327. private _onFullscreenChange;
  10328. private _onPointerLockChange;
  10329. private _onVRDisplayPointerRestricted;
  10330. private _onVRDisplayPointerUnrestricted;
  10331. private _onVrDisplayConnect;
  10332. private _onVrDisplayDisconnect;
  10333. private _onVrDisplayPresentChange;
  10334. /**
  10335. * Observable signaled when VR display mode changes
  10336. */
  10337. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10338. /**
  10339. * Observable signaled when VR request present is complete
  10340. */
  10341. onVRRequestPresentComplete: Observable<boolean>;
  10342. /**
  10343. * Observable signaled when VR request present starts
  10344. */
  10345. onVRRequestPresentStart: Observable<Engine>;
  10346. private _hardwareScalingLevel;
  10347. /** @hidden */
  10348. protected _caps: EngineCapabilities;
  10349. private _pointerLockRequested;
  10350. private _isStencilEnable;
  10351. private _colorWrite;
  10352. private _loadingScreen;
  10353. /** @hidden */
  10354. _drawCalls: PerfCounter;
  10355. /** @hidden */
  10356. _textureCollisions: PerfCounter;
  10357. private _glVersion;
  10358. private _glRenderer;
  10359. private _glVendor;
  10360. private _videoTextureSupported;
  10361. private _renderingQueueLaunched;
  10362. private _activeRenderLoops;
  10363. private _deterministicLockstep;
  10364. private _lockstepMaxSteps;
  10365. /**
  10366. * Observable signaled when a context lost event is raised
  10367. */
  10368. onContextLostObservable: Observable<Engine>;
  10369. /**
  10370. * Observable signaled when a context restored event is raised
  10371. */
  10372. onContextRestoredObservable: Observable<Engine>;
  10373. private _onContextLost;
  10374. private _onContextRestored;
  10375. private _contextWasLost;
  10376. private _doNotHandleContextLost;
  10377. /**
  10378. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10380. */
  10381. doNotHandleContextLost: boolean;
  10382. private _performanceMonitor;
  10383. private _fps;
  10384. private _deltaTime;
  10385. /**
  10386. * Turn this value on if you want to pause FPS computation when in background
  10387. */
  10388. disablePerformanceMonitorInBackground: boolean;
  10389. /**
  10390. * Gets the performance monitor attached to this engine
  10391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10392. */
  10393. readonly performanceMonitor: PerformanceMonitor;
  10394. /** @hidden */
  10395. protected _depthCullingState: _DepthCullingState;
  10396. /** @hidden */
  10397. protected _stencilState: _StencilState;
  10398. /** @hidden */
  10399. protected _alphaState: _AlphaState;
  10400. /** @hidden */
  10401. protected _alphaMode: number;
  10402. protected _internalTexturesCache: InternalTexture[];
  10403. /** @hidden */
  10404. protected _activeChannel: number;
  10405. private _currentTextureChannel;
  10406. /** @hidden */
  10407. protected _boundTexturesCache: {
  10408. [key: string]: Nullable<InternalTexture>;
  10409. };
  10410. /** @hidden */
  10411. protected _currentEffect: Nullable<Effect>;
  10412. /** @hidden */
  10413. protected _currentProgram: Nullable<WebGLProgram>;
  10414. private _compiledEffects;
  10415. private _vertexAttribArraysEnabled;
  10416. /** @hidden */
  10417. protected _cachedViewport: Nullable<Viewport>;
  10418. private _cachedVertexArrayObject;
  10419. /** @hidden */
  10420. protected _cachedVertexBuffers: any;
  10421. /** @hidden */
  10422. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10423. /** @hidden */
  10424. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10425. /** @hidden */
  10426. protected _currentRenderTarget: Nullable<InternalTexture>;
  10427. private _uintIndicesCurrentlySet;
  10428. private _currentBoundBuffer;
  10429. /** @hidden */
  10430. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10431. private _currentBufferPointers;
  10432. private _currentInstanceLocations;
  10433. private _currentInstanceBuffers;
  10434. private _textureUnits;
  10435. private _firstBoundInternalTextureTracker;
  10436. private _lastBoundInternalTextureTracker;
  10437. private _workingCanvas;
  10438. private _workingContext;
  10439. private _rescalePostProcess;
  10440. private _dummyFramebuffer;
  10441. private _externalData;
  10442. private _bindedRenderFunction;
  10443. private _vaoRecordInProgress;
  10444. private _mustWipeVertexAttributes;
  10445. private _emptyTexture;
  10446. private _emptyCubeTexture;
  10447. private _emptyTexture3D;
  10448. private _frameHandler;
  10449. private _nextFreeTextureSlots;
  10450. private _maxSimultaneousTextures;
  10451. private _activeRequests;
  10452. private _texturesSupported;
  10453. private _textureFormatInUse;
  10454. /**
  10455. * Gets the list of texture formats supported
  10456. */
  10457. readonly texturesSupported: Array<string>;
  10458. /**
  10459. * Gets the list of texture formats in use
  10460. */
  10461. readonly textureFormatInUse: Nullable<string>;
  10462. /**
  10463. * Gets the current viewport
  10464. */
  10465. readonly currentViewport: Nullable<Viewport>;
  10466. /**
  10467. * Gets the default empty texture
  10468. */
  10469. readonly emptyTexture: InternalTexture;
  10470. /**
  10471. * Gets the default empty 3D texture
  10472. */
  10473. readonly emptyTexture3D: InternalTexture;
  10474. /**
  10475. * Gets the default empty cube texture
  10476. */
  10477. readonly emptyCubeTexture: InternalTexture;
  10478. /**
  10479. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10480. */
  10481. readonly premultipliedAlpha: boolean;
  10482. /**
  10483. * Creates a new engine
  10484. * @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
  10485. * @param antialias defines enable antialiasing (default: false)
  10486. * @param options defines further options to be sent to the getContext() function
  10487. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10488. */
  10489. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10490. private _rebuildInternalTextures;
  10491. private _rebuildEffects;
  10492. /**
  10493. * Gets a boolean indicating if all created effects are ready
  10494. * @returns true if all effects are ready
  10495. */
  10496. areAllEffectsReady(): boolean;
  10497. private _rebuildBuffers;
  10498. private _initGLContext;
  10499. /**
  10500. * Gets version of the current webGL context
  10501. */
  10502. readonly webGLVersion: number;
  10503. /**
  10504. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10505. */
  10506. readonly isStencilEnable: boolean;
  10507. private _prepareWorkingCanvas;
  10508. /**
  10509. * Reset the texture cache to empty state
  10510. */
  10511. resetTextureCache(): void;
  10512. /**
  10513. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10514. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10515. * @returns true if engine is in deterministic lock step mode
  10516. */
  10517. isDeterministicLockStep(): boolean;
  10518. /**
  10519. * Gets the max steps when engine is running in deterministic lock step
  10520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10521. * @returns the max steps
  10522. */
  10523. getLockstepMaxSteps(): number;
  10524. /**
  10525. * Gets an object containing information about the current webGL context
  10526. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10527. */
  10528. getGlInfo(): {
  10529. vendor: string;
  10530. renderer: string;
  10531. version: string;
  10532. };
  10533. /**
  10534. * Gets current aspect ratio
  10535. * @param camera defines the camera to use to get the aspect ratio
  10536. * @param useScreen defines if screen size must be used (or the current render target if any)
  10537. * @returns a number defining the aspect ratio
  10538. */
  10539. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10540. /**
  10541. * Gets current screen aspect ratio
  10542. * @returns a number defining the aspect ratio
  10543. */
  10544. getScreenAspectRatio(): number;
  10545. /**
  10546. * Gets the current render width
  10547. * @param useScreen defines if screen size must be used (or the current render target if any)
  10548. * @returns a number defining the current render width
  10549. */
  10550. getRenderWidth(useScreen?: boolean): number;
  10551. /**
  10552. * Gets the current render height
  10553. * @param useScreen defines if screen size must be used (or the current render target if any)
  10554. * @returns a number defining the current render height
  10555. */
  10556. getRenderHeight(useScreen?: boolean): number;
  10557. /**
  10558. * Gets the HTML canvas attached with the current webGL context
  10559. * @returns a HTML canvas
  10560. */
  10561. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10562. /**
  10563. * Gets the client rect of the HTML canvas attached with the current webGL context
  10564. * @returns a client rectanglee
  10565. */
  10566. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10567. /**
  10568. * Defines the hardware scaling level.
  10569. * By default the hardware scaling level is computed from the window device ratio.
  10570. * 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.
  10571. * @param level defines the level to use
  10572. */
  10573. setHardwareScalingLevel(level: number): void;
  10574. /**
  10575. * Gets the current hardware scaling level.
  10576. * By default the hardware scaling level is computed from the window device ratio.
  10577. * 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.
  10578. * @returns a number indicating the current hardware scaling level
  10579. */
  10580. getHardwareScalingLevel(): number;
  10581. /**
  10582. * Gets the list of loaded textures
  10583. * @returns an array containing all loaded textures
  10584. */
  10585. getLoadedTexturesCache(): InternalTexture[];
  10586. /**
  10587. * Gets the object containing all engine capabilities
  10588. * @returns the EngineCapabilities object
  10589. */
  10590. getCaps(): EngineCapabilities;
  10591. /** @hidden */
  10592. readonly drawCalls: number;
  10593. /** @hidden */
  10594. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10595. /**
  10596. * Gets the current depth function
  10597. * @returns a number defining the depth function
  10598. */
  10599. getDepthFunction(): Nullable<number>;
  10600. /**
  10601. * Sets the current depth function
  10602. * @param depthFunc defines the function to use
  10603. */
  10604. setDepthFunction(depthFunc: number): void;
  10605. /**
  10606. * Sets the current depth function to GREATER
  10607. */
  10608. setDepthFunctionToGreater(): void;
  10609. /**
  10610. * Sets the current depth function to GEQUAL
  10611. */
  10612. setDepthFunctionToGreaterOrEqual(): void;
  10613. /**
  10614. * Sets the current depth function to LESS
  10615. */
  10616. setDepthFunctionToLess(): void;
  10617. /**
  10618. * Sets the current depth function to LEQUAL
  10619. */
  10620. setDepthFunctionToLessOrEqual(): void;
  10621. /**
  10622. * Gets a boolean indicating if stencil buffer is enabled
  10623. * @returns the current stencil buffer state
  10624. */
  10625. getStencilBuffer(): boolean;
  10626. /**
  10627. * Enable or disable the stencil buffer
  10628. * @param enable defines if the stencil buffer must be enabled or disabled
  10629. */
  10630. setStencilBuffer(enable: boolean): void;
  10631. /**
  10632. * Gets the current stencil mask
  10633. * @returns a number defining the new stencil mask to use
  10634. */
  10635. getStencilMask(): number;
  10636. /**
  10637. * Sets the current stencil mask
  10638. * @param mask defines the new stencil mask to use
  10639. */
  10640. setStencilMask(mask: number): void;
  10641. /**
  10642. * Gets the current stencil function
  10643. * @returns a number defining the stencil function to use
  10644. */
  10645. getStencilFunction(): number;
  10646. /**
  10647. * Gets the current stencil reference value
  10648. * @returns a number defining the stencil reference value to use
  10649. */
  10650. getStencilFunctionReference(): number;
  10651. /**
  10652. * Gets the current stencil mask
  10653. * @returns a number defining the stencil mask to use
  10654. */
  10655. getStencilFunctionMask(): number;
  10656. /**
  10657. * Sets the current stencil function
  10658. * @param stencilFunc defines the new stencil function to use
  10659. */
  10660. setStencilFunction(stencilFunc: number): void;
  10661. /**
  10662. * Sets the current stencil reference
  10663. * @param reference defines the new stencil reference to use
  10664. */
  10665. setStencilFunctionReference(reference: number): void;
  10666. /**
  10667. * Sets the current stencil mask
  10668. * @param mask defines the new stencil mask to use
  10669. */
  10670. setStencilFunctionMask(mask: number): void;
  10671. /**
  10672. * Gets the current stencil operation when stencil fails
  10673. * @returns a number defining stencil operation to use when stencil fails
  10674. */
  10675. getStencilOperationFail(): number;
  10676. /**
  10677. * Gets the current stencil operation when depth fails
  10678. * @returns a number defining stencil operation to use when depth fails
  10679. */
  10680. getStencilOperationDepthFail(): number;
  10681. /**
  10682. * Gets the current stencil operation when stencil passes
  10683. * @returns a number defining stencil operation to use when stencil passes
  10684. */
  10685. getStencilOperationPass(): number;
  10686. /**
  10687. * Sets the stencil operation to use when stencil fails
  10688. * @param operation defines the stencil operation to use when stencil fails
  10689. */
  10690. setStencilOperationFail(operation: number): void;
  10691. /**
  10692. * Sets the stencil operation to use when depth fails
  10693. * @param operation defines the stencil operation to use when depth fails
  10694. */
  10695. setStencilOperationDepthFail(operation: number): void;
  10696. /**
  10697. * Sets the stencil operation to use when stencil passes
  10698. * @param operation defines the stencil operation to use when stencil passes
  10699. */
  10700. setStencilOperationPass(operation: number): void;
  10701. /**
  10702. * Sets a boolean indicating if the dithering state is enabled or disabled
  10703. * @param value defines the dithering state
  10704. */
  10705. setDitheringState(value: boolean): void;
  10706. /**
  10707. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10708. * @param value defines the rasterizer state
  10709. */
  10710. setRasterizerState(value: boolean): void;
  10711. /**
  10712. * stop executing a render loop function and remove it from the execution array
  10713. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10714. */
  10715. stopRenderLoop(renderFunction?: () => void): void;
  10716. /** @hidden */
  10717. _renderLoop(): void;
  10718. /**
  10719. * Register and execute a render loop. The engine can have more than one render function
  10720. * @param renderFunction defines the function to continuously execute
  10721. */
  10722. runRenderLoop(renderFunction: () => void): void;
  10723. /**
  10724. * Toggle full screen mode
  10725. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10726. */
  10727. switchFullscreen(requestPointerLock: boolean): void;
  10728. /**
  10729. * Clear the current render buffer or the current render target (if any is set up)
  10730. * @param color defines the color to use
  10731. * @param backBuffer defines if the back buffer must be cleared
  10732. * @param depth defines if the depth buffer must be cleared
  10733. * @param stencil defines if the stencil buffer must be cleared
  10734. */
  10735. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10736. /**
  10737. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10738. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10739. * @param y defines the y-coordinate of the corner of the clear rectangle
  10740. * @param width defines the width of the clear rectangle
  10741. * @param height defines the height of the clear rectangle
  10742. * @param clearColor defines the clear color
  10743. */
  10744. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10745. private _viewportCached;
  10746. /** @hidden */
  10747. _viewport(x: number, y: number, width: number, height: number): void;
  10748. /**
  10749. * Set the WebGL's viewport
  10750. * @param viewport defines the viewport element to be used
  10751. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10752. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10753. */
  10754. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10755. /**
  10756. * Directly set the WebGL Viewport
  10757. * @param x defines the x coordinate of the viewport (in screen space)
  10758. * @param y defines the y coordinate of the viewport (in screen space)
  10759. * @param width defines the width of the viewport (in screen space)
  10760. * @param height defines the height of the viewport (in screen space)
  10761. * @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
  10762. */
  10763. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10764. /**
  10765. * Begin a new frame
  10766. */
  10767. beginFrame(): void;
  10768. /**
  10769. * Enf the current frame
  10770. */
  10771. endFrame(): void;
  10772. /**
  10773. * Resize the view according to the canvas' size
  10774. */
  10775. resize(): void;
  10776. /**
  10777. * Force a specific size of the canvas
  10778. * @param width defines the new canvas' width
  10779. * @param height defines the new canvas' height
  10780. */
  10781. setSize(width: number, height: number): void;
  10782. /**
  10783. * Gets a boolean indicating if a webVR device was detected
  10784. * @returns true if a webVR device was detected
  10785. */
  10786. isVRDevicePresent(): boolean;
  10787. /**
  10788. * Gets the current webVR device
  10789. * @returns the current webVR device (or null)
  10790. */
  10791. getVRDevice(): any;
  10792. /**
  10793. * Initializes a webVR display and starts listening to display change events
  10794. * The onVRDisplayChangedObservable will be notified upon these changes
  10795. * @returns The onVRDisplayChangedObservable
  10796. */
  10797. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10798. /**
  10799. * Initializes a webVR display and starts listening to display change events
  10800. * The onVRDisplayChangedObservable will be notified upon these changes
  10801. * @returns A promise containing a VRDisplay and if vr is supported
  10802. */
  10803. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10804. /**
  10805. * Call this function to switch to webVR mode
  10806. * Will do nothing if webVR is not supported or if there is no webVR device
  10807. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10808. */
  10809. enableVR(): void;
  10810. /**
  10811. * Call this function to leave webVR mode
  10812. * Will do nothing if webVR is not supported or if there is no webVR device
  10813. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10814. */
  10815. disableVR(): void;
  10816. private _onVRFullScreenTriggered;
  10817. private _getVRDisplaysAsync;
  10818. /**
  10819. * Binds the frame buffer to the specified texture.
  10820. * @param texture The texture to render to or null for the default canvas
  10821. * @param faceIndex The face of the texture to render to in case of cube texture
  10822. * @param requiredWidth The width of the target to render to
  10823. * @param requiredHeight The height of the target to render to
  10824. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10825. * @param depthStencilTexture The depth stencil texture to use to render
  10826. * @param lodLevel defines le lod level to bind to the frame buffer
  10827. */
  10828. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10829. private bindUnboundFramebuffer;
  10830. /**
  10831. * Unbind the current render target texture from the webGL context
  10832. * @param texture defines the render target texture to unbind
  10833. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10834. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10835. */
  10836. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10837. /**
  10838. * Unbind a list of render target textures from the webGL context
  10839. * This is used only when drawBuffer extension or webGL2 are active
  10840. * @param textures defines the render target textures to unbind
  10841. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10842. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10843. */
  10844. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10845. /**
  10846. * Force the mipmap generation for the given render target texture
  10847. * @param texture defines the render target texture to use
  10848. */
  10849. generateMipMapsForCubemap(texture: InternalTexture): void;
  10850. /**
  10851. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10852. */
  10853. flushFramebuffer(): void;
  10854. /**
  10855. * Unbind the current render target and bind the default framebuffer
  10856. */
  10857. restoreDefaultFramebuffer(): void;
  10858. /**
  10859. * Create an uniform buffer
  10860. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10861. * @param elements defines the content of the uniform buffer
  10862. * @returns the webGL uniform buffer
  10863. */
  10864. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10865. /**
  10866. * Create a dynamic uniform buffer
  10867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10868. * @param elements defines the content of the uniform buffer
  10869. * @returns the webGL uniform buffer
  10870. */
  10871. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10872. /**
  10873. * Update an existing uniform buffer
  10874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10875. * @param uniformBuffer defines the target uniform buffer
  10876. * @param elements defines the content to update
  10877. * @param offset defines the offset in the uniform buffer where update should start
  10878. * @param count defines the size of the data to update
  10879. */
  10880. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10881. private _resetVertexBufferBinding;
  10882. /**
  10883. * Creates a vertex buffer
  10884. * @param data the data for the vertex buffer
  10885. * @returns the new WebGL static buffer
  10886. */
  10887. createVertexBuffer(data: DataArray): WebGLBuffer;
  10888. /**
  10889. * Creates a dynamic vertex buffer
  10890. * @param data the data for the dynamic vertex buffer
  10891. * @returns the new WebGL dynamic buffer
  10892. */
  10893. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10894. /**
  10895. * Update a dynamic index buffer
  10896. * @param indexBuffer defines the target index buffer
  10897. * @param indices defines the data to update
  10898. * @param offset defines the offset in the target index buffer where update should start
  10899. */
  10900. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10901. /**
  10902. * Updates a dynamic vertex buffer.
  10903. * @param vertexBuffer the vertex buffer to update
  10904. * @param data the data used to update the vertex buffer
  10905. * @param byteOffset the byte offset of the data
  10906. * @param byteLength the byte length of the data
  10907. */
  10908. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10909. private _resetIndexBufferBinding;
  10910. /**
  10911. * Creates a new index buffer
  10912. * @param indices defines the content of the index buffer
  10913. * @param updatable defines if the index buffer must be updatable
  10914. * @returns a new webGL buffer
  10915. */
  10916. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10917. /**
  10918. * Bind a webGL buffer to the webGL context
  10919. * @param buffer defines the buffer to bind
  10920. */
  10921. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10922. /**
  10923. * Bind an uniform buffer to the current webGL context
  10924. * @param buffer defines the buffer to bind
  10925. */
  10926. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10927. /**
  10928. * Bind a buffer to the current webGL context at a given location
  10929. * @param buffer defines the buffer to bind
  10930. * @param location defines the index where to bind the buffer
  10931. */
  10932. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10933. /**
  10934. * Bind a specific block at a given index in a specific shader program
  10935. * @param shaderProgram defines the shader program
  10936. * @param blockName defines the block name
  10937. * @param index defines the index where to bind the block
  10938. */
  10939. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10940. private bindIndexBuffer;
  10941. private bindBuffer;
  10942. /**
  10943. * update the bound buffer with the given data
  10944. * @param data defines the data to update
  10945. */
  10946. updateArrayBuffer(data: Float32Array): void;
  10947. private _vertexAttribPointer;
  10948. private _bindIndexBufferWithCache;
  10949. private _bindVertexBuffersAttributes;
  10950. /**
  10951. * Records a vertex array object
  10952. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10953. * @param vertexBuffers defines the list of vertex buffers to store
  10954. * @param indexBuffer defines the index buffer to store
  10955. * @param effect defines the effect to store
  10956. * @returns the new vertex array object
  10957. */
  10958. recordVertexArrayObject(vertexBuffers: {
  10959. [key: string]: VertexBuffer;
  10960. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10961. /**
  10962. * Bind a specific vertex array object
  10963. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10964. * @param vertexArrayObject defines the vertex array object to bind
  10965. * @param indexBuffer defines the index buffer to bind
  10966. */
  10967. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10968. /**
  10969. * Bind webGl buffers directly to the webGL context
  10970. * @param vertexBuffer defines the vertex buffer to bind
  10971. * @param indexBuffer defines the index buffer to bind
  10972. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10973. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10974. * @param effect defines the effect associated with the vertex buffer
  10975. */
  10976. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10977. private _unbindVertexArrayObject;
  10978. /**
  10979. * Bind a list of vertex buffers to the webGL context
  10980. * @param vertexBuffers defines the list of vertex buffers to bind
  10981. * @param indexBuffer defines the index buffer to bind
  10982. * @param effect defines the effect associated with the vertex buffers
  10983. */
  10984. bindBuffers(vertexBuffers: {
  10985. [key: string]: Nullable<VertexBuffer>;
  10986. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10987. /**
  10988. * Unbind all instance attributes
  10989. */
  10990. unbindInstanceAttributes(): void;
  10991. /**
  10992. * Release and free the memory of a vertex array object
  10993. * @param vao defines the vertex array object to delete
  10994. */
  10995. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10996. /** @hidden */
  10997. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10998. /**
  10999. * Creates a webGL buffer to use with instanciation
  11000. * @param capacity defines the size of the buffer
  11001. * @returns the webGL buffer
  11002. */
  11003. createInstancesBuffer(capacity: number): WebGLBuffer;
  11004. /**
  11005. * Delete a webGL buffer used with instanciation
  11006. * @param buffer defines the webGL buffer to delete
  11007. */
  11008. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11009. /**
  11010. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11011. * @param instancesBuffer defines the webGL buffer to update and bind
  11012. * @param data defines the data to store in the buffer
  11013. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11014. */
  11015. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11016. /**
  11017. * Apply all cached states (depth, culling, stencil and alpha)
  11018. */
  11019. applyStates(): void;
  11020. /**
  11021. * Send a draw order
  11022. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11023. * @param indexStart defines the starting index
  11024. * @param indexCount defines the number of index to draw
  11025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11026. */
  11027. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11028. /**
  11029. * Draw a list of points
  11030. * @param verticesStart defines the index of first vertex to draw
  11031. * @param verticesCount defines the count of vertices to draw
  11032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11033. */
  11034. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11035. /**
  11036. * Draw a list of unindexed primitives
  11037. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11038. * @param verticesStart defines the index of first vertex to draw
  11039. * @param verticesCount defines the count of vertices to draw
  11040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11041. */
  11042. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11043. /**
  11044. * Draw a list of indexed primitives
  11045. * @param fillMode defines the primitive to use
  11046. * @param indexStart defines the starting index
  11047. * @param indexCount defines the number of index to draw
  11048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11049. */
  11050. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11051. /**
  11052. * Draw a list of unindexed primitives
  11053. * @param fillMode defines the primitive to use
  11054. * @param verticesStart defines the index of first vertex to draw
  11055. * @param verticesCount defines the count of vertices to draw
  11056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11057. */
  11058. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11059. private _drawMode;
  11060. /** @hidden */
  11061. _releaseEffect(effect: Effect): void;
  11062. /** @hidden */
  11063. _deleteProgram(program: WebGLProgram): void;
  11064. /**
  11065. * Create a new effect (used to store vertex/fragment shaders)
  11066. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11067. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11068. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11069. * @param samplers defines an array of string used to represent textures
  11070. * @param defines defines the string containing the defines to use to compile the shaders
  11071. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11072. * @param onCompiled defines a function to call when the effect creation is successful
  11073. * @param onError defines a function to call when the effect creation has failed
  11074. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11075. * @returns the new Effect
  11076. */
  11077. 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;
  11078. private _compileShader;
  11079. private _compileRawShader;
  11080. /**
  11081. * Directly creates a webGL program
  11082. * @param vertexCode defines the vertex shader code to use
  11083. * @param fragmentCode defines the fragment shader code to use
  11084. * @param context defines the webGL context to use (if not set, the current one will be used)
  11085. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11086. * @returns the new webGL program
  11087. */
  11088. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11089. /**
  11090. * Creates a webGL program
  11091. * @param vertexCode defines the vertex shader code to use
  11092. * @param fragmentCode defines the fragment shader code to use
  11093. * @param defines defines the string containing the defines to use to compile the shaders
  11094. * @param context defines the webGL context to use (if not set, the current one will be used)
  11095. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11096. * @returns the new webGL program
  11097. */
  11098. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11099. private _createShaderProgram;
  11100. private _finalizeProgram;
  11101. /** @hidden */
  11102. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11103. /** @hidden */
  11104. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11105. /**
  11106. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11107. * @param shaderProgram defines the webGL program to use
  11108. * @param uniformsNames defines the list of uniform names
  11109. * @returns an array of webGL uniform locations
  11110. */
  11111. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11112. /**
  11113. * Gets the lsit of active attributes for a given webGL program
  11114. * @param shaderProgram defines the webGL program to use
  11115. * @param attributesNames defines the list of attribute names to get
  11116. * @returns an array of indices indicating the offset of each attribute
  11117. */
  11118. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11119. /**
  11120. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11121. * @param effect defines the effect to activate
  11122. */
  11123. enableEffect(effect: Nullable<Effect>): void;
  11124. /**
  11125. * Set the value of an uniform to an array of int32
  11126. * @param uniform defines the webGL uniform location where to store the value
  11127. * @param array defines the array of int32 to store
  11128. */
  11129. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11130. /**
  11131. * Set the value of an uniform to an array of int32 (stored as vec2)
  11132. * @param uniform defines the webGL uniform location where to store the value
  11133. * @param array defines the array of int32 to store
  11134. */
  11135. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11136. /**
  11137. * Set the value of an uniform to an array of int32 (stored as vec3)
  11138. * @param uniform defines the webGL uniform location where to store the value
  11139. * @param array defines the array of int32 to store
  11140. */
  11141. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11142. /**
  11143. * Set the value of an uniform to an array of int32 (stored as vec4)
  11144. * @param uniform defines the webGL uniform location where to store the value
  11145. * @param array defines the array of int32 to store
  11146. */
  11147. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11148. /**
  11149. * Set the value of an uniform to an array of float32
  11150. * @param uniform defines the webGL uniform location where to store the value
  11151. * @param array defines the array of float32 to store
  11152. */
  11153. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11154. /**
  11155. * Set the value of an uniform to an array of float32 (stored as vec2)
  11156. * @param uniform defines the webGL uniform location where to store the value
  11157. * @param array defines the array of float32 to store
  11158. */
  11159. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11160. /**
  11161. * Set the value of an uniform to an array of float32 (stored as vec3)
  11162. * @param uniform defines the webGL uniform location where to store the value
  11163. * @param array defines the array of float32 to store
  11164. */
  11165. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11166. /**
  11167. * Set the value of an uniform to an array of float32 (stored as vec4)
  11168. * @param uniform defines the webGL uniform location where to store the value
  11169. * @param array defines the array of float32 to store
  11170. */
  11171. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11172. /**
  11173. * Set the value of an uniform to an array of number
  11174. * @param uniform defines the webGL uniform location where to store the value
  11175. * @param array defines the array of number to store
  11176. */
  11177. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11178. /**
  11179. * Set the value of an uniform to an array of number (stored as vec2)
  11180. * @param uniform defines the webGL uniform location where to store the value
  11181. * @param array defines the array of number to store
  11182. */
  11183. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11184. /**
  11185. * Set the value of an uniform to an array of number (stored as vec3)
  11186. * @param uniform defines the webGL uniform location where to store the value
  11187. * @param array defines the array of number to store
  11188. */
  11189. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11190. /**
  11191. * Set the value of an uniform to an array of number (stored as vec4)
  11192. * @param uniform defines the webGL uniform location where to store the value
  11193. * @param array defines the array of number to store
  11194. */
  11195. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11196. /**
  11197. * Set the value of an uniform to an array of float32 (stored as matrices)
  11198. * @param uniform defines the webGL uniform location where to store the value
  11199. * @param matrices defines the array of float32 to store
  11200. */
  11201. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11202. /**
  11203. * Set the value of an uniform to a matrix
  11204. * @param uniform defines the webGL uniform location where to store the value
  11205. * @param matrix defines the matrix to store
  11206. */
  11207. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11208. /**
  11209. * Set the value of an uniform to a matrix (3x3)
  11210. * @param uniform defines the webGL uniform location where to store the value
  11211. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11212. */
  11213. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11214. /**
  11215. * Set the value of an uniform to a matrix (2x2)
  11216. * @param uniform defines the webGL uniform location where to store the value
  11217. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11218. */
  11219. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11220. /**
  11221. * Set the value of an uniform to a number (int)
  11222. * @param uniform defines the webGL uniform location where to store the value
  11223. * @param value defines the int number to store
  11224. */
  11225. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11226. /**
  11227. * Set the value of an uniform to a number (float)
  11228. * @param uniform defines the webGL uniform location where to store the value
  11229. * @param value defines the float number to store
  11230. */
  11231. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11232. /**
  11233. * Set the value of an uniform to a vec2
  11234. * @param uniform defines the webGL uniform location where to store the value
  11235. * @param x defines the 1st component of the value
  11236. * @param y defines the 2nd component of the value
  11237. */
  11238. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11239. /**
  11240. * Set the value of an uniform to a vec3
  11241. * @param uniform defines the webGL uniform location where to store the value
  11242. * @param x defines the 1st component of the value
  11243. * @param y defines the 2nd component of the value
  11244. * @param z defines the 3rd component of the value
  11245. */
  11246. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11247. /**
  11248. * Set the value of an uniform to a boolean
  11249. * @param uniform defines the webGL uniform location where to store the value
  11250. * @param bool defines the boolean to store
  11251. */
  11252. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11253. /**
  11254. * Set the value of an uniform to a vec4
  11255. * @param uniform defines the webGL uniform location where to store the value
  11256. * @param x defines the 1st component of the value
  11257. * @param y defines the 2nd component of the value
  11258. * @param z defines the 3rd component of the value
  11259. * @param w defines the 4th component of the value
  11260. */
  11261. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11262. /**
  11263. * Set the value of an uniform to a Color3
  11264. * @param uniform defines the webGL uniform location where to store the value
  11265. * @param color3 defines the color to store
  11266. */
  11267. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11268. /**
  11269. * Set the value of an uniform to a Color3 and an alpha value
  11270. * @param uniform defines the webGL uniform location where to store the value
  11271. * @param color3 defines the color to store
  11272. * @param alpha defines the alpha component to store
  11273. */
  11274. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11275. /**
  11276. * Sets a Color4 on a uniform variable
  11277. * @param uniform defines the uniform location
  11278. * @param color4 defines the value to be set
  11279. */
  11280. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11281. /**
  11282. * Set various states to the webGL context
  11283. * @param culling defines backface culling state
  11284. * @param zOffset defines the value to apply to zOffset (0 by default)
  11285. * @param force defines if states must be applied even if cache is up to date
  11286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11287. */
  11288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11289. /**
  11290. * Set the z offset to apply to current rendering
  11291. * @param value defines the offset to apply
  11292. */
  11293. setZOffset(value: number): void;
  11294. /**
  11295. * Gets the current value of the zOffset
  11296. * @returns the current zOffset state
  11297. */
  11298. getZOffset(): number;
  11299. /**
  11300. * Enable or disable depth buffering
  11301. * @param enable defines the state to set
  11302. */
  11303. setDepthBuffer(enable: boolean): void;
  11304. /**
  11305. * Gets a boolean indicating if depth writing is enabled
  11306. * @returns the current depth writing state
  11307. */
  11308. getDepthWrite(): boolean;
  11309. /**
  11310. * Enable or disable depth writing
  11311. * @param enable defines the state to set
  11312. */
  11313. setDepthWrite(enable: boolean): void;
  11314. /**
  11315. * Enable or disable color writing
  11316. * @param enable defines the state to set
  11317. */
  11318. setColorWrite(enable: boolean): void;
  11319. /**
  11320. * Gets a boolean indicating if color writing is enabled
  11321. * @returns the current color writing state
  11322. */
  11323. getColorWrite(): boolean;
  11324. /**
  11325. * Sets alpha constants used by some alpha blending modes
  11326. * @param r defines the red component
  11327. * @param g defines the green component
  11328. * @param b defines the blue component
  11329. * @param a defines the alpha component
  11330. */
  11331. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11332. /**
  11333. * Sets the current alpha mode
  11334. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11335. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11337. */
  11338. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11339. /**
  11340. * Gets the current alpha mode
  11341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11342. * @returns the current alpha mode
  11343. */
  11344. getAlphaMode(): number;
  11345. /**
  11346. * Clears the list of texture accessible through engine.
  11347. * This can help preventing texture load conflict due to name collision.
  11348. */
  11349. clearInternalTexturesCache(): void;
  11350. /**
  11351. * Force the entire cache to be cleared
  11352. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11353. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11354. */
  11355. wipeCaches(bruteForce?: boolean): void;
  11356. /**
  11357. * Set the compressed texture format to use, based on the formats you have, and the formats
  11358. * supported by the hardware / browser.
  11359. *
  11360. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11361. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11362. * to API arguments needed to compressed textures. This puts the burden on the container
  11363. * generator to house the arcane code for determining these for current & future formats.
  11364. *
  11365. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11366. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11367. *
  11368. * Note: The result of this call is not taken into account when a texture is base64.
  11369. *
  11370. * @param formatsAvailable defines the list of those format families you have created
  11371. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11372. *
  11373. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11374. * @returns The extension selected.
  11375. */
  11376. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11377. private _getSamplingParameters;
  11378. private _partialLoadImg;
  11379. private _cascadeLoadImgs;
  11380. /** @hidden */
  11381. _createTexture(): WebGLTexture;
  11382. /**
  11383. * Usually called from BABYLON.Texture.ts.
  11384. * Passed information to create a WebGLTexture
  11385. * @param urlArg defines a value which contains one of the following:
  11386. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11387. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11388. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11389. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11390. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11391. * @param scene needed for loading to the correct scene
  11392. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11393. * @param onLoad optional callback to be called upon successful completion
  11394. * @param onError optional callback to be called upon failure
  11395. * @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
  11396. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11397. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11398. * @param forcedExtension defines the extension to use to pick the right loader
  11399. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11400. */
  11401. 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;
  11402. private _rescaleTexture;
  11403. /**
  11404. * Update a raw texture
  11405. * @param texture defines the texture to update
  11406. * @param data defines the data to store in the texture
  11407. * @param format defines the format of the data
  11408. * @param invertY defines if data must be stored with Y axis inverted
  11409. * @param compression defines the compression used (null by default)
  11410. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11411. */
  11412. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11413. /**
  11414. * Creates a raw texture
  11415. * @param data defines the data to store in the texture
  11416. * @param width defines the width of the texture
  11417. * @param height defines the height of the texture
  11418. * @param format defines the format of the data
  11419. * @param generateMipMaps defines if the engine should generate the mip levels
  11420. * @param invertY defines if data must be stored with Y axis inverted
  11421. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11422. * @param compression defines the compression used (null by default)
  11423. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11424. * @returns the raw texture inside an InternalTexture
  11425. */
  11426. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11427. private _unpackFlipYCached;
  11428. /**
  11429. * In case you are sharing the context with other applications, it might
  11430. * be interested to not cache the unpack flip y state to ensure a consistent
  11431. * value would be set.
  11432. */
  11433. enableUnpackFlipYCached: boolean;
  11434. /** @hidden */
  11435. _unpackFlipY(value: boolean): void;
  11436. /** @hidden */
  11437. _getUnpackAlignement(): number;
  11438. /**
  11439. * Creates a dynamic texture
  11440. * @param width defines the width of the texture
  11441. * @param height defines the height of the texture
  11442. * @param generateMipMaps defines if the engine should generate the mip levels
  11443. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11444. * @returns the dynamic texture inside an InternalTexture
  11445. */
  11446. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11447. /**
  11448. * Update the sampling mode of a given texture
  11449. * @param samplingMode defines the required sampling mode
  11450. * @param texture defines the texture to update
  11451. */
  11452. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11453. /**
  11454. * Update the content of a dynamic texture
  11455. * @param texture defines the texture to update
  11456. * @param canvas defines the canvas containing the source
  11457. * @param invertY defines if data must be stored with Y axis inverted
  11458. * @param premulAlpha defines if alpha is stored as premultiplied
  11459. * @param format defines the format of the data
  11460. */
  11461. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11462. /**
  11463. * Update a video texture
  11464. * @param texture defines the texture to update
  11465. * @param video defines the video element to use
  11466. * @param invertY defines if data must be stored with Y axis inverted
  11467. */
  11468. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11469. /**
  11470. * Updates a depth texture Comparison Mode and Function.
  11471. * If the comparison Function is equal to 0, the mode will be set to none.
  11472. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11473. * @param texture The texture to set the comparison function for
  11474. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11475. */
  11476. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11477. private _setupDepthStencilTexture;
  11478. /**
  11479. * Creates a depth stencil texture.
  11480. * This is only available in WebGL 2 or with the depth texture extension available.
  11481. * @param size The size of face edge in the texture.
  11482. * @param options The options defining the texture.
  11483. * @returns The texture
  11484. */
  11485. createDepthStencilTexture(size: number | {
  11486. width: number;
  11487. height: number;
  11488. }, options: DepthTextureCreationOptions): InternalTexture;
  11489. /**
  11490. * Creates a depth stencil texture.
  11491. * This is only available in WebGL 2 or with the depth texture extension available.
  11492. * @param size The size of face edge in the texture.
  11493. * @param options The options defining the texture.
  11494. * @returns The texture
  11495. */
  11496. private _createDepthStencilTexture;
  11497. /**
  11498. * Creates a depth stencil cube texture.
  11499. * This is only available in WebGL 2.
  11500. * @param size The size of face edge in the cube texture.
  11501. * @param options The options defining the cube texture.
  11502. * @returns The cube texture
  11503. */
  11504. private _createDepthStencilCubeTexture;
  11505. /**
  11506. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11507. * @param renderTarget The render target to set the frame buffer for
  11508. */
  11509. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11510. /**
  11511. * Creates a new render target texture
  11512. * @param size defines the size of the texture
  11513. * @param options defines the options used to create the texture
  11514. * @returns a new render target texture stored in an InternalTexture
  11515. */
  11516. createRenderTargetTexture(size: number | {
  11517. width: number;
  11518. height: number;
  11519. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11520. /**
  11521. * Create a multi render target texture
  11522. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11523. * @param size defines the size of the texture
  11524. * @param options defines the creation options
  11525. * @returns the cube texture as an InternalTexture
  11526. */
  11527. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11528. private _setupFramebufferDepthAttachments;
  11529. /**
  11530. * Updates the sample count of a render target texture
  11531. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11532. * @param texture defines the texture to update
  11533. * @param samples defines the sample count to set
  11534. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11535. */
  11536. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11537. /**
  11538. * Update the sample count for a given multiple render target texture
  11539. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11540. * @param textures defines the textures to update
  11541. * @param samples defines the sample count to set
  11542. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11543. */
  11544. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11545. /** @hidden */
  11546. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11547. /** @hidden */
  11548. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11549. /** @hidden */
  11550. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11551. /** @hidden */
  11552. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11553. /**
  11554. * Creates a new render target cube texture
  11555. * @param size defines the size of the texture
  11556. * @param options defines the options used to create the texture
  11557. * @returns a new render target cube texture stored in an InternalTexture
  11558. */
  11559. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11560. /**
  11561. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11562. * @param rootUrl defines the url where the file to load is located
  11563. * @param scene defines the current scene
  11564. * @param lodScale defines scale to apply to the mip map selection
  11565. * @param lodOffset defines offset to apply to the mip map selection
  11566. * @param onLoad defines an optional callback raised when the texture is loaded
  11567. * @param onError defines an optional callback raised if there is an issue to load the texture
  11568. * @param format defines the format of the data
  11569. * @param forcedExtension defines the extension to use to pick the right loader
  11570. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11571. * @returns the cube texture as an InternalTexture
  11572. */
  11573. 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;
  11574. /**
  11575. * Creates a cube texture
  11576. * @param rootUrl defines the url where the files to load is located
  11577. * @param scene defines the current scene
  11578. * @param files defines the list of files to load (1 per face)
  11579. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11580. * @param onLoad defines an optional callback raised when the texture is loaded
  11581. * @param onError defines an optional callback raised if there is an issue to load the texture
  11582. * @param format defines the format of the data
  11583. * @param forcedExtension defines the extension to use to pick the right loader
  11584. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11585. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11586. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11587. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11588. * @returns the cube texture as an InternalTexture
  11589. */
  11590. 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;
  11591. /**
  11592. * @hidden
  11593. */
  11594. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11595. /**
  11596. * Update a raw cube texture
  11597. * @param texture defines the texture to udpdate
  11598. * @param data defines the data to store
  11599. * @param format defines the data format
  11600. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11601. * @param invertY defines if data must be stored with Y axis inverted
  11602. * @param compression defines the compression used (null by default)
  11603. * @param level defines which level of the texture to update
  11604. */
  11605. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11606. /**
  11607. * Creates a new raw cube texture
  11608. * @param data defines the array of data to use to create each face
  11609. * @param size defines the size of the textures
  11610. * @param format defines the format of the data
  11611. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11612. * @param generateMipMaps defines if the engine should generate the mip levels
  11613. * @param invertY defines if data must be stored with Y axis inverted
  11614. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11615. * @param compression defines the compression used (null by default)
  11616. * @returns the cube texture as an InternalTexture
  11617. */
  11618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11619. /**
  11620. * Creates a new raw cube texture from a specified url
  11621. * @param url defines the url where the data is located
  11622. * @param scene defines the current scene
  11623. * @param size defines the size of the textures
  11624. * @param format defines the format of the data
  11625. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11626. * @param noMipmap defines if the engine should avoid generating the mip levels
  11627. * @param callback defines a callback used to extract texture data from loaded data
  11628. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11629. * @param onLoad defines a callback called when texture is loaded
  11630. * @param onError defines a callback called if there is an error
  11631. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11632. * @param invertY defines if data must be stored with Y axis inverted
  11633. * @returns the cube texture as an InternalTexture
  11634. */
  11635. 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;
  11636. /**
  11637. * Update a raw 3D texture
  11638. * @param texture defines the texture to update
  11639. * @param data defines the data to store
  11640. * @param format defines the data format
  11641. * @param invertY defines if data must be stored with Y axis inverted
  11642. * @param compression defines the used compression (can be null)
  11643. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11644. */
  11645. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11646. /**
  11647. * Creates a new raw 3D texture
  11648. * @param data defines the data used to create the texture
  11649. * @param width defines the width of the texture
  11650. * @param height defines the height of the texture
  11651. * @param depth defines the depth of the texture
  11652. * @param format defines the format of the texture
  11653. * @param generateMipMaps defines if the engine must generate mip levels
  11654. * @param invertY defines if data must be stored with Y axis inverted
  11655. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11656. * @param compression defines the compressed used (can be null)
  11657. * @param textureType defines the compressed used (can be null)
  11658. * @returns a new raw 3D texture (stored in an InternalTexture)
  11659. */
  11660. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11661. private _prepareWebGLTextureContinuation;
  11662. private _prepareWebGLTexture;
  11663. private _convertRGBtoRGBATextureData;
  11664. /** @hidden */
  11665. _releaseFramebufferObjects(texture: InternalTexture): void;
  11666. /** @hidden */
  11667. _releaseTexture(texture: InternalTexture): void;
  11668. private setProgram;
  11669. private _boundUniforms;
  11670. /**
  11671. * Binds an effect to the webGL context
  11672. * @param effect defines the effect to bind
  11673. */
  11674. bindSamplers(effect: Effect): void;
  11675. private _moveBoundTextureOnTop;
  11676. private _getCorrectTextureChannel;
  11677. private _linkTrackers;
  11678. private _removeDesignatedSlot;
  11679. private _activateCurrentTexture;
  11680. /** @hidden */
  11681. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11682. /** @hidden */
  11683. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11684. /**
  11685. * Sets a texture to the webGL context from a postprocess
  11686. * @param channel defines the channel to use
  11687. * @param postProcess defines the source postprocess
  11688. */
  11689. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11690. /**
  11691. * Binds the output of the passed in post process to the texture channel specified
  11692. * @param channel The channel the texture should be bound to
  11693. * @param postProcess The post process which's output should be bound
  11694. */
  11695. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11696. /**
  11697. * Unbind all textures from the webGL context
  11698. */
  11699. unbindAllTextures(): void;
  11700. /**
  11701. * Sets a texture to the according uniform.
  11702. * @param channel The texture channel
  11703. * @param uniform The uniform to set
  11704. * @param texture The texture to apply
  11705. */
  11706. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11707. /**
  11708. * Sets a depth stencil texture from a render target to the according uniform.
  11709. * @param channel The texture channel
  11710. * @param uniform The uniform to set
  11711. * @param texture The render target texture containing the depth stencil texture to apply
  11712. */
  11713. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11714. private _bindSamplerUniformToChannel;
  11715. private _getTextureWrapMode;
  11716. private _setTexture;
  11717. /**
  11718. * Sets an array of texture to the webGL context
  11719. * @param channel defines the channel where the texture array must be set
  11720. * @param uniform defines the associated uniform location
  11721. * @param textures defines the array of textures to bind
  11722. */
  11723. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11724. /** @hidden */
  11725. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11726. private _setTextureParameterFloat;
  11727. private _setTextureParameterInteger;
  11728. /**
  11729. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11730. * @param x defines the x coordinate of the rectangle where pixels must be read
  11731. * @param y defines the y coordinate of the rectangle where pixels must be read
  11732. * @param width defines the width of the rectangle where pixels must be read
  11733. * @param height defines the height of the rectangle where pixels must be read
  11734. * @returns a Uint8Array containing RGBA colors
  11735. */
  11736. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11737. /**
  11738. * Add an externaly attached data from its key.
  11739. * This method call will fail and return false, if such key already exists.
  11740. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11741. * @param key the unique key that identifies the data
  11742. * @param data the data object to associate to the key for this Engine instance
  11743. * @return true if no such key were already present and the data was added successfully, false otherwise
  11744. */
  11745. addExternalData<T>(key: string, data: T): boolean;
  11746. /**
  11747. * Get an externaly attached data from its key
  11748. * @param key the unique key that identifies the data
  11749. * @return the associated data, if present (can be null), or undefined if not present
  11750. */
  11751. getExternalData<T>(key: string): T;
  11752. /**
  11753. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11754. * @param key the unique key that identifies the data
  11755. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11756. * @return the associated data, can be null if the factory returned null.
  11757. */
  11758. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11759. /**
  11760. * Remove an externaly attached data from the Engine instance
  11761. * @param key the unique key that identifies the data
  11762. * @return true if the data was successfully removed, false if it doesn't exist
  11763. */
  11764. removeExternalData(key: string): boolean;
  11765. /**
  11766. * Unbind all vertex attributes from the webGL context
  11767. */
  11768. unbindAllAttributes(): void;
  11769. /**
  11770. * 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
  11771. */
  11772. releaseEffects(): void;
  11773. /**
  11774. * Dispose and release all associated resources
  11775. */
  11776. dispose(): void;
  11777. /**
  11778. * Display the loading screen
  11779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11780. */
  11781. displayLoadingUI(): void;
  11782. /**
  11783. * Hide the loading screen
  11784. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11785. */
  11786. hideLoadingUI(): void;
  11787. /**
  11788. * Gets the current loading screen object
  11789. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11790. */
  11791. /**
  11792. * Sets the current loading screen object
  11793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11794. */
  11795. loadingScreen: ILoadingScreen;
  11796. /**
  11797. * Sets the current loading screen text
  11798. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11799. */
  11800. loadingUIText: string;
  11801. /**
  11802. * Sets the current loading screen background color
  11803. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11804. */
  11805. loadingUIBackgroundColor: string;
  11806. /**
  11807. * Attach a new callback raised when context lost event is fired
  11808. * @param callback defines the callback to call
  11809. */
  11810. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11811. /**
  11812. * Attach a new callback raised when context restored event is fired
  11813. * @param callback defines the callback to call
  11814. */
  11815. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11816. /**
  11817. * Gets the source code of the vertex shader associated with a specific webGL program
  11818. * @param program defines the program to use
  11819. * @returns a string containing the source code of the vertex shader associated with the program
  11820. */
  11821. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11822. /**
  11823. * Gets the source code of the fragment shader associated with a specific webGL program
  11824. * @param program defines the program to use
  11825. * @returns a string containing the source code of the fragment shader associated with the program
  11826. */
  11827. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11828. /**
  11829. * Get the current error code of the webGL context
  11830. * @returns the error code
  11831. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11832. */
  11833. getError(): number;
  11834. /**
  11835. * Gets the current framerate
  11836. * @returns a number representing the framerate
  11837. */
  11838. getFps(): number;
  11839. /**
  11840. * Gets the time spent between current and previous frame
  11841. * @returns a number representing the delta time in ms
  11842. */
  11843. getDeltaTime(): number;
  11844. private _measureFps;
  11845. /** @hidden */
  11846. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11847. private _canRenderToFloatFramebuffer;
  11848. private _canRenderToHalfFloatFramebuffer;
  11849. private _canRenderToFramebuffer;
  11850. /** @hidden */
  11851. _getWebGLTextureType(type: number): number;
  11852. private _getInternalFormat;
  11853. /** @hidden */
  11854. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11855. /** @hidden */
  11856. _getRGBAMultiSampleBufferFormat(type: number): number;
  11857. /** @hidden */
  11858. _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;
  11859. /** @hidden */
  11860. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11861. private _partialLoadFile;
  11862. private _cascadeLoadFiles;
  11863. /**
  11864. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11865. * @returns true if the engine can be created
  11866. * @ignorenaming
  11867. */
  11868. static isSupported(): boolean;
  11869. }
  11870. }
  11871. declare module BABYLON {
  11872. /**
  11873. * Options to create the null engine
  11874. */
  11875. class NullEngineOptions {
  11876. /**
  11877. * Render width (Default: 512)
  11878. */
  11879. renderWidth: number;
  11880. /**
  11881. * Render height (Default: 256)
  11882. */
  11883. renderHeight: number;
  11884. /**
  11885. * Texture size (Default: 512)
  11886. */
  11887. textureSize: number;
  11888. /**
  11889. * If delta time between frames should be constant
  11890. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11891. */
  11892. deterministicLockstep: boolean;
  11893. /**
  11894. * Maximum about of steps between frames (Default: 4)
  11895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11896. */
  11897. lockstepMaxSteps: number;
  11898. }
  11899. /**
  11900. * The null engine class provides support for headless version of babylon.js.
  11901. * This can be used in server side scenario or for testing purposes
  11902. */
  11903. class NullEngine extends Engine {
  11904. private _options;
  11905. /**
  11906. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11907. */
  11908. isDeterministicLockStep(): boolean;
  11909. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11910. getLockstepMaxSteps(): number;
  11911. /**
  11912. * Sets hardware scaling, used to save performance if needed
  11913. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11914. */
  11915. getHardwareScalingLevel(): number;
  11916. constructor(options?: NullEngineOptions);
  11917. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11918. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11919. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11920. getRenderWidth(useScreen?: boolean): number;
  11921. getRenderHeight(useScreen?: boolean): number;
  11922. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11923. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11924. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11925. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11926. bindSamplers(effect: Effect): void;
  11927. enableEffect(effect: Effect): void;
  11928. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11929. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11930. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11931. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11932. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11933. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11934. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11935. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11936. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11937. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11938. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11939. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11940. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11941. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11942. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11943. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11944. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11945. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11946. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11947. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11948. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11949. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11950. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11951. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11952. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11953. bindBuffers(vertexBuffers: {
  11954. [key: string]: VertexBuffer;
  11955. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11956. wipeCaches(bruteForce?: boolean): void;
  11957. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11958. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11959. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11960. /** @hidden */
  11961. _createTexture(): WebGLTexture;
  11962. /** @hidden */
  11963. _releaseTexture(texture: InternalTexture): void;
  11964. 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;
  11965. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11966. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11967. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11968. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11969. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11970. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11971. areAllEffectsReady(): boolean;
  11972. /**
  11973. * @hidden
  11974. * Get the current error code of the webGL context
  11975. * @returns the error code
  11976. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11977. */
  11978. getError(): number;
  11979. /** @hidden */
  11980. _getUnpackAlignement(): number;
  11981. /** @hidden */
  11982. _unpackFlipY(value: boolean): void;
  11983. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11984. /**
  11985. * Updates a dynamic vertex buffer.
  11986. * @param vertexBuffer the vertex buffer to update
  11987. * @param data the data used to update the vertex buffer
  11988. * @param byteOffset the byte offset of the data (optional)
  11989. * @param byteLength the byte length of the data (optional)
  11990. */
  11991. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11992. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11993. /** @hidden */
  11994. _bindTexture(channel: number, texture: InternalTexture): void;
  11995. /** @hidden */
  11996. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11997. releaseEffects(): void;
  11998. displayLoadingUI(): void;
  11999. hideLoadingUI(): void;
  12000. /** @hidden */
  12001. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12002. /** @hidden */
  12003. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12004. /** @hidden */
  12005. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12006. /** @hidden */
  12007. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12008. }
  12009. }
  12010. interface WebGLRenderingContext {
  12011. readonly RASTERIZER_DISCARD: number;
  12012. readonly DEPTH_COMPONENT24: number;
  12013. readonly TEXTURE_3D: number;
  12014. readonly TEXTURE_2D_ARRAY: number;
  12015. readonly TEXTURE_COMPARE_FUNC: number;
  12016. readonly TEXTURE_COMPARE_MODE: number;
  12017. readonly COMPARE_REF_TO_TEXTURE: number;
  12018. readonly TEXTURE_WRAP_R: number;
  12019. readonly HALF_FLOAT: number;
  12020. readonly RGB8: number;
  12021. readonly RED_INTEGER: number;
  12022. readonly RG_INTEGER: number;
  12023. readonly RGB_INTEGER: number;
  12024. readonly RGBA_INTEGER: number;
  12025. readonly R8_SNORM: number;
  12026. readonly RG8_SNORM: number;
  12027. readonly RGB8_SNORM: number;
  12028. readonly RGBA8_SNORM: number;
  12029. readonly R8I: number;
  12030. readonly RG8I: number;
  12031. readonly RGB8I: number;
  12032. readonly RGBA8I: number;
  12033. readonly R8UI: number;
  12034. readonly RG8UI: number;
  12035. readonly RGB8UI: number;
  12036. readonly RGBA8UI: number;
  12037. readonly R16I: number;
  12038. readonly RG16I: number;
  12039. readonly RGB16I: number;
  12040. readonly RGBA16I: number;
  12041. readonly R16UI: number;
  12042. readonly RG16UI: number;
  12043. readonly RGB16UI: number;
  12044. readonly RGBA16UI: number;
  12045. readonly R32I: number;
  12046. readonly RG32I: number;
  12047. readonly RGB32I: number;
  12048. readonly RGBA32I: number;
  12049. readonly R32UI: number;
  12050. readonly RG32UI: number;
  12051. readonly RGB32UI: number;
  12052. readonly RGBA32UI: number;
  12053. readonly RGB10_A2UI: number;
  12054. readonly R11F_G11F_B10F: number;
  12055. readonly RGB9_E5: number;
  12056. readonly RGB10_A2: number;
  12057. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12058. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12059. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12060. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12061. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12062. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12063. 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;
  12064. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12065. readonly TRANSFORM_FEEDBACK: number;
  12066. readonly INTERLEAVED_ATTRIBS: number;
  12067. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12068. createTransformFeedback(): WebGLTransformFeedback;
  12069. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12070. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12071. beginTransformFeedback(primitiveMode: number): void;
  12072. endTransformFeedback(): void;
  12073. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12074. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12075. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12076. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12077. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12078. }
  12079. interface ImageBitmap {
  12080. readonly width: number;
  12081. readonly height: number;
  12082. close(): void;
  12083. }
  12084. interface WebGLQuery extends WebGLObject {
  12085. }
  12086. declare var WebGLQuery: {
  12087. prototype: WebGLQuery;
  12088. new (): WebGLQuery;
  12089. };
  12090. interface WebGLSampler extends WebGLObject {
  12091. }
  12092. declare var WebGLSampler: {
  12093. prototype: WebGLSampler;
  12094. new (): WebGLSampler;
  12095. };
  12096. interface WebGLSync extends WebGLObject {
  12097. }
  12098. declare var WebGLSync: {
  12099. prototype: WebGLSync;
  12100. new (): WebGLSync;
  12101. };
  12102. interface WebGLTransformFeedback extends WebGLObject {
  12103. }
  12104. declare var WebGLTransformFeedback: {
  12105. prototype: WebGLTransformFeedback;
  12106. new (): WebGLTransformFeedback;
  12107. };
  12108. interface WebGLVertexArrayObject extends WebGLObject {
  12109. }
  12110. declare var WebGLVertexArrayObject: {
  12111. prototype: WebGLVertexArrayObject;
  12112. new (): WebGLVertexArrayObject;
  12113. };
  12114. declare module BABYLON {
  12115. /**
  12116. * Gather the list of keyboard event types as constants.
  12117. */
  12118. class KeyboardEventTypes {
  12119. /**
  12120. * The keydown event is fired when a key becomes active (pressed).
  12121. */
  12122. static readonly KEYDOWN: number;
  12123. /**
  12124. * The keyup event is fired when a key has been released.
  12125. */
  12126. static readonly KEYUP: number;
  12127. }
  12128. /**
  12129. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12130. */
  12131. class KeyboardInfo {
  12132. /**
  12133. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12134. */
  12135. type: number;
  12136. /**
  12137. * Defines the related dom event
  12138. */
  12139. event: KeyboardEvent;
  12140. /**
  12141. * Instantiates a new keyboard info.
  12142. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12143. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12144. * @param event Defines the related dom event
  12145. */
  12146. constructor(
  12147. /**
  12148. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12149. */
  12150. type: number,
  12151. /**
  12152. * Defines the related dom event
  12153. */
  12154. event: KeyboardEvent);
  12155. }
  12156. /**
  12157. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12158. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12159. */
  12160. class KeyboardInfoPre extends KeyboardInfo {
  12161. /**
  12162. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12163. */
  12164. type: number;
  12165. /**
  12166. * Defines the related dom event
  12167. */
  12168. event: KeyboardEvent;
  12169. /**
  12170. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12171. */
  12172. skipOnPointerObservable: boolean;
  12173. /**
  12174. * Instantiates a new keyboard pre info.
  12175. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12176. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12177. * @param event Defines the related dom event
  12178. */
  12179. constructor(
  12180. /**
  12181. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12182. */
  12183. type: number,
  12184. /**
  12185. * Defines the related dom event
  12186. */
  12187. event: KeyboardEvent);
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Gather the list of pointer event types as constants.
  12193. */
  12194. class PointerEventTypes {
  12195. /**
  12196. * 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.
  12197. */
  12198. static readonly POINTERDOWN: number;
  12199. /**
  12200. * The pointerup event is fired when a pointer is no longer active.
  12201. */
  12202. static readonly POINTERUP: number;
  12203. /**
  12204. * The pointermove event is fired when a pointer changes coordinates.
  12205. */
  12206. static readonly POINTERMOVE: number;
  12207. /**
  12208. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12209. */
  12210. static readonly POINTERWHEEL: number;
  12211. /**
  12212. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12213. */
  12214. static readonly POINTERPICK: number;
  12215. /**
  12216. * The pointertap event is fired when a the object has been touched and released without drag.
  12217. */
  12218. static readonly POINTERTAP: number;
  12219. /**
  12220. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12221. */
  12222. static readonly POINTERDOUBLETAP: number;
  12223. }
  12224. /**
  12225. * Base class of pointer info types.
  12226. */
  12227. class PointerInfoBase {
  12228. /**
  12229. * Defines the type of event (BABYLON.PointerEventTypes)
  12230. */
  12231. type: number;
  12232. /**
  12233. * Defines the related dom event
  12234. */
  12235. event: PointerEvent | MouseWheelEvent;
  12236. /**
  12237. * Instantiates the base class of pointers info.
  12238. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12239. * @param event Defines the related dom event
  12240. */
  12241. constructor(
  12242. /**
  12243. * Defines the type of event (BABYLON.PointerEventTypes)
  12244. */
  12245. type: number,
  12246. /**
  12247. * Defines the related dom event
  12248. */
  12249. event: PointerEvent | MouseWheelEvent);
  12250. }
  12251. /**
  12252. * This class is used to store pointer related info for the onPrePointerObservable event.
  12253. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12254. */
  12255. class PointerInfoPre extends PointerInfoBase {
  12256. /**
  12257. * Ray from a pointer if availible (eg. 6dof controller)
  12258. */
  12259. ray: Nullable<Ray>;
  12260. /**
  12261. * Defines the local position of the pointer on the canvas.
  12262. */
  12263. localPosition: Vector2;
  12264. /**
  12265. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12266. */
  12267. skipOnPointerObservable: boolean;
  12268. /**
  12269. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12270. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12271. * @param event Defines the related dom event
  12272. * @param localX Defines the local x coordinates of the pointer when the event occured
  12273. * @param localY Defines the local y coordinates of the pointer when the event occured
  12274. */
  12275. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12276. }
  12277. /**
  12278. * This type contains all the data related to a pointer event in Babylon.js.
  12279. * 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.
  12280. */
  12281. class PointerInfo extends PointerInfoBase {
  12282. /**
  12283. * Defines the picking info associated to the info (if any)\
  12284. */
  12285. pickInfo: Nullable<PickingInfo>;
  12286. /**
  12287. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12288. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12289. * @param event Defines the related dom event
  12290. * @param pickInfo Defines the picking info associated to the info (if any)\
  12291. */
  12292. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12293. /**
  12294. * Defines the picking info associated to the info (if any)\
  12295. */
  12296. pickInfo: Nullable<PickingInfo>);
  12297. }
  12298. }
  12299. declare module BABYLON {
  12300. /**
  12301. * Represents a gamepad control stick position
  12302. */
  12303. class StickValues {
  12304. /**
  12305. * The x component of the control stick
  12306. */
  12307. x: number;
  12308. /**
  12309. * The y component of the control stick
  12310. */
  12311. y: number;
  12312. /**
  12313. * Initializes the gamepad x and y control stick values
  12314. * @param x The x component of the gamepad control stick value
  12315. * @param y The y component of the gamepad control stick value
  12316. */
  12317. constructor(
  12318. /**
  12319. * The x component of the control stick
  12320. */
  12321. x: number,
  12322. /**
  12323. * The y component of the control stick
  12324. */
  12325. y: number);
  12326. }
  12327. /**
  12328. * An interface which manages callbacks for gamepad button changes
  12329. */
  12330. interface GamepadButtonChanges {
  12331. /**
  12332. * Called when a gamepad has been changed
  12333. */
  12334. changed: boolean;
  12335. /**
  12336. * Called when a gamepad press event has been triggered
  12337. */
  12338. pressChanged: boolean;
  12339. /**
  12340. * Called when a touch event has been triggered
  12341. */
  12342. touchChanged: boolean;
  12343. /**
  12344. * Called when a value has changed
  12345. */
  12346. valueChanged: boolean;
  12347. }
  12348. /**
  12349. * Represents a gamepad
  12350. */
  12351. class Gamepad {
  12352. /**
  12353. * The id of the gamepad
  12354. */
  12355. id: string;
  12356. /**
  12357. * The index of the gamepad
  12358. */
  12359. index: number;
  12360. /**
  12361. * The browser gamepad
  12362. */
  12363. browserGamepad: any;
  12364. /**
  12365. * Specifies what type of gamepad this represents
  12366. */
  12367. type: number;
  12368. private _leftStick;
  12369. private _rightStick;
  12370. /** @hidden */
  12371. _isConnected: boolean;
  12372. private _leftStickAxisX;
  12373. private _leftStickAxisY;
  12374. private _rightStickAxisX;
  12375. private _rightStickAxisY;
  12376. /**
  12377. * Triggered when the left control stick has been changed
  12378. */
  12379. private _onleftstickchanged;
  12380. /**
  12381. * Triggered when the right control stick has been changed
  12382. */
  12383. private _onrightstickchanged;
  12384. /**
  12385. * Represents a gamepad controller
  12386. */
  12387. static GAMEPAD: number;
  12388. /**
  12389. * Represents a generic controller
  12390. */
  12391. static GENERIC: number;
  12392. /**
  12393. * Represents an XBox controller
  12394. */
  12395. static XBOX: number;
  12396. /**
  12397. * Represents a pose-enabled controller
  12398. */
  12399. static POSE_ENABLED: number;
  12400. /**
  12401. * Specifies whether the left control stick should be Y-inverted
  12402. */
  12403. protected _invertLeftStickY: boolean;
  12404. /**
  12405. * Specifies if the gamepad has been connected
  12406. */
  12407. readonly isConnected: boolean;
  12408. /**
  12409. * Initializes the gamepad
  12410. * @param id The id of the gamepad
  12411. * @param index The index of the gamepad
  12412. * @param browserGamepad The browser gamepad
  12413. * @param leftStickX The x component of the left joystick
  12414. * @param leftStickY The y component of the left joystick
  12415. * @param rightStickX The x component of the right joystick
  12416. * @param rightStickY The y component of the right joystick
  12417. */
  12418. constructor(
  12419. /**
  12420. * The id of the gamepad
  12421. */
  12422. id: string,
  12423. /**
  12424. * The index of the gamepad
  12425. */
  12426. index: number,
  12427. /**
  12428. * The browser gamepad
  12429. */
  12430. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12431. /**
  12432. * Callback triggered when the left joystick has changed
  12433. * @param callback
  12434. */
  12435. onleftstickchanged(callback: (values: StickValues) => void): void;
  12436. /**
  12437. * Callback triggered when the right joystick has changed
  12438. * @param callback
  12439. */
  12440. onrightstickchanged(callback: (values: StickValues) => void): void;
  12441. /**
  12442. * Gets the left joystick
  12443. */
  12444. /**
  12445. * Sets the left joystick values
  12446. */
  12447. leftStick: StickValues;
  12448. /**
  12449. * Gets the right joystick
  12450. */
  12451. /**
  12452. * Sets the right joystick value
  12453. */
  12454. rightStick: StickValues;
  12455. /**
  12456. * Updates the gamepad joystick positions
  12457. */
  12458. update(): void;
  12459. /**
  12460. * Disposes the gamepad
  12461. */
  12462. dispose(): void;
  12463. }
  12464. /**
  12465. * Represents a generic gamepad
  12466. */
  12467. class GenericPad extends Gamepad {
  12468. private _buttons;
  12469. private _onbuttondown;
  12470. private _onbuttonup;
  12471. /**
  12472. * Observable triggered when a button has been pressed
  12473. */
  12474. onButtonDownObservable: Observable<number>;
  12475. /**
  12476. * Observable triggered when a button has been released
  12477. */
  12478. onButtonUpObservable: Observable<number>;
  12479. /**
  12480. * Callback triggered when a button has been pressed
  12481. * @param callback Called when a button has been pressed
  12482. */
  12483. onbuttondown(callback: (buttonPressed: number) => void): void;
  12484. /**
  12485. * Callback triggered when a button has been released
  12486. * @param callback Called when a button has been released
  12487. */
  12488. onbuttonup(callback: (buttonReleased: number) => void): void;
  12489. /**
  12490. * Initializes the generic gamepad
  12491. * @param id The id of the generic gamepad
  12492. * @param index The index of the generic gamepad
  12493. * @param browserGamepad The browser gamepad
  12494. */
  12495. constructor(id: string, index: number, browserGamepad: any);
  12496. private _setButtonValue;
  12497. /**
  12498. * Updates the generic gamepad
  12499. */
  12500. update(): void;
  12501. /**
  12502. * Disposes the generic gamepad
  12503. */
  12504. dispose(): void;
  12505. }
  12506. }
  12507. declare module BABYLON {
  12508. /**
  12509. * Manager for handling gamepads
  12510. */
  12511. class GamepadManager {
  12512. private _scene?;
  12513. private _babylonGamepads;
  12514. private _oneGamepadConnected;
  12515. /** @hidden */
  12516. _isMonitoring: boolean;
  12517. private _gamepadEventSupported;
  12518. private _gamepadSupport;
  12519. /**
  12520. * observable to be triggered when the gamepad controller has been connected
  12521. */
  12522. onGamepadConnectedObservable: Observable<Gamepad>;
  12523. /**
  12524. * observable to be triggered when the gamepad controller has been disconnected
  12525. */
  12526. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12527. private _onGamepadConnectedEvent;
  12528. private _onGamepadDisconnectedEvent;
  12529. /**
  12530. * Initializes the gamepad manager
  12531. * @param _scene BabylonJS scene
  12532. */
  12533. constructor(_scene?: Scene | undefined);
  12534. /**
  12535. * The gamepads in the game pad manager
  12536. */
  12537. readonly gamepads: Gamepad[];
  12538. /**
  12539. * Get the gamepad controllers based on type
  12540. * @param type The type of gamepad controller
  12541. * @returns Nullable gamepad
  12542. */
  12543. getGamepadByType(type?: number): Nullable<Gamepad>;
  12544. /**
  12545. * Disposes the gamepad manager
  12546. */
  12547. dispose(): void;
  12548. private _addNewGamepad;
  12549. private _startMonitoringGamepads;
  12550. private _stopMonitoringGamepads;
  12551. /** @hidden */
  12552. _checkGamepadsStatus(): void;
  12553. private _updateGamepadObjects;
  12554. }
  12555. }
  12556. declare module BABYLON {
  12557. interface Scene {
  12558. /** @hidden */
  12559. _gamepadManager: Nullable<GamepadManager>;
  12560. /**
  12561. * Gets the gamepad manager associated with the scene
  12562. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12563. */
  12564. gamepadManager: GamepadManager;
  12565. }
  12566. /**
  12567. * Interface representing a free camera inputs manager
  12568. */
  12569. interface FreeCameraInputsManager {
  12570. /**
  12571. * Adds gamepad input support to the FreeCameraInputsManager.
  12572. * @returns the FreeCameraInputsManager
  12573. */
  12574. addGamepad(): FreeCameraInputsManager;
  12575. }
  12576. /**
  12577. * Interface representing an arc rotate camera inputs manager
  12578. */
  12579. interface ArcRotateCameraInputsManager {
  12580. /**
  12581. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12582. * @returns the camera inputs manager
  12583. */
  12584. addGamepad(): ArcRotateCameraInputsManager;
  12585. }
  12586. /**
  12587. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12588. */
  12589. class GamepadSystemSceneComponent implements ISceneComponent {
  12590. /**
  12591. * The component name helpfull to identify the component in the list of scene components.
  12592. */
  12593. readonly name: string;
  12594. /**
  12595. * The scene the component belongs to.
  12596. */
  12597. scene: Scene;
  12598. /**
  12599. * Creates a new instance of the component for the given scene
  12600. * @param scene Defines the scene to register the component in
  12601. */
  12602. constructor(scene: Scene);
  12603. /**
  12604. * Registers the component in a given scene
  12605. */
  12606. register(): void;
  12607. /**
  12608. * Rebuilds the elements related to this component in case of
  12609. * context lost for instance.
  12610. */
  12611. rebuild(): void;
  12612. /**
  12613. * Disposes the component and the associated ressources
  12614. */
  12615. dispose(): void;
  12616. private _beforeCameraUpdate;
  12617. }
  12618. }
  12619. declare module BABYLON {
  12620. /**
  12621. * Defines supported buttons for XBox360 compatible gamepads
  12622. */
  12623. enum Xbox360Button {
  12624. /** A */
  12625. A = 0,
  12626. /** B */
  12627. B = 1,
  12628. /** X */
  12629. X = 2,
  12630. /** Y */
  12631. Y = 3,
  12632. /** Start */
  12633. Start = 4,
  12634. /** Back */
  12635. Back = 5,
  12636. /** Left button */
  12637. LB = 6,
  12638. /** Right button */
  12639. RB = 7,
  12640. /** Left stick */
  12641. LeftStick = 8,
  12642. /** Right stick */
  12643. RightStick = 9
  12644. }
  12645. /** Defines values for XBox360 DPad */
  12646. enum Xbox360Dpad {
  12647. /** Up */
  12648. Up = 0,
  12649. /** Down */
  12650. Down = 1,
  12651. /** Left */
  12652. Left = 2,
  12653. /** Right */
  12654. Right = 3
  12655. }
  12656. /**
  12657. * Defines a XBox360 gamepad
  12658. */
  12659. class Xbox360Pad extends Gamepad {
  12660. private _leftTrigger;
  12661. private _rightTrigger;
  12662. private _onlefttriggerchanged;
  12663. private _onrighttriggerchanged;
  12664. private _onbuttondown;
  12665. private _onbuttonup;
  12666. private _ondpaddown;
  12667. private _ondpadup;
  12668. /** Observable raised when a button is pressed */
  12669. onButtonDownObservable: Observable<Xbox360Button>;
  12670. /** Observable raised when a button is released */
  12671. onButtonUpObservable: Observable<Xbox360Button>;
  12672. /** Observable raised when a pad is pressed */
  12673. onPadDownObservable: Observable<Xbox360Dpad>;
  12674. /** Observable raised when a pad is released */
  12675. onPadUpObservable: Observable<Xbox360Dpad>;
  12676. private _buttonA;
  12677. private _buttonB;
  12678. private _buttonX;
  12679. private _buttonY;
  12680. private _buttonBack;
  12681. private _buttonStart;
  12682. private _buttonLB;
  12683. private _buttonRB;
  12684. private _buttonLeftStick;
  12685. private _buttonRightStick;
  12686. private _dPadUp;
  12687. private _dPadDown;
  12688. private _dPadLeft;
  12689. private _dPadRight;
  12690. private _isXboxOnePad;
  12691. /**
  12692. * Creates a new XBox360 gamepad object
  12693. * @param id defines the id of this gamepad
  12694. * @param index defines its index
  12695. * @param gamepad defines the internal HTML gamepad object
  12696. * @param xboxOne defines if it is a XBox One gamepad
  12697. */
  12698. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12699. /**
  12700. * Defines the callback to call when left trigger is pressed
  12701. * @param callback defines the callback to use
  12702. */
  12703. onlefttriggerchanged(callback: (value: number) => void): void;
  12704. /**
  12705. * Defines the callback to call when right trigger is pressed
  12706. * @param callback defines the callback to use
  12707. */
  12708. onrighttriggerchanged(callback: (value: number) => void): void;
  12709. /**
  12710. * Gets the left trigger value
  12711. */
  12712. /**
  12713. * Sets the left trigger value
  12714. */
  12715. leftTrigger: number;
  12716. /**
  12717. * Gets the right trigger value
  12718. */
  12719. /**
  12720. * Sets the right trigger value
  12721. */
  12722. rightTrigger: number;
  12723. /**
  12724. * Defines the callback to call when a button is pressed
  12725. * @param callback defines the callback to use
  12726. */
  12727. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12728. /**
  12729. * Defines the callback to call when a button is released
  12730. * @param callback defines the callback to use
  12731. */
  12732. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12733. /**
  12734. * Defines the callback to call when a pad is pressed
  12735. * @param callback defines the callback to use
  12736. */
  12737. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12738. /**
  12739. * Defines the callback to call when a pad is released
  12740. * @param callback defines the callback to use
  12741. */
  12742. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12743. private _setButtonValue;
  12744. private _setDPadValue;
  12745. /**
  12746. * Gets the value of the `A` button
  12747. */
  12748. /**
  12749. * Sets the value of the `A` button
  12750. */
  12751. buttonA: number;
  12752. /**
  12753. * Gets the value of the `B` button
  12754. */
  12755. /**
  12756. * Sets the value of the `B` button
  12757. */
  12758. buttonB: number;
  12759. /**
  12760. * Gets the value of the `X` button
  12761. */
  12762. /**
  12763. * Sets the value of the `X` button
  12764. */
  12765. buttonX: number;
  12766. /**
  12767. * Gets the value of the `Y` button
  12768. */
  12769. /**
  12770. * Sets the value of the `Y` button
  12771. */
  12772. buttonY: number;
  12773. /**
  12774. * Gets the value of the `Start` button
  12775. */
  12776. /**
  12777. * Sets the value of the `Start` button
  12778. */
  12779. buttonStart: number;
  12780. /**
  12781. * Gets the value of the `Back` button
  12782. */
  12783. /**
  12784. * Sets the value of the `Back` button
  12785. */
  12786. buttonBack: number;
  12787. /**
  12788. * Gets the value of the `Left` button
  12789. */
  12790. /**
  12791. * Sets the value of the `Left` button
  12792. */
  12793. buttonLB: number;
  12794. /**
  12795. * Gets the value of the `Right` button
  12796. */
  12797. /**
  12798. * Sets the value of the `Right` button
  12799. */
  12800. buttonRB: number;
  12801. /**
  12802. * Gets the value of the Left joystick
  12803. */
  12804. /**
  12805. * Sets the value of the Left joystick
  12806. */
  12807. buttonLeftStick: number;
  12808. /**
  12809. * Gets the value of the Right joystick
  12810. */
  12811. /**
  12812. * Sets the value of the Right joystick
  12813. */
  12814. buttonRightStick: number;
  12815. /**
  12816. * Gets the value of D-pad up
  12817. */
  12818. /**
  12819. * Sets the value of D-pad up
  12820. */
  12821. dPadUp: number;
  12822. /**
  12823. * Gets the value of D-pad down
  12824. */
  12825. /**
  12826. * Sets the value of D-pad down
  12827. */
  12828. dPadDown: number;
  12829. /**
  12830. * Gets the value of D-pad left
  12831. */
  12832. /**
  12833. * Sets the value of D-pad left
  12834. */
  12835. dPadLeft: number;
  12836. /**
  12837. * Gets the value of D-pad right
  12838. */
  12839. /**
  12840. * Sets the value of D-pad right
  12841. */
  12842. dPadRight: number;
  12843. /**
  12844. * Force the gamepad to synchronize with device values
  12845. */
  12846. update(): void;
  12847. /**
  12848. * Disposes the gamepad
  12849. */
  12850. dispose(): void;
  12851. }
  12852. }
  12853. declare module BABYLON {
  12854. /**
  12855. * Single axis drag gizmo
  12856. */
  12857. class AxisDragGizmo extends Gizmo {
  12858. /**
  12859. * Drag behavior responsible for the gizmos dragging interactions
  12860. */
  12861. dragBehavior: PointerDragBehavior;
  12862. private _pointerObserver;
  12863. /**
  12864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12865. */
  12866. snapDistance: number;
  12867. /**
  12868. * Event that fires each time the gizmo snaps to a new location.
  12869. * * snapDistance is the the change in distance
  12870. */
  12871. onSnapObservable: Observable<{
  12872. snapDistance: number;
  12873. }>;
  12874. /**
  12875. * Creates an AxisDragGizmo
  12876. * @param gizmoLayer The utility layer the gizmo will be added to
  12877. * @param dragAxis The axis which the gizmo will be able to drag on
  12878. * @param color The color of the gizmo
  12879. */
  12880. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12881. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12882. /**
  12883. * Disposes of the gizmo
  12884. */
  12885. dispose(): void;
  12886. }
  12887. }
  12888. declare module BABYLON {
  12889. /**
  12890. * Single axis scale gizmo
  12891. */
  12892. class AxisScaleGizmo extends Gizmo {
  12893. private _coloredMaterial;
  12894. /**
  12895. * Drag behavior responsible for the gizmos dragging interactions
  12896. */
  12897. dragBehavior: PointerDragBehavior;
  12898. private _pointerObserver;
  12899. /**
  12900. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12901. */
  12902. snapDistance: number;
  12903. /**
  12904. * Event that fires each time the gizmo snaps to a new location.
  12905. * * snapDistance is the the change in distance
  12906. */
  12907. onSnapObservable: Observable<{
  12908. snapDistance: number;
  12909. }>;
  12910. /**
  12911. * If the scaling operation should be done on all axis (default: false)
  12912. */
  12913. uniformScaling: boolean;
  12914. /**
  12915. * Creates an AxisScaleGizmo
  12916. * @param gizmoLayer The utility layer the gizmo will be added to
  12917. * @param dragAxis The axis which the gizmo will be able to scale on
  12918. * @param color The color of the gizmo
  12919. */
  12920. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12921. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12922. /**
  12923. * Disposes of the gizmo
  12924. */
  12925. dispose(): void;
  12926. /**
  12927. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12928. * @param mesh The mesh to replace the default mesh of the gizmo
  12929. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12930. */
  12931. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12932. }
  12933. }
  12934. declare module BABYLON {
  12935. /**
  12936. * Bounding box gizmo
  12937. */
  12938. class BoundingBoxGizmo extends Gizmo {
  12939. private _lineBoundingBox;
  12940. private _rotateSpheresParent;
  12941. private _scaleBoxesParent;
  12942. private _boundingDimensions;
  12943. private _renderObserver;
  12944. private _pointerObserver;
  12945. private _scaleDragSpeed;
  12946. private _tmpQuaternion;
  12947. private _tmpVector;
  12948. private _tmpRotationMatrix;
  12949. /**
  12950. * 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)
  12951. */
  12952. ignoreChildren: boolean;
  12953. /**
  12954. * 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)
  12955. */
  12956. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12957. /**
  12958. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12959. */
  12960. rotationSphereSize: number;
  12961. /**
  12962. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12963. */
  12964. scaleBoxSize: number;
  12965. /**
  12966. * 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)
  12967. */
  12968. fixedDragMeshScreenSize: boolean;
  12969. /**
  12970. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12971. */
  12972. fixedDragMeshScreenSizeDistanceFactor: number;
  12973. /**
  12974. * Fired when a rotation sphere or scale box is dragged
  12975. */
  12976. onDragStartObservable: Observable<{}>;
  12977. /**
  12978. * Fired when a scale box is dragged
  12979. */
  12980. onScaleBoxDragObservable: Observable<{}>;
  12981. /**
  12982. * Fired when a scale box drag is ended
  12983. */
  12984. onScaleBoxDragEndObservable: Observable<{}>;
  12985. /**
  12986. * Fired when a rotation sphere is dragged
  12987. */
  12988. onRotationSphereDragObservable: Observable<{}>;
  12989. /**
  12990. * Fired when a rotation sphere drag is ended
  12991. */
  12992. onRotationSphereDragEndObservable: Observable<{}>;
  12993. /**
  12994. * 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)
  12995. */
  12996. scalePivot: Nullable<Vector3>;
  12997. private _anchorMesh;
  12998. private _existingMeshScale;
  12999. private static _PivotCached;
  13000. private static _OldPivotPoint;
  13001. private static _PivotTranslation;
  13002. private static _PivotTmpVector;
  13003. /** @hidden */
  13004. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13005. /** @hidden */
  13006. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13007. /**
  13008. * Creates an BoundingBoxGizmo
  13009. * @param gizmoLayer The utility layer the gizmo will be added to
  13010. * @param color The color of the gizmo
  13011. */
  13012. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13013. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13014. private _selectNode;
  13015. /**
  13016. * Updates the bounding box information for the Gizmo
  13017. */
  13018. updateBoundingBox(): void;
  13019. /**
  13020. * Enables rotation on the specified axis and disables rotation on the others
  13021. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13022. */
  13023. setEnabledRotationAxis(axis: string): void;
  13024. /**
  13025. * Disposes of the gizmo
  13026. */
  13027. dispose(): void;
  13028. /**
  13029. * 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)
  13030. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13031. * @returns the bounding box mesh with the passed in mesh as a child
  13032. */
  13033. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13034. /**
  13035. * CustomMeshes are not supported by this gizmo
  13036. * @param mesh The mesh to replace the default mesh of the gizmo
  13037. */
  13038. setCustomMesh(mesh: Mesh): void;
  13039. }
  13040. }
  13041. declare module BABYLON {
  13042. /**
  13043. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13044. */
  13045. class Gizmo implements IDisposable {
  13046. /** The utility layer the gizmo will be added to */
  13047. gizmoLayer: UtilityLayerRenderer;
  13048. /**
  13049. * The root mesh of the gizmo
  13050. */
  13051. protected _rootMesh: Mesh;
  13052. private _attachedMesh;
  13053. /**
  13054. * Ratio for the scale of the gizmo (Default: 1)
  13055. */
  13056. scaleRatio: number;
  13057. private _tmpMatrix;
  13058. /**
  13059. * If a custom mesh has been set (Default: false)
  13060. */
  13061. protected _customMeshSet: boolean;
  13062. /**
  13063. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13064. * * When set, interactions will be enabled
  13065. */
  13066. attachedMesh: Nullable<AbstractMesh>;
  13067. /**
  13068. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13069. * @param mesh The mesh to replace the default mesh of the gizmo
  13070. */
  13071. setCustomMesh(mesh: Mesh): void;
  13072. /**
  13073. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13074. */
  13075. updateGizmoRotationToMatchAttachedMesh: boolean;
  13076. /**
  13077. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13078. */
  13079. updateGizmoPositionToMatchAttachedMesh: boolean;
  13080. /**
  13081. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13082. */
  13083. protected _updateScale: boolean;
  13084. protected _interactionsEnabled: boolean;
  13085. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13086. private _beforeRenderObserver;
  13087. /**
  13088. * Creates a gizmo
  13089. * @param gizmoLayer The utility layer the gizmo will be added to
  13090. */
  13091. constructor(
  13092. /** The utility layer the gizmo will be added to */
  13093. gizmoLayer?: UtilityLayerRenderer);
  13094. private _tempVector;
  13095. /**
  13096. * @hidden
  13097. * Updates the gizmo to match the attached mesh's position/rotation
  13098. */
  13099. protected _update(): void;
  13100. /**
  13101. * Disposes of the gizmo
  13102. */
  13103. dispose(): void;
  13104. }
  13105. }
  13106. declare module BABYLON {
  13107. /**
  13108. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13109. */
  13110. class GizmoManager implements IDisposable {
  13111. private scene;
  13112. /**
  13113. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13114. */
  13115. gizmos: {
  13116. positionGizmo: Nullable<PositionGizmo>;
  13117. rotationGizmo: Nullable<RotationGizmo>;
  13118. scaleGizmo: Nullable<ScaleGizmo>;
  13119. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13120. };
  13121. private _gizmosEnabled;
  13122. private _pointerObserver;
  13123. private _attachedMesh;
  13124. private _boundingBoxColor;
  13125. private _defaultUtilityLayer;
  13126. private _defaultKeepDepthUtilityLayer;
  13127. /**
  13128. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13129. */
  13130. boundingBoxDragBehavior: SixDofDragBehavior;
  13131. /**
  13132. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13133. */
  13134. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13135. /**
  13136. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13137. */
  13138. usePointerToAttachGizmos: boolean;
  13139. /**
  13140. * Instatiates a gizmo manager
  13141. * @param scene the scene to overlay the gizmos on top of
  13142. */
  13143. constructor(scene: Scene);
  13144. /**
  13145. * Attaches a set of gizmos to the specified mesh
  13146. * @param mesh The mesh the gizmo's should be attached to
  13147. */
  13148. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13149. /**
  13150. * If the position gizmo is enabled
  13151. */
  13152. positionGizmoEnabled: boolean;
  13153. /**
  13154. * If the rotation gizmo is enabled
  13155. */
  13156. rotationGizmoEnabled: boolean;
  13157. /**
  13158. * If the scale gizmo is enabled
  13159. */
  13160. scaleGizmoEnabled: boolean;
  13161. /**
  13162. * If the boundingBox gizmo is enabled
  13163. */
  13164. boundingBoxGizmoEnabled: boolean;
  13165. /**
  13166. * Disposes of the gizmo manager
  13167. */
  13168. dispose(): void;
  13169. }
  13170. }
  13171. declare module BABYLON {
  13172. /**
  13173. * Single plane rotation gizmo
  13174. */
  13175. class PlaneRotationGizmo extends Gizmo {
  13176. /**
  13177. * Drag behavior responsible for the gizmos dragging interactions
  13178. */
  13179. dragBehavior: PointerDragBehavior;
  13180. private _pointerObserver;
  13181. /**
  13182. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13183. */
  13184. snapDistance: number;
  13185. /**
  13186. * Event that fires each time the gizmo snaps to a new location.
  13187. * * snapDistance is the the change in distance
  13188. */
  13189. onSnapObservable: Observable<{
  13190. snapDistance: number;
  13191. }>;
  13192. /**
  13193. * Creates a PlaneRotationGizmo
  13194. * @param gizmoLayer The utility layer the gizmo will be added to
  13195. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13196. * @param color The color of the gizmo
  13197. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13198. */
  13199. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13200. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13201. /**
  13202. * Disposes of the gizmo
  13203. */
  13204. dispose(): void;
  13205. }
  13206. }
  13207. declare module BABYLON {
  13208. /**
  13209. * Gizmo that enables dragging a mesh along 3 axis
  13210. */
  13211. class PositionGizmo extends Gizmo {
  13212. /**
  13213. * Internal gizmo used for interactions on the x axis
  13214. */
  13215. xGizmo: AxisDragGizmo;
  13216. /**
  13217. * Internal gizmo used for interactions on the y axis
  13218. */
  13219. yGizmo: AxisDragGizmo;
  13220. /**
  13221. * Internal gizmo used for interactions on the z axis
  13222. */
  13223. zGizmo: AxisDragGizmo;
  13224. /** Fires an event when any of it's sub gizmos are dragged */
  13225. onDragStartObservable: Observable<{}>;
  13226. /** Fires an event when any of it's sub gizmos are released from dragging */
  13227. onDragEndObservable: Observable<{}>;
  13228. attachedMesh: Nullable<AbstractMesh>;
  13229. /**
  13230. * Creates a PositionGizmo
  13231. * @param gizmoLayer The utility layer the gizmo will be added to
  13232. */
  13233. constructor(gizmoLayer?: UtilityLayerRenderer);
  13234. updateGizmoRotationToMatchAttachedMesh: boolean;
  13235. /**
  13236. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13237. */
  13238. snapDistance: number;
  13239. /**
  13240. * Ratio for the scale of the gizmo (Default: 1)
  13241. */
  13242. scaleRatio: number;
  13243. /**
  13244. * Disposes of the gizmo
  13245. */
  13246. dispose(): void;
  13247. /**
  13248. * CustomMeshes are not supported by this gizmo
  13249. * @param mesh The mesh to replace the default mesh of the gizmo
  13250. */
  13251. setCustomMesh(mesh: Mesh): void;
  13252. }
  13253. }
  13254. declare module BABYLON {
  13255. /**
  13256. * Gizmo that enables rotating a mesh along 3 axis
  13257. */
  13258. class RotationGizmo extends Gizmo {
  13259. /**
  13260. * Internal gizmo used for interactions on the x axis
  13261. */
  13262. xGizmo: PlaneRotationGizmo;
  13263. /**
  13264. * Internal gizmo used for interactions on the y axis
  13265. */
  13266. yGizmo: PlaneRotationGizmo;
  13267. /**
  13268. * Internal gizmo used for interactions on the z axis
  13269. */
  13270. zGizmo: PlaneRotationGizmo;
  13271. /** Fires an event when any of it's sub gizmos are dragged */
  13272. onDragStartObservable: Observable<{}>;
  13273. /** Fires an event when any of it's sub gizmos are released from dragging */
  13274. onDragEndObservable: Observable<{}>;
  13275. attachedMesh: Nullable<AbstractMesh>;
  13276. /**
  13277. * Creates a RotationGizmo
  13278. * @param gizmoLayer The utility layer the gizmo will be added to
  13279. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13280. */
  13281. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13282. updateGizmoRotationToMatchAttachedMesh: boolean;
  13283. /**
  13284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13285. */
  13286. snapDistance: number;
  13287. /**
  13288. * Ratio for the scale of the gizmo (Default: 1)
  13289. */
  13290. scaleRatio: number;
  13291. /**
  13292. * Disposes of the gizmo
  13293. */
  13294. dispose(): void;
  13295. /**
  13296. * CustomMeshes are not supported by this gizmo
  13297. * @param mesh The mesh to replace the default mesh of the gizmo
  13298. */
  13299. setCustomMesh(mesh: Mesh): void;
  13300. }
  13301. }
  13302. declare module BABYLON {
  13303. /**
  13304. * Gizmo that enables scaling a mesh along 3 axis
  13305. */
  13306. class ScaleGizmo extends Gizmo {
  13307. /**
  13308. * Internal gizmo used for interactions on the x axis
  13309. */
  13310. xGizmo: AxisScaleGizmo;
  13311. /**
  13312. * Internal gizmo used for interactions on the y axis
  13313. */
  13314. yGizmo: AxisScaleGizmo;
  13315. /**
  13316. * Internal gizmo used for interactions on the z axis
  13317. */
  13318. zGizmo: AxisScaleGizmo;
  13319. /**
  13320. * Internal gizmo used to scale all axis equally
  13321. */
  13322. uniformScaleGizmo: AxisScaleGizmo;
  13323. /** Fires an event when any of it's sub gizmos are dragged */
  13324. onDragStartObservable: Observable<{}>;
  13325. /** Fires an event when any of it's sub gizmos are released from dragging */
  13326. onDragEndObservable: Observable<{}>;
  13327. attachedMesh: Nullable<AbstractMesh>;
  13328. /**
  13329. * Creates a ScaleGizmo
  13330. * @param gizmoLayer The utility layer the gizmo will be added to
  13331. */
  13332. constructor(gizmoLayer?: UtilityLayerRenderer);
  13333. updateGizmoRotationToMatchAttachedMesh: boolean;
  13334. /**
  13335. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13336. */
  13337. snapDistance: number;
  13338. /**
  13339. * Ratio for the scale of the gizmo (Default: 1)
  13340. */
  13341. scaleRatio: number;
  13342. /**
  13343. * Disposes of the gizmo
  13344. */
  13345. dispose(): void;
  13346. }
  13347. }
  13348. declare module BABYLON {
  13349. /**
  13350. * Represents the different options available during the creation of
  13351. * a Environment helper.
  13352. *
  13353. * This can control the default ground, skybox and image processing setup of your scene.
  13354. */
  13355. interface IEnvironmentHelperOptions {
  13356. /**
  13357. * Specifies wether or not to create a ground.
  13358. * True by default.
  13359. */
  13360. createGround: boolean;
  13361. /**
  13362. * Specifies the ground size.
  13363. * 15 by default.
  13364. */
  13365. groundSize: number;
  13366. /**
  13367. * The texture used on the ground for the main color.
  13368. * Comes from the BabylonJS CDN by default.
  13369. *
  13370. * Remarks: Can be either a texture or a url.
  13371. */
  13372. groundTexture: string | BaseTexture;
  13373. /**
  13374. * The color mixed in the ground texture by default.
  13375. * BabylonJS clearColor by default.
  13376. */
  13377. groundColor: Color3;
  13378. /**
  13379. * Specifies the ground opacity.
  13380. * 1 by default.
  13381. */
  13382. groundOpacity: number;
  13383. /**
  13384. * Enables the ground to receive shadows.
  13385. * True by default.
  13386. */
  13387. enableGroundShadow: boolean;
  13388. /**
  13389. * Helps preventing the shadow to be fully black on the ground.
  13390. * 0.5 by default.
  13391. */
  13392. groundShadowLevel: number;
  13393. /**
  13394. * Creates a mirror texture attach to the ground.
  13395. * false by default.
  13396. */
  13397. enableGroundMirror: boolean;
  13398. /**
  13399. * Specifies the ground mirror size ratio.
  13400. * 0.3 by default as the default kernel is 64.
  13401. */
  13402. groundMirrorSizeRatio: number;
  13403. /**
  13404. * Specifies the ground mirror blur kernel size.
  13405. * 64 by default.
  13406. */
  13407. groundMirrorBlurKernel: number;
  13408. /**
  13409. * Specifies the ground mirror visibility amount.
  13410. * 1 by default
  13411. */
  13412. groundMirrorAmount: number;
  13413. /**
  13414. * Specifies the ground mirror reflectance weight.
  13415. * This uses the standard weight of the background material to setup the fresnel effect
  13416. * of the mirror.
  13417. * 1 by default.
  13418. */
  13419. groundMirrorFresnelWeight: number;
  13420. /**
  13421. * Specifies the ground mirror Falloff distance.
  13422. * This can helps reducing the size of the reflection.
  13423. * 0 by Default.
  13424. */
  13425. groundMirrorFallOffDistance: number;
  13426. /**
  13427. * Specifies the ground mirror texture type.
  13428. * Unsigned Int by Default.
  13429. */
  13430. groundMirrorTextureType: number;
  13431. /**
  13432. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13433. * the shown objects.
  13434. */
  13435. groundYBias: number;
  13436. /**
  13437. * Specifies wether or not to create a skybox.
  13438. * True by default.
  13439. */
  13440. createSkybox: boolean;
  13441. /**
  13442. * Specifies the skybox size.
  13443. * 20 by default.
  13444. */
  13445. skyboxSize: number;
  13446. /**
  13447. * The texture used on the skybox for the main color.
  13448. * Comes from the BabylonJS CDN by default.
  13449. *
  13450. * Remarks: Can be either a texture or a url.
  13451. */
  13452. skyboxTexture: string | BaseTexture;
  13453. /**
  13454. * The color mixed in the skybox texture by default.
  13455. * BabylonJS clearColor by default.
  13456. */
  13457. skyboxColor: Color3;
  13458. /**
  13459. * The background rotation around the Y axis of the scene.
  13460. * This helps aligning the key lights of your scene with the background.
  13461. * 0 by default.
  13462. */
  13463. backgroundYRotation: number;
  13464. /**
  13465. * Compute automatically the size of the elements to best fit with the scene.
  13466. */
  13467. sizeAuto: boolean;
  13468. /**
  13469. * Default position of the rootMesh if autoSize is not true.
  13470. */
  13471. rootPosition: Vector3;
  13472. /**
  13473. * Sets up the image processing in the scene.
  13474. * true by default.
  13475. */
  13476. setupImageProcessing: boolean;
  13477. /**
  13478. * The texture used as your environment texture in the scene.
  13479. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13480. *
  13481. * Remarks: Can be either a texture or a url.
  13482. */
  13483. environmentTexture: string | BaseTexture;
  13484. /**
  13485. * The value of the exposure to apply to the scene.
  13486. * 0.6 by default if setupImageProcessing is true.
  13487. */
  13488. cameraExposure: number;
  13489. /**
  13490. * The value of the contrast to apply to the scene.
  13491. * 1.6 by default if setupImageProcessing is true.
  13492. */
  13493. cameraContrast: number;
  13494. /**
  13495. * Specifies wether or not tonemapping should be enabled in the scene.
  13496. * true by default if setupImageProcessing is true.
  13497. */
  13498. toneMappingEnabled: boolean;
  13499. }
  13500. /**
  13501. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13502. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13503. * It also helps with the default setup of your imageProcessing configuration.
  13504. */
  13505. class EnvironmentHelper {
  13506. /**
  13507. * Default ground texture URL.
  13508. */
  13509. private static _groundTextureCDNUrl;
  13510. /**
  13511. * Default skybox texture URL.
  13512. */
  13513. private static _skyboxTextureCDNUrl;
  13514. /**
  13515. * Default environment texture URL.
  13516. */
  13517. private static _environmentTextureCDNUrl;
  13518. /**
  13519. * Creates the default options for the helper.
  13520. */
  13521. private static _getDefaultOptions;
  13522. private _rootMesh;
  13523. /**
  13524. * Gets the root mesh created by the helper.
  13525. */
  13526. readonly rootMesh: Mesh;
  13527. private _skybox;
  13528. /**
  13529. * Gets the skybox created by the helper.
  13530. */
  13531. readonly skybox: Nullable<Mesh>;
  13532. private _skyboxTexture;
  13533. /**
  13534. * Gets the skybox texture created by the helper.
  13535. */
  13536. readonly skyboxTexture: Nullable<BaseTexture>;
  13537. private _skyboxMaterial;
  13538. /**
  13539. * Gets the skybox material created by the helper.
  13540. */
  13541. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13542. private _ground;
  13543. /**
  13544. * Gets the ground mesh created by the helper.
  13545. */
  13546. readonly ground: Nullable<Mesh>;
  13547. private _groundTexture;
  13548. /**
  13549. * Gets the ground texture created by the helper.
  13550. */
  13551. readonly groundTexture: Nullable<BaseTexture>;
  13552. private _groundMirror;
  13553. /**
  13554. * Gets the ground mirror created by the helper.
  13555. */
  13556. readonly groundMirror: Nullable<MirrorTexture>;
  13557. /**
  13558. * Gets the ground mirror render list to helps pushing the meshes
  13559. * you wish in the ground reflection.
  13560. */
  13561. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13562. private _groundMaterial;
  13563. /**
  13564. * Gets the ground material created by the helper.
  13565. */
  13566. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13567. /**
  13568. * Stores the creation options.
  13569. */
  13570. private readonly _scene;
  13571. private _options;
  13572. /**
  13573. * This observable will be notified with any error during the creation of the environment,
  13574. * mainly texture creation errors.
  13575. */
  13576. onErrorObservable: Observable<{
  13577. message?: string;
  13578. exception?: any;
  13579. }>;
  13580. /**
  13581. * constructor
  13582. * @param options
  13583. * @param scene The scene to add the material to
  13584. */
  13585. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13586. /**
  13587. * Updates the background according to the new options
  13588. * @param options
  13589. */
  13590. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13591. /**
  13592. * Sets the primary color of all the available elements.
  13593. * @param color the main color to affect to the ground and the background
  13594. */
  13595. setMainColor(color: Color3): void;
  13596. /**
  13597. * Setup the image processing according to the specified options.
  13598. */
  13599. private _setupImageProcessing;
  13600. /**
  13601. * Setup the environment texture according to the specified options.
  13602. */
  13603. private _setupEnvironmentTexture;
  13604. /**
  13605. * Setup the background according to the specified options.
  13606. */
  13607. private _setupBackground;
  13608. /**
  13609. * Get the scene sizes according to the setup.
  13610. */
  13611. private _getSceneSize;
  13612. /**
  13613. * Setup the ground according to the specified options.
  13614. */
  13615. private _setupGround;
  13616. /**
  13617. * Setup the ground material according to the specified options.
  13618. */
  13619. private _setupGroundMaterial;
  13620. /**
  13621. * Setup the ground diffuse texture according to the specified options.
  13622. */
  13623. private _setupGroundDiffuseTexture;
  13624. /**
  13625. * Setup the ground mirror texture according to the specified options.
  13626. */
  13627. private _setupGroundMirrorTexture;
  13628. /**
  13629. * Setup the ground to receive the mirror texture.
  13630. */
  13631. private _setupMirrorInGroundMaterial;
  13632. /**
  13633. * Setup the skybox according to the specified options.
  13634. */
  13635. private _setupSkybox;
  13636. /**
  13637. * Setup the skybox material according to the specified options.
  13638. */
  13639. private _setupSkyboxMaterial;
  13640. /**
  13641. * Setup the skybox reflection texture according to the specified options.
  13642. */
  13643. private _setupSkyboxReflectionTexture;
  13644. private _errorHandler;
  13645. /**
  13646. * Dispose all the elements created by the Helper.
  13647. */
  13648. dispose(): void;
  13649. }
  13650. }
  13651. declare module BABYLON {
  13652. /**
  13653. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13654. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13655. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13656. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13657. */
  13658. class PhotoDome extends TransformNode {
  13659. private _useDirectMapping;
  13660. /**
  13661. * The texture being displayed on the sphere
  13662. */
  13663. protected _photoTexture: Texture;
  13664. /**
  13665. * Gets or sets the texture being displayed on the sphere
  13666. */
  13667. photoTexture: Texture;
  13668. /**
  13669. * Observable raised when an error occured while loading the 360 image
  13670. */
  13671. onLoadErrorObservable: Observable<string>;
  13672. /**
  13673. * The skybox material
  13674. */
  13675. protected _material: BackgroundMaterial;
  13676. /**
  13677. * The surface used for the skybox
  13678. */
  13679. protected _mesh: Mesh;
  13680. /**
  13681. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13682. * Also see the options.resolution property.
  13683. */
  13684. fovMultiplier: number;
  13685. /**
  13686. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13687. * @param name Element's name, child elements will append suffixes for their own names.
  13688. * @param urlsOfPhoto defines the url of the photo to display
  13689. * @param options defines an object containing optional or exposed sub element properties
  13690. * @param onError defines a callback called when an error occured while loading the texture
  13691. */
  13692. constructor(name: string, urlOfPhoto: string, options: {
  13693. resolution?: number;
  13694. size?: number;
  13695. useDirectMapping?: boolean;
  13696. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13697. /**
  13698. * Releases resources associated with this node.
  13699. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13700. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13701. */
  13702. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13703. }
  13704. }
  13705. declare module BABYLON {
  13706. interface Scene {
  13707. /**
  13708. * Creates a default light for the scene.
  13709. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13710. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13711. */
  13712. createDefaultLight(replace?: boolean): void;
  13713. /**
  13714. * Creates a default camera for the scene.
  13715. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13716. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13717. * @param replace has default false, when true replaces the active camera in the scene
  13718. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13719. */
  13720. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13721. /**
  13722. * Creates a default camera and a default light.
  13723. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13724. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13725. * @param replace has the default false, when true replaces the active camera/light in the scene
  13726. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13727. */
  13728. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13729. /**
  13730. * Creates a new sky box
  13731. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13732. * @param environmentTexture defines the texture to use as environment texture
  13733. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13734. * @param scale defines the overall scale of the skybox
  13735. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13736. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13737. * @returns a new mesh holding the sky box
  13738. */
  13739. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13740. /**
  13741. * Creates a new environment
  13742. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13743. * @param options defines the options you can use to configure the environment
  13744. * @returns the new EnvironmentHelper
  13745. */
  13746. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13747. /**
  13748. * Creates a new VREXperienceHelper
  13749. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13750. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13751. * @returns a new VREXperienceHelper
  13752. */
  13753. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13754. }
  13755. }
  13756. declare module BABYLON {
  13757. /**
  13758. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13759. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13760. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13761. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13762. */
  13763. class VideoDome extends TransformNode {
  13764. private _useDirectMapping;
  13765. /**
  13766. * The video texture being displayed on the sphere
  13767. */
  13768. protected _videoTexture: VideoTexture;
  13769. /**
  13770. * Gets the video texture being displayed on the sphere
  13771. */
  13772. readonly videoTexture: VideoTexture;
  13773. /**
  13774. * The skybox material
  13775. */
  13776. protected _material: BackgroundMaterial;
  13777. /**
  13778. * The surface used for the skybox
  13779. */
  13780. protected _mesh: Mesh;
  13781. /**
  13782. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13783. * Also see the options.resolution property.
  13784. */
  13785. fovMultiplier: number;
  13786. /**
  13787. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13788. * @param name Element's name, child elements will append suffixes for their own names.
  13789. * @param urlsOrVideo defines the url(s) or the video element to use
  13790. * @param options An object containing optional or exposed sub element properties
  13791. */
  13792. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13793. resolution?: number;
  13794. clickToPlay?: boolean;
  13795. autoPlay?: boolean;
  13796. loop?: boolean;
  13797. size?: number;
  13798. poster?: string;
  13799. useDirectMapping?: boolean;
  13800. }, scene: Scene);
  13801. /**
  13802. * Releases resources associated with this node.
  13803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13805. */
  13806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13807. }
  13808. }
  13809. declare module BABYLON {
  13810. /**
  13811. * This class can be used to get instrumentation data from a Babylon engine
  13812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13813. */
  13814. class EngineInstrumentation implements IDisposable {
  13815. /**
  13816. * Define the instrumented engine.
  13817. */
  13818. engine: Engine;
  13819. private _captureGPUFrameTime;
  13820. private _gpuFrameTimeToken;
  13821. private _gpuFrameTime;
  13822. private _captureShaderCompilationTime;
  13823. private _shaderCompilationTime;
  13824. private _onBeginFrameObserver;
  13825. private _onEndFrameObserver;
  13826. private _onBeforeShaderCompilationObserver;
  13827. private _onAfterShaderCompilationObserver;
  13828. /**
  13829. * Gets the perf counter used for GPU frame time
  13830. */
  13831. readonly gpuFrameTimeCounter: PerfCounter;
  13832. /**
  13833. * Gets the GPU frame time capture status
  13834. */
  13835. /**
  13836. * Enable or disable the GPU frame time capture
  13837. */
  13838. captureGPUFrameTime: boolean;
  13839. /**
  13840. * Gets the perf counter used for shader compilation time
  13841. */
  13842. readonly shaderCompilationTimeCounter: PerfCounter;
  13843. /**
  13844. * Gets the shader compilation time capture status
  13845. */
  13846. /**
  13847. * Enable or disable the shader compilation time capture
  13848. */
  13849. captureShaderCompilationTime: boolean;
  13850. /**
  13851. * Instantiates a new engine instrumentation.
  13852. * This class can be used to get instrumentation data from a Babylon engine
  13853. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13854. * @param engine Defines the engine to instrument
  13855. */
  13856. constructor(
  13857. /**
  13858. * Define the instrumented engine.
  13859. */
  13860. engine: Engine);
  13861. /**
  13862. * Dispose and release associated resources.
  13863. */
  13864. dispose(): void;
  13865. }
  13866. }
  13867. declare module BABYLON {
  13868. /**
  13869. * This class can be used to get instrumentation data from a Babylon engine
  13870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13871. */
  13872. class SceneInstrumentation implements IDisposable {
  13873. /**
  13874. * Defines the scene to instrument
  13875. */
  13876. scene: Scene;
  13877. private _captureActiveMeshesEvaluationTime;
  13878. private _activeMeshesEvaluationTime;
  13879. private _captureRenderTargetsRenderTime;
  13880. private _renderTargetsRenderTime;
  13881. private _captureFrameTime;
  13882. private _frameTime;
  13883. private _captureRenderTime;
  13884. private _renderTime;
  13885. private _captureInterFrameTime;
  13886. private _interFrameTime;
  13887. private _captureParticlesRenderTime;
  13888. private _particlesRenderTime;
  13889. private _captureSpritesRenderTime;
  13890. private _spritesRenderTime;
  13891. private _capturePhysicsTime;
  13892. private _physicsTime;
  13893. private _captureAnimationsTime;
  13894. private _animationsTime;
  13895. private _captureCameraRenderTime;
  13896. private _cameraRenderTime;
  13897. private _onBeforeActiveMeshesEvaluationObserver;
  13898. private _onAfterActiveMeshesEvaluationObserver;
  13899. private _onBeforeRenderTargetsRenderObserver;
  13900. private _onAfterRenderTargetsRenderObserver;
  13901. private _onAfterRenderObserver;
  13902. private _onBeforeDrawPhaseObserver;
  13903. private _onAfterDrawPhaseObserver;
  13904. private _onBeforeAnimationsObserver;
  13905. private _onBeforeParticlesRenderingObserver;
  13906. private _onAfterParticlesRenderingObserver;
  13907. private _onBeforeSpritesRenderingObserver;
  13908. private _onAfterSpritesRenderingObserver;
  13909. private _onBeforePhysicsObserver;
  13910. private _onAfterPhysicsObserver;
  13911. private _onAfterAnimationsObserver;
  13912. private _onBeforeCameraRenderObserver;
  13913. private _onAfterCameraRenderObserver;
  13914. /**
  13915. * Gets the perf counter used for active meshes evaluation time
  13916. */
  13917. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13918. /**
  13919. * Gets the active meshes evaluation time capture status
  13920. */
  13921. /**
  13922. * Enable or disable the active meshes evaluation time capture
  13923. */
  13924. captureActiveMeshesEvaluationTime: boolean;
  13925. /**
  13926. * Gets the perf counter used for render targets render time
  13927. */
  13928. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13929. /**
  13930. * Gets the render targets render time capture status
  13931. */
  13932. /**
  13933. * Enable or disable the render targets render time capture
  13934. */
  13935. captureRenderTargetsRenderTime: boolean;
  13936. /**
  13937. * Gets the perf counter used for particles render time
  13938. */
  13939. readonly particlesRenderTimeCounter: PerfCounter;
  13940. /**
  13941. * Gets the particles render time capture status
  13942. */
  13943. /**
  13944. * Enable or disable the particles render time capture
  13945. */
  13946. captureParticlesRenderTime: boolean;
  13947. /**
  13948. * Gets the perf counter used for sprites render time
  13949. */
  13950. readonly spritesRenderTimeCounter: PerfCounter;
  13951. /**
  13952. * Gets the sprites render time capture status
  13953. */
  13954. /**
  13955. * Enable or disable the sprites render time capture
  13956. */
  13957. captureSpritesRenderTime: boolean;
  13958. /**
  13959. * Gets the perf counter used for physics time
  13960. */
  13961. readonly physicsTimeCounter: PerfCounter;
  13962. /**
  13963. * Gets the physics time capture status
  13964. */
  13965. /**
  13966. * Enable or disable the physics time capture
  13967. */
  13968. capturePhysicsTime: boolean;
  13969. /**
  13970. * Gets the perf counter used for animations time
  13971. */
  13972. readonly animationsTimeCounter: PerfCounter;
  13973. /**
  13974. * Gets the animations time capture status
  13975. */
  13976. /**
  13977. * Enable or disable the animations time capture
  13978. */
  13979. captureAnimationsTime: boolean;
  13980. /**
  13981. * Gets the perf counter used for frame time capture
  13982. */
  13983. readonly frameTimeCounter: PerfCounter;
  13984. /**
  13985. * Gets the frame time capture status
  13986. */
  13987. /**
  13988. * Enable or disable the frame time capture
  13989. */
  13990. captureFrameTime: boolean;
  13991. /**
  13992. * Gets the perf counter used for inter-frames time capture
  13993. */
  13994. readonly interFrameTimeCounter: PerfCounter;
  13995. /**
  13996. * Gets the inter-frames time capture status
  13997. */
  13998. /**
  13999. * Enable or disable the inter-frames time capture
  14000. */
  14001. captureInterFrameTime: boolean;
  14002. /**
  14003. * Gets the perf counter used for render time capture
  14004. */
  14005. readonly renderTimeCounter: PerfCounter;
  14006. /**
  14007. * Gets the render time capture status
  14008. */
  14009. /**
  14010. * Enable or disable the render time capture
  14011. */
  14012. captureRenderTime: boolean;
  14013. /**
  14014. * Gets the perf counter used for camera render time capture
  14015. */
  14016. readonly cameraRenderTimeCounter: PerfCounter;
  14017. /**
  14018. * Gets the camera render time capture status
  14019. */
  14020. /**
  14021. * Enable or disable the camera render time capture
  14022. */
  14023. captureCameraRenderTime: boolean;
  14024. /**
  14025. * Gets the perf counter used for draw calls
  14026. */
  14027. readonly drawCallsCounter: PerfCounter;
  14028. /**
  14029. * Gets the perf counter used for texture collisions
  14030. */
  14031. readonly textureCollisionsCounter: PerfCounter;
  14032. /**
  14033. * Instantiates a new scene instrumentation.
  14034. * This class can be used to get instrumentation data from a Babylon engine
  14035. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14036. * @param scene Defines the scene to instrument
  14037. */
  14038. constructor(
  14039. /**
  14040. * Defines the scene to instrument
  14041. */
  14042. scene: Scene);
  14043. /**
  14044. * Dispose and release associated resources.
  14045. */
  14046. dispose(): void;
  14047. }
  14048. }
  14049. declare module BABYLON {
  14050. /**
  14051. * @hidden
  14052. **/
  14053. class _TimeToken {
  14054. _startTimeQuery: Nullable<WebGLQuery>;
  14055. _endTimeQuery: Nullable<WebGLQuery>;
  14056. _timeElapsedQuery: Nullable<WebGLQuery>;
  14057. _timeElapsedQueryEnded: boolean;
  14058. }
  14059. }
  14060. declare module BABYLON {
  14061. /**
  14062. * Effect layer options. This helps customizing the behaviour
  14063. * of the effect layer.
  14064. */
  14065. interface IEffectLayerOptions {
  14066. /**
  14067. * Multiplication factor apply to the canvas size to compute the render target size
  14068. * used to generated the objects (the smaller the faster).
  14069. */
  14070. mainTextureRatio: number;
  14071. /**
  14072. * Enforces a fixed size texture to ensure effect stability across devices.
  14073. */
  14074. mainTextureFixedSize?: number;
  14075. /**
  14076. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14077. */
  14078. alphaBlendingMode: number;
  14079. /**
  14080. * The camera attached to the layer.
  14081. */
  14082. camera: Nullable<Camera>;
  14083. /**
  14084. * The rendering group to draw the layer in.
  14085. */
  14086. renderingGroupId: number;
  14087. }
  14088. /**
  14089. * The effect layer Helps adding post process effect blended with the main pass.
  14090. *
  14091. * This can be for instance use to generate glow or higlight effects on the scene.
  14092. *
  14093. * The effect layer class can not be used directly and is intented to inherited from to be
  14094. * customized per effects.
  14095. */
  14096. abstract class EffectLayer {
  14097. private _vertexBuffers;
  14098. private _indexBuffer;
  14099. private _cachedDefines;
  14100. private _effectLayerMapGenerationEffect;
  14101. private _effectLayerOptions;
  14102. private _mergeEffect;
  14103. protected _scene: Scene;
  14104. protected _engine: Engine;
  14105. protected _maxSize: number;
  14106. protected _mainTextureDesiredSize: ISize;
  14107. protected _mainTexture: RenderTargetTexture;
  14108. protected _shouldRender: boolean;
  14109. protected _postProcesses: PostProcess[];
  14110. protected _textures: BaseTexture[];
  14111. protected _emissiveTextureAndColor: {
  14112. texture: Nullable<BaseTexture>;
  14113. color: Color4;
  14114. };
  14115. /**
  14116. * The name of the layer
  14117. */
  14118. name: string;
  14119. /**
  14120. * The clear color of the texture used to generate the glow map.
  14121. */
  14122. neutralColor: Color4;
  14123. /**
  14124. * Specifies wether the highlight layer is enabled or not.
  14125. */
  14126. isEnabled: boolean;
  14127. /**
  14128. * Gets the camera attached to the layer.
  14129. */
  14130. readonly camera: Nullable<Camera>;
  14131. /**
  14132. * Gets the rendering group id the layer should render in.
  14133. */
  14134. readonly renderingGroupId: number;
  14135. /**
  14136. * An event triggered when the effect layer has been disposed.
  14137. */
  14138. onDisposeObservable: Observable<EffectLayer>;
  14139. /**
  14140. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14141. */
  14142. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14143. /**
  14144. * An event triggered when the generated texture is being merged in the scene.
  14145. */
  14146. onBeforeComposeObservable: Observable<EffectLayer>;
  14147. /**
  14148. * An event triggered when the generated texture has been merged in the scene.
  14149. */
  14150. onAfterComposeObservable: Observable<EffectLayer>;
  14151. /**
  14152. * An event triggered when the efffect layer changes its size.
  14153. */
  14154. onSizeChangedObservable: Observable<EffectLayer>;
  14155. /**
  14156. * Instantiates a new effect Layer and references it in the scene.
  14157. * @param name The name of the layer
  14158. * @param scene The scene to use the layer in
  14159. */
  14160. constructor(
  14161. /** The Friendly of the effect in the scene */
  14162. name: string, scene: Scene);
  14163. /**
  14164. * Get the effect name of the layer.
  14165. * @return The effect name
  14166. */
  14167. abstract getEffectName(): string;
  14168. /**
  14169. * Checks for the readiness of the element composing the layer.
  14170. * @param subMesh the mesh to check for
  14171. * @param useInstances specify wether or not to use instances to render the mesh
  14172. * @return true if ready otherwise, false
  14173. */
  14174. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14175. /**
  14176. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14177. * @returns true if the effect requires stencil during the main canvas render pass.
  14178. */
  14179. abstract needStencil(): boolean;
  14180. /**
  14181. * Create the merge effect. This is the shader use to blit the information back
  14182. * to the main canvas at the end of the scene rendering.
  14183. * @returns The effect containing the shader used to merge the effect on the main canvas
  14184. */
  14185. protected abstract _createMergeEffect(): Effect;
  14186. /**
  14187. * Creates the render target textures and post processes used in the effect layer.
  14188. */
  14189. protected abstract _createTextureAndPostProcesses(): void;
  14190. /**
  14191. * Implementation specific of rendering the generating effect on the main canvas.
  14192. * @param effect The effect used to render through
  14193. */
  14194. protected abstract _internalRender(effect: Effect): void;
  14195. /**
  14196. * Sets the required values for both the emissive texture and and the main color.
  14197. */
  14198. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14199. /**
  14200. * Free any resources and references associated to a mesh.
  14201. * Internal use
  14202. * @param mesh The mesh to free.
  14203. */
  14204. abstract _disposeMesh(mesh: Mesh): void;
  14205. /**
  14206. * Serializes this layer (Glow or Highlight for example)
  14207. * @returns a serialized layer object
  14208. */
  14209. abstract serialize?(): any;
  14210. /**
  14211. * Initializes the effect layer with the required options.
  14212. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14213. */
  14214. protected _init(options: Partial<IEffectLayerOptions>): void;
  14215. /**
  14216. * Generates the index buffer of the full screen quad blending to the main canvas.
  14217. */
  14218. private _generateIndexBuffer;
  14219. /**
  14220. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14221. */
  14222. private _genrateVertexBuffer;
  14223. /**
  14224. * Sets the main texture desired size which is the closest power of two
  14225. * of the engine canvas size.
  14226. */
  14227. private _setMainTextureSize;
  14228. /**
  14229. * Creates the main texture for the effect layer.
  14230. */
  14231. protected _createMainTexture(): void;
  14232. /**
  14233. * Checks for the readiness of the element composing the layer.
  14234. * @param subMesh the mesh to check for
  14235. * @param useInstances specify wether or not to use instances to render the mesh
  14236. * @param emissiveTexture the associated emissive texture used to generate the glow
  14237. * @return true if ready otherwise, false
  14238. */
  14239. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14240. /**
  14241. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14242. */
  14243. render(): void;
  14244. /**
  14245. * Determine if a given mesh will be used in the current effect.
  14246. * @param mesh mesh to test
  14247. * @returns true if the mesh will be used
  14248. */
  14249. hasMesh(mesh: AbstractMesh): boolean;
  14250. /**
  14251. * Returns true if the layer contains information to display, otherwise false.
  14252. * @returns true if the glow layer should be rendered
  14253. */
  14254. shouldRender(): boolean;
  14255. /**
  14256. * Returns true if the mesh should render, otherwise false.
  14257. * @param mesh The mesh to render
  14258. * @returns true if it should render otherwise false
  14259. */
  14260. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14261. /**
  14262. * Returns true if the mesh should render, otherwise false.
  14263. * @param mesh The mesh to render
  14264. * @returns true if it should render otherwise false
  14265. */
  14266. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14267. /**
  14268. * Renders the submesh passed in parameter to the generation map.
  14269. */
  14270. protected _renderSubMesh(subMesh: SubMesh): void;
  14271. /**
  14272. * Rebuild the required buffers.
  14273. * @hidden Internal use only.
  14274. */
  14275. _rebuild(): void;
  14276. /**
  14277. * Dispose only the render target textures and post process.
  14278. */
  14279. private _disposeTextureAndPostProcesses;
  14280. /**
  14281. * Dispose the highlight layer and free resources.
  14282. */
  14283. dispose(): void;
  14284. /**
  14285. * Gets the class name of the effect layer
  14286. * @returns the string with the class name of the effect layer
  14287. */
  14288. getClassName(): string;
  14289. /**
  14290. * Creates an effect layer from parsed effect layer data
  14291. * @param parsedEffectLayer defines effect layer data
  14292. * @param scene defines the current scene
  14293. * @param rootUrl defines the root URL containing the effect layer information
  14294. * @returns a parsed effect Layer
  14295. */
  14296. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14297. }
  14298. }
  14299. declare module BABYLON {
  14300. interface AbstractScene {
  14301. /**
  14302. * The list of effect layers (highlights/glow) added to the scene
  14303. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14304. * @see http://doc.babylonjs.com/how_to/glow_layer
  14305. */
  14306. effectLayers: Array<EffectLayer>;
  14307. /**
  14308. * Removes the given effect layer from this scene.
  14309. * @param toRemove defines the effect layer to remove
  14310. * @returns the index of the removed effect layer
  14311. */
  14312. removeEffectLayer(toRemove: EffectLayer): number;
  14313. /**
  14314. * Adds the given effect layer to this scene
  14315. * @param newEffectLayer defines the effect layer to add
  14316. */
  14317. addEffectLayer(newEffectLayer: EffectLayer): void;
  14318. }
  14319. /**
  14320. * Defines the layer scene component responsible to manage any effect layers
  14321. * in a given scene.
  14322. */
  14323. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14324. /**
  14325. * The component name helpfull to identify the component in the list of scene components.
  14326. */
  14327. readonly name: string;
  14328. /**
  14329. * The scene the component belongs to.
  14330. */
  14331. scene: Scene;
  14332. private _engine;
  14333. private _renderEffects;
  14334. private _needStencil;
  14335. private _previousStencilState;
  14336. /**
  14337. * Creates a new instance of the component for the given scene
  14338. * @param scene Defines the scene to register the component in
  14339. */
  14340. constructor(scene: Scene);
  14341. /**
  14342. * Registers the component in a given scene
  14343. */
  14344. register(): void;
  14345. /**
  14346. * Rebuilds the elements related to this component in case of
  14347. * context lost for instance.
  14348. */
  14349. rebuild(): void;
  14350. /**
  14351. * Serializes the component data to the specified json object
  14352. * @param serializationObject The object to serialize to
  14353. */
  14354. serialize(serializationObject: any): void;
  14355. /**
  14356. * Adds all the element from the container to the scene
  14357. * @param container the container holding the elements
  14358. */
  14359. addFromContainer(container: AbstractScene): void;
  14360. /**
  14361. * Removes all the elements in the container from the scene
  14362. * @param container contains the elements to remove
  14363. */
  14364. removeFromContainer(container: AbstractScene): void;
  14365. /**
  14366. * Disposes the component and the associated ressources.
  14367. */
  14368. dispose(): void;
  14369. private _isReadyForMesh;
  14370. private _renderMainTexture;
  14371. private _setStencil;
  14372. private _setStencilBack;
  14373. private _draw;
  14374. private _drawCamera;
  14375. private _drawRenderingGroup;
  14376. }
  14377. }
  14378. declare module BABYLON {
  14379. interface AbstractScene {
  14380. /**
  14381. * Return a the first highlight layer of the scene with a given name.
  14382. * @param name The name of the highlight layer to look for.
  14383. * @return The highlight layer if found otherwise null.
  14384. */
  14385. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14386. }
  14387. /**
  14388. * Glow layer options. This helps customizing the behaviour
  14389. * of the glow layer.
  14390. */
  14391. interface IGlowLayerOptions {
  14392. /**
  14393. * Multiplication factor apply to the canvas size to compute the render target size
  14394. * used to generated the glowing objects (the smaller the faster).
  14395. */
  14396. mainTextureRatio: number;
  14397. /**
  14398. * Enforces a fixed size texture to ensure resize independant blur.
  14399. */
  14400. mainTextureFixedSize?: number;
  14401. /**
  14402. * How big is the kernel of the blur texture.
  14403. */
  14404. blurKernelSize: number;
  14405. /**
  14406. * The camera attached to the layer.
  14407. */
  14408. camera: Nullable<Camera>;
  14409. /**
  14410. * Enable MSAA by chosing the number of samples.
  14411. */
  14412. mainTextureSamples?: number;
  14413. /**
  14414. * The rendering group to draw the layer in.
  14415. */
  14416. renderingGroupId: number;
  14417. }
  14418. /**
  14419. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14420. *
  14421. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14422. * glowy meshes to your scene.
  14423. *
  14424. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14425. */
  14426. class GlowLayer extends EffectLayer {
  14427. /**
  14428. * Effect Name of the layer.
  14429. */
  14430. static readonly EffectName: string;
  14431. /**
  14432. * The default blur kernel size used for the glow.
  14433. */
  14434. static DefaultBlurKernelSize: number;
  14435. /**
  14436. * The default texture size ratio used for the glow.
  14437. */
  14438. static DefaultTextureRatio: number;
  14439. /**
  14440. * Sets the kernel size of the blur.
  14441. */
  14442. /**
  14443. * Gets the kernel size of the blur.
  14444. */
  14445. blurKernelSize: number;
  14446. /**
  14447. * Sets the glow intensity.
  14448. */
  14449. /**
  14450. * Gets the glow intensity.
  14451. */
  14452. intensity: number;
  14453. private _options;
  14454. private _intensity;
  14455. private _horizontalBlurPostprocess1;
  14456. private _verticalBlurPostprocess1;
  14457. private _horizontalBlurPostprocess2;
  14458. private _verticalBlurPostprocess2;
  14459. private _blurTexture1;
  14460. private _blurTexture2;
  14461. private _postProcesses1;
  14462. private _postProcesses2;
  14463. private _includedOnlyMeshes;
  14464. private _excludedMeshes;
  14465. /**
  14466. * Callback used to let the user override the color selection on a per mesh basis
  14467. */
  14468. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14469. /**
  14470. * Callback used to let the user override the texture selection on a per mesh basis
  14471. */
  14472. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14473. /**
  14474. * Instantiates a new glow Layer and references it to the scene.
  14475. * @param name The name of the layer
  14476. * @param scene The scene to use the layer in
  14477. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14478. */
  14479. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14480. /**
  14481. * Get the effect name of the layer.
  14482. * @return The effect name
  14483. */
  14484. getEffectName(): string;
  14485. /**
  14486. * Create the merge effect. This is the shader use to blit the information back
  14487. * to the main canvas at the end of the scene rendering.
  14488. */
  14489. protected _createMergeEffect(): Effect;
  14490. /**
  14491. * Creates the render target textures and post processes used in the glow layer.
  14492. */
  14493. protected _createTextureAndPostProcesses(): void;
  14494. /**
  14495. * Checks for the readiness of the element composing the layer.
  14496. * @param subMesh the mesh to check for
  14497. * @param useInstances specify wether or not to use instances to render the mesh
  14498. * @param emissiveTexture the associated emissive texture used to generate the glow
  14499. * @return true if ready otherwise, false
  14500. */
  14501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14502. /**
  14503. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14504. */
  14505. needStencil(): boolean;
  14506. /**
  14507. * Implementation specific of rendering the generating effect on the main canvas.
  14508. * @param effect The effect used to render through
  14509. */
  14510. protected _internalRender(effect: Effect): void;
  14511. /**
  14512. * Sets the required values for both the emissive texture and and the main color.
  14513. */
  14514. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14515. /**
  14516. * Returns true if the mesh should render, otherwise false.
  14517. * @param mesh The mesh to render
  14518. * @returns true if it should render otherwise false
  14519. */
  14520. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14521. /**
  14522. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14523. * @param mesh The mesh to exclude from the glow layer
  14524. */
  14525. addExcludedMesh(mesh: Mesh): void;
  14526. /**
  14527. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14528. * @param mesh The mesh to remove
  14529. */
  14530. removeExcludedMesh(mesh: Mesh): void;
  14531. /**
  14532. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14533. * @param mesh The mesh to include in the glow layer
  14534. */
  14535. addIncludedOnlyMesh(mesh: Mesh): void;
  14536. /**
  14537. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14538. * @param mesh The mesh to remove
  14539. */
  14540. removeIncludedOnlyMesh(mesh: Mesh): void;
  14541. /**
  14542. * Determine if a given mesh will be used in the glow layer
  14543. * @param mesh The mesh to test
  14544. * @returns true if the mesh will be highlighted by the current glow layer
  14545. */
  14546. hasMesh(mesh: AbstractMesh): boolean;
  14547. /**
  14548. * Free any resources and references associated to a mesh.
  14549. * Internal use
  14550. * @param mesh The mesh to free.
  14551. * @hidden
  14552. */
  14553. _disposeMesh(mesh: Mesh): void;
  14554. /**
  14555. * Gets the class name of the effect layer
  14556. * @returns the string with the class name of the effect layer
  14557. */
  14558. getClassName(): string;
  14559. /**
  14560. * Serializes this glow layer
  14561. * @returns a serialized glow layer object
  14562. */
  14563. serialize(): any;
  14564. /**
  14565. * Creates a Glow Layer from parsed glow layer data
  14566. * @param parsedGlowLayer defines glow layer data
  14567. * @param scene defines the current scene
  14568. * @param rootUrl defines the root URL containing the glow layer information
  14569. * @returns a parsed Glow Layer
  14570. */
  14571. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14572. }
  14573. }
  14574. declare module BABYLON {
  14575. interface AbstractScene {
  14576. /**
  14577. * Return a the first highlight layer of the scene with a given name.
  14578. * @param name The name of the highlight layer to look for.
  14579. * @return The highlight layer if found otherwise null.
  14580. */
  14581. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14582. }
  14583. /**
  14584. * Highlight layer options. This helps customizing the behaviour
  14585. * of the highlight layer.
  14586. */
  14587. interface IHighlightLayerOptions {
  14588. /**
  14589. * Multiplication factor apply to the canvas size to compute the render target size
  14590. * used to generated the glowing objects (the smaller the faster).
  14591. */
  14592. mainTextureRatio: number;
  14593. /**
  14594. * Enforces a fixed size texture to ensure resize independant blur.
  14595. */
  14596. mainTextureFixedSize?: number;
  14597. /**
  14598. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14599. * of the picture to blur (the smaller the faster).
  14600. */
  14601. blurTextureSizeRatio: number;
  14602. /**
  14603. * How big in texel of the blur texture is the vertical blur.
  14604. */
  14605. blurVerticalSize: number;
  14606. /**
  14607. * How big in texel of the blur texture is the horizontal blur.
  14608. */
  14609. blurHorizontalSize: number;
  14610. /**
  14611. * Alpha blending mode used to apply the blur. Default is combine.
  14612. */
  14613. alphaBlendingMode: number;
  14614. /**
  14615. * The camera attached to the layer.
  14616. */
  14617. camera: Nullable<Camera>;
  14618. /**
  14619. * Should we display highlight as a solid stroke?
  14620. */
  14621. isStroke?: boolean;
  14622. /**
  14623. * The rendering group to draw the layer in.
  14624. */
  14625. renderingGroupId: number;
  14626. }
  14627. /**
  14628. * The highlight layer Helps adding a glow effect around a mesh.
  14629. *
  14630. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14631. * glowy meshes to your scene.
  14632. *
  14633. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14634. */
  14635. class HighlightLayer extends EffectLayer {
  14636. name: string;
  14637. /**
  14638. * Effect Name of the highlight layer.
  14639. */
  14640. static readonly EffectName: string;
  14641. /**
  14642. * The neutral color used during the preparation of the glow effect.
  14643. * This is black by default as the blend operation is a blend operation.
  14644. */
  14645. static NeutralColor: Color4;
  14646. /**
  14647. * Stencil value used for glowing meshes.
  14648. */
  14649. static GlowingMeshStencilReference: number;
  14650. /**
  14651. * Stencil value used for the other meshes in the scene.
  14652. */
  14653. static NormalMeshStencilReference: number;
  14654. /**
  14655. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14656. */
  14657. innerGlow: boolean;
  14658. /**
  14659. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14660. */
  14661. outerGlow: boolean;
  14662. /**
  14663. * Specifies the horizontal size of the blur.
  14664. */
  14665. /**
  14666. * Gets the horizontal size of the blur.
  14667. */
  14668. blurHorizontalSize: number;
  14669. /**
  14670. * Specifies the vertical size of the blur.
  14671. */
  14672. /**
  14673. * Gets the vertical size of the blur.
  14674. */
  14675. blurVerticalSize: number;
  14676. /**
  14677. * An event triggered when the highlight layer is being blurred.
  14678. */
  14679. onBeforeBlurObservable: Observable<HighlightLayer>;
  14680. /**
  14681. * An event triggered when the highlight layer has been blurred.
  14682. */
  14683. onAfterBlurObservable: Observable<HighlightLayer>;
  14684. private _instanceGlowingMeshStencilReference;
  14685. private _options;
  14686. private _downSamplePostprocess;
  14687. private _horizontalBlurPostprocess;
  14688. private _verticalBlurPostprocess;
  14689. private _blurTexture;
  14690. private _meshes;
  14691. private _excludedMeshes;
  14692. /**
  14693. * Instantiates a new highlight Layer and references it to the scene..
  14694. * @param name The name of the layer
  14695. * @param scene The scene to use the layer in
  14696. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14697. */
  14698. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14699. /**
  14700. * Get the effect name of the layer.
  14701. * @return The effect name
  14702. */
  14703. getEffectName(): string;
  14704. /**
  14705. * Create the merge effect. This is the shader use to blit the information back
  14706. * to the main canvas at the end of the scene rendering.
  14707. */
  14708. protected _createMergeEffect(): Effect;
  14709. /**
  14710. * Creates the render target textures and post processes used in the highlight layer.
  14711. */
  14712. protected _createTextureAndPostProcesses(): void;
  14713. /**
  14714. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14715. */
  14716. needStencil(): boolean;
  14717. /**
  14718. * Checks for the readiness of the element composing the layer.
  14719. * @param subMesh the mesh to check for
  14720. * @param useInstances specify wether or not to use instances to render the mesh
  14721. * @param emissiveTexture the associated emissive texture used to generate the glow
  14722. * @return true if ready otherwise, false
  14723. */
  14724. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14725. /**
  14726. * Implementation specific of rendering the generating effect on the main canvas.
  14727. * @param effect The effect used to render through
  14728. */
  14729. protected _internalRender(effect: Effect): void;
  14730. /**
  14731. * Returns true if the layer contains information to display, otherwise false.
  14732. */
  14733. shouldRender(): boolean;
  14734. /**
  14735. * Returns true if the mesh should render, otherwise false.
  14736. * @param mesh The mesh to render
  14737. * @returns true if it should render otherwise false
  14738. */
  14739. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14740. /**
  14741. * Sets the required values for both the emissive texture and and the main color.
  14742. */
  14743. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14744. /**
  14745. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14746. * @param mesh The mesh to exclude from the highlight layer
  14747. */
  14748. addExcludedMesh(mesh: Mesh): void;
  14749. /**
  14750. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14751. * @param mesh The mesh to highlight
  14752. */
  14753. removeExcludedMesh(mesh: Mesh): void;
  14754. /**
  14755. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14756. * @param mesh mesh to test
  14757. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14758. */
  14759. hasMesh(mesh: AbstractMesh): boolean;
  14760. /**
  14761. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14762. * @param mesh The mesh to highlight
  14763. * @param color The color of the highlight
  14764. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14765. */
  14766. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14767. /**
  14768. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14769. * @param mesh The mesh to highlight
  14770. */
  14771. removeMesh(mesh: Mesh): void;
  14772. /**
  14773. * Force the stencil to the normal expected value for none glowing parts
  14774. */
  14775. private _defaultStencilReference;
  14776. /**
  14777. * Free any resources and references associated to a mesh.
  14778. * Internal use
  14779. * @param mesh The mesh to free.
  14780. * @hidden
  14781. */
  14782. _disposeMesh(mesh: Mesh): void;
  14783. /**
  14784. * Dispose the highlight layer and free resources.
  14785. */
  14786. dispose(): void;
  14787. /**
  14788. * Gets the class name of the effect layer
  14789. * @returns the string with the class name of the effect layer
  14790. */
  14791. getClassName(): string;
  14792. /**
  14793. * Serializes this Highlight layer
  14794. * @returns a serialized Highlight layer object
  14795. */
  14796. serialize(): any;
  14797. /**
  14798. * Creates a Highlight layer from parsed Highlight layer data
  14799. * @param parsedHightlightLayer defines the Highlight layer data
  14800. * @param scene defines the current scene
  14801. * @param rootUrl defines the root URL containing the Highlight layer information
  14802. * @returns a parsed Highlight layer
  14803. */
  14804. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14805. }
  14806. }
  14807. declare module BABYLON {
  14808. /**
  14809. * This represents a full screen 2d layer.
  14810. * This can be usefull to display a picture in the background of your scene for instance.
  14811. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14812. */
  14813. class Layer {
  14814. /**
  14815. * Define the name of the layer.
  14816. */
  14817. name: string;
  14818. /**
  14819. * Define the texture the layer should display.
  14820. */
  14821. texture: Nullable<Texture>;
  14822. /**
  14823. * Is the layer in background or foreground.
  14824. */
  14825. isBackground: boolean;
  14826. /**
  14827. * Define the color of the layer (instead of texture).
  14828. */
  14829. color: Color4;
  14830. /**
  14831. * Define the scale of the layer in order to zoom in out of the texture.
  14832. */
  14833. scale: Vector2;
  14834. /**
  14835. * Define an offset for the layer in order to shift the texture.
  14836. */
  14837. offset: Vector2;
  14838. /**
  14839. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14840. */
  14841. alphaBlendingMode: number;
  14842. /**
  14843. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14844. * Alpha test will not mix with the background color in case of transparency.
  14845. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14846. */
  14847. alphaTest: boolean;
  14848. /**
  14849. * Define a mask to restrict the layer to only some of the scene cameras.
  14850. */
  14851. layerMask: number;
  14852. private _scene;
  14853. private _vertexBuffers;
  14854. private _indexBuffer;
  14855. private _effect;
  14856. private _alphaTestEffect;
  14857. /**
  14858. * An event triggered when the layer is disposed.
  14859. */
  14860. onDisposeObservable: Observable<Layer>;
  14861. private _onDisposeObserver;
  14862. /**
  14863. * Back compatibility with callback before the onDisposeObservable existed.
  14864. * The set callback will be triggered when the layer has been disposed.
  14865. */
  14866. onDispose: () => void;
  14867. /**
  14868. * An event triggered before rendering the scene
  14869. */
  14870. onBeforeRenderObservable: Observable<Layer>;
  14871. private _onBeforeRenderObserver;
  14872. /**
  14873. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14874. * The set callback will be triggered just before rendering the layer.
  14875. */
  14876. onBeforeRender: () => void;
  14877. /**
  14878. * An event triggered after rendering the scene
  14879. */
  14880. onAfterRenderObservable: Observable<Layer>;
  14881. private _onAfterRenderObserver;
  14882. /**
  14883. * Back compatibility with callback before the onAfterRenderObservable existed.
  14884. * The set callback will be triggered just after rendering the layer.
  14885. */
  14886. onAfterRender: () => void;
  14887. /**
  14888. * Instantiates a new layer.
  14889. * This represents a full screen 2d layer.
  14890. * This can be usefull to display a picture in the background of your scene for instance.
  14891. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14892. * @param name Define the name of the layer in the scene
  14893. * @param imgUrl Define the url of the texture to display in the layer
  14894. * @param scene Define the scene the layer belongs to
  14895. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14896. * @param color Defines a color for the layer
  14897. */
  14898. constructor(
  14899. /**
  14900. * Define the name of the layer.
  14901. */
  14902. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14903. private _createIndexBuffer;
  14904. /** @hidden */
  14905. _rebuild(): void;
  14906. /**
  14907. * Renders the layer in the scene.
  14908. */
  14909. render(): void;
  14910. /**
  14911. * Disposes and releases the associated ressources.
  14912. */
  14913. dispose(): void;
  14914. }
  14915. }
  14916. declare module BABYLON {
  14917. interface AbstractScene {
  14918. /**
  14919. * The list of layers (background and foreground) of the scene
  14920. */
  14921. layers: Array<Layer>;
  14922. }
  14923. /**
  14924. * Defines the layer scene component responsible to manage any layers
  14925. * in a given scene.
  14926. */
  14927. class LayerSceneComponent implements ISceneComponent {
  14928. /**
  14929. * The component name helpfull to identify the component in the list of scene components.
  14930. */
  14931. readonly name: string;
  14932. /**
  14933. * The scene the component belongs to.
  14934. */
  14935. scene: Scene;
  14936. private _engine;
  14937. /**
  14938. * Creates a new instance of the component for the given scene
  14939. * @param scene Defines the scene to register the component in
  14940. */
  14941. constructor(scene: Scene);
  14942. /**
  14943. * Registers the component in a given scene
  14944. */
  14945. register(): void;
  14946. /**
  14947. * Rebuilds the elements related to this component in case of
  14948. * context lost for instance.
  14949. */
  14950. rebuild(): void;
  14951. /**
  14952. * Disposes the component and the associated ressources.
  14953. */
  14954. dispose(): void;
  14955. private _draw;
  14956. private _drawBackground;
  14957. private _drawForeground;
  14958. }
  14959. }
  14960. declare module BABYLON {
  14961. /**
  14962. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14963. * It controls one of the indiviual texture used in the effect.
  14964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14965. */
  14966. class LensFlare {
  14967. /**
  14968. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14969. */
  14970. size: number;
  14971. /**
  14972. * 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.
  14973. */
  14974. position: number;
  14975. /**
  14976. * Define the lens color.
  14977. */
  14978. color: Color3;
  14979. /**
  14980. * Define the lens texture.
  14981. */
  14982. texture: Nullable<Texture>;
  14983. /**
  14984. * Define the alpha mode to render this particular lens.
  14985. */
  14986. alphaMode: number;
  14987. private _system;
  14988. /**
  14989. * Creates a new Lens Flare.
  14990. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14991. * It controls one of the indiviual texture used in the effect.
  14992. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14993. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14994. * @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.
  14995. * @param color Define the lens color
  14996. * @param imgUrl Define the lens texture url
  14997. * @param system Define the `lensFlareSystem` this flare is part of
  14998. * @returns The newly created Lens Flare
  14999. */
  15000. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15001. /**
  15002. * Instantiates a new Lens Flare.
  15003. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15004. * It controls one of the indiviual texture used in the effect.
  15005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15006. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15007. * @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.
  15008. * @param color Define the lens color
  15009. * @param imgUrl Define the lens texture url
  15010. * @param system Define the `lensFlareSystem` this flare is part of
  15011. */
  15012. constructor(
  15013. /**
  15014. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15015. */
  15016. size: number,
  15017. /**
  15018. * 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.
  15019. */
  15020. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15021. /**
  15022. * Dispose and release the lens flare with its associated resources.
  15023. */
  15024. dispose(): void;
  15025. }
  15026. }
  15027. declare module BABYLON {
  15028. /**
  15029. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15030. * It is usually composed of several `BABYLON.lensFlare`.
  15031. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15032. */
  15033. class LensFlareSystem {
  15034. /**
  15035. * Define the name of the lens flare system
  15036. */
  15037. name: string;
  15038. /**
  15039. * List of lens flares used in this system.
  15040. */
  15041. lensFlares: LensFlare[];
  15042. /**
  15043. * Define a limit from the border the lens flare can be visible.
  15044. */
  15045. borderLimit: number;
  15046. /**
  15047. * Define a viewport border we do not want to see the lens flare in.
  15048. */
  15049. viewportBorder: number;
  15050. /**
  15051. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15052. */
  15053. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15054. /**
  15055. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15056. */
  15057. layerMask: number;
  15058. /**
  15059. * Define the id of the lens flare system in the scene.
  15060. * (equal to name by default)
  15061. */
  15062. id: string;
  15063. private _scene;
  15064. private _emitter;
  15065. private _vertexBuffers;
  15066. private _indexBuffer;
  15067. private _effect;
  15068. private _positionX;
  15069. private _positionY;
  15070. private _isEnabled;
  15071. /**
  15072. * Instantiates a lens flare system.
  15073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15074. * It is usually composed of several `BABYLON.lensFlare`.
  15075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15076. * @param name Define the name of the lens flare system in the scene
  15077. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15078. * @param scene Define the scene the lens flare system belongs to
  15079. */
  15080. constructor(
  15081. /**
  15082. * Define the name of the lens flare system
  15083. */
  15084. name: string, emitter: any, scene: Scene);
  15085. /**
  15086. * Define if the lens flare system is enabled.
  15087. */
  15088. isEnabled: boolean;
  15089. /**
  15090. * Get the scene the effects belongs to.
  15091. * @returns the scene holding the lens flare system
  15092. */
  15093. getScene(): Scene;
  15094. /**
  15095. * Get the emitter of the lens flare system.
  15096. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15097. * @returns the emitter of the lens flare system
  15098. */
  15099. getEmitter(): any;
  15100. /**
  15101. * Set the emitter of the lens flare system.
  15102. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15103. * @param newEmitter Define the new emitter of the system
  15104. */
  15105. setEmitter(newEmitter: any): void;
  15106. /**
  15107. * Get the lens flare system emitter position.
  15108. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15109. * @returns the position
  15110. */
  15111. getEmitterPosition(): Vector3;
  15112. /**
  15113. * @hidden
  15114. */
  15115. computeEffectivePosition(globalViewport: Viewport): boolean;
  15116. /** @hidden */
  15117. _isVisible(): boolean;
  15118. /**
  15119. * @hidden
  15120. */
  15121. render(): boolean;
  15122. /**
  15123. * Dispose and release the lens flare with its associated resources.
  15124. */
  15125. dispose(): void;
  15126. /**
  15127. * Parse a lens flare system from a JSON repressentation
  15128. * @param parsedLensFlareSystem Define the JSON to parse
  15129. * @param scene Define the scene the parsed system should be instantiated in
  15130. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15131. * @returns the parsed system
  15132. */
  15133. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15134. /**
  15135. * Serialize the current Lens Flare System into a JSON representation.
  15136. * @returns the serialized JSON
  15137. */
  15138. serialize(): any;
  15139. }
  15140. }
  15141. declare module BABYLON {
  15142. interface AbstractScene {
  15143. /**
  15144. * The list of lens flare system added to the scene
  15145. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15146. */
  15147. lensFlareSystems: Array<LensFlareSystem>;
  15148. /**
  15149. * Removes the given lens flare system from this scene.
  15150. * @param toRemove The lens flare system to remove
  15151. * @returns The index of the removed lens flare system
  15152. */
  15153. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15154. /**
  15155. * Adds the given lens flare system to this scene
  15156. * @param newLensFlareSystem The lens flare system to add
  15157. */
  15158. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15159. /**
  15160. * Gets a lens flare system using its name
  15161. * @param name defines the name to look for
  15162. * @returns the lens flare system or null if not found
  15163. */
  15164. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15165. /**
  15166. * Gets a lens flare system using its id
  15167. * @param id defines the id to look for
  15168. * @returns the lens flare system or null if not found
  15169. */
  15170. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15171. }
  15172. /**
  15173. * Defines the lens flare scene component responsible to manage any lens flares
  15174. * in a given scene.
  15175. */
  15176. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15177. /**
  15178. * The component name helpfull to identify the component in the list of scene components.
  15179. */
  15180. readonly name: string;
  15181. /**
  15182. * The scene the component belongs to.
  15183. */
  15184. scene: Scene;
  15185. /**
  15186. * Creates a new instance of the component for the given scene
  15187. * @param scene Defines the scene to register the component in
  15188. */
  15189. constructor(scene: Scene);
  15190. /**
  15191. * Registers the component in a given scene
  15192. */
  15193. register(): void;
  15194. /**
  15195. * Rebuilds the elements related to this component in case of
  15196. * context lost for instance.
  15197. */
  15198. rebuild(): void;
  15199. /**
  15200. * Adds all the element from the container to the scene
  15201. * @param container the container holding the elements
  15202. */
  15203. addFromContainer(container: AbstractScene): void;
  15204. /**
  15205. * Removes all the elements in the container from the scene
  15206. * @param container contains the elements to remove
  15207. */
  15208. removeFromContainer(container: AbstractScene): void;
  15209. /**
  15210. * Serializes the component data to the specified json object
  15211. * @param serializationObject The object to serialize to
  15212. */
  15213. serialize(serializationObject: any): void;
  15214. /**
  15215. * Disposes the component and the associated ressources.
  15216. */
  15217. dispose(): void;
  15218. private _draw;
  15219. }
  15220. }
  15221. declare module BABYLON {
  15222. /**
  15223. * A directional light is defined by a direction (what a surprise!).
  15224. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15225. * 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.
  15226. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15227. */
  15228. class DirectionalLight extends ShadowLight {
  15229. private _shadowFrustumSize;
  15230. /**
  15231. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15232. */
  15233. /**
  15234. * Specifies a fix frustum size for the shadow generation.
  15235. */
  15236. shadowFrustumSize: number;
  15237. private _shadowOrthoScale;
  15238. /**
  15239. * Gets the shadow projection scale against the optimal computed one.
  15240. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15241. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15242. */
  15243. /**
  15244. * Sets the shadow projection scale against the optimal computed one.
  15245. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15246. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15247. */
  15248. shadowOrthoScale: number;
  15249. /**
  15250. * Automatically compute the projection matrix to best fit (including all the casters)
  15251. * on each frame.
  15252. */
  15253. autoUpdateExtends: boolean;
  15254. private _orthoLeft;
  15255. private _orthoRight;
  15256. private _orthoTop;
  15257. private _orthoBottom;
  15258. /**
  15259. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15260. * The directional light is emitted from everywhere in the given direction.
  15261. * It can cast shadows.
  15262. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15263. * @param name The friendly name of the light
  15264. * @param direction The direction of the light
  15265. * @param scene The scene the light belongs to
  15266. */
  15267. constructor(name: string, direction: Vector3, scene: Scene);
  15268. /**
  15269. * Returns the string "DirectionalLight".
  15270. * @return The class name
  15271. */
  15272. getClassName(): string;
  15273. /**
  15274. * Returns the integer 1.
  15275. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15276. */
  15277. getTypeID(): number;
  15278. /**
  15279. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15280. * Returns the DirectionalLight Shadow projection matrix.
  15281. */
  15282. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15283. /**
  15284. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15285. * Returns the DirectionalLight Shadow projection matrix.
  15286. */
  15287. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15288. /**
  15289. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15290. * Returns the DirectionalLight Shadow projection matrix.
  15291. */
  15292. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15293. protected _buildUniformLayout(): void;
  15294. /**
  15295. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15296. * @param effect The effect to update
  15297. * @param lightIndex The index of the light in the effect to update
  15298. * @returns The directional light
  15299. */
  15300. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15301. /**
  15302. * Gets the minZ used for shadow according to both the scene and the light.
  15303. *
  15304. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15305. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15306. * @param activeCamera The camera we are returning the min for
  15307. * @returns the depth min z
  15308. */
  15309. getDepthMinZ(activeCamera: Camera): number;
  15310. /**
  15311. * Gets the maxZ used for shadow according to both the scene and the light.
  15312. *
  15313. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15314. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15315. * @param activeCamera The camera we are returning the max for
  15316. * @returns the depth max z
  15317. */
  15318. getDepthMaxZ(activeCamera: Camera): number;
  15319. /**
  15320. * Prepares the list of defines specific to the light type.
  15321. * @param defines the list of defines
  15322. * @param lightIndex defines the index of the light for the effect
  15323. */
  15324. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15325. }
  15326. }
  15327. declare module BABYLON {
  15328. /**
  15329. * The HemisphericLight simulates the ambient environment light,
  15330. * so the passed direction is the light reflection direction, not the incoming direction.
  15331. */
  15332. class HemisphericLight extends Light {
  15333. /**
  15334. * The groundColor is the light in the opposite direction to the one specified during creation.
  15335. * 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.
  15336. */
  15337. groundColor: Color3;
  15338. /**
  15339. * The light reflection direction, not the incoming direction.
  15340. */
  15341. direction: Vector3;
  15342. /**
  15343. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15344. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15345. * The HemisphericLight can't cast shadows.
  15346. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15347. * @param name The friendly name of the light
  15348. * @param direction The direction of the light reflection
  15349. * @param scene The scene the light belongs to
  15350. */
  15351. constructor(name: string, direction: Vector3, scene: Scene);
  15352. protected _buildUniformLayout(): void;
  15353. /**
  15354. * Returns the string "HemisphericLight".
  15355. * @return The class name
  15356. */
  15357. getClassName(): string;
  15358. /**
  15359. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15360. * Returns the updated direction.
  15361. * @param target The target the direction should point to
  15362. * @return The computed direction
  15363. */
  15364. setDirectionToTarget(target: Vector3): Vector3;
  15365. /**
  15366. * Returns the shadow generator associated to the light.
  15367. * @returns Always null for hemispheric lights because it does not support shadows.
  15368. */
  15369. getShadowGenerator(): Nullable<IShadowGenerator>;
  15370. /**
  15371. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15372. * @param effect The effect to update
  15373. * @param lightIndex The index of the light in the effect to update
  15374. * @returns The hemispheric light
  15375. */
  15376. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15377. /**
  15378. * Computes the world matrix of the node
  15379. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15380. * @param useWasUpdatedFlag defines a reserved property
  15381. * @returns the world matrix
  15382. */
  15383. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15384. /**
  15385. * Returns the integer 3.
  15386. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15387. */
  15388. getTypeID(): number;
  15389. /**
  15390. * Prepares the list of defines specific to the light type.
  15391. * @param defines the list of defines
  15392. * @param lightIndex defines the index of the light for the effect
  15393. */
  15394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15395. }
  15396. }
  15397. declare module BABYLON {
  15398. /**
  15399. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15400. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15401. * 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.
  15402. */
  15403. abstract class Light extends Node {
  15404. /**
  15405. * Falloff Default: light is falling off following the material specification:
  15406. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15407. */
  15408. static readonly FALLOFF_DEFAULT: number;
  15409. /**
  15410. * Falloff Physical: light is falling off following the inverse squared distance law.
  15411. */
  15412. static readonly FALLOFF_PHYSICAL: number;
  15413. /**
  15414. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15415. * to enhance interoperability with other engines.
  15416. */
  15417. static readonly FALLOFF_GLTF: number;
  15418. /**
  15419. * Falloff Standard: light is falling off like in the standard material
  15420. * to enhance interoperability with other materials.
  15421. */
  15422. static readonly FALLOFF_STANDARD: number;
  15423. /**
  15424. * If every light affecting the material is in this lightmapMode,
  15425. * material.lightmapTexture adds or multiplies
  15426. * (depends on material.useLightmapAsShadowmap)
  15427. * after every other light calculations.
  15428. */
  15429. static readonly LIGHTMAP_DEFAULT: number;
  15430. /**
  15431. * material.lightmapTexture as only diffuse lighting from this light
  15432. * adds only specular lighting from this light
  15433. * adds dynamic shadows
  15434. */
  15435. static readonly LIGHTMAP_SPECULAR: number;
  15436. /**
  15437. * material.lightmapTexture as only lighting
  15438. * no light calculation from this light
  15439. * only adds dynamic shadows from this light
  15440. */
  15441. static readonly LIGHTMAP_SHADOWSONLY: number;
  15442. /**
  15443. * Each light type uses the default quantity according to its type:
  15444. * point/spot lights use luminous intensity
  15445. * directional lights use illuminance
  15446. */
  15447. static readonly INTENSITYMODE_AUTOMATIC: number;
  15448. /**
  15449. * lumen (lm)
  15450. */
  15451. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15452. /**
  15453. * candela (lm/sr)
  15454. */
  15455. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15456. /**
  15457. * lux (lm/m^2)
  15458. */
  15459. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15460. /**
  15461. * nit (cd/m^2)
  15462. */
  15463. static readonly INTENSITYMODE_LUMINANCE: number;
  15464. /**
  15465. * Light type const id of the point light.
  15466. */
  15467. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15468. /**
  15469. * Light type const id of the directional light.
  15470. */
  15471. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15472. /**
  15473. * Light type const id of the spot light.
  15474. */
  15475. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15476. /**
  15477. * Light type const id of the hemispheric light.
  15478. */
  15479. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15480. /**
  15481. * Diffuse gives the basic color to an object.
  15482. */
  15483. diffuse: Color3;
  15484. /**
  15485. * Specular produces a highlight color on an object.
  15486. * Note: This is note affecting PBR materials.
  15487. */
  15488. specular: Color3;
  15489. /**
  15490. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15491. * falling off base on range or angle.
  15492. * This can be set to any values in Light.FALLOFF_x.
  15493. *
  15494. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15495. * other types of materials.
  15496. */
  15497. falloffType: number;
  15498. /**
  15499. * Strength of the light.
  15500. * Note: By default it is define in the framework own unit.
  15501. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15502. */
  15503. intensity: number;
  15504. private _range;
  15505. protected _inverseSquaredRange: number;
  15506. /**
  15507. * Defines how far from the source the light is impacting in scene units.
  15508. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15509. */
  15510. /**
  15511. * Defines how far from the source the light is impacting in scene units.
  15512. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15513. */
  15514. range: number;
  15515. /**
  15516. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15517. * of light.
  15518. */
  15519. private _photometricScale;
  15520. private _intensityMode;
  15521. /**
  15522. * Gets the photometric scale used to interpret the intensity.
  15523. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15524. */
  15525. /**
  15526. * Sets the photometric scale used to interpret the intensity.
  15527. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15528. */
  15529. intensityMode: number;
  15530. private _radius;
  15531. /**
  15532. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15533. */
  15534. /**
  15535. * sets the light radius used by PBR Materials to simulate soft area lights.
  15536. */
  15537. radius: number;
  15538. private _renderPriority;
  15539. /**
  15540. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15541. * exceeding the number allowed of the materials.
  15542. */
  15543. renderPriority: number;
  15544. private _shadowEnabled;
  15545. /**
  15546. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15547. * the current shadow generator.
  15548. */
  15549. /**
  15550. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15551. * the current shadow generator.
  15552. */
  15553. shadowEnabled: boolean;
  15554. private _includedOnlyMeshes;
  15555. /**
  15556. * Gets the only meshes impacted by this light.
  15557. */
  15558. /**
  15559. * Sets the only meshes impacted by this light.
  15560. */
  15561. includedOnlyMeshes: AbstractMesh[];
  15562. private _excludedMeshes;
  15563. /**
  15564. * Gets the meshes not impacted by this light.
  15565. */
  15566. /**
  15567. * Sets the meshes not impacted by this light.
  15568. */
  15569. excludedMeshes: AbstractMesh[];
  15570. private _excludeWithLayerMask;
  15571. /**
  15572. * Gets the layer id use to find what meshes are not impacted by the light.
  15573. * Inactive if 0
  15574. */
  15575. /**
  15576. * Sets the layer id use to find what meshes are not impacted by the light.
  15577. * Inactive if 0
  15578. */
  15579. excludeWithLayerMask: number;
  15580. private _includeOnlyWithLayerMask;
  15581. /**
  15582. * Gets the layer id use to find what meshes are impacted by the light.
  15583. * Inactive if 0
  15584. */
  15585. /**
  15586. * Sets the layer id use to find what meshes are impacted by the light.
  15587. * Inactive if 0
  15588. */
  15589. includeOnlyWithLayerMask: number;
  15590. private _lightmapMode;
  15591. /**
  15592. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15593. */
  15594. /**
  15595. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15596. */
  15597. lightmapMode: number;
  15598. /**
  15599. * Shadow generator associted to the light.
  15600. * @hidden Internal use only.
  15601. */
  15602. _shadowGenerator: Nullable<IShadowGenerator>;
  15603. /**
  15604. * @hidden Internal use only.
  15605. */
  15606. _excludedMeshesIds: string[];
  15607. /**
  15608. * @hidden Internal use only.
  15609. */
  15610. _includedOnlyMeshesIds: string[];
  15611. /**
  15612. * The current light unifom buffer.
  15613. * @hidden Internal use only.
  15614. */
  15615. _uniformBuffer: UniformBuffer;
  15616. /**
  15617. * Creates a Light object in the scene.
  15618. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15619. * @param name The firendly name of the light
  15620. * @param scene The scene the light belongs too
  15621. */
  15622. constructor(name: string, scene: Scene);
  15623. protected abstract _buildUniformLayout(): void;
  15624. /**
  15625. * Sets the passed Effect "effect" with the Light information.
  15626. * @param effect The effect to update
  15627. * @param lightIndex The index of the light in the effect to update
  15628. * @returns The light
  15629. */
  15630. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15631. /**
  15632. * Returns the string "Light".
  15633. * @returns the class name
  15634. */
  15635. getClassName(): string;
  15636. /**
  15637. * Converts the light information to a readable string for debug purpose.
  15638. * @param fullDetails Supports for multiple levels of logging within scene loading
  15639. * @returns the human readable light info
  15640. */
  15641. toString(fullDetails?: boolean): string;
  15642. /** @hidden */
  15643. protected _syncParentEnabledState(): void;
  15644. /**
  15645. * Set the enabled state of this node.
  15646. * @param value - the new enabled state
  15647. */
  15648. setEnabled(value: boolean): void;
  15649. /**
  15650. * Returns the Light associated shadow generator if any.
  15651. * @return the associated shadow generator.
  15652. */
  15653. getShadowGenerator(): Nullable<IShadowGenerator>;
  15654. /**
  15655. * Returns a Vector3, the absolute light position in the World.
  15656. * @returns the world space position of the light
  15657. */
  15658. getAbsolutePosition(): Vector3;
  15659. /**
  15660. * Specifies if the light will affect the passed mesh.
  15661. * @param mesh The mesh to test against the light
  15662. * @return true the mesh is affected otherwise, false.
  15663. */
  15664. canAffectMesh(mesh: AbstractMesh): boolean;
  15665. /**
  15666. * Sort function to order lights for rendering.
  15667. * @param a First Light object to compare to second.
  15668. * @param b Second Light object to compare first.
  15669. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15670. */
  15671. static CompareLightsPriority(a: Light, b: Light): number;
  15672. /**
  15673. * Releases resources associated with this node.
  15674. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15675. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15676. */
  15677. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15678. /**
  15679. * Returns the light type ID (integer).
  15680. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15681. */
  15682. getTypeID(): number;
  15683. /**
  15684. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15685. * @returns the scaled intensity in intensity mode unit
  15686. */
  15687. getScaledIntensity(): number;
  15688. /**
  15689. * Returns a new Light object, named "name", from the current one.
  15690. * @param name The name of the cloned light
  15691. * @returns the new created light
  15692. */
  15693. clone(name: string): Nullable<Light>;
  15694. /**
  15695. * Serializes the current light into a Serialization object.
  15696. * @returns the serialized object.
  15697. */
  15698. serialize(): any;
  15699. /**
  15700. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15701. * This new light is named "name" and added to the passed scene.
  15702. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15703. * @param name The friendly name of the light
  15704. * @param scene The scene the new light will belong to
  15705. * @returns the constructor function
  15706. */
  15707. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15708. /**
  15709. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15710. * @param parsedLight The JSON representation of the light
  15711. * @param scene The scene to create the parsed light in
  15712. * @returns the created light after parsing
  15713. */
  15714. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15715. private _hookArrayForExcluded;
  15716. private _hookArrayForIncludedOnly;
  15717. private _resyncMeshes;
  15718. /**
  15719. * Forces the meshes to update their light related information in their rendering used effects
  15720. * @hidden Internal Use Only
  15721. */
  15722. _markMeshesAsLightDirty(): void;
  15723. /**
  15724. * Recomputes the cached photometric scale if needed.
  15725. */
  15726. private _computePhotometricScale;
  15727. /**
  15728. * Returns the Photometric Scale according to the light type and intensity mode.
  15729. */
  15730. private _getPhotometricScale;
  15731. /**
  15732. * Reorder the light in the scene according to their defined priority.
  15733. * @hidden Internal Use Only
  15734. */
  15735. _reorderLightsInScene(): void;
  15736. /**
  15737. * Prepares the list of defines specific to the light type.
  15738. * @param defines the list of defines
  15739. * @param lightIndex defines the index of the light for the effect
  15740. */
  15741. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /**
  15746. * A point light is a light defined by an unique point in world space.
  15747. * The light is emitted in every direction from this point.
  15748. * A good example of a point light is a standard light bulb.
  15749. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15750. */
  15751. class PointLight extends ShadowLight {
  15752. private _shadowAngle;
  15753. /**
  15754. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15755. * This specifies what angle the shadow will use to be created.
  15756. *
  15757. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15758. */
  15759. /**
  15760. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15761. * This specifies what angle the shadow will use to be created.
  15762. *
  15763. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15764. */
  15765. shadowAngle: number;
  15766. /**
  15767. * Gets the direction if it has been set.
  15768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15769. */
  15770. /**
  15771. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15772. */
  15773. direction: Vector3;
  15774. /**
  15775. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15776. * A PointLight emits the light in every direction.
  15777. * It can cast shadows.
  15778. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15779. * ```javascript
  15780. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15781. * ```
  15782. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15783. * @param name The light friendly name
  15784. * @param position The position of the point light in the scene
  15785. * @param scene The scene the lights belongs to
  15786. */
  15787. constructor(name: string, position: Vector3, scene: Scene);
  15788. /**
  15789. * Returns the string "PointLight"
  15790. * @returns the class name
  15791. */
  15792. getClassName(): string;
  15793. /**
  15794. * Returns the integer 0.
  15795. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15796. */
  15797. getTypeID(): number;
  15798. /**
  15799. * Specifies wether or not the shadowmap should be a cube texture.
  15800. * @returns true if the shadowmap needs to be a cube texture.
  15801. */
  15802. needCube(): boolean;
  15803. /**
  15804. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15805. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15806. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15807. */
  15808. getShadowDirection(faceIndex?: number): Vector3;
  15809. /**
  15810. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15811. * - fov = PI / 2
  15812. * - aspect ratio : 1.0
  15813. * - z-near and far equal to the active camera minZ and maxZ.
  15814. * Returns the PointLight.
  15815. */
  15816. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15817. protected _buildUniformLayout(): void;
  15818. /**
  15819. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15820. * @param effect The effect to update
  15821. * @param lightIndex The index of the light in the effect to update
  15822. * @returns The point light
  15823. */
  15824. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15825. /**
  15826. * Prepares the list of defines specific to the light type.
  15827. * @param defines the list of defines
  15828. * @param lightIndex defines the index of the light for the effect
  15829. */
  15830. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15831. }
  15832. }
  15833. declare module BABYLON {
  15834. /**
  15835. * Interface describing all the common properties and methods a shadow light needs to implement.
  15836. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15837. * as well as binding the different shadow properties to the effects.
  15838. */
  15839. interface IShadowLight extends Light {
  15840. /**
  15841. * The light id in the scene (used in scene.findLighById for instance)
  15842. */
  15843. id: string;
  15844. /**
  15845. * The position the shdow will be casted from.
  15846. */
  15847. position: Vector3;
  15848. /**
  15849. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15850. */
  15851. direction: Vector3;
  15852. /**
  15853. * The transformed position. Position of the light in world space taking parenting in account.
  15854. */
  15855. transformedPosition: Vector3;
  15856. /**
  15857. * The transformed direction. Direction of the light in world space taking parenting in account.
  15858. */
  15859. transformedDirection: Vector3;
  15860. /**
  15861. * The friendly name of the light in the scene.
  15862. */
  15863. name: string;
  15864. /**
  15865. * Defines the shadow projection clipping minimum z value.
  15866. */
  15867. shadowMinZ: number;
  15868. /**
  15869. * Defines the shadow projection clipping maximum z value.
  15870. */
  15871. shadowMaxZ: number;
  15872. /**
  15873. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15874. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15875. */
  15876. computeTransformedInformation(): boolean;
  15877. /**
  15878. * Gets the scene the light belongs to.
  15879. * @returns The scene
  15880. */
  15881. getScene(): Scene;
  15882. /**
  15883. * Callback defining a custom Projection Matrix Builder.
  15884. * This can be used to override the default projection matrix computation.
  15885. */
  15886. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15887. /**
  15888. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15889. * @param matrix The materix to updated with the projection information
  15890. * @param viewMatrix The transform matrix of the light
  15891. * @param renderList The list of mesh to render in the map
  15892. * @returns The current light
  15893. */
  15894. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15895. /**
  15896. * Gets the current depth scale used in ESM.
  15897. * @returns The scale
  15898. */
  15899. getDepthScale(): number;
  15900. /**
  15901. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15902. * @returns true if a cube texture needs to be use
  15903. */
  15904. needCube(): boolean;
  15905. /**
  15906. * Detects if the projection matrix requires to be recomputed this frame.
  15907. * @returns true if it requires to be recomputed otherwise, false.
  15908. */
  15909. needProjectionMatrixCompute(): boolean;
  15910. /**
  15911. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15912. */
  15913. forceProjectionMatrixCompute(): void;
  15914. /**
  15915. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15916. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15917. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15918. */
  15919. getShadowDirection(faceIndex?: number): Vector3;
  15920. /**
  15921. * Gets the minZ used for shadow according to both the scene and the light.
  15922. * @param activeCamera The camera we are returning the min for
  15923. * @returns the depth min z
  15924. */
  15925. getDepthMinZ(activeCamera: Camera): number;
  15926. /**
  15927. * Gets the maxZ used for shadow according to both the scene and the light.
  15928. * @param activeCamera The camera we are returning the max for
  15929. * @returns the depth max z
  15930. */
  15931. getDepthMaxZ(activeCamera: Camera): number;
  15932. }
  15933. /**
  15934. * Base implementation IShadowLight
  15935. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15936. */
  15937. abstract class ShadowLight extends Light implements IShadowLight {
  15938. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15939. protected _position: Vector3;
  15940. protected _setPosition(value: Vector3): void;
  15941. /**
  15942. * Sets the position the shadow will be casted from. Also use as the light position for both
  15943. * point and spot lights.
  15944. */
  15945. /**
  15946. * Sets the position the shadow will be casted from. Also use as the light position for both
  15947. * point and spot lights.
  15948. */
  15949. position: Vector3;
  15950. protected _direction: Vector3;
  15951. protected _setDirection(value: Vector3): void;
  15952. /**
  15953. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15954. * Also use as the light direction on spot and directional lights.
  15955. */
  15956. /**
  15957. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15958. * Also use as the light direction on spot and directional lights.
  15959. */
  15960. direction: Vector3;
  15961. private _shadowMinZ;
  15962. /**
  15963. * Gets the shadow projection clipping minimum z value.
  15964. */
  15965. /**
  15966. * Sets the shadow projection clipping minimum z value.
  15967. */
  15968. shadowMinZ: number;
  15969. private _shadowMaxZ;
  15970. /**
  15971. * Sets the shadow projection clipping maximum z value.
  15972. */
  15973. /**
  15974. * Gets the shadow projection clipping maximum z value.
  15975. */
  15976. shadowMaxZ: number;
  15977. /**
  15978. * Callback defining a custom Projection Matrix Builder.
  15979. * This can be used to override the default projection matrix computation.
  15980. */
  15981. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15982. /**
  15983. * The transformed position. Position of the light in world space taking parenting in account.
  15984. */
  15985. transformedPosition: Vector3;
  15986. /**
  15987. * The transformed direction. Direction of the light in world space taking parenting in account.
  15988. */
  15989. transformedDirection: Vector3;
  15990. private _needProjectionMatrixCompute;
  15991. /**
  15992. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15993. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15994. */
  15995. computeTransformedInformation(): boolean;
  15996. /**
  15997. * Return the depth scale used for the shadow map.
  15998. * @returns the depth scale.
  15999. */
  16000. getDepthScale(): number;
  16001. /**
  16002. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16003. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16004. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16005. */
  16006. getShadowDirection(faceIndex?: number): Vector3;
  16007. /**
  16008. * Returns the ShadowLight absolute position in the World.
  16009. * @returns the position vector in world space
  16010. */
  16011. getAbsolutePosition(): Vector3;
  16012. /**
  16013. * Sets the ShadowLight direction toward the passed target.
  16014. * @param target The point tot target in local space
  16015. * @returns the updated ShadowLight direction
  16016. */
  16017. setDirectionToTarget(target: Vector3): Vector3;
  16018. /**
  16019. * Returns the light rotation in euler definition.
  16020. * @returns the x y z rotation in local space.
  16021. */
  16022. getRotation(): Vector3;
  16023. /**
  16024. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16025. * @returns true if a cube texture needs to be use
  16026. */
  16027. needCube(): boolean;
  16028. /**
  16029. * Detects if the projection matrix requires to be recomputed this frame.
  16030. * @returns true if it requires to be recomputed otherwise, false.
  16031. */
  16032. needProjectionMatrixCompute(): boolean;
  16033. /**
  16034. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16035. */
  16036. forceProjectionMatrixCompute(): void;
  16037. /** @hidden */
  16038. _initCache(): void;
  16039. /** @hidden */
  16040. _isSynchronized(): boolean;
  16041. /**
  16042. * Computes the world matrix of the node
  16043. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16044. * @returns the world matrix
  16045. */
  16046. computeWorldMatrix(force?: boolean): Matrix;
  16047. /**
  16048. * Gets the minZ used for shadow according to both the scene and the light.
  16049. * @param activeCamera The camera we are returning the min for
  16050. * @returns the depth min z
  16051. */
  16052. getDepthMinZ(activeCamera: Camera): number;
  16053. /**
  16054. * Gets the maxZ used for shadow according to both the scene and the light.
  16055. * @param activeCamera The camera we are returning the max for
  16056. * @returns the depth max z
  16057. */
  16058. getDepthMaxZ(activeCamera: Camera): number;
  16059. /**
  16060. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16061. * @param matrix The materix to updated with the projection information
  16062. * @param viewMatrix The transform matrix of the light
  16063. * @param renderList The list of mesh to render in the map
  16064. * @returns The current light
  16065. */
  16066. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16067. }
  16068. }
  16069. declare module BABYLON {
  16070. /**
  16071. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16072. * These values define a cone of light starting from the position, emitting toward the direction.
  16073. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16074. * and the exponent defines the speed of the decay of the light with distance (reach).
  16075. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16076. */
  16077. class SpotLight extends ShadowLight {
  16078. private _angle;
  16079. private _innerAngle;
  16080. private _cosHalfAngle;
  16081. private _lightAngleScale;
  16082. private _lightAngleOffset;
  16083. /**
  16084. * Gets the cone angle of the spot light in Radians.
  16085. */
  16086. /**
  16087. * Sets the cone angle of the spot light in Radians.
  16088. */
  16089. angle: number;
  16090. /**
  16091. * Only used in gltf falloff mode, this defines the angle where
  16092. * the directional falloff will start before cutting at angle which could be seen
  16093. * as outer angle.
  16094. */
  16095. /**
  16096. * Only used in gltf falloff mode, this defines the angle where
  16097. * the directional falloff will start before cutting at angle which could be seen
  16098. * as outer angle.
  16099. */
  16100. innerAngle: number;
  16101. private _shadowAngleScale;
  16102. /**
  16103. * Allows scaling the angle of the light for shadow generation only.
  16104. */
  16105. /**
  16106. * Allows scaling the angle of the light for shadow generation only.
  16107. */
  16108. shadowAngleScale: number;
  16109. /**
  16110. * The light decay speed with the distance from the emission spot.
  16111. */
  16112. exponent: number;
  16113. private _projectionTextureMatrix;
  16114. /**
  16115. * Allows reading the projecton texture
  16116. */
  16117. readonly projectionTextureMatrix: Matrix;
  16118. protected _projectionTextureLightNear: number;
  16119. /**
  16120. * Gets the near clip of the Spotlight for texture projection.
  16121. */
  16122. /**
  16123. * Sets the near clip of the Spotlight for texture projection.
  16124. */
  16125. projectionTextureLightNear: number;
  16126. protected _projectionTextureLightFar: number;
  16127. /**
  16128. * Gets the far clip of the Spotlight for texture projection.
  16129. */
  16130. /**
  16131. * Sets the far clip of the Spotlight for texture projection.
  16132. */
  16133. projectionTextureLightFar: number;
  16134. protected _projectionTextureUpDirection: Vector3;
  16135. /**
  16136. * Gets the Up vector of the Spotlight for texture projection.
  16137. */
  16138. /**
  16139. * Sets the Up vector of the Spotlight for texture projection.
  16140. */
  16141. projectionTextureUpDirection: Vector3;
  16142. private _projectionTexture;
  16143. /**
  16144. * Gets the projection texture of the light.
  16145. */
  16146. /**
  16147. * Sets the projection texture of the light.
  16148. */
  16149. projectionTexture: Nullable<BaseTexture>;
  16150. private _projectionTextureViewLightDirty;
  16151. private _projectionTextureProjectionLightDirty;
  16152. private _projectionTextureDirty;
  16153. private _projectionTextureViewTargetVector;
  16154. private _projectionTextureViewLightMatrix;
  16155. private _projectionTextureProjectionLightMatrix;
  16156. private _projectionTextureScalingMatrix;
  16157. /**
  16158. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16159. * It can cast shadows.
  16160. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16161. * @param name The light friendly name
  16162. * @param position The position of the spot light in the scene
  16163. * @param direction The direction of the light in the scene
  16164. * @param angle The cone angle of the light in Radians
  16165. * @param exponent The light decay speed with the distance from the emission spot
  16166. * @param scene The scene the lights belongs to
  16167. */
  16168. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16169. /**
  16170. * Returns the string "SpotLight".
  16171. * @returns the class name
  16172. */
  16173. getClassName(): string;
  16174. /**
  16175. * Returns the integer 2.
  16176. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16177. */
  16178. getTypeID(): number;
  16179. /**
  16180. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16181. */
  16182. protected _setDirection(value: Vector3): void;
  16183. /**
  16184. * Overrides the position setter to recompute the projection texture view light Matrix.
  16185. */
  16186. protected _setPosition(value: Vector3): void;
  16187. /**
  16188. * 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.
  16189. * Returns the SpotLight.
  16190. */
  16191. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16192. protected _computeProjectionTextureViewLightMatrix(): void;
  16193. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16194. /**
  16195. * Main function for light texture projection matrix computing.
  16196. */
  16197. protected _computeProjectionTextureMatrix(): void;
  16198. protected _buildUniformLayout(): void;
  16199. private _computeAngleValues;
  16200. /**
  16201. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16202. * @param effect The effect to update
  16203. * @param lightIndex The index of the light in the effect to update
  16204. * @returns The spot light
  16205. */
  16206. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16207. /**
  16208. * Disposes the light and the associated resources.
  16209. */
  16210. dispose(): void;
  16211. /**
  16212. * Prepares the list of defines specific to the light type.
  16213. * @param defines the list of defines
  16214. * @param lightIndex defines the index of the light for the effect
  16215. */
  16216. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16217. }
  16218. }
  16219. declare module BABYLON {
  16220. /**
  16221. * Interface used to present a loading screen while loading a scene
  16222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16223. */
  16224. interface ILoadingScreen {
  16225. /**
  16226. * Function called to display the loading screen
  16227. */
  16228. displayLoadingUI: () => void;
  16229. /**
  16230. * Function called to hide the loading screen
  16231. */
  16232. hideLoadingUI: () => void;
  16233. /**
  16234. * Gets or sets the color to use for the background
  16235. */
  16236. loadingUIBackgroundColor: string;
  16237. /**
  16238. * Gets or sets the text to display while loading
  16239. */
  16240. loadingUIText: string;
  16241. }
  16242. /**
  16243. * Class used for the default loading screen
  16244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16245. */
  16246. class DefaultLoadingScreen implements ILoadingScreen {
  16247. private _renderingCanvas;
  16248. private _loadingText;
  16249. private _loadingDivBackgroundColor;
  16250. private _loadingDiv;
  16251. private _loadingTextDiv;
  16252. /**
  16253. * Creates a new default loading screen
  16254. * @param _renderingCanvas defines the canvas used to render the scene
  16255. * @param _loadingText defines the default text to display
  16256. * @param _loadingDivBackgroundColor defines the default background color
  16257. */
  16258. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16259. /**
  16260. * Function called to display the loading screen
  16261. */
  16262. displayLoadingUI(): void;
  16263. /**
  16264. * Function called to hide the loading screen
  16265. */
  16266. hideLoadingUI(): void;
  16267. /**
  16268. * Gets or sets the text to display while loading
  16269. */
  16270. loadingUIText: string;
  16271. /**
  16272. * Gets or sets the color to use for the background
  16273. */
  16274. loadingUIBackgroundColor: string;
  16275. private _resizeLoadingUI;
  16276. }
  16277. }
  16278. declare module BABYLON {
  16279. /**
  16280. * Class used to represent data loading progression
  16281. */
  16282. class SceneLoaderProgressEvent {
  16283. /** defines if data length to load can be evaluated */
  16284. readonly lengthComputable: boolean;
  16285. /** defines the loaded data length */
  16286. readonly loaded: number;
  16287. /** defines the data length to load */
  16288. readonly total: number;
  16289. /**
  16290. * Create a new progress event
  16291. * @param lengthComputable defines if data length to load can be evaluated
  16292. * @param loaded defines the loaded data length
  16293. * @param total defines the data length to load
  16294. */
  16295. constructor(
  16296. /** defines if data length to load can be evaluated */
  16297. lengthComputable: boolean,
  16298. /** defines the loaded data length */
  16299. loaded: number,
  16300. /** defines the data length to load */
  16301. total: number);
  16302. /**
  16303. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16304. * @param event defines the source event
  16305. * @returns a new SceneLoaderProgressEvent
  16306. */
  16307. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16308. }
  16309. /**
  16310. * Interface used by SceneLoader plugins to define supported file extensions
  16311. */
  16312. interface ISceneLoaderPluginExtensions {
  16313. /**
  16314. * Defines the list of supported extensions
  16315. */
  16316. [extension: string]: {
  16317. isBinary: boolean;
  16318. };
  16319. }
  16320. /**
  16321. * Interface used by SceneLoader plugin factory
  16322. */
  16323. interface ISceneLoaderPluginFactory {
  16324. /**
  16325. * Defines the name of the factory
  16326. */
  16327. name: string;
  16328. /**
  16329. * Function called to create a new plugin
  16330. * @return the new plugin
  16331. */
  16332. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16333. /**
  16334. * Boolean indicating if the plugin can direct load specific data
  16335. */
  16336. canDirectLoad?: (data: string) => boolean;
  16337. }
  16338. /**
  16339. * Interface used to define a SceneLoader plugin
  16340. */
  16341. interface ISceneLoaderPlugin {
  16342. /**
  16343. * The friendly name of this plugin.
  16344. */
  16345. name: string;
  16346. /**
  16347. * The file extensions supported by this plugin.
  16348. */
  16349. extensions: string | ISceneLoaderPluginExtensions;
  16350. /**
  16351. * Import meshes into a scene.
  16352. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16353. * @param scene The scene to import into
  16354. * @param data The data to import
  16355. * @param rootUrl The root url for scene and resources
  16356. * @param meshes The meshes array to import into
  16357. * @param particleSystems The particle systems array to import into
  16358. * @param skeletons The skeletons array to import into
  16359. * @param onError The callback when import fails
  16360. * @returns True if successful or false otherwise
  16361. */
  16362. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16363. /**
  16364. * Load into a scene.
  16365. * @param scene The scene to load into
  16366. * @param data The data to import
  16367. * @param rootUrl The root url for scene and resources
  16368. * @param onError The callback when import fails
  16369. * @returns true if successful or false otherwise
  16370. */
  16371. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16372. /**
  16373. * The callback that returns true if the data can be directly loaded.
  16374. */
  16375. canDirectLoad?: (data: string) => boolean;
  16376. /**
  16377. * The callback that allows custom handling of the root url based on the response url.
  16378. */
  16379. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16380. /**
  16381. * Load into an asset container.
  16382. * @param scene The scene to load into
  16383. * @param data The data to import
  16384. * @param rootUrl The root url for scene and resources
  16385. * @param onError The callback when import fails
  16386. * @returns The loaded asset container
  16387. */
  16388. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16389. }
  16390. /**
  16391. * Interface used to define an async SceneLoader plugin
  16392. */
  16393. interface ISceneLoaderPluginAsync {
  16394. /**
  16395. * The friendly name of this plugin.
  16396. */
  16397. name: string;
  16398. /**
  16399. * The file extensions supported by this plugin.
  16400. */
  16401. extensions: string | ISceneLoaderPluginExtensions;
  16402. /**
  16403. * Import meshes into a scene.
  16404. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16405. * @param scene The scene to import into
  16406. * @param data The data to import
  16407. * @param rootUrl The root url for scene and resources
  16408. * @param onProgress The callback when the load progresses
  16409. * @param fileName Defines the name of the file to load
  16410. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16411. */
  16412. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16413. meshes: AbstractMesh[];
  16414. particleSystems: IParticleSystem[];
  16415. skeletons: Skeleton[];
  16416. animationGroups: AnimationGroup[];
  16417. }>;
  16418. /**
  16419. * Load into a scene.
  16420. * @param scene The scene to load into
  16421. * @param data The data to import
  16422. * @param rootUrl The root url for scene and resources
  16423. * @param onProgress The callback when the load progresses
  16424. * @param fileName Defines the name of the file to load
  16425. * @returns Nothing
  16426. */
  16427. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16428. /**
  16429. * The callback that returns true if the data can be directly loaded.
  16430. */
  16431. canDirectLoad?: (data: string) => boolean;
  16432. /**
  16433. * The callback that allows custom handling of the root url based on the response url.
  16434. */
  16435. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16436. /**
  16437. * Load into an asset container.
  16438. * @param scene The scene to load into
  16439. * @param data The data to import
  16440. * @param rootUrl The root url for scene and resources
  16441. * @param onProgress The callback when the load progresses
  16442. * @param fileName Defines the name of the file to load
  16443. * @returns The loaded asset container
  16444. */
  16445. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16446. }
  16447. /**
  16448. * Class used to load scene from various file formats using registered plugins
  16449. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16450. */
  16451. class SceneLoader {
  16452. private static _ForceFullSceneLoadingForIncremental;
  16453. private static _ShowLoadingScreen;
  16454. private static _CleanBoneMatrixWeights;
  16455. /**
  16456. * No logging while loading
  16457. */
  16458. static readonly NO_LOGGING: number;
  16459. /**
  16460. * Minimal logging while loading
  16461. */
  16462. static readonly MINIMAL_LOGGING: number;
  16463. /**
  16464. * Summary logging while loading
  16465. */
  16466. static readonly SUMMARY_LOGGING: number;
  16467. /**
  16468. * Detailled logging while loading
  16469. */
  16470. static readonly DETAILED_LOGGING: number;
  16471. private static _loggingLevel;
  16472. /**
  16473. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16474. */
  16475. static ForceFullSceneLoadingForIncremental: boolean;
  16476. /**
  16477. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16478. */
  16479. static ShowLoadingScreen: boolean;
  16480. /**
  16481. * Defines the current logging level (while loading the scene)
  16482. * @ignorenaming
  16483. */
  16484. static loggingLevel: number;
  16485. /**
  16486. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16487. */
  16488. static CleanBoneMatrixWeights: boolean;
  16489. /**
  16490. * Event raised when a plugin is used to load a scene
  16491. */
  16492. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16493. private static _registeredPlugins;
  16494. private static _getDefaultPlugin;
  16495. private static _getPluginForExtension;
  16496. private static _getPluginForDirectLoad;
  16497. private static _getPluginForFilename;
  16498. private static _getDirectLoad;
  16499. private static _loadData;
  16500. private static _getFileInfo;
  16501. /**
  16502. * Gets a plugin that can load the given extension
  16503. * @param extension defines the extension to load
  16504. * @returns a plugin or null if none works
  16505. */
  16506. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16507. /**
  16508. * Gets a boolean indicating that the given extension can be loaded
  16509. * @param extension defines the extension to load
  16510. * @returns true if the extension is supported
  16511. */
  16512. static IsPluginForExtensionAvailable(extension: string): boolean;
  16513. /**
  16514. * Adds a new plugin to the list of registered plugins
  16515. * @param plugin defines the plugin to add
  16516. */
  16517. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16518. /**
  16519. * Import meshes into a scene
  16520. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16521. * @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)
  16522. * @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)
  16523. * @param scene the instance of BABYLON.Scene to append to
  16524. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16525. * @param onProgress a callback with a progress event for each file being loaded
  16526. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16527. * @param pluginExtension the extension used to determine the plugin
  16528. * @returns The loaded plugin
  16529. */
  16530. 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>;
  16531. /**
  16532. * Import meshes into a scene
  16533. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16534. * @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)
  16535. * @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)
  16536. * @param scene the instance of BABYLON.Scene to append to
  16537. * @param onProgress a callback with a progress event for each file being loaded
  16538. * @param pluginExtension the extension used to determine the plugin
  16539. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16540. */
  16541. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16542. meshes: AbstractMesh[];
  16543. particleSystems: IParticleSystem[];
  16544. skeletons: Skeleton[];
  16545. animationGroups: AnimationGroup[];
  16546. }>;
  16547. /**
  16548. * Load a scene
  16549. * @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)
  16550. * @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)
  16551. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16552. * @param onSuccess a callback with the scene when import succeeds
  16553. * @param onProgress a callback with a progress event for each file being loaded
  16554. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16555. * @param pluginExtension the extension used to determine the plugin
  16556. * @returns The loaded plugin
  16557. */
  16558. 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>;
  16559. /**
  16560. * Load a scene
  16561. * @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)
  16562. * @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)
  16563. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16564. * @param onProgress a callback with a progress event for each file being loaded
  16565. * @param pluginExtension the extension used to determine the plugin
  16566. * @returns The loaded scene
  16567. */
  16568. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16569. /**
  16570. * Append a scene
  16571. * @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)
  16572. * @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)
  16573. * @param scene is the instance of BABYLON.Scene to append to
  16574. * @param onSuccess a callback with the scene when import succeeds
  16575. * @param onProgress a callback with a progress event for each file being loaded
  16576. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16577. * @param pluginExtension the extension used to determine the plugin
  16578. * @returns The loaded plugin
  16579. */
  16580. 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>;
  16581. /**
  16582. * Append a scene
  16583. * @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)
  16584. * @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)
  16585. * @param scene is the instance of BABYLON.Scene to append to
  16586. * @param onProgress a callback with a progress event for each file being loaded
  16587. * @param pluginExtension the extension used to determine the plugin
  16588. * @returns The given scene
  16589. */
  16590. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16591. /**
  16592. * Load a scene into an asset container
  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 is the instance of BABYLON.Scene to append to (default: last created scene)
  16596. * @param onSuccess a callback with the scene 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 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>;
  16603. /**
  16604. * Load a scene into an asset container
  16605. * @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)
  16606. * @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)
  16607. * @param scene is the instance of BABYLON.Scene to append to
  16608. * @param onProgress a callback with a progress event for each file being loaded
  16609. * @param pluginExtension the extension used to determine the plugin
  16610. * @returns The loaded asset container
  16611. */
  16612. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16613. }
  16614. }
  16615. declare module BABYLON {
  16616. /**
  16617. * Scalar computation library
  16618. */
  16619. class Scalar {
  16620. /**
  16621. * Two pi constants convenient for computation.
  16622. */
  16623. static TwoPi: number;
  16624. /**
  16625. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16626. * @param a number
  16627. * @param b number
  16628. * @param epsilon (default = 1.401298E-45)
  16629. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  16630. */
  16631. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  16632. /**
  16633. * Returns a string : the upper case translation of the number i to hexadecimal.
  16634. * @param i number
  16635. * @returns the upper case translation of the number i to hexadecimal.
  16636. */
  16637. static ToHex(i: number): string;
  16638. /**
  16639. * Returns -1 if value is negative and +1 is value is positive.
  16640. * @param value the value
  16641. * @returns the value itself if it's equal to zero.
  16642. */
  16643. static Sign(value: number): number;
  16644. /**
  16645. * Returns the value itself if it's between min and max.
  16646. * Returns min if the value is lower than min.
  16647. * Returns max if the value is greater than max.
  16648. * @param value the value to clmap
  16649. * @param min the min value to clamp to (default: 0)
  16650. * @param max the max value to clamp to (default: 1)
  16651. * @returns the clamped value
  16652. */
  16653. static Clamp(value: number, min?: number, max?: number): number;
  16654. /**
  16655. * the log2 of value.
  16656. * @param value the value to compute log2 of
  16657. * @returns the log2 of value.
  16658. */
  16659. static Log2(value: number): number;
  16660. /**
  16661. * Loops the value, so that it is never larger than length and never smaller than 0.
  16662. *
  16663. * This is similar to the modulo operator but it works with floating point numbers.
  16664. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  16665. * With t = 5 and length = 2.5, the result would be 0.0.
  16666. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  16667. * @param value the value
  16668. * @param length the length
  16669. * @returns the looped value
  16670. */
  16671. static Repeat(value: number, length: number): number;
  16672. /**
  16673. * Normalize the value between 0.0 and 1.0 using min and max values
  16674. * @param value value to normalize
  16675. * @param min max to normalize between
  16676. * @param max min to normalize between
  16677. * @returns the normalized value
  16678. */
  16679. static Normalize(value: number, min: number, max: number): number;
  16680. /**
  16681. * Denormalize the value from 0.0 and 1.0 using min and max values
  16682. * @param normalized value to denormalize
  16683. * @param min max to denormalize between
  16684. * @param max min to denormalize between
  16685. * @returns the denormalized value
  16686. */
  16687. static Denormalize(normalized: number, min: number, max: number): number;
  16688. /**
  16689. * Calculates the shortest difference between two given angles given in degrees.
  16690. * @param current current angle in degrees
  16691. * @param target target angle in degrees
  16692. * @returns the delta
  16693. */
  16694. static DeltaAngle(current: number, target: number): number;
  16695. /**
  16696. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  16697. * @param tx value
  16698. * @param length length
  16699. * @returns The returned value will move back and forth between 0 and length
  16700. */
  16701. static PingPong(tx: number, length: number): number;
  16702. /**
  16703. * Interpolates between min and max with smoothing at the limits.
  16704. *
  16705. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  16706. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  16707. * @param from from
  16708. * @param to to
  16709. * @param tx value
  16710. * @returns the smooth stepped value
  16711. */
  16712. static SmoothStep(from: number, to: number, tx: number): number;
  16713. /**
  16714. * Moves a value current towards target.
  16715. *
  16716. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  16717. * Negative values of maxDelta pushes the value away from target.
  16718. * @param current current value
  16719. * @param target target value
  16720. * @param maxDelta max distance to move
  16721. * @returns resulting value
  16722. */
  16723. static MoveTowards(current: number, target: number, maxDelta: number): number;
  16724. /**
  16725. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16726. *
  16727. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  16728. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  16729. * @param current current value
  16730. * @param target target value
  16731. * @param maxDelta max distance to move
  16732. * @returns resulting angle
  16733. */
  16734. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  16735. /**
  16736. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  16737. * @param start start value
  16738. * @param end target value
  16739. * @param amount amount to lerp between
  16740. * @returns the lerped value
  16741. */
  16742. static Lerp(start: number, end: number, amount: number): number;
  16743. /**
  16744. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  16745. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  16746. * @param start start value
  16747. * @param end target value
  16748. * @param amount amount to lerp between
  16749. * @returns the lerped value
  16750. */
  16751. static LerpAngle(start: number, end: number, amount: number): number;
  16752. /**
  16753. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  16754. * @param a start value
  16755. * @param b target value
  16756. * @param value value between a and b
  16757. * @returns the inverseLerp value
  16758. */
  16759. static InverseLerp(a: number, b: number, value: number): number;
  16760. /**
  16761. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  16762. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  16763. * @param value1 spline value
  16764. * @param tangent1 spline value
  16765. * @param value2 spline value
  16766. * @param tangent2 spline value
  16767. * @param amount input value
  16768. * @returns hermite result
  16769. */
  16770. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  16771. /**
  16772. * Returns a random float number between and min and max values
  16773. * @param min min value of random
  16774. * @param max max value of random
  16775. * @returns random value
  16776. */
  16777. static RandomRange(min: number, max: number): number;
  16778. /**
  16779. * This function returns percentage of a number in a given range.
  16780. *
  16781. * RangeToPercent(40,20,60) will return 0.5 (50%)
  16782. * RangeToPercent(34,0,100) will return 0.34 (34%)
  16783. * @param number to convert to percentage
  16784. * @param min min range
  16785. * @param max max range
  16786. * @returns the percentage
  16787. */
  16788. static RangeToPercent(number: number, min: number, max: number): number;
  16789. /**
  16790. * This function returns number that corresponds to the percentage in a given range.
  16791. *
  16792. * PercentToRange(0.34,0,100) will return 34.
  16793. * @param percent to convert to number
  16794. * @param min min range
  16795. * @param max max range
  16796. * @returns the number
  16797. */
  16798. static PercentToRange(percent: number, min: number, max: number): number;
  16799. /**
  16800. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  16801. * @param angle The angle to normalize in radian.
  16802. * @return The converted angle.
  16803. */
  16804. static NormalizeRadians(angle: number): number;
  16805. }
  16806. }
  16807. declare module BABYLON {
  16808. /**
  16809. * Constant used to convert a value to gamma space
  16810. * @ignorenaming
  16811. */
  16812. const ToGammaSpace: number;
  16813. /**
  16814. * Constant used to convert a value to linear space
  16815. * @ignorenaming
  16816. */
  16817. const ToLinearSpace = 2.2;
  16818. /**
  16819. * Constant used to define the minimal number value in Babylon.js
  16820. * @ignorenaming
  16821. */
  16822. const Epsilon = 0.001;
  16823. /**
  16824. * Class used to hold a RBG color
  16825. */
  16826. class Color3 {
  16827. /**
  16828. * Defines the red component (between 0 and 1, default is 0)
  16829. */
  16830. r: number;
  16831. /**
  16832. * Defines the green component (between 0 and 1, default is 0)
  16833. */
  16834. g: number;
  16835. /**
  16836. * Defines the blue component (between 0 and 1, default is 0)
  16837. */
  16838. b: number;
  16839. /**
  16840. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  16841. * @param r defines the red component (between 0 and 1, default is 0)
  16842. * @param g defines the green component (between 0 and 1, default is 0)
  16843. * @param b defines the blue component (between 0 and 1, default is 0)
  16844. */
  16845. constructor(
  16846. /**
  16847. * Defines the red component (between 0 and 1, default is 0)
  16848. */
  16849. r?: number,
  16850. /**
  16851. * Defines the green component (between 0 and 1, default is 0)
  16852. */
  16853. g?: number,
  16854. /**
  16855. * Defines the blue component (between 0 and 1, default is 0)
  16856. */
  16857. b?: number);
  16858. /**
  16859. * Creates a string with the Color3 current values
  16860. * @returns the string representation of the Color3 object
  16861. */
  16862. toString(): string;
  16863. /**
  16864. * Returns the string "Color3"
  16865. * @returns "Color3"
  16866. */
  16867. getClassName(): string;
  16868. /**
  16869. * Compute the Color3 hash code
  16870. * @returns an unique number that can be used to hash Color3 objects
  16871. */
  16872. getHashCode(): number;
  16873. /**
  16874. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  16875. * @param array defines the array where to store the r,g,b components
  16876. * @param index defines an optional index in the target array to define where to start storing values
  16877. * @returns the current Color3 object
  16878. */
  16879. toArray(array: FloatArray, index?: number): Color3;
  16880. /**
  16881. * Returns a new Color4 object from the current Color3 and the given alpha
  16882. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  16883. * @returns a new Color4 object
  16884. */
  16885. toColor4(alpha?: number): Color4;
  16886. /**
  16887. * Returns a new array populated with 3 numeric elements : red, green and blue values
  16888. * @returns the new array
  16889. */
  16890. asArray(): number[];
  16891. /**
  16892. * Returns the luminance value
  16893. * @returns a float value
  16894. */
  16895. toLuminance(): number;
  16896. /**
  16897. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  16898. * @param otherColor defines the second operand
  16899. * @returns the new Color3 object
  16900. */
  16901. multiply(otherColor: Color3): Color3;
  16902. /**
  16903. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  16904. * @param otherColor defines the second operand
  16905. * @param result defines the Color3 object where to store the result
  16906. * @returns the current Color3
  16907. */
  16908. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  16909. /**
  16910. * Determines equality between Color3 objects
  16911. * @param otherColor defines the second operand
  16912. * @returns true if the rgb values are equal to the given ones
  16913. */
  16914. equals(otherColor: Color3): boolean;
  16915. /**
  16916. * Determines equality between the current Color3 object and a set of r,b,g values
  16917. * @param r defines the red component to check
  16918. * @param g defines the green component to check
  16919. * @param b defines the blue component to check
  16920. * @returns true if the rgb values are equal to the given ones
  16921. */
  16922. equalsFloats(r: number, g: number, b: number): boolean;
  16923. /**
  16924. * Multiplies in place each rgb value by scale
  16925. * @param scale defines the scaling factor
  16926. * @returns the updated Color3
  16927. */
  16928. scale(scale: number): Color3;
  16929. /**
  16930. * Multiplies the rgb values by scale and stores the result into "result"
  16931. * @param scale defines the scaling factor
  16932. * @param result defines the Color3 object where to store the result
  16933. * @returns the unmodified current Color3
  16934. */
  16935. scaleToRef(scale: number, result: Color3): Color3;
  16936. /**
  16937. * Scale the current Color3 values by a factor and add the result to a given Color3
  16938. * @param scale defines the scale factor
  16939. * @param result defines color to store the result into
  16940. * @returns the unmodified current Color3
  16941. */
  16942. scaleAndAddToRef(scale: number, result: Color3): Color3;
  16943. /**
  16944. * Clamps the rgb values by the min and max values and stores the result into "result"
  16945. * @param min defines minimum clamping value (default is 0)
  16946. * @param max defines maximum clamping value (default is 1)
  16947. * @param result defines color to store the result into
  16948. * @returns the original Color3
  16949. */
  16950. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  16951. /**
  16952. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  16953. * @param otherColor defines the second operand
  16954. * @returns the new Color3
  16955. */
  16956. add(otherColor: Color3): Color3;
  16957. /**
  16958. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  16959. * @param otherColor defines the second operand
  16960. * @param result defines Color3 object to store the result into
  16961. * @returns the unmodified current Color3
  16962. */
  16963. addToRef(otherColor: Color3, result: Color3): Color3;
  16964. /**
  16965. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  16966. * @param otherColor defines the second operand
  16967. * @returns the new Color3
  16968. */
  16969. subtract(otherColor: Color3): Color3;
  16970. /**
  16971. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  16972. * @param otherColor defines the second operand
  16973. * @param result defines Color3 object to store the result into
  16974. * @returns the unmodified current Color3
  16975. */
  16976. subtractToRef(otherColor: Color3, result: Color3): Color3;
  16977. /**
  16978. * Copy the current object
  16979. * @returns a new Color3 copied the current one
  16980. */
  16981. clone(): Color3;
  16982. /**
  16983. * Copies the rgb values from the source in the current Color3
  16984. * @param source defines the source Color3 object
  16985. * @returns the updated Color3 object
  16986. */
  16987. copyFrom(source: Color3): Color3;
  16988. /**
  16989. * Updates the Color3 rgb values from the given floats
  16990. * @param r defines the red component to read from
  16991. * @param g defines the green component to read from
  16992. * @param b defines the blue component to read from
  16993. * @returns the current Color3 object
  16994. */
  16995. copyFromFloats(r: number, g: number, b: number): Color3;
  16996. /**
  16997. * Updates the Color3 rgb values from the given floats
  16998. * @param r defines the red component to read from
  16999. * @param g defines the green component to read from
  17000. * @param b defines the blue component to read from
  17001. * @returns the current Color3 object
  17002. */
  17003. set(r: number, g: number, b: number): Color3;
  17004. /**
  17005. * Compute the Color3 hexadecimal code as a string
  17006. * @returns a string containing the hexadecimal representation of the Color3 object
  17007. */
  17008. toHexString(): string;
  17009. /**
  17010. * Computes a new Color3 converted from the current one to linear space
  17011. * @returns a new Color3 object
  17012. */
  17013. toLinearSpace(): Color3;
  17014. /**
  17015. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  17016. * @param convertedColor defines the Color3 object where to store the linear space version
  17017. * @returns the unmodified Color3
  17018. */
  17019. toLinearSpaceToRef(convertedColor: Color3): Color3;
  17020. /**
  17021. * Computes a new Color3 converted from the current one to gamma space
  17022. * @returns a new Color3 object
  17023. */
  17024. toGammaSpace(): Color3;
  17025. /**
  17026. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  17027. * @param convertedColor defines the Color3 object where to store the gamma space version
  17028. * @returns the unmodified Color3
  17029. */
  17030. toGammaSpaceToRef(convertedColor: Color3): Color3;
  17031. /**
  17032. * Creates a new Color3 from the string containing valid hexadecimal values
  17033. * @param hex defines a string containing valid hexadecimal values
  17034. * @returns a new Color3 object
  17035. */
  17036. static FromHexString(hex: string): Color3;
  17037. /**
  17038. * Creates a new Vector3 from the starting index of the given array
  17039. * @param array defines the source array
  17040. * @param offset defines an offset in the source array
  17041. * @returns a new Color3 object
  17042. */
  17043. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  17044. /**
  17045. * Creates a new Color3 from integer values (< 256)
  17046. * @param r defines the red component to read from (value between 0 and 255)
  17047. * @param g defines the green component to read from (value between 0 and 255)
  17048. * @param b defines the blue component to read from (value between 0 and 255)
  17049. * @returns a new Color3 object
  17050. */
  17051. static FromInts(r: number, g: number, b: number): Color3;
  17052. /**
  17053. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17054. * @param start defines the start Color3 value
  17055. * @param end defines the end Color3 value
  17056. * @param amount defines the gradient value between start and end
  17057. * @returns a new Color3 object
  17058. */
  17059. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  17060. /**
  17061. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  17062. * @param left defines the start value
  17063. * @param right defines the end value
  17064. * @param amount defines the gradient factor
  17065. * @param result defines the Color3 object where to store the result
  17066. */
  17067. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  17068. /**
  17069. * Returns a Color3 value containing a red color
  17070. * @returns a new Color3 object
  17071. */
  17072. static Red(): Color3;
  17073. /**
  17074. * Returns a Color3 value containing a green color
  17075. * @returns a new Color3 object
  17076. */
  17077. static Green(): Color3;
  17078. /**
  17079. * Returns a Color3 value containing a blue color
  17080. * @returns a new Color3 object
  17081. */
  17082. static Blue(): Color3;
  17083. /**
  17084. * Returns a Color3 value containing a black color
  17085. * @returns a new Color3 object
  17086. */
  17087. static Black(): Color3;
  17088. /**
  17089. * Returns a Color3 value containing a white color
  17090. * @returns a new Color3 object
  17091. */
  17092. static White(): Color3;
  17093. /**
  17094. * Returns a Color3 value containing a purple color
  17095. * @returns a new Color3 object
  17096. */
  17097. static Purple(): Color3;
  17098. /**
  17099. * Returns a Color3 value containing a magenta color
  17100. * @returns a new Color3 object
  17101. */
  17102. static Magenta(): Color3;
  17103. /**
  17104. * Returns a Color3 value containing a yellow color
  17105. * @returns a new Color3 object
  17106. */
  17107. static Yellow(): Color3;
  17108. /**
  17109. * Returns a Color3 value containing a gray color
  17110. * @returns a new Color3 object
  17111. */
  17112. static Gray(): Color3;
  17113. /**
  17114. * Returns a Color3 value containing a teal color
  17115. * @returns a new Color3 object
  17116. */
  17117. static Teal(): Color3;
  17118. /**
  17119. * Returns a Color3 value containing a random color
  17120. * @returns a new Color3 object
  17121. */
  17122. static Random(): Color3;
  17123. }
  17124. /**
  17125. * Class used to hold a RBGA color
  17126. */
  17127. class Color4 {
  17128. /**
  17129. * Defines the red component (between 0 and 1, default is 0)
  17130. */
  17131. r: number;
  17132. /**
  17133. * Defines the green component (between 0 and 1, default is 0)
  17134. */
  17135. g: number;
  17136. /**
  17137. * Defines the blue component (between 0 and 1, default is 0)
  17138. */
  17139. b: number;
  17140. /**
  17141. * Defines the alpha component (between 0 and 1, default is 1)
  17142. */
  17143. a: number;
  17144. /**
  17145. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  17146. * @param r defines the red component (between 0 and 1, default is 0)
  17147. * @param g defines the green component (between 0 and 1, default is 0)
  17148. * @param b defines the blue component (between 0 and 1, default is 0)
  17149. * @param a defines the alpha component (between 0 and 1, default is 1)
  17150. */
  17151. constructor(
  17152. /**
  17153. * Defines the red component (between 0 and 1, default is 0)
  17154. */
  17155. r?: number,
  17156. /**
  17157. * Defines the green component (between 0 and 1, default is 0)
  17158. */
  17159. g?: number,
  17160. /**
  17161. * Defines the blue component (between 0 and 1, default is 0)
  17162. */
  17163. b?: number,
  17164. /**
  17165. * Defines the alpha component (between 0 and 1, default is 1)
  17166. */
  17167. a?: number);
  17168. /**
  17169. * Adds in place the given Color4 values to the current Color4 object
  17170. * @param right defines the second operand
  17171. * @returns the current updated Color4 object
  17172. */
  17173. addInPlace(right: Color4): Color4;
  17174. /**
  17175. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  17176. * @returns the new array
  17177. */
  17178. asArray(): number[];
  17179. /**
  17180. * Stores from the starting index in the given array the Color4 successive values
  17181. * @param array defines the array where to store the r,g,b components
  17182. * @param index defines an optional index in the target array to define where to start storing values
  17183. * @returns the current Color4 object
  17184. */
  17185. toArray(array: number[], index?: number): Color4;
  17186. /**
  17187. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  17188. * @param right defines the second operand
  17189. * @returns a new Color4 object
  17190. */
  17191. add(right: Color4): Color4;
  17192. /**
  17193. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  17194. * @param right defines the second operand
  17195. * @returns a new Color4 object
  17196. */
  17197. subtract(right: Color4): Color4;
  17198. /**
  17199. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  17200. * @param right defines the second operand
  17201. * @param result defines the Color4 object where to store the result
  17202. * @returns the current Color4 object
  17203. */
  17204. subtractToRef(right: Color4, result: Color4): Color4;
  17205. /**
  17206. * Creates a new Color4 with the current Color4 values multiplied by scale
  17207. * @param scale defines the scaling factor to apply
  17208. * @returns a new Color4 object
  17209. */
  17210. scale(scale: number): Color4;
  17211. /**
  17212. * Multiplies the current Color4 values by scale and stores the result in "result"
  17213. * @param scale defines the scaling factor to apply
  17214. * @param result defines the Color4 object where to store the result
  17215. * @returns the current unmodified Color4
  17216. */
  17217. scaleToRef(scale: number, result: Color4): Color4;
  17218. /**
  17219. * Scale the current Color4 values by a factor and add the result to a given Color4
  17220. * @param scale defines the scale factor
  17221. * @param result defines the Color4 object where to store the result
  17222. * @returns the unmodified current Color4
  17223. */
  17224. scaleAndAddToRef(scale: number, result: Color4): Color4;
  17225. /**
  17226. * Clamps the rgb values by the min and max values and stores the result into "result"
  17227. * @param min defines minimum clamping value (default is 0)
  17228. * @param max defines maximum clamping value (default is 1)
  17229. * @param result defines color to store the result into.
  17230. * @returns the cuurent Color4
  17231. */
  17232. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  17233. /**
  17234. * Multipy an Color4 value by another and return a new Color4 object
  17235. * @param color defines the Color4 value to multiply by
  17236. * @returns a new Color4 object
  17237. */
  17238. multiply(color: Color4): Color4;
  17239. /**
  17240. * Multipy a Color4 value by another and push the result in a reference value
  17241. * @param color defines the Color4 value to multiply by
  17242. * @param result defines the Color4 to fill the result in
  17243. * @returns the result Color4
  17244. */
  17245. multiplyToRef(color: Color4, result: Color4): Color4;
  17246. /**
  17247. * Creates a string with the Color4 current values
  17248. * @returns the string representation of the Color4 object
  17249. */
  17250. toString(): string;
  17251. /**
  17252. * Returns the string "Color4"
  17253. * @returns "Color4"
  17254. */
  17255. getClassName(): string;
  17256. /**
  17257. * Compute the Color4 hash code
  17258. * @returns an unique number that can be used to hash Color4 objects
  17259. */
  17260. getHashCode(): number;
  17261. /**
  17262. * Creates a new Color4 copied from the current one
  17263. * @returns a new Color4 object
  17264. */
  17265. clone(): Color4;
  17266. /**
  17267. * Copies the given Color4 values into the current one
  17268. * @param source defines the source Color4 object
  17269. * @returns the current updated Color4 object
  17270. */
  17271. copyFrom(source: Color4): Color4;
  17272. /**
  17273. * Copies the given float values into the current one
  17274. * @param r defines the red component to read from
  17275. * @param g defines the green component to read from
  17276. * @param b defines the blue component to read from
  17277. * @param a defines the alpha component to read from
  17278. * @returns the current updated Color4 object
  17279. */
  17280. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  17281. /**
  17282. * Copies the given float values into the current one
  17283. * @param r defines the red component to read from
  17284. * @param g defines the green component to read from
  17285. * @param b defines the blue component to read from
  17286. * @param a defines the alpha component to read from
  17287. * @returns the current updated Color4 object
  17288. */
  17289. set(r: number, g: number, b: number, a: number): Color4;
  17290. /**
  17291. * Compute the Color4 hexadecimal code as a string
  17292. * @returns a string containing the hexadecimal representation of the Color4 object
  17293. */
  17294. toHexString(): string;
  17295. /**
  17296. * Computes a new Color4 converted from the current one to linear space
  17297. * @returns a new Color4 object
  17298. */
  17299. toLinearSpace(): Color4;
  17300. /**
  17301. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  17302. * @param convertedColor defines the Color4 object where to store the linear space version
  17303. * @returns the unmodified Color4
  17304. */
  17305. toLinearSpaceToRef(convertedColor: Color4): Color4;
  17306. /**
  17307. * Computes a new Color4 converted from the current one to gamma space
  17308. * @returns a new Color4 object
  17309. */
  17310. toGammaSpace(): Color4;
  17311. /**
  17312. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  17313. * @param convertedColor defines the Color4 object where to store the gamma space version
  17314. * @returns the unmodified Color4
  17315. */
  17316. toGammaSpaceToRef(convertedColor: Color4): Color4;
  17317. /**
  17318. * Creates a new Color4 from the string containing valid hexadecimal values
  17319. * @param hex defines a string containing valid hexadecimal values
  17320. * @returns a new Color4 object
  17321. */
  17322. static FromHexString(hex: string): Color4;
  17323. /**
  17324. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17325. * @param left defines the start value
  17326. * @param right defines the end value
  17327. * @param amount defines the gradient factor
  17328. * @returns a new Color4 object
  17329. */
  17330. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  17331. /**
  17332. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  17333. * @param left defines the start value
  17334. * @param right defines the end value
  17335. * @param amount defines the gradient factor
  17336. * @param result defines the Color4 object where to store data
  17337. */
  17338. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  17339. /**
  17340. * Creates a new Color4 from a Color3 and an alpha value
  17341. * @param color3 defines the source Color3 to read from
  17342. * @param alpha defines the alpha component (1.0 by default)
  17343. * @returns a new Color4 object
  17344. */
  17345. static FromColor3(color3: Color3, alpha?: number): Color4;
  17346. /**
  17347. * Creates a new Color4 from the starting index element of the given array
  17348. * @param array defines the source array to read from
  17349. * @param offset defines the offset in the source array
  17350. * @returns a new Color4 object
  17351. */
  17352. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  17353. /**
  17354. * Creates a new Color3 from integer values (< 256)
  17355. * @param r defines the red component to read from (value between 0 and 255)
  17356. * @param g defines the green component to read from (value between 0 and 255)
  17357. * @param b defines the blue component to read from (value between 0 and 255)
  17358. * @param a defines the alpha component to read from (value between 0 and 255)
  17359. * @returns a new Color3 object
  17360. */
  17361. static FromInts(r: number, g: number, b: number, a: number): Color4;
  17362. /**
  17363. * Check the content of a given array and convert it to an array containing RGBA data
  17364. * If the original array was already containing count * 4 values then it is returned directly
  17365. * @param colors defines the array to check
  17366. * @param count defines the number of RGBA data to expect
  17367. * @returns an array containing count * 4 values (RGBA)
  17368. */
  17369. static CheckColors4(colors: number[], count: number): number[];
  17370. }
  17371. /**
  17372. * Class representing a vector containing 2 coordinates
  17373. */
  17374. class Vector2 {
  17375. /** defines the first coordinate */
  17376. x: number;
  17377. /** defines the second coordinate */
  17378. y: number;
  17379. /**
  17380. * Creates a new Vector2 from the given x and y coordinates
  17381. * @param x defines the first coordinate
  17382. * @param y defines the second coordinate
  17383. */
  17384. constructor(
  17385. /** defines the first coordinate */
  17386. x?: number,
  17387. /** defines the second coordinate */
  17388. y?: number);
  17389. /**
  17390. * Gets a string with the Vector2 coordinates
  17391. * @returns a string with the Vector2 coordinates
  17392. */
  17393. toString(): string;
  17394. /**
  17395. * Gets class name
  17396. * @returns the string "Vector2"
  17397. */
  17398. getClassName(): string;
  17399. /**
  17400. * Gets current vector hash code
  17401. * @returns the Vector2 hash code as a number
  17402. */
  17403. getHashCode(): number;
  17404. /**
  17405. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  17406. * @param array defines the source array
  17407. * @param index defines the offset in source array
  17408. * @returns the current Vector2
  17409. */
  17410. toArray(array: FloatArray, index?: number): Vector2;
  17411. /**
  17412. * Copy the current vector to an array
  17413. * @returns a new array with 2 elements: the Vector2 coordinates.
  17414. */
  17415. asArray(): number[];
  17416. /**
  17417. * Sets the Vector2 coordinates with the given Vector2 coordinates
  17418. * @param source defines the source Vector2
  17419. * @returns the current updated Vector2
  17420. */
  17421. copyFrom(source: Vector2): Vector2;
  17422. /**
  17423. * Sets the Vector2 coordinates with the given floats
  17424. * @param x defines the first coordinate
  17425. * @param y defines the second coordinate
  17426. * @returns the current updated Vector2
  17427. */
  17428. copyFromFloats(x: number, y: number): Vector2;
  17429. /**
  17430. * Sets the Vector2 coordinates with the given floats
  17431. * @param x defines the first coordinate
  17432. * @param y defines the second coordinate
  17433. * @returns the current updated Vector2
  17434. */
  17435. set(x: number, y: number): Vector2;
  17436. /**
  17437. * Add another vector with the current one
  17438. * @param otherVector defines the other vector
  17439. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  17440. */
  17441. add(otherVector: Vector2): Vector2;
  17442. /**
  17443. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  17444. * @param otherVector defines the other vector
  17445. * @param result defines the target vector
  17446. * @returns the unmodified current Vector2
  17447. */
  17448. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  17449. /**
  17450. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  17451. * @param otherVector defines the other vector
  17452. * @returns the current updated Vector2
  17453. */
  17454. addInPlace(otherVector: Vector2): Vector2;
  17455. /**
  17456. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  17457. * @param otherVector defines the other vector
  17458. * @returns a new Vector2
  17459. */
  17460. addVector3(otherVector: Vector3): Vector2;
  17461. /**
  17462. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  17463. * @param otherVector defines the other vector
  17464. * @returns a new Vector2
  17465. */
  17466. subtract(otherVector: Vector2): Vector2;
  17467. /**
  17468. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  17469. * @param otherVector defines the other vector
  17470. * @param result defines the target vector
  17471. * @returns the unmodified current Vector2
  17472. */
  17473. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  17474. /**
  17475. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  17476. * @param otherVector defines the other vector
  17477. * @returns the current updated Vector2
  17478. */
  17479. subtractInPlace(otherVector: Vector2): Vector2;
  17480. /**
  17481. * Multiplies in place the current Vector2 coordinates by the given ones
  17482. * @param otherVector defines the other vector
  17483. * @returns the current updated Vector2
  17484. */
  17485. multiplyInPlace(otherVector: Vector2): Vector2;
  17486. /**
  17487. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  17488. * @param otherVector defines the other vector
  17489. * @returns a new Vector2
  17490. */
  17491. multiply(otherVector: Vector2): Vector2;
  17492. /**
  17493. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  17494. * @param otherVector defines the other vector
  17495. * @param result defines the target vector
  17496. * @returns the unmodified current Vector2
  17497. */
  17498. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  17499. /**
  17500. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  17501. * @param x defines the first coordinate
  17502. * @param y defines the second coordinate
  17503. * @returns a new Vector2
  17504. */
  17505. multiplyByFloats(x: number, y: number): Vector2;
  17506. /**
  17507. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  17508. * @param otherVector defines the other vector
  17509. * @returns a new Vector2
  17510. */
  17511. divide(otherVector: Vector2): Vector2;
  17512. /**
  17513. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  17514. * @param otherVector defines the other vector
  17515. * @param result defines the target vector
  17516. * @returns the unmodified current Vector2
  17517. */
  17518. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  17519. /**
  17520. * Divides the current Vector2 coordinates by the given ones
  17521. * @param otherVector defines the other vector
  17522. * @returns the current updated Vector2
  17523. */
  17524. divideInPlace(otherVector: Vector2): Vector2;
  17525. /**
  17526. * Gets a new Vector2 with current Vector2 negated coordinates
  17527. * @returns a new Vector2
  17528. */
  17529. negate(): Vector2;
  17530. /**
  17531. * Multiply the Vector2 coordinates by scale
  17532. * @param scale defines the scaling factor
  17533. * @returns the current updated Vector2
  17534. */
  17535. scaleInPlace(scale: number): Vector2;
  17536. /**
  17537. * Returns a new Vector2 scaled by "scale" from the current Vector2
  17538. * @param scale defines the scaling factor
  17539. * @returns a new Vector2
  17540. */
  17541. scale(scale: number): Vector2;
  17542. /**
  17543. * Scale the current Vector2 values by a factor to a given Vector2
  17544. * @param scale defines the scale factor
  17545. * @param result defines the Vector2 object where to store the result
  17546. * @returns the unmodified current Vector2
  17547. */
  17548. scaleToRef(scale: number, result: Vector2): Vector2;
  17549. /**
  17550. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  17551. * @param scale defines the scale factor
  17552. * @param result defines the Vector2 object where to store the result
  17553. * @returns the unmodified current Vector2
  17554. */
  17555. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  17556. /**
  17557. * Gets a boolean if two vectors are equals
  17558. * @param otherVector defines the other vector
  17559. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  17560. */
  17561. equals(otherVector: Vector2): boolean;
  17562. /**
  17563. * Gets a boolean if two vectors are equals (using an epsilon value)
  17564. * @param otherVector defines the other vector
  17565. * @param epsilon defines the minimal distance to consider equality
  17566. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  17567. */
  17568. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  17569. /**
  17570. * Gets a new Vector2 from current Vector2 floored values
  17571. * @returns a new Vector2
  17572. */
  17573. floor(): Vector2;
  17574. /**
  17575. * Gets a new Vector2 from current Vector2 floored values
  17576. * @returns a new Vector2
  17577. */
  17578. fract(): Vector2;
  17579. /**
  17580. * Gets the length of the vector
  17581. * @returns the vector length (float)
  17582. */
  17583. length(): number;
  17584. /**
  17585. * Gets the vector squared length
  17586. * @returns the vector squared length (float)
  17587. */
  17588. lengthSquared(): number;
  17589. /**
  17590. * Normalize the vector
  17591. * @returns the current updated Vector2
  17592. */
  17593. normalize(): Vector2;
  17594. /**
  17595. * Gets a new Vector2 copied from the Vector2
  17596. * @returns a new Vector2
  17597. */
  17598. clone(): Vector2;
  17599. /**
  17600. * Gets a new Vector2(0, 0)
  17601. * @returns a new Vector2
  17602. */
  17603. static Zero(): Vector2;
  17604. /**
  17605. * Gets a new Vector2(1, 1)
  17606. * @returns a new Vector2
  17607. */
  17608. static One(): Vector2;
  17609. /**
  17610. * Gets a new Vector2 set from the given index element of the given array
  17611. * @param array defines the data source
  17612. * @param offset defines the offset in the data source
  17613. * @returns a new Vector2
  17614. */
  17615. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  17616. /**
  17617. * Sets "result" from the given index element of the given array
  17618. * @param array defines the data source
  17619. * @param offset defines the offset in the data source
  17620. * @param result defines the target vector
  17621. */
  17622. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  17623. /**
  17624. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  17625. * @param value1 defines 1st point of control
  17626. * @param value2 defines 2nd point of control
  17627. * @param value3 defines 3rd point of control
  17628. * @param value4 defines 4th point of control
  17629. * @param amount defines the interpolation factor
  17630. * @returns a new Vector2
  17631. */
  17632. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  17633. /**
  17634. * 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".
  17635. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  17636. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  17637. * @param value defines the value to clamp
  17638. * @param min defines the lower limit
  17639. * @param max defines the upper limit
  17640. * @returns a new Vector2
  17641. */
  17642. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  17643. /**
  17644. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  17645. * @param value1 defines the 1st control point
  17646. * @param tangent1 defines the outgoing tangent
  17647. * @param value2 defines the 2nd control point
  17648. * @param tangent2 defines the incoming tangent
  17649. * @param amount defines the interpolation factor
  17650. * @returns a new Vector2
  17651. */
  17652. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  17653. /**
  17654. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  17655. * @param start defines the start vector
  17656. * @param end defines the end vector
  17657. * @param amount defines the interpolation factor
  17658. * @returns a new Vector2
  17659. */
  17660. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  17661. /**
  17662. * Gets the dot product of the vector "left" and the vector "right"
  17663. * @param left defines first vector
  17664. * @param right defines second vector
  17665. * @returns the dot product (float)
  17666. */
  17667. static Dot(left: Vector2, right: Vector2): number;
  17668. /**
  17669. * Returns a new Vector2 equal to the normalized given vector
  17670. * @param vector defines the vector to normalize
  17671. * @returns a new Vector2
  17672. */
  17673. static Normalize(vector: Vector2): Vector2;
  17674. /**
  17675. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  17676. * @param left defines 1st vector
  17677. * @param right defines 2nd vector
  17678. * @returns a new Vector2
  17679. */
  17680. static Minimize(left: Vector2, right: Vector2): Vector2;
  17681. /**
  17682. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  17683. * @param left defines 1st vector
  17684. * @param right defines 2nd vector
  17685. * @returns a new Vector2
  17686. */
  17687. static Maximize(left: Vector2, right: Vector2): Vector2;
  17688. /**
  17689. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  17690. * @param vector defines the vector to transform
  17691. * @param transformation defines the matrix to apply
  17692. * @returns a new Vector2
  17693. */
  17694. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  17695. /**
  17696. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  17697. * @param vector defines the vector to transform
  17698. * @param transformation defines the matrix to apply
  17699. * @param result defines the target vector
  17700. */
  17701. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  17702. /**
  17703. * Determines if a given vector is included in a triangle
  17704. * @param p defines the vector to test
  17705. * @param p0 defines 1st triangle point
  17706. * @param p1 defines 2nd triangle point
  17707. * @param p2 defines 3rd triangle point
  17708. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  17709. */
  17710. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  17711. /**
  17712. * Gets the distance between the vectors "value1" and "value2"
  17713. * @param value1 defines first vector
  17714. * @param value2 defines second vector
  17715. * @returns the distance between vectors
  17716. */
  17717. static Distance(value1: Vector2, value2: Vector2): number;
  17718. /**
  17719. * Returns the squared distance between the vectors "value1" and "value2"
  17720. * @param value1 defines first vector
  17721. * @param value2 defines second vector
  17722. * @returns the squared distance between vectors
  17723. */
  17724. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  17725. /**
  17726. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  17727. * @param value1 defines first vector
  17728. * @param value2 defines second vector
  17729. * @returns a new Vector2
  17730. */
  17731. static Center(value1: Vector2, value2: Vector2): Vector2;
  17732. /**
  17733. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  17734. * @param p defines the middle point
  17735. * @param segA defines one point of the segment
  17736. * @param segB defines the other point of the segment
  17737. * @returns the shortest distance
  17738. */
  17739. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  17740. }
  17741. /**
  17742. * Classed used to store (x,y,z) vector representation
  17743. * A Vector3 is the main object used in 3D geometry
  17744. * It can represent etiher the coordinates of a point the space, either a direction
  17745. * Reminder: Babylon.js uses a left handed forward facing system
  17746. */
  17747. class Vector3 {
  17748. /**
  17749. * Defines the first coordinates (on X axis)
  17750. */
  17751. x: number;
  17752. /**
  17753. * Defines the second coordinates (on Y axis)
  17754. */
  17755. y: number;
  17756. /**
  17757. * Defines the third coordinates (on Z axis)
  17758. */
  17759. z: number;
  17760. /**
  17761. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  17762. * @param x defines the first coordinates (on X axis)
  17763. * @param y defines the second coordinates (on Y axis)
  17764. * @param z defines the third coordinates (on Z axis)
  17765. */
  17766. constructor(
  17767. /**
  17768. * Defines the first coordinates (on X axis)
  17769. */
  17770. x?: number,
  17771. /**
  17772. * Defines the second coordinates (on Y axis)
  17773. */
  17774. y?: number,
  17775. /**
  17776. * Defines the third coordinates (on Z axis)
  17777. */
  17778. z?: number);
  17779. /**
  17780. * Creates a string representation of the Vector3
  17781. * @returns a string with the Vector3 coordinates.
  17782. */
  17783. toString(): string;
  17784. /**
  17785. * Gets the class name
  17786. * @returns the string "Vector3"
  17787. */
  17788. getClassName(): string;
  17789. /**
  17790. * Creates the Vector3 hash code
  17791. * @returns a number which tends to be unique between Vector3 instances
  17792. */
  17793. getHashCode(): number;
  17794. /**
  17795. * Creates an array containing three elements : the coordinates of the Vector3
  17796. * @returns a new array of numbers
  17797. */
  17798. asArray(): number[];
  17799. /**
  17800. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  17801. * @param array defines the destination array
  17802. * @param index defines the offset in the destination array
  17803. * @returns the current Vector3
  17804. */
  17805. toArray(array: FloatArray, index?: number): Vector3;
  17806. /**
  17807. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  17808. * @returns a new Quaternion object, computed from the Vector3 coordinates
  17809. */
  17810. toQuaternion(): Quaternion;
  17811. /**
  17812. * Adds the given vector to the current Vector3
  17813. * @param otherVector defines the second operand
  17814. * @returns the current updated Vector3
  17815. */
  17816. addInPlace(otherVector: Vector3): Vector3;
  17817. /**
  17818. * Adds the given coordinates to the current Vector3
  17819. * @param x defines the x coordinate of the operand
  17820. * @param y defines the y coordinate of the operand
  17821. * @param z defines the z coordinate of the operand
  17822. * @returns the current updated Vector3
  17823. */
  17824. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  17825. /**
  17826. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  17827. * @param otherVector defines the second operand
  17828. * @returns the resulting Vector3
  17829. */
  17830. add(otherVector: Vector3): Vector3;
  17831. /**
  17832. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  17833. * @param otherVector defines the second operand
  17834. * @param result defines the Vector3 object where to store the result
  17835. * @returns the current Vector3
  17836. */
  17837. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  17838. /**
  17839. * Subtract the given vector from the current Vector3
  17840. * @param otherVector defines the second operand
  17841. * @returns the current updated Vector3
  17842. */
  17843. subtractInPlace(otherVector: Vector3): Vector3;
  17844. /**
  17845. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  17846. * @param otherVector defines the second operand
  17847. * @returns the resulting Vector3
  17848. */
  17849. subtract(otherVector: Vector3): Vector3;
  17850. /**
  17851. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  17852. * @param otherVector defines the second operand
  17853. * @param result defines the Vector3 object where to store the result
  17854. * @returns the current Vector3
  17855. */
  17856. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  17857. /**
  17858. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  17859. * @param x defines the x coordinate of the operand
  17860. * @param y defines the y coordinate of the operand
  17861. * @param z defines the z coordinate of the operand
  17862. * @returns the resulting Vector3
  17863. */
  17864. subtractFromFloats(x: number, y: number, z: number): Vector3;
  17865. /**
  17866. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  17867. * @param x defines the x coordinate of the operand
  17868. * @param y defines the y coordinate of the operand
  17869. * @param z defines the z coordinate of the operand
  17870. * @param result defines the Vector3 object where to store the result
  17871. * @returns the current Vector3
  17872. */
  17873. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  17874. /**
  17875. * Gets a new Vector3 set with the current Vector3 negated coordinates
  17876. * @returns a new Vector3
  17877. */
  17878. negate(): Vector3;
  17879. /**
  17880. * Multiplies the Vector3 coordinates by the float "scale"
  17881. * @param scale defines the multiplier factor
  17882. * @returns the current updated Vector3
  17883. */
  17884. scaleInPlace(scale: number): Vector3;
  17885. /**
  17886. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  17887. * @param scale defines the multiplier factor
  17888. * @returns a new Vector3
  17889. */
  17890. scale(scale: number): Vector3;
  17891. /**
  17892. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  17893. * @param scale defines the multiplier factor
  17894. * @param result defines the Vector3 object where to store the result
  17895. * @returns the current Vector3
  17896. */
  17897. scaleToRef(scale: number, result: Vector3): Vector3;
  17898. /**
  17899. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  17900. * @param scale defines the scale factor
  17901. * @param result defines the Vector3 object where to store the result
  17902. * @returns the unmodified current Vector3
  17903. */
  17904. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  17905. /**
  17906. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  17907. * @param otherVector defines the second operand
  17908. * @returns true if both vectors are equals
  17909. */
  17910. equals(otherVector: Vector3): boolean;
  17911. /**
  17912. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  17913. * @param otherVector defines the second operand
  17914. * @param epsilon defines the minimal distance to define values as equals
  17915. * @returns true if both vectors are distant less than epsilon
  17916. */
  17917. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  17918. /**
  17919. * Returns true if the current Vector3 coordinates equals the given floats
  17920. * @param x defines the x coordinate of the operand
  17921. * @param y defines the y coordinate of the operand
  17922. * @param z defines the z coordinate of the operand
  17923. * @returns true if both vectors are equals
  17924. */
  17925. equalsToFloats(x: number, y: number, z: number): boolean;
  17926. /**
  17927. * Multiplies the current Vector3 coordinates by the given ones
  17928. * @param otherVector defines the second operand
  17929. * @returns the current updated Vector3
  17930. */
  17931. multiplyInPlace(otherVector: Vector3): Vector3;
  17932. /**
  17933. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  17934. * @param otherVector defines the second operand
  17935. * @returns the new Vector3
  17936. */
  17937. multiply(otherVector: Vector3): Vector3;
  17938. /**
  17939. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  17940. * @param otherVector defines the second operand
  17941. * @param result defines the Vector3 object where to store the result
  17942. * @returns the current Vector3
  17943. */
  17944. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  17945. /**
  17946. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  17947. * @param x defines the x coordinate of the operand
  17948. * @param y defines the y coordinate of the operand
  17949. * @param z defines the z coordinate of the operand
  17950. * @returns the new Vector3
  17951. */
  17952. multiplyByFloats(x: number, y: number, z: number): Vector3;
  17953. /**
  17954. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  17955. * @param otherVector defines the second operand
  17956. * @returns the new Vector3
  17957. */
  17958. divide(otherVector: Vector3): Vector3;
  17959. /**
  17960. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  17961. * @param otherVector defines the second operand
  17962. * @param result defines the Vector3 object where to store the result
  17963. * @returns the current Vector3
  17964. */
  17965. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  17966. /**
  17967. * Divides the current Vector3 coordinates by the given ones.
  17968. * @param otherVector defines the second operand
  17969. * @returns the current updated Vector3
  17970. */
  17971. divideInPlace(otherVector: Vector3): Vector3;
  17972. /**
  17973. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  17974. * @param other defines the second operand
  17975. * @returns the current updated Vector3
  17976. */
  17977. minimizeInPlace(other: Vector3): Vector3;
  17978. /**
  17979. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  17980. * @param other defines the second operand
  17981. * @returns the current updated Vector3
  17982. */
  17983. maximizeInPlace(other: Vector3): Vector3;
  17984. /**
  17985. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  17986. * @param x defines the x coordinate of the operand
  17987. * @param y defines the y coordinate of the operand
  17988. * @param z defines the z coordinate of the operand
  17989. * @returns the current updated Vector3
  17990. */
  17991. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  17992. /**
  17993. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  17994. * @param x defines the x coordinate of the operand
  17995. * @param y defines the y coordinate of the operand
  17996. * @param z defines the z coordinate of the operand
  17997. * @returns the current updated Vector3
  17998. */
  17999. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  18000. /**
  18001. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  18002. */
  18003. readonly isNonUniform: boolean;
  18004. /**
  18005. * Gets a new Vector3 from current Vector3 floored values
  18006. * @returns a new Vector3
  18007. */
  18008. floor(): Vector3;
  18009. /**
  18010. * Gets a new Vector3 from current Vector3 floored values
  18011. * @returns a new Vector3
  18012. */
  18013. fract(): Vector3;
  18014. /**
  18015. * Gets the length of the Vector3
  18016. * @returns the length of the Vecto3
  18017. */
  18018. length(): number;
  18019. /**
  18020. * Gets the squared length of the Vector3
  18021. * @returns squared length of the Vector3
  18022. */
  18023. lengthSquared(): number;
  18024. /**
  18025. * Normalize the current Vector3.
  18026. * Please note that this is an in place operation.
  18027. * @returns the current updated Vector3
  18028. */
  18029. normalize(): Vector3;
  18030. /**
  18031. * Normalize the current Vector3 with the given input length.
  18032. * Please note that this is an in place operation.
  18033. * @param len the length of the vector
  18034. * @returns the current updated Vector3
  18035. */
  18036. normalizeFromLength(len: number): Vector3;
  18037. /**
  18038. * Normalize the current Vector3 to a new vector
  18039. * @returns the new Vector3
  18040. */
  18041. normalizeToNew(): Vector3;
  18042. /**
  18043. * Normalize the current Vector3 to the reference
  18044. * @param reference define the Vector3 to update
  18045. * @returns the updated Vector3
  18046. */
  18047. normalizeToRef(reference: Vector3): Vector3;
  18048. /**
  18049. * Creates a new Vector3 copied from the current Vector3
  18050. * @returns the new Vector3
  18051. */
  18052. clone(): Vector3;
  18053. /**
  18054. * Copies the given vector coordinates to the current Vector3 ones
  18055. * @param source defines the source Vector3
  18056. * @returns the current updated Vector3
  18057. */
  18058. copyFrom(source: Vector3): Vector3;
  18059. /**
  18060. * Copies the given floats to the current Vector3 coordinates
  18061. * @param x defines the x coordinate of the operand
  18062. * @param y defines the y coordinate of the operand
  18063. * @param z defines the z coordinate of the operand
  18064. * @returns the current updated Vector3
  18065. */
  18066. copyFromFloats(x: number, y: number, z: number): Vector3;
  18067. /**
  18068. * Copies the given floats to the current Vector3 coordinates
  18069. * @param x defines the x coordinate of the operand
  18070. * @param y defines the y coordinate of the operand
  18071. * @param z defines the z coordinate of the operand
  18072. * @returns the current updated Vector3
  18073. */
  18074. set(x: number, y: number, z: number): Vector3;
  18075. /**
  18076. * Copies the given float to the current Vector3 coordinates
  18077. * @param v defines the x, y and z coordinates of the operand
  18078. * @returns the current updated Vector3
  18079. */
  18080. setAll(v: number): Vector3;
  18081. /**
  18082. * Get the clip factor between two vectors
  18083. * @param vector0 defines the first operand
  18084. * @param vector1 defines the second operand
  18085. * @param axis defines the axis to use
  18086. * @param size defines the size along the axis
  18087. * @returns the clip factor
  18088. */
  18089. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  18090. /**
  18091. * Get angle between two vectors
  18092. * @param vector0 angle between vector0 and vector1
  18093. * @param vector1 angle between vector0 and vector1
  18094. * @param normal direction of the normal
  18095. * @return the angle between vector0 and vector1
  18096. */
  18097. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  18098. /**
  18099. * Returns a new Vector3 set from the index "offset" of the given array
  18100. * @param array defines the source array
  18101. * @param offset defines the offset in the source array
  18102. * @returns the new Vector3
  18103. */
  18104. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  18105. /**
  18106. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  18107. * This function is deprecated. Use FromArray instead
  18108. * @param array defines the source array
  18109. * @param offset defines the offset in the source array
  18110. * @returns the new Vector3
  18111. */
  18112. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  18113. /**
  18114. * Sets the given vector "result" with the element values from the index "offset" of the given array
  18115. * @param array defines the source array
  18116. * @param offset defines the offset in the source array
  18117. * @param result defines the Vector3 where to store the result
  18118. */
  18119. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  18120. /**
  18121. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  18122. * This function is deprecated. Use FromArrayToRef instead.
  18123. * @param array defines the source array
  18124. * @param offset defines the offset in the source array
  18125. * @param result defines the Vector3 where to store the result
  18126. */
  18127. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  18128. /**
  18129. * Sets the given vector "result" with the given floats.
  18130. * @param x defines the x coordinate of the source
  18131. * @param y defines the y coordinate of the source
  18132. * @param z defines the z coordinate of the source
  18133. * @param result defines the Vector3 where to store the result
  18134. */
  18135. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  18136. /**
  18137. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  18138. * @returns a new empty Vector3
  18139. */
  18140. static Zero(): Vector3;
  18141. /**
  18142. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  18143. * @returns a new unit Vector3
  18144. */
  18145. static One(): Vector3;
  18146. /**
  18147. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  18148. * @returns a new up Vector3
  18149. */
  18150. static Up(): Vector3;
  18151. /**
  18152. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  18153. * @returns a new down Vector3
  18154. */
  18155. static Down(): Vector3;
  18156. /**
  18157. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  18158. * @returns a new forward Vector3
  18159. */
  18160. static Forward(): Vector3;
  18161. /**
  18162. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  18163. * @returns a new forward Vector3
  18164. */
  18165. static Backward(): Vector3;
  18166. /**
  18167. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  18168. * @returns a new right Vector3
  18169. */
  18170. static Right(): Vector3;
  18171. /**
  18172. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  18173. * @returns a new left Vector3
  18174. */
  18175. static Left(): Vector3;
  18176. /**
  18177. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  18178. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18179. * @param vector defines the Vector3 to transform
  18180. * @param transformation defines the transformation matrix
  18181. * @returns the transformed Vector3
  18182. */
  18183. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  18184. /**
  18185. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  18186. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  18187. * @param vector defines the Vector3 to transform
  18188. * @param transformation defines the transformation matrix
  18189. * @param result defines the Vector3 where to store the result
  18190. */
  18191. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  18192. /**
  18193. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  18194. * This method computes tranformed coordinates only, not transformed direction vectors
  18195. * @param x define the x coordinate of the source vector
  18196. * @param y define the y coordinate of the source vector
  18197. * @param z define the z coordinate of the source vector
  18198. * @param transformation defines the transformation matrix
  18199. * @param result defines the Vector3 where to store the result
  18200. */
  18201. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  18202. /**
  18203. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  18204. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18205. * @param vector defines the Vector3 to transform
  18206. * @param transformation defines the transformation matrix
  18207. * @returns the new Vector3
  18208. */
  18209. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  18210. /**
  18211. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  18212. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18213. * @param vector defines the Vector3 to transform
  18214. * @param transformation defines the transformation matrix
  18215. * @param result defines the Vector3 where to store the result
  18216. */
  18217. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  18218. /**
  18219. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  18220. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  18221. * @param x define the x coordinate of the source vector
  18222. * @param y define the y coordinate of the source vector
  18223. * @param z define the z coordinate of the source vector
  18224. * @param transformation defines the transformation matrix
  18225. * @param result defines the Vector3 where to store the result
  18226. */
  18227. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  18228. /**
  18229. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  18230. * @param value1 defines the first control point
  18231. * @param value2 defines the second control point
  18232. * @param value3 defines the third control point
  18233. * @param value4 defines the fourth control point
  18234. * @param amount defines the amount on the spline to use
  18235. * @returns the new Vector3
  18236. */
  18237. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  18238. /**
  18239. * 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"
  18240. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  18241. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  18242. * @param value defines the current value
  18243. * @param min defines the lower range value
  18244. * @param max defines the upper range value
  18245. * @returns the new Vector3
  18246. */
  18247. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  18248. /**
  18249. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  18250. * @param value1 defines the first control point
  18251. * @param tangent1 defines the first tangent vector
  18252. * @param value2 defines the second control point
  18253. * @param tangent2 defines the second tangent vector
  18254. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  18255. * @returns the new Vector3
  18256. */
  18257. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  18258. /**
  18259. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  18260. * @param start defines the start value
  18261. * @param end defines the end value
  18262. * @param amount max defines amount between both (between 0 and 1)
  18263. * @returns the new Vector3
  18264. */
  18265. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  18266. /**
  18267. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  18268. * @param start defines the start value
  18269. * @param end defines the end value
  18270. * @param amount max defines amount between both (between 0 and 1)
  18271. * @param result defines the Vector3 where to store the result
  18272. */
  18273. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  18274. /**
  18275. * Returns the dot product (float) between the vectors "left" and "right"
  18276. * @param left defines the left operand
  18277. * @param right defines the right operand
  18278. * @returns the dot product
  18279. */
  18280. static Dot(left: Vector3, right: Vector3): number;
  18281. /**
  18282. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  18283. * The cross product is then orthogonal to both "left" and "right"
  18284. * @param left defines the left operand
  18285. * @param right defines the right operand
  18286. * @returns the cross product
  18287. */
  18288. static Cross(left: Vector3, right: Vector3): Vector3;
  18289. /**
  18290. * Sets the given vector "result" with the cross product of "left" and "right"
  18291. * The cross product is then orthogonal to both "left" and "right"
  18292. * @param left defines the left operand
  18293. * @param right defines the right operand
  18294. * @param result defines the Vector3 where to store the result
  18295. */
  18296. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  18297. /**
  18298. * Returns a new Vector3 as the normalization of the given vector
  18299. * @param vector defines the Vector3 to normalize
  18300. * @returns the new Vector3
  18301. */
  18302. static Normalize(vector: Vector3): Vector3;
  18303. /**
  18304. * Sets the given vector "result" with the normalization of the given first vector
  18305. * @param vector defines the Vector3 to normalize
  18306. * @param result defines the Vector3 where to store the result
  18307. */
  18308. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  18309. private static _viewportMatrixCache;
  18310. /**
  18311. * Project a Vector3 onto screen space
  18312. * @param vector defines the Vector3 to project
  18313. * @param world defines the world matrix to use
  18314. * @param transform defines the transform (view x projection) matrix to use
  18315. * @param viewport defines the screen viewport to use
  18316. * @returns the new Vector3
  18317. */
  18318. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  18319. /**
  18320. * Unproject from screen space to object space
  18321. * @param source defines the screen space Vector3 to use
  18322. * @param viewportWidth defines the current width of the viewport
  18323. * @param viewportHeight defines the current height of the viewport
  18324. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18325. * @param transform defines the transform (view x projection) matrix to use
  18326. * @returns the new Vector3
  18327. */
  18328. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  18329. /**
  18330. * Unproject from screen space to object space
  18331. * @param source defines the screen space Vector3 to use
  18332. * @param viewportWidth defines the current width of the viewport
  18333. * @param viewportHeight defines the current height of the viewport
  18334. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18335. * @param view defines the view matrix to use
  18336. * @param projection defines the projection matrix to use
  18337. * @returns the new Vector3
  18338. */
  18339. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  18340. /**
  18341. * Unproject from screen space to object space
  18342. * @param source defines the screen space Vector3 to use
  18343. * @param viewportWidth defines the current width of the viewport
  18344. * @param viewportHeight defines the current height of the viewport
  18345. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18346. * @param view defines the view matrix to use
  18347. * @param projection defines the projection matrix to use
  18348. * @param result defines the Vector3 where to store the result
  18349. */
  18350. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  18351. /**
  18352. * Unproject from screen space to object space
  18353. * @param sourceX defines the screen space x coordinate to use
  18354. * @param sourceY defines the screen space y coordinate to use
  18355. * @param sourceZ defines the screen space z coordinate to use
  18356. * @param viewportWidth defines the current width of the viewport
  18357. * @param viewportHeight defines the current height of the viewport
  18358. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  18359. * @param view defines the view matrix to use
  18360. * @param projection defines the projection matrix to use
  18361. * @param result defines the Vector3 where to store the result
  18362. */
  18363. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  18364. /**
  18365. * Gets the minimal coordinate values between two Vector3
  18366. * @param left defines the first operand
  18367. * @param right defines the second operand
  18368. * @returns the new Vector3
  18369. */
  18370. static Minimize(left: Vector3, right: Vector3): Vector3;
  18371. /**
  18372. * Gets the maximal coordinate values between two Vector3
  18373. * @param left defines the first operand
  18374. * @param right defines the second operand
  18375. * @returns the new Vector3
  18376. */
  18377. static Maximize(left: Vector3, right: Vector3): Vector3;
  18378. /**
  18379. * Returns the distance between the vectors "value1" and "value2"
  18380. * @param value1 defines the first operand
  18381. * @param value2 defines the second operand
  18382. * @returns the distance
  18383. */
  18384. static Distance(value1: Vector3, value2: Vector3): number;
  18385. /**
  18386. * Returns the squared distance between the vectors "value1" and "value2"
  18387. * @param value1 defines the first operand
  18388. * @param value2 defines the second operand
  18389. * @returns the squared distance
  18390. */
  18391. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  18392. /**
  18393. * Returns a new Vector3 located at the center between "value1" and "value2"
  18394. * @param value1 defines the first operand
  18395. * @param value2 defines the second operand
  18396. * @returns the new Vector3
  18397. */
  18398. static Center(value1: Vector3, value2: Vector3): Vector3;
  18399. /**
  18400. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  18401. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  18402. * to something in order to rotate it from its local system to the given target system
  18403. * Note: axis1, axis2 and axis3 are normalized during this operation
  18404. * @param axis1 defines the first axis
  18405. * @param axis2 defines the second axis
  18406. * @param axis3 defines the third axis
  18407. * @returns a new Vector3
  18408. */
  18409. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  18410. /**
  18411. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  18412. * @param axis1 defines the first axis
  18413. * @param axis2 defines the second axis
  18414. * @param axis3 defines the third axis
  18415. * @param ref defines the Vector3 where to store the result
  18416. */
  18417. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  18418. }
  18419. /**
  18420. * Vector4 class created for EulerAngle class conversion to Quaternion
  18421. */
  18422. class Vector4 {
  18423. /** x value of the vector */
  18424. x: number;
  18425. /** y value of the vector */
  18426. y: number;
  18427. /** z value of the vector */
  18428. z: number;
  18429. /** w value of the vector */
  18430. w: number;
  18431. /**
  18432. * Creates a Vector4 object from the given floats.
  18433. * @param x x value of the vector
  18434. * @param y y value of the vector
  18435. * @param z z value of the vector
  18436. * @param w w value of the vector
  18437. */
  18438. constructor(
  18439. /** x value of the vector */
  18440. x: number,
  18441. /** y value of the vector */
  18442. y: number,
  18443. /** z value of the vector */
  18444. z: number,
  18445. /** w value of the vector */
  18446. w: number);
  18447. /**
  18448. * Returns the string with the Vector4 coordinates.
  18449. * @returns a string containing all the vector values
  18450. */
  18451. toString(): string;
  18452. /**
  18453. * Returns the string "Vector4".
  18454. * @returns "Vector4"
  18455. */
  18456. getClassName(): string;
  18457. /**
  18458. * Returns the Vector4 hash code.
  18459. * @returns a unique hash code
  18460. */
  18461. getHashCode(): number;
  18462. /**
  18463. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  18464. * @returns the resulting array
  18465. */
  18466. asArray(): number[];
  18467. /**
  18468. * Populates the given array from the given index with the Vector4 coordinates.
  18469. * @param array array to populate
  18470. * @param index index of the array to start at (default: 0)
  18471. * @returns the Vector4.
  18472. */
  18473. toArray(array: FloatArray, index?: number): Vector4;
  18474. /**
  18475. * Adds the given vector to the current Vector4.
  18476. * @param otherVector the vector to add
  18477. * @returns the updated Vector4.
  18478. */
  18479. addInPlace(otherVector: Vector4): Vector4;
  18480. /**
  18481. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  18482. * @param otherVector the vector to add
  18483. * @returns the resulting vector
  18484. */
  18485. add(otherVector: Vector4): Vector4;
  18486. /**
  18487. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  18488. * @param otherVector the vector to add
  18489. * @param result the vector to store the result
  18490. * @returns the current Vector4.
  18491. */
  18492. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  18493. /**
  18494. * Subtract in place the given vector from the current Vector4.
  18495. * @param otherVector the vector to subtract
  18496. * @returns the updated Vector4.
  18497. */
  18498. subtractInPlace(otherVector: Vector4): Vector4;
  18499. /**
  18500. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  18501. * @param otherVector the vector to add
  18502. * @returns the new vector with the result
  18503. */
  18504. subtract(otherVector: Vector4): Vector4;
  18505. /**
  18506. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  18507. * @param otherVector the vector to subtract
  18508. * @param result the vector to store the result
  18509. * @returns the current Vector4.
  18510. */
  18511. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  18512. /**
  18513. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18514. */
  18515. /**
  18516. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18517. * @param x value to subtract
  18518. * @param y value to subtract
  18519. * @param z value to subtract
  18520. * @param w value to subtract
  18521. * @returns new vector containing the result
  18522. */
  18523. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18524. /**
  18525. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  18526. * @param x value to subtract
  18527. * @param y value to subtract
  18528. * @param z value to subtract
  18529. * @param w value to subtract
  18530. * @param result the vector to store the result in
  18531. * @returns the current Vector4.
  18532. */
  18533. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  18534. /**
  18535. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  18536. * @returns a new vector with the negated values
  18537. */
  18538. negate(): Vector4;
  18539. /**
  18540. * Multiplies the current Vector4 coordinates by scale (float).
  18541. * @param scale the number to scale with
  18542. * @returns the updated Vector4.
  18543. */
  18544. scaleInPlace(scale: number): Vector4;
  18545. /**
  18546. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  18547. * @param scale the number to scale with
  18548. * @returns a new vector with the result
  18549. */
  18550. scale(scale: number): Vector4;
  18551. /**
  18552. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  18553. * @param scale the number to scale with
  18554. * @param result a vector to store the result in
  18555. * @returns the current Vector4.
  18556. */
  18557. scaleToRef(scale: number, result: Vector4): Vector4;
  18558. /**
  18559. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  18560. * @param scale defines the scale factor
  18561. * @param result defines the Vector4 object where to store the result
  18562. * @returns the unmodified current Vector4
  18563. */
  18564. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  18565. /**
  18566. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  18567. * @param otherVector the vector to compare against
  18568. * @returns true if they are equal
  18569. */
  18570. equals(otherVector: Vector4): boolean;
  18571. /**
  18572. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  18573. * @param otherVector vector to compare against
  18574. * @param epsilon (Default: very small number)
  18575. * @returns true if they are equal
  18576. */
  18577. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  18578. /**
  18579. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  18580. * @param x x value to compare against
  18581. * @param y y value to compare against
  18582. * @param z z value to compare against
  18583. * @param w w value to compare against
  18584. * @returns true if equal
  18585. */
  18586. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  18587. /**
  18588. * Multiplies in place the current Vector4 by the given one.
  18589. * @param otherVector vector to multiple with
  18590. * @returns the updated Vector4.
  18591. */
  18592. multiplyInPlace(otherVector: Vector4): Vector4;
  18593. /**
  18594. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  18595. * @param otherVector vector to multiple with
  18596. * @returns resulting new vector
  18597. */
  18598. multiply(otherVector: Vector4): Vector4;
  18599. /**
  18600. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  18601. * @param otherVector vector to multiple with
  18602. * @param result vector to store the result
  18603. * @returns the current Vector4.
  18604. */
  18605. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  18606. /**
  18607. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  18608. * @param x x value multiply with
  18609. * @param y y value multiply with
  18610. * @param z z value multiply with
  18611. * @param w w value multiply with
  18612. * @returns resulting new vector
  18613. */
  18614. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  18615. /**
  18616. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  18617. * @param otherVector vector to devide with
  18618. * @returns resulting new vector
  18619. */
  18620. divide(otherVector: Vector4): Vector4;
  18621. /**
  18622. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  18623. * @param otherVector vector to devide with
  18624. * @param result vector to store the result
  18625. * @returns the current Vector4.
  18626. */
  18627. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  18628. /**
  18629. * Divides the current Vector3 coordinates by the given ones.
  18630. * @param otherVector vector to devide with
  18631. * @returns the updated Vector3.
  18632. */
  18633. divideInPlace(otherVector: Vector4): Vector4;
  18634. /**
  18635. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  18636. * @param other defines the second operand
  18637. * @returns the current updated Vector4
  18638. */
  18639. minimizeInPlace(other: Vector4): Vector4;
  18640. /**
  18641. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  18642. * @param other defines the second operand
  18643. * @returns the current updated Vector4
  18644. */
  18645. maximizeInPlace(other: Vector4): Vector4;
  18646. /**
  18647. * Gets a new Vector4 from current Vector4 floored values
  18648. * @returns a new Vector4
  18649. */
  18650. floor(): Vector4;
  18651. /**
  18652. * Gets a new Vector4 from current Vector3 floored values
  18653. * @returns a new Vector4
  18654. */
  18655. fract(): Vector4;
  18656. /**
  18657. * Returns the Vector4 length (float).
  18658. * @returns the length
  18659. */
  18660. length(): number;
  18661. /**
  18662. * Returns the Vector4 squared length (float).
  18663. * @returns the length squared
  18664. */
  18665. lengthSquared(): number;
  18666. /**
  18667. * Normalizes in place the Vector4.
  18668. * @returns the updated Vector4.
  18669. */
  18670. normalize(): Vector4;
  18671. /**
  18672. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  18673. * @returns this converted to a new vector3
  18674. */
  18675. toVector3(): Vector3;
  18676. /**
  18677. * Returns a new Vector4 copied from the current one.
  18678. * @returns the new cloned vector
  18679. */
  18680. clone(): Vector4;
  18681. /**
  18682. * Updates the current Vector4 with the given one coordinates.
  18683. * @param source the source vector to copy from
  18684. * @returns the updated Vector4.
  18685. */
  18686. copyFrom(source: Vector4): Vector4;
  18687. /**
  18688. * Updates the current Vector4 coordinates with the given floats.
  18689. * @param x float to copy from
  18690. * @param y float to copy from
  18691. * @param z float to copy from
  18692. * @param w float to copy from
  18693. * @returns the updated Vector4.
  18694. */
  18695. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  18696. /**
  18697. * Updates the current Vector4 coordinates with the given floats.
  18698. * @param x float to set from
  18699. * @param y float to set from
  18700. * @param z float to set from
  18701. * @param w float to set from
  18702. * @returns the updated Vector4.
  18703. */
  18704. set(x: number, y: number, z: number, w: number): Vector4;
  18705. /**
  18706. * Copies the given float to the current Vector3 coordinates
  18707. * @param v defines the x, y, z and w coordinates of the operand
  18708. * @returns the current updated Vector3
  18709. */
  18710. setAll(v: number): Vector4;
  18711. /**
  18712. * Returns a new Vector4 set from the starting index of the given array.
  18713. * @param array the array to pull values from
  18714. * @param offset the offset into the array to start at
  18715. * @returns the new vector
  18716. */
  18717. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  18718. /**
  18719. * Updates the given vector "result" from the starting index of the given array.
  18720. * @param array the array to pull values from
  18721. * @param offset the offset into the array to start at
  18722. * @param result the vector to store the result in
  18723. */
  18724. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  18725. /**
  18726. * Updates the given vector "result" from the starting index of the given Float32Array.
  18727. * @param array the array to pull values from
  18728. * @param offset the offset into the array to start at
  18729. * @param result the vector to store the result in
  18730. */
  18731. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  18732. /**
  18733. * Updates the given vector "result" coordinates from the given floats.
  18734. * @param x float to set from
  18735. * @param y float to set from
  18736. * @param z float to set from
  18737. * @param w float to set from
  18738. * @param result the vector to the floats in
  18739. */
  18740. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  18741. /**
  18742. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  18743. * @returns the new vector
  18744. */
  18745. static Zero(): Vector4;
  18746. /**
  18747. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  18748. * @returns the new vector
  18749. */
  18750. static One(): Vector4;
  18751. /**
  18752. * Returns a new normalized Vector4 from the given one.
  18753. * @param vector the vector to normalize
  18754. * @returns the vector
  18755. */
  18756. static Normalize(vector: Vector4): Vector4;
  18757. /**
  18758. * Updates the given vector "result" from the normalization of the given one.
  18759. * @param vector the vector to normalize
  18760. * @param result the vector to store the result in
  18761. */
  18762. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  18763. /**
  18764. * Returns a vector with the minimum values from the left and right vectors
  18765. * @param left left vector to minimize
  18766. * @param right right vector to minimize
  18767. * @returns a new vector with the minimum of the left and right vector values
  18768. */
  18769. static Minimize(left: Vector4, right: Vector4): Vector4;
  18770. /**
  18771. * Returns a vector with the maximum values from the left and right vectors
  18772. * @param left left vector to maximize
  18773. * @param right right vector to maximize
  18774. * @returns a new vector with the maximum of the left and right vector values
  18775. */
  18776. static Maximize(left: Vector4, right: Vector4): Vector4;
  18777. /**
  18778. * Returns the distance (float) between the vectors "value1" and "value2".
  18779. * @param value1 value to calulate the distance between
  18780. * @param value2 value to calulate the distance between
  18781. * @return the distance between the two vectors
  18782. */
  18783. static Distance(value1: Vector4, value2: Vector4): number;
  18784. /**
  18785. * Returns the squared distance (float) between the vectors "value1" and "value2".
  18786. * @param value1 value to calulate the distance between
  18787. * @param value2 value to calulate the distance between
  18788. * @return the distance between the two vectors squared
  18789. */
  18790. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  18791. /**
  18792. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  18793. * @param value1 value to calulate the center between
  18794. * @param value2 value to calulate the center between
  18795. * @return the center between the two vectors
  18796. */
  18797. static Center(value1: Vector4, value2: Vector4): Vector4;
  18798. /**
  18799. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  18800. * This methods computes transformed normalized direction vectors only.
  18801. * @param vector the vector to transform
  18802. * @param transformation the transformation matrix to apply
  18803. * @returns the new vector
  18804. */
  18805. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  18806. /**
  18807. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  18808. * This methods computes transformed normalized direction vectors only.
  18809. * @param vector the vector to transform
  18810. * @param transformation the transformation matrix to apply
  18811. * @param result the vector to store the result in
  18812. */
  18813. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  18814. /**
  18815. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  18816. * This methods computes transformed normalized direction vectors only.
  18817. * @param x value to transform
  18818. * @param y value to transform
  18819. * @param z value to transform
  18820. * @param w value to transform
  18821. * @param transformation the transformation matrix to apply
  18822. * @param result the vector to store the results in
  18823. */
  18824. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  18825. }
  18826. /**
  18827. * Interface for the size containing width and height
  18828. */
  18829. interface ISize {
  18830. /**
  18831. * Width
  18832. */
  18833. width: number;
  18834. /**
  18835. * Heighht
  18836. */
  18837. height: number;
  18838. }
  18839. /**
  18840. * Size containing widht and height
  18841. */
  18842. class Size implements ISize {
  18843. /**
  18844. * Width
  18845. */
  18846. width: number;
  18847. /**
  18848. * Height
  18849. */
  18850. height: number;
  18851. /**
  18852. * Creates a Size object from the given width and height (floats).
  18853. * @param width width of the new size
  18854. * @param height height of the new size
  18855. */
  18856. constructor(width: number, height: number);
  18857. /**
  18858. * Returns a string with the Size width and height
  18859. * @returns a string with the Size width and height
  18860. */
  18861. toString(): string;
  18862. /**
  18863. * "Size"
  18864. * @returns the string "Size"
  18865. */
  18866. getClassName(): string;
  18867. /**
  18868. * Returns the Size hash code.
  18869. * @returns a hash code for a unique width and height
  18870. */
  18871. getHashCode(): number;
  18872. /**
  18873. * Updates the current size from the given one.
  18874. * @param src the given size
  18875. */
  18876. copyFrom(src: Size): void;
  18877. /**
  18878. * Updates in place the current Size from the given floats.
  18879. * @param width width of the new size
  18880. * @param height height of the new size
  18881. * @returns the updated Size.
  18882. */
  18883. copyFromFloats(width: number, height: number): Size;
  18884. /**
  18885. * Updates in place the current Size from the given floats.
  18886. * @param width width to set
  18887. * @param height height to set
  18888. * @returns the updated Size.
  18889. */
  18890. set(width: number, height: number): Size;
  18891. /**
  18892. * Multiplies the width and height by numbers
  18893. * @param w factor to multiple the width by
  18894. * @param h factor to multiple the height by
  18895. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  18896. */
  18897. multiplyByFloats(w: number, h: number): Size;
  18898. /**
  18899. * Clones the size
  18900. * @returns a new Size copied from the given one.
  18901. */
  18902. clone(): Size;
  18903. /**
  18904. * True if the current Size and the given one width and height are strictly equal.
  18905. * @param other the other size to compare against
  18906. * @returns True if the current Size and the given one width and height are strictly equal.
  18907. */
  18908. equals(other: Size): boolean;
  18909. /**
  18910. * The surface of the Size : width * height (float).
  18911. */
  18912. readonly surface: number;
  18913. /**
  18914. * Create a new size of zero
  18915. * @returns a new Size set to (0.0, 0.0)
  18916. */
  18917. static Zero(): Size;
  18918. /**
  18919. * Sums the width and height of two sizes
  18920. * @param otherSize size to add to this size
  18921. * @returns a new Size set as the addition result of the current Size and the given one.
  18922. */
  18923. add(otherSize: Size): Size;
  18924. /**
  18925. * Subtracts the width and height of two
  18926. * @param otherSize size to subtract to this size
  18927. * @returns a new Size set as the subtraction result of the given one from the current Size.
  18928. */
  18929. subtract(otherSize: Size): Size;
  18930. /**
  18931. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  18932. * @param start starting size to lerp between
  18933. * @param end end size to lerp between
  18934. * @param amount amount to lerp between the start and end values
  18935. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  18936. */
  18937. static Lerp(start: Size, end: Size, amount: number): Size;
  18938. }
  18939. /**
  18940. * Class used to store quaternion data
  18941. * @see https://en.wikipedia.org/wiki/Quaternion
  18942. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  18943. */
  18944. class Quaternion {
  18945. /** defines the first component (0 by default) */
  18946. x: number;
  18947. /** defines the second component (0 by default) */
  18948. y: number;
  18949. /** defines the third component (0 by default) */
  18950. z: number;
  18951. /** defines the fourth component (1.0 by default) */
  18952. w: number;
  18953. /**
  18954. * Creates a new Quaternion from the given floats
  18955. * @param x defines the first component (0 by default)
  18956. * @param y defines the second component (0 by default)
  18957. * @param z defines the third component (0 by default)
  18958. * @param w defines the fourth component (1.0 by default)
  18959. */
  18960. constructor(
  18961. /** defines the first component (0 by default) */
  18962. x?: number,
  18963. /** defines the second component (0 by default) */
  18964. y?: number,
  18965. /** defines the third component (0 by default) */
  18966. z?: number,
  18967. /** defines the fourth component (1.0 by default) */
  18968. w?: number);
  18969. /**
  18970. * Gets a string representation for the current quaternion
  18971. * @returns a string with the Quaternion coordinates
  18972. */
  18973. toString(): string;
  18974. /**
  18975. * Gets the class name of the quaternion
  18976. * @returns the string "Quaternion"
  18977. */
  18978. getClassName(): string;
  18979. /**
  18980. * Gets a hash code for this quaternion
  18981. * @returns the quaternion hash code
  18982. */
  18983. getHashCode(): number;
  18984. /**
  18985. * Copy the quaternion to an array
  18986. * @returns a new array populated with 4 elements from the quaternion coordinates
  18987. */
  18988. asArray(): number[];
  18989. /**
  18990. * Check if two quaternions are equals
  18991. * @param otherQuaternion defines the second operand
  18992. * @return true if the current quaternion and the given one coordinates are strictly equals
  18993. */
  18994. equals(otherQuaternion: Quaternion): boolean;
  18995. /**
  18996. * Clone the current quaternion
  18997. * @returns a new quaternion copied from the current one
  18998. */
  18999. clone(): Quaternion;
  19000. /**
  19001. * Copy a quaternion to the current one
  19002. * @param other defines the other quaternion
  19003. * @returns the updated current quaternion
  19004. */
  19005. copyFrom(other: Quaternion): Quaternion;
  19006. /**
  19007. * Updates the current quaternion with the given float coordinates
  19008. * @param x defines the x coordinate
  19009. * @param y defines the y coordinate
  19010. * @param z defines the z coordinate
  19011. * @param w defines the w coordinate
  19012. * @returns the updated current quaternion
  19013. */
  19014. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  19015. /**
  19016. * Updates the current quaternion from the given float coordinates
  19017. * @param x defines the x coordinate
  19018. * @param y defines the y coordinate
  19019. * @param z defines the z coordinate
  19020. * @param w defines the w coordinate
  19021. * @returns the updated current quaternion
  19022. */
  19023. set(x: number, y: number, z: number, w: number): Quaternion;
  19024. /**
  19025. * Adds two quaternions
  19026. * @param other defines the second operand
  19027. * @returns a new quaternion as the addition result of the given one and the current quaternion
  19028. */
  19029. add(other: Quaternion): Quaternion;
  19030. /**
  19031. * Add a quaternion to the current one
  19032. * @param other defines the quaternion to add
  19033. * @returns the current quaternion
  19034. */
  19035. addInPlace(other: Quaternion): Quaternion;
  19036. /**
  19037. * Subtract two quaternions
  19038. * @param other defines the second operand
  19039. * @returns a new quaternion as the subtraction result of the given one from the current one
  19040. */
  19041. subtract(other: Quaternion): Quaternion;
  19042. /**
  19043. * Multiplies the current quaternion by a scale factor
  19044. * @param value defines the scale factor
  19045. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  19046. */
  19047. scale(value: number): Quaternion;
  19048. /**
  19049. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  19050. * @param scale defines the scale factor
  19051. * @param result defines the Quaternion object where to store the result
  19052. * @returns the unmodified current quaternion
  19053. */
  19054. scaleToRef(scale: number, result: Quaternion): Quaternion;
  19055. /**
  19056. * Multiplies in place the current quaternion by a scale factor
  19057. * @param value defines the scale factor
  19058. * @returns the current modified quaternion
  19059. */
  19060. scaleInPlace(value: number): Quaternion;
  19061. /**
  19062. * Scale the current quaternion values by a factor and add the result to a given quaternion
  19063. * @param scale defines the scale factor
  19064. * @param result defines the Quaternion object where to store the result
  19065. * @returns the unmodified current quaternion
  19066. */
  19067. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  19068. /**
  19069. * Multiplies two quaternions
  19070. * @param q1 defines the second operand
  19071. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  19072. */
  19073. multiply(q1: Quaternion): Quaternion;
  19074. /**
  19075. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  19076. * @param q1 defines the second operand
  19077. * @param result defines the target quaternion
  19078. * @returns the current quaternion
  19079. */
  19080. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  19081. /**
  19082. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  19083. * @param q1 defines the second operand
  19084. * @returns the currentupdated quaternion
  19085. */
  19086. multiplyInPlace(q1: Quaternion): Quaternion;
  19087. /**
  19088. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  19089. * @param ref defines the target quaternion
  19090. * @returns the current quaternion
  19091. */
  19092. conjugateToRef(ref: Quaternion): Quaternion;
  19093. /**
  19094. * Conjugates in place (1-q) the current quaternion
  19095. * @returns the current updated quaternion
  19096. */
  19097. conjugateInPlace(): Quaternion;
  19098. /**
  19099. * Conjugates in place (1-q) the current quaternion
  19100. * @returns a new quaternion
  19101. */
  19102. conjugate(): Quaternion;
  19103. /**
  19104. * Gets length of current quaternion
  19105. * @returns the quaternion length (float)
  19106. */
  19107. length(): number;
  19108. /**
  19109. * Normalize in place the current quaternion
  19110. * @returns the current updated quaternion
  19111. */
  19112. normalize(): Quaternion;
  19113. /**
  19114. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  19115. * @param order is a reserved parameter and is ignore for now
  19116. * @returns a new Vector3 containing the Euler angles
  19117. */
  19118. toEulerAngles(order?: string): Vector3;
  19119. /**
  19120. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  19121. * @param result defines the vector which will be filled with the Euler angles
  19122. * @param order is a reserved parameter and is ignore for now
  19123. * @returns the current unchanged quaternion
  19124. */
  19125. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  19126. /**
  19127. * Updates the given rotation matrix with the current quaternion values
  19128. * @param result defines the target matrix
  19129. * @returns the current unchanged quaternion
  19130. */
  19131. toRotationMatrix(result: Matrix): Quaternion;
  19132. /**
  19133. * Updates the current quaternion from the given rotation matrix values
  19134. * @param matrix defines the source matrix
  19135. * @returns the current updated quaternion
  19136. */
  19137. fromRotationMatrix(matrix: Matrix): Quaternion;
  19138. /**
  19139. * Creates a new quaternion from a rotation matrix
  19140. * @param matrix defines the source matrix
  19141. * @returns a new quaternion created from the given rotation matrix values
  19142. */
  19143. static FromRotationMatrix(matrix: Matrix): Quaternion;
  19144. /**
  19145. * Updates the given quaternion with the given rotation matrix values
  19146. * @param matrix defines the source matrix
  19147. * @param result defines the target quaternion
  19148. */
  19149. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  19150. /**
  19151. * Returns the dot product (float) between the quaternions "left" and "right"
  19152. * @param left defines the left operand
  19153. * @param right defines the right operand
  19154. * @returns the dot product
  19155. */
  19156. static Dot(left: Quaternion, right: Quaternion): number;
  19157. /**
  19158. * Checks if the two quaternions are close to each other
  19159. * @param quat0 defines the first quaternion to check
  19160. * @param quat1 defines the second quaternion to check
  19161. * @returns true if the two quaternions are close to each other
  19162. */
  19163. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  19164. /**
  19165. * Creates an empty quaternion
  19166. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  19167. */
  19168. static Zero(): Quaternion;
  19169. /**
  19170. * Inverse a given quaternion
  19171. * @param q defines the source quaternion
  19172. * @returns a new quaternion as the inverted current quaternion
  19173. */
  19174. static Inverse(q: Quaternion): Quaternion;
  19175. /**
  19176. * Creates an identity quaternion
  19177. * @returns the identity quaternion
  19178. */
  19179. static Identity(): Quaternion;
  19180. /**
  19181. * Gets a boolean indicating if the given quaternion is identity
  19182. * @param quaternion defines the quaternion to check
  19183. * @returns true if the quaternion is identity
  19184. */
  19185. static IsIdentity(quaternion: Quaternion): boolean;
  19186. /**
  19187. * Creates a quaternion from a rotation around an axis
  19188. * @param axis defines the axis to use
  19189. * @param angle defines the angle to use
  19190. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  19191. */
  19192. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  19193. /**
  19194. * Creates a rotation around an axis and stores it into the given quaternion
  19195. * @param axis defines the axis to use
  19196. * @param angle defines the angle to use
  19197. * @param result defines the target quaternion
  19198. * @returns the target quaternion
  19199. */
  19200. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  19201. /**
  19202. * Creates a new quaternion from data stored into an array
  19203. * @param array defines the data source
  19204. * @param offset defines the offset in the source array where the data starts
  19205. * @returns a new quaternion
  19206. */
  19207. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  19208. /**
  19209. * Creates a new quaternion from the given Euler float angles (y, x, z)
  19210. * @param yaw defines the rotation around Y axis
  19211. * @param pitch defines the rotation around X axis
  19212. * @param roll defines the rotation around Z axis
  19213. * @returns the new quaternion
  19214. */
  19215. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  19216. /**
  19217. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  19218. * @param yaw defines the rotation around Y axis
  19219. * @param pitch defines the rotation around X axis
  19220. * @param roll defines the rotation around Z axis
  19221. * @param result defines the target quaternion
  19222. */
  19223. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  19224. /**
  19225. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  19226. * @param alpha defines the rotation around first axis
  19227. * @param beta defines the rotation around second axis
  19228. * @param gamma defines the rotation around third axis
  19229. * @returns the new quaternion
  19230. */
  19231. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  19232. /**
  19233. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  19234. * @param alpha defines the rotation around first axis
  19235. * @param beta defines the rotation around second axis
  19236. * @param gamma defines the rotation around third axis
  19237. * @param result defines the target quaternion
  19238. */
  19239. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  19240. /**
  19241. * 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)
  19242. * @param axis1 defines the first axis
  19243. * @param axis2 defines the second axis
  19244. * @param axis3 defines the third axis
  19245. * @returns the new quaternion
  19246. */
  19247. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  19248. /**
  19249. * 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
  19250. * @param axis1 defines the first axis
  19251. * @param axis2 defines the second axis
  19252. * @param axis3 defines the third axis
  19253. * @param ref defines the target quaternion
  19254. */
  19255. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  19256. /**
  19257. * Interpolates between two quaternions
  19258. * @param left defines first quaternion
  19259. * @param right defines second quaternion
  19260. * @param amount defines the gradient to use
  19261. * @returns the new interpolated quaternion
  19262. */
  19263. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  19264. /**
  19265. * Interpolates between two quaternions and stores it into a target quaternion
  19266. * @param left defines first quaternion
  19267. * @param right defines second quaternion
  19268. * @param amount defines the gradient to use
  19269. * @param result defines the target quaternion
  19270. */
  19271. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  19272. /**
  19273. * Interpolate between two quaternions using Hermite interpolation
  19274. * @param value1 defines first quaternion
  19275. * @param tangent1 defines the incoming tangent
  19276. * @param value2 defines second quaternion
  19277. * @param tangent2 defines the outgoing tangent
  19278. * @param amount defines the target quaternion
  19279. * @returns the new interpolated quaternion
  19280. */
  19281. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  19282. }
  19283. /**
  19284. * Class used to store matrix data (4x4)
  19285. */
  19286. class Matrix {
  19287. private static _tempQuaternion;
  19288. private static _xAxis;
  19289. private static _yAxis;
  19290. private static _zAxis;
  19291. private static _updateFlagSeed;
  19292. private static _identityReadOnly;
  19293. private _isIdentity;
  19294. private _isIdentityDirty;
  19295. /**
  19296. * Gets the update flag of the matrix which is an unique number for the matrix.
  19297. * It will be incremented every time the matrix data change.
  19298. * You can use it to speed the comparison between two versions of the same matrix.
  19299. */
  19300. updateFlag: number;
  19301. /**
  19302. * Gets or sets the internal data of the matrix
  19303. */
  19304. m: Float32Array;
  19305. /** @hidden */
  19306. _markAsUpdated(): void;
  19307. /**
  19308. * Creates an empty matrix (filled with zeros)
  19309. */
  19310. constructor();
  19311. /**
  19312. * Check if the current matrix is indentity
  19313. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  19314. * @returns true is the matrix is the identity matrix
  19315. */
  19316. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  19317. /**
  19318. * Gets the determinant of the matrix
  19319. * @returns the matrix determinant
  19320. */
  19321. determinant(): number;
  19322. /**
  19323. * Returns the matrix as a Float32Array
  19324. * @returns the matrix underlying array
  19325. */
  19326. toArray(): Float32Array;
  19327. /**
  19328. * Returns the matrix as a Float32Array
  19329. * @returns the matrix underlying array.
  19330. */
  19331. asArray(): Float32Array;
  19332. /**
  19333. * Inverts the current matrix in place
  19334. * @returns the current inverted matrix
  19335. */
  19336. invert(): Matrix;
  19337. /**
  19338. * Sets all the matrix elements to zero
  19339. * @returns the current matrix
  19340. */
  19341. reset(): Matrix;
  19342. /**
  19343. * Adds the current matrix with a second one
  19344. * @param other defines the matrix to add
  19345. * @returns a new matrix as the addition of the current matrix and the given one
  19346. */
  19347. add(other: Matrix): Matrix;
  19348. /**
  19349. * Sets the given matrix "result" to the addition of the current matrix and the given one
  19350. * @param other defines the matrix to add
  19351. * @param result defines the target matrix
  19352. * @returns the current matrix
  19353. */
  19354. addToRef(other: Matrix, result: Matrix): Matrix;
  19355. /**
  19356. * Adds in place the given matrix to the current matrix
  19357. * @param other defines the second operand
  19358. * @returns the current updated matrix
  19359. */
  19360. addToSelf(other: Matrix): Matrix;
  19361. /**
  19362. * Sets the given matrix to the current inverted Matrix
  19363. * @param other defines the target matrix
  19364. * @returns the unmodified current matrix
  19365. */
  19366. invertToRef(other: Matrix): Matrix;
  19367. /**
  19368. * Inserts the translation vector (using 3 floats) in the current matrix
  19369. * @param x defines the 1st component of the translation
  19370. * @param y defines the 2nd component of the translation
  19371. * @param z defines the 3rd component of the translation
  19372. * @returns the current updated matrix
  19373. */
  19374. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  19375. /**
  19376. * Inserts the translation vector in the current matrix
  19377. * @param vector3 defines the translation to insert
  19378. * @returns the current updated matrix
  19379. */
  19380. setTranslation(vector3: Vector3): Matrix;
  19381. /**
  19382. * Gets the translation value of the current matrix
  19383. * @returns a new Vector3 as the extracted translation from the matrix
  19384. */
  19385. getTranslation(): Vector3;
  19386. /**
  19387. * Fill a Vector3 with the extracted translation from the matrix
  19388. * @param result defines the Vector3 where to store the translation
  19389. * @returns the current matrix
  19390. */
  19391. getTranslationToRef(result: Vector3): Matrix;
  19392. /**
  19393. * Remove rotation and scaling part from the matrix
  19394. * @returns the updated matrix
  19395. */
  19396. removeRotationAndScaling(): Matrix;
  19397. /**
  19398. * Multiply two matrices
  19399. * @param other defines the second operand
  19400. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  19401. */
  19402. multiply(other: Matrix): Matrix;
  19403. /**
  19404. * Copy the current matrix from the given one
  19405. * @param other defines the source matrix
  19406. * @returns the current updated matrix
  19407. */
  19408. copyFrom(other: Matrix): Matrix;
  19409. /**
  19410. * Populates the given array from the starting index with the current matrix values
  19411. * @param array defines the target array
  19412. * @param offset defines the offset in the target array where to start storing values
  19413. * @returns the current matrix
  19414. */
  19415. copyToArray(array: Float32Array, offset?: number): Matrix;
  19416. /**
  19417. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  19418. * @param other defines the second operand
  19419. * @param result defines the matrix where to store the multiplication
  19420. * @returns the current matrix
  19421. */
  19422. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  19423. /**
  19424. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  19425. * @param other defines the second operand
  19426. * @param result defines the array where to store the multiplication
  19427. * @param offset defines the offset in the target array where to start storing values
  19428. * @returns the current matrix
  19429. */
  19430. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  19431. /**
  19432. * Check equality between this matrix and a second one
  19433. * @param value defines the second matrix to compare
  19434. * @returns true is the current matrix and the given one values are strictly equal
  19435. */
  19436. equals(value: Matrix): boolean;
  19437. /**
  19438. * Clone the current matrix
  19439. * @returns a new matrix from the current matrix
  19440. */
  19441. clone(): Matrix;
  19442. /**
  19443. * Returns the name of the current matrix class
  19444. * @returns the string "Matrix"
  19445. */
  19446. getClassName(): string;
  19447. /**
  19448. * Gets the hash code of the current matrix
  19449. * @returns the hash code
  19450. */
  19451. getHashCode(): number;
  19452. /**
  19453. * Decomposes the current Matrix into a translation, rotation and scaling components
  19454. * @param scale defines the scale vector3 given as a reference to update
  19455. * @param rotation defines the rotation quaternion given as a reference to update
  19456. * @param translation defines the translation vector3 given as a reference to update
  19457. * @returns true if operation was successful
  19458. */
  19459. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  19460. /**
  19461. * Gets specific row of the matrix
  19462. * @param index defines the number of the row to get
  19463. * @returns the index-th row of the current matrix as a new Vector4
  19464. */
  19465. getRow(index: number): Nullable<Vector4>;
  19466. /**
  19467. * Sets the index-th row of the current matrix to the vector4 values
  19468. * @param index defines the number of the row to set
  19469. * @param row defines the target vector4
  19470. * @returns the updated current matrix
  19471. */
  19472. setRow(index: number, row: Vector4): Matrix;
  19473. /**
  19474. * Compute the transpose of the matrix
  19475. * @returns the new transposed matrix
  19476. */
  19477. transpose(): Matrix;
  19478. /**
  19479. * Compute the transpose of the matrix and store it in a given matrix
  19480. * @param result defines the target matrix
  19481. * @returns the current matrix
  19482. */
  19483. transposeToRef(result: Matrix): Matrix;
  19484. /**
  19485. * Sets the index-th row of the current matrix with the given 4 x float values
  19486. * @param index defines the row index
  19487. * @param x defines the x component to set
  19488. * @param y defines the y component to set
  19489. * @param z defines the z component to set
  19490. * @param w defines the w component to set
  19491. * @returns the updated current matrix
  19492. */
  19493. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  19494. /**
  19495. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  19496. * @param scale defines the scale factor
  19497. * @returns a new matrix
  19498. */
  19499. scale(scale: number): Matrix;
  19500. /**
  19501. * Scale the current matrix values by a factor to a given result matrix
  19502. * @param scale defines the scale factor
  19503. * @param result defines the matrix to store the result
  19504. * @returns the current matrix
  19505. */
  19506. scaleToRef(scale: number, result: Matrix): Matrix;
  19507. /**
  19508. * Scale the current matrix values by a factor and add the result to a given matrix
  19509. * @param scale defines the scale factor
  19510. * @param result defines the Matrix to store the result
  19511. * @returns the current matrix
  19512. */
  19513. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  19514. /**
  19515. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  19516. * @param ref matrix to store the result
  19517. */
  19518. toNormalMatrix(ref: Matrix): void;
  19519. /**
  19520. * Gets only rotation part of the current matrix
  19521. * @returns a new matrix sets to the extracted rotation matrix from the current one
  19522. */
  19523. getRotationMatrix(): Matrix;
  19524. /**
  19525. * Extracts the rotation matrix from the current one and sets it as the given "result"
  19526. * @param result defines the target matrix to store data to
  19527. * @returns the current matrix
  19528. */
  19529. getRotationMatrixToRef(result: Matrix): Matrix;
  19530. /**
  19531. * Creates a matrix from an array
  19532. * @param array defines the source array
  19533. * @param offset defines an offset in the source array
  19534. * @returns a new Matrix set from the starting index of the given array
  19535. */
  19536. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  19537. /**
  19538. * Copy the content of an array into a given matrix
  19539. * @param array defines the source array
  19540. * @param offset defines an offset in the source array
  19541. * @param result defines the target matrix
  19542. */
  19543. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  19544. /**
  19545. * Stores an array into a matrix after having multiplied each component by a given factor
  19546. * @param array defines the source array
  19547. * @param offset defines the offset in the source array
  19548. * @param scale defines the scaling factor
  19549. * @param result defines the target matrix
  19550. */
  19551. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  19552. /**
  19553. * Stores a list of values (16) inside a given matrix
  19554. * @param initialM11 defines 1st value of 1st row
  19555. * @param initialM12 defines 2nd value of 1st row
  19556. * @param initialM13 defines 3rd value of 1st row
  19557. * @param initialM14 defines 4th value of 1st row
  19558. * @param initialM21 defines 1st value of 2nd row
  19559. * @param initialM22 defines 2nd value of 2nd row
  19560. * @param initialM23 defines 3rd value of 2nd row
  19561. * @param initialM24 defines 4th value of 2nd row
  19562. * @param initialM31 defines 1st value of 3rd row
  19563. * @param initialM32 defines 2nd value of 3rd row
  19564. * @param initialM33 defines 3rd value of 3rd row
  19565. * @param initialM34 defines 4th value of 3rd row
  19566. * @param initialM41 defines 1st value of 4th row
  19567. * @param initialM42 defines 2nd value of 4th row
  19568. * @param initialM43 defines 3rd value of 4th row
  19569. * @param initialM44 defines 4th value of 4th row
  19570. * @param result defines the target matrix
  19571. */
  19572. 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;
  19573. /**
  19574. * Gets an identity matrix that must not be updated
  19575. */
  19576. static readonly IdentityReadOnly: Matrix;
  19577. /**
  19578. * Creates new matrix from a list of values (16)
  19579. * @param initialM11 defines 1st value of 1st row
  19580. * @param initialM12 defines 2nd value of 1st row
  19581. * @param initialM13 defines 3rd value of 1st row
  19582. * @param initialM14 defines 4th value of 1st row
  19583. * @param initialM21 defines 1st value of 2nd row
  19584. * @param initialM22 defines 2nd value of 2nd row
  19585. * @param initialM23 defines 3rd value of 2nd row
  19586. * @param initialM24 defines 4th value of 2nd row
  19587. * @param initialM31 defines 1st value of 3rd row
  19588. * @param initialM32 defines 2nd value of 3rd row
  19589. * @param initialM33 defines 3rd value of 3rd row
  19590. * @param initialM34 defines 4th value of 3rd row
  19591. * @param initialM41 defines 1st value of 4th row
  19592. * @param initialM42 defines 2nd value of 4th row
  19593. * @param initialM43 defines 3rd value of 4th row
  19594. * @param initialM44 defines 4th value of 4th row
  19595. * @returns the new matrix
  19596. */
  19597. 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;
  19598. /**
  19599. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19600. * @param scale defines the scale vector3
  19601. * @param rotation defines the rotation quaternion
  19602. * @param translation defines the translation vector3
  19603. * @returns a new matrix
  19604. */
  19605. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  19606. /**
  19607. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  19608. * @param scale defines the scale vector3
  19609. * @param rotation defines the rotation quaternion
  19610. * @param translation defines the translation vector3
  19611. * @param result defines the target matrix
  19612. */
  19613. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  19614. /**
  19615. * Creates a new identity matrix
  19616. * @returns a new identity matrix
  19617. */
  19618. static Identity(): Matrix;
  19619. /**
  19620. * Creates a new identity matrix and stores the result in a given matrix
  19621. * @param result defines the target matrix
  19622. */
  19623. static IdentityToRef(result: Matrix): void;
  19624. /**
  19625. * Creates a new zero matrix
  19626. * @returns a new zero matrix
  19627. */
  19628. static Zero(): Matrix;
  19629. /**
  19630. * Creates a new rotation matrix for "angle" radians around the X axis
  19631. * @param angle defines the angle (in radians) to use
  19632. * @return the new matrix
  19633. */
  19634. static RotationX(angle: number): Matrix;
  19635. /**
  19636. * Creates a new matrix as the invert of a given matrix
  19637. * @param source defines the source matrix
  19638. * @returns the new matrix
  19639. */
  19640. static Invert(source: Matrix): Matrix;
  19641. /**
  19642. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  19643. * @param angle defines the angle (in radians) to use
  19644. * @param result defines the target matrix
  19645. */
  19646. static RotationXToRef(angle: number, result: Matrix): void;
  19647. /**
  19648. * Creates a new rotation matrix for "angle" radians around the Y axis
  19649. * @param angle defines the angle (in radians) to use
  19650. * @return the new matrix
  19651. */
  19652. static RotationY(angle: number): Matrix;
  19653. /**
  19654. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  19655. * @param angle defines the angle (in radians) to use
  19656. * @param result defines the target matrix
  19657. */
  19658. static RotationYToRef(angle: number, result: Matrix): void;
  19659. /**
  19660. * Creates a new rotation matrix for "angle" radians around the Z axis
  19661. * @param angle defines the angle (in radians) to use
  19662. * @return the new matrix
  19663. */
  19664. static RotationZ(angle: number): Matrix;
  19665. /**
  19666. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  19667. * @param angle defines the angle (in radians) to use
  19668. * @param result defines the target matrix
  19669. */
  19670. static RotationZToRef(angle: number, result: Matrix): void;
  19671. /**
  19672. * Creates a new rotation matrix for "angle" radians around the given axis
  19673. * @param axis defines the axis to use
  19674. * @param angle defines the angle (in radians) to use
  19675. * @return the new matrix
  19676. */
  19677. static RotationAxis(axis: Vector3, angle: number): Matrix;
  19678. /**
  19679. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  19680. * @param axis defines the axis to use
  19681. * @param angle defines the angle (in radians) to use
  19682. * @param result defines the target matrix
  19683. */
  19684. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  19685. /**
  19686. * Creates a rotation matrix
  19687. * @param yaw defines the yaw angle in radians (Y axis)
  19688. * @param pitch defines the pitch angle in radians (X axis)
  19689. * @param roll defines the roll angle in radians (X axis)
  19690. * @returns the new rotation matrix
  19691. */
  19692. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  19693. /**
  19694. * Creates a rotation matrix and stores it in a given matrix
  19695. * @param yaw defines the yaw angle in radians (Y axis)
  19696. * @param pitch defines the pitch angle in radians (X axis)
  19697. * @param roll defines the roll angle in radians (X axis)
  19698. * @param result defines the target matrix
  19699. */
  19700. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  19701. /**
  19702. * Creates a scaling matrix
  19703. * @param x defines the scale factor on X axis
  19704. * @param y defines the scale factor on Y axis
  19705. * @param z defines the scale factor on Z axis
  19706. * @returns the new matrix
  19707. */
  19708. static Scaling(x: number, y: number, z: number): Matrix;
  19709. /**
  19710. * Creates a scaling matrix and stores it in a given matrix
  19711. * @param x defines the scale factor on X axis
  19712. * @param y defines the scale factor on Y axis
  19713. * @param z defines the scale factor on Z axis
  19714. * @param result defines the target matrix
  19715. */
  19716. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  19717. /**
  19718. * Creates a translation matrix
  19719. * @param x defines the translation on X axis
  19720. * @param y defines the translation on Y axis
  19721. * @param z defines the translationon Z axis
  19722. * @returns the new matrix
  19723. */
  19724. static Translation(x: number, y: number, z: number): Matrix;
  19725. /**
  19726. * Creates a translation matrix and stores it in a given matrix
  19727. * @param x defines the translation on X axis
  19728. * @param y defines the translation on Y axis
  19729. * @param z defines the translationon Z axis
  19730. * @param result defines the target matrix
  19731. */
  19732. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  19733. /**
  19734. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  19735. * @param startValue defines the start value
  19736. * @param endValue defines the end value
  19737. * @param gradient defines the gradient factor
  19738. * @returns the new matrix
  19739. */
  19740. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  19741. /**
  19742. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  19743. * @param startValue defines the start value
  19744. * @param endValue defines the end value
  19745. * @param gradient defines the gradient factor
  19746. * @param result defines the Matrix object where to store data
  19747. */
  19748. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  19749. /**
  19750. * Builds a new matrix whose values are computed by:
  19751. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  19752. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  19753. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  19754. * @param startValue defines the first matrix
  19755. * @param endValue defines the second matrix
  19756. * @param gradient defines the gradient between the two matrices
  19757. * @returns the new matrix
  19758. */
  19759. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  19760. /**
  19761. * Update a matrix to values which are computed by:
  19762. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  19763. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  19764. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  19765. * @param startValue defines the first matrix
  19766. * @param endValue defines the second matrix
  19767. * @param gradient defines the gradient between the two matrices
  19768. * @param result defines the target matrix
  19769. */
  19770. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  19771. /**
  19772. * 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"
  19773. * This function works in left handed mode
  19774. * @param eye defines the final position of the entity
  19775. * @param target defines where the entity should look at
  19776. * @param up defines the up vector for the entity
  19777. * @returns the new matrix
  19778. */
  19779. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  19780. /**
  19781. * 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".
  19782. * This function works in left handed mode
  19783. * @param eye defines the final position of the entity
  19784. * @param target defines where the entity should look at
  19785. * @param up defines the up vector for the entity
  19786. * @param result defines the target matrix
  19787. */
  19788. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  19789. /**
  19790. * 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"
  19791. * This function works in right handed mode
  19792. * @param eye defines the final position of the entity
  19793. * @param target defines where the entity should look at
  19794. * @param up defines the up vector for the entity
  19795. * @returns the new matrix
  19796. */
  19797. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  19798. /**
  19799. * 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".
  19800. * This function works in right handed mode
  19801. * @param eye defines the final position of the entity
  19802. * @param target defines where the entity should look at
  19803. * @param up defines the up vector for the entity
  19804. * @param result defines the target matrix
  19805. */
  19806. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  19807. /**
  19808. * Create a left-handed orthographic projection matrix
  19809. * @param width defines the viewport width
  19810. * @param height defines the viewport height
  19811. * @param znear defines the near clip plane
  19812. * @param zfar defines the far clip plane
  19813. * @returns a new matrix as a left-handed orthographic projection matrix
  19814. */
  19815. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  19816. /**
  19817. * Store a left-handed orthographic projection to a given matrix
  19818. * @param width defines the viewport width
  19819. * @param height defines the viewport height
  19820. * @param znear defines the near clip plane
  19821. * @param zfar defines the far clip plane
  19822. * @param result defines the target matrix
  19823. */
  19824. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  19825. /**
  19826. * Create a left-handed orthographic projection matrix
  19827. * @param left defines the viewport left coordinate
  19828. * @param right defines the viewport right coordinate
  19829. * @param bottom defines the viewport bottom coordinate
  19830. * @param top defines the viewport top coordinate
  19831. * @param znear defines the near clip plane
  19832. * @param zfar defines the far clip plane
  19833. * @returns a new matrix as a left-handed orthographic projection matrix
  19834. */
  19835. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  19836. /**
  19837. * Stores a left-handed orthographic projection into a given matrix
  19838. * @param left defines the viewport left coordinate
  19839. * @param right defines the viewport right coordinate
  19840. * @param bottom defines the viewport bottom coordinate
  19841. * @param top defines the viewport top coordinate
  19842. * @param znear defines the near clip plane
  19843. * @param zfar defines the far clip plane
  19844. * @param result defines the target matrix
  19845. */
  19846. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  19847. /**
  19848. * Creates a right-handed orthographic projection matrix
  19849. * @param left defines the viewport left coordinate
  19850. * @param right defines the viewport right coordinate
  19851. * @param bottom defines the viewport bottom coordinate
  19852. * @param top defines the viewport top coordinate
  19853. * @param znear defines the near clip plane
  19854. * @param zfar defines the far clip plane
  19855. * @returns a new matrix as a right-handed orthographic projection matrix
  19856. */
  19857. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  19858. /**
  19859. * Stores a right-handed orthographic projection into a given matrix
  19860. * @param left defines the viewport left coordinate
  19861. * @param right defines the viewport right coordinate
  19862. * @param bottom defines the viewport bottom coordinate
  19863. * @param top defines the viewport top coordinate
  19864. * @param znear defines the near clip plane
  19865. * @param zfar defines the far clip plane
  19866. * @param result defines the target matrix
  19867. */
  19868. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  19869. /**
  19870. * Creates a left-handed perspective projection matrix
  19871. * @param width defines the viewport width
  19872. * @param height defines the viewport height
  19873. * @param znear defines the near clip plane
  19874. * @param zfar defines the far clip plane
  19875. * @returns a new matrix as a left-handed perspective projection matrix
  19876. */
  19877. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  19878. /**
  19879. * Creates a left-handed perspective projection matrix
  19880. * @param fov defines the horizontal field of view
  19881. * @param aspect defines the aspect ratio
  19882. * @param znear defines the near clip plane
  19883. * @param zfar defines the far clip plane
  19884. * @returns a new matrix as a left-handed perspective projection matrix
  19885. */
  19886. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  19887. /**
  19888. * Stores a left-handed perspective projection into a given matrix
  19889. * @param fov defines the horizontal field of view
  19890. * @param aspect defines the aspect ratio
  19891. * @param znear defines the near clip plane
  19892. * @param zfar defines the far clip plane
  19893. * @param result defines the target matrix
  19894. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  19895. */
  19896. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  19897. /**
  19898. * Creates a right-handed perspective projection matrix
  19899. * @param fov defines the horizontal field of view
  19900. * @param aspect defines the aspect ratio
  19901. * @param znear defines the near clip plane
  19902. * @param zfar defines the far clip plane
  19903. * @returns a new matrix as a right-handed perspective projection matrix
  19904. */
  19905. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  19906. /**
  19907. * Stores a right-handed perspective projection into a given matrix
  19908. * @param fov defines the horizontal field of view
  19909. * @param aspect defines the aspect ratio
  19910. * @param znear defines the near clip plane
  19911. * @param zfar defines the far clip plane
  19912. * @param result defines the target matrix
  19913. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  19914. */
  19915. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  19916. /**
  19917. * Stores a perspective projection for WebVR info a given matrix
  19918. * @param fov defines the field of view
  19919. * @param znear defines the near clip plane
  19920. * @param zfar defines the far clip plane
  19921. * @param result defines the target matrix
  19922. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  19923. */
  19924. static PerspectiveFovWebVRToRef(fov: {
  19925. upDegrees: number;
  19926. downDegrees: number;
  19927. leftDegrees: number;
  19928. rightDegrees: number;
  19929. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  19930. /**
  19931. * Computes a complete transformation matrix
  19932. * @param viewport defines the viewport to use
  19933. * @param world defines the world matrix
  19934. * @param view defines the view matrix
  19935. * @param projection defines the projection matrix
  19936. * @param zmin defines the near clip plane
  19937. * @param zmax defines the far clip plane
  19938. * @returns the transformation matrix
  19939. */
  19940. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  19941. /**
  19942. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  19943. * @param matrix defines the matrix to use
  19944. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  19945. */
  19946. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  19947. /**
  19948. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  19949. * @param matrix defines the matrix to use
  19950. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  19951. */
  19952. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  19953. /**
  19954. * Compute the transpose of a given matrix
  19955. * @param matrix defines the matrix to transpose
  19956. * @returns the new matrix
  19957. */
  19958. static Transpose(matrix: Matrix): Matrix;
  19959. /**
  19960. * Compute the transpose of a matrix and store it in a target matrix
  19961. * @param matrix defines the matrix to transpose
  19962. * @param result defines the target matrix
  19963. */
  19964. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  19965. /**
  19966. * Computes a reflection matrix from a plane
  19967. * @param plane defines the reflection plane
  19968. * @returns a new matrix
  19969. */
  19970. static Reflection(plane: Plane): Matrix;
  19971. /**
  19972. * Computes a reflection matrix from a plane
  19973. * @param plane defines the reflection plane
  19974. * @param result defines the target matrix
  19975. */
  19976. static ReflectionToRef(plane: Plane, result: Matrix): void;
  19977. /**
  19978. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  19979. * @param xaxis defines the value of the 1st axis
  19980. * @param yaxis defines the value of the 2nd axis
  19981. * @param zaxis defines the value of the 3rd axis
  19982. * @param result defines the target matrix
  19983. */
  19984. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  19985. /**
  19986. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  19987. * @param quat defines the quaternion to use
  19988. * @param result defines the target matrix
  19989. */
  19990. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  19991. }
  19992. /**
  19993. * Represens a plane by the equation ax + by + cz + d = 0
  19994. */
  19995. class Plane {
  19996. /**
  19997. * Normal of the plane (a,b,c)
  19998. */
  19999. normal: Vector3;
  20000. /**
  20001. * d component of the plane
  20002. */
  20003. d: number;
  20004. /**
  20005. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  20006. * @param a a component of the plane
  20007. * @param b b component of the plane
  20008. * @param c c component of the plane
  20009. * @param d d component of the plane
  20010. */
  20011. constructor(a: number, b: number, c: number, d: number);
  20012. /**
  20013. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  20014. */
  20015. asArray(): number[];
  20016. /**
  20017. * @returns a new plane copied from the current Plane.
  20018. */
  20019. clone(): Plane;
  20020. /**
  20021. * @returns the string "Plane".
  20022. */
  20023. getClassName(): string;
  20024. /**
  20025. * @returns the Plane hash code.
  20026. */
  20027. getHashCode(): number;
  20028. /**
  20029. * Normalize the current Plane in place.
  20030. * @returns the updated Plane.
  20031. */
  20032. normalize(): Plane;
  20033. /**
  20034. * Applies a transformation the plane and returns the result
  20035. * @param transformation the transformation matrix to be applied to the plane
  20036. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  20037. */
  20038. transform(transformation: Matrix): Plane;
  20039. /**
  20040. * Calcualtte the dot product between the point and the plane normal
  20041. * @param point point to calculate the dot product with
  20042. * @returns the dot product (float) of the point coordinates and the plane normal.
  20043. */
  20044. dotCoordinate(point: Vector3): number;
  20045. /**
  20046. * Updates the current Plane from the plane defined by the three given points.
  20047. * @param point1 one of the points used to contruct the plane
  20048. * @param point2 one of the points used to contruct the plane
  20049. * @param point3 one of the points used to contruct the plane
  20050. * @returns the updated Plane.
  20051. */
  20052. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  20053. /**
  20054. * Checks if the plane is facing a given direction
  20055. * @param direction the direction to check if the plane is facing
  20056. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  20057. * @returns True is the vector "direction" is the same side than the plane normal.
  20058. */
  20059. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  20060. /**
  20061. * Calculates the distance to a point
  20062. * @param point point to calculate distance to
  20063. * @returns the signed distance (float) from the given point to the Plane.
  20064. */
  20065. signedDistanceTo(point: Vector3): number;
  20066. /**
  20067. * Creates a plane from an array
  20068. * @param array the array to create a plane from
  20069. * @returns a new Plane from the given array.
  20070. */
  20071. static FromArray(array: ArrayLike<number>): Plane;
  20072. /**
  20073. * Creates a plane from three points
  20074. * @param point1 point used to create the plane
  20075. * @param point2 point used to create the plane
  20076. * @param point3 point used to create the plane
  20077. * @returns a new Plane defined by the three given points.
  20078. */
  20079. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  20080. /**
  20081. * Creates a plane from an origin point and a normal
  20082. * @param origin origin of the plane to be constructed
  20083. * @param normal normal of the plane to be constructed
  20084. * @returns a new Plane the normal vector to this plane at the given origin point.
  20085. * Note : the vector "normal" is updated because normalized.
  20086. */
  20087. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  20088. /**
  20089. * Calculates the distance from a plane and a point
  20090. * @param origin origin of the plane to be constructed
  20091. * @param normal normal of the plane to be constructed
  20092. * @param point point to calculate distance to
  20093. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  20094. */
  20095. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  20096. }
  20097. /**
  20098. * Class used to represent a viewport on screen
  20099. */
  20100. class Viewport {
  20101. /** viewport left coordinate */
  20102. x: number;
  20103. /** viewport top coordinate */
  20104. y: number;
  20105. /**viewport width */
  20106. width: number;
  20107. /** viewport height */
  20108. height: number;
  20109. /**
  20110. * Creates a Viewport object located at (x, y) and sized (width, height)
  20111. * @param x defines viewport left coordinate
  20112. * @param y defines viewport top coordinate
  20113. * @param width defines the viewport width
  20114. * @param height defines the viewport height
  20115. */
  20116. constructor(
  20117. /** viewport left coordinate */
  20118. x: number,
  20119. /** viewport top coordinate */
  20120. y: number,
  20121. /**viewport width */
  20122. width: number,
  20123. /** viewport height */
  20124. height: number);
  20125. /**
  20126. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  20127. * @param renderWidthOrEngine defines either an engine or the rendering width
  20128. * @param renderHeight defines the rendering height
  20129. * @returns a new Viewport
  20130. */
  20131. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  20132. /**
  20133. * Returns a new Viewport copied from the current one
  20134. * @returns a new Viewport
  20135. */
  20136. clone(): Viewport;
  20137. }
  20138. /**
  20139. * Reprasents a camera frustum
  20140. */
  20141. class Frustum {
  20142. /**
  20143. * Gets the planes representing the frustum
  20144. * @param transform matrix to be applied to the returned planes
  20145. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  20146. */
  20147. static GetPlanes(transform: Matrix): Plane[];
  20148. /**
  20149. * Gets the near frustum plane transformed by the transform matrix
  20150. * @param transform transformation matrix to be applied to the resulting frustum plane
  20151. * @param frustumPlane the resuling frustum plane
  20152. */
  20153. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20154. /**
  20155. * Gets the far frustum plane transformed by the transform matrix
  20156. * @param transform transformation matrix to be applied to the resulting frustum plane
  20157. * @param frustumPlane the resuling frustum plane
  20158. */
  20159. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20160. /**
  20161. * Gets the left frustum plane transformed by the transform matrix
  20162. * @param transform transformation matrix to be applied to the resulting frustum plane
  20163. * @param frustumPlane the resuling frustum plane
  20164. */
  20165. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20166. /**
  20167. * Gets the right frustum plane transformed by the transform matrix
  20168. * @param transform transformation matrix to be applied to the resulting frustum plane
  20169. * @param frustumPlane the resuling frustum plane
  20170. */
  20171. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20172. /**
  20173. * Gets the top frustum plane transformed by the transform matrix
  20174. * @param transform transformation matrix to be applied to the resulting frustum plane
  20175. * @param frustumPlane the resuling frustum plane
  20176. */
  20177. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20178. /**
  20179. * Gets the bottom frustum plane transformed by the transform matrix
  20180. * @param transform transformation matrix to be applied to the resulting frustum plane
  20181. * @param frustumPlane the resuling frustum plane
  20182. */
  20183. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  20184. /**
  20185. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  20186. * @param transform transformation matrix to be applied to the resulting frustum planes
  20187. * @param frustumPlanes the resuling frustum planes
  20188. */
  20189. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  20190. }
  20191. /** Defines supported spaces */
  20192. enum Space {
  20193. /** Local (object) space */
  20194. LOCAL = 0,
  20195. /** World space */
  20196. WORLD = 1,
  20197. /** Bone space */
  20198. BONE = 2
  20199. }
  20200. /** Defines the 3 main axes */
  20201. class Axis {
  20202. /** X axis */
  20203. static X: Vector3;
  20204. /** Y axis */
  20205. static Y: Vector3;
  20206. /** Z axis */
  20207. static Z: Vector3;
  20208. }
  20209. /** Class used to represent a Bezier curve */
  20210. class BezierCurve {
  20211. /**
  20212. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  20213. * @param t defines the time
  20214. * @param x1 defines the left coordinate on X axis
  20215. * @param y1 defines the left coordinate on Y axis
  20216. * @param x2 defines the right coordinate on X axis
  20217. * @param y2 defines the right coordinate on Y axis
  20218. * @returns the interpolated value
  20219. */
  20220. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  20221. }
  20222. /**
  20223. * Defines potential orientation for back face culling
  20224. */
  20225. enum Orientation {
  20226. /**
  20227. * Clockwise
  20228. */
  20229. CW = 0,
  20230. /** Counter clockwise */
  20231. CCW = 1
  20232. }
  20233. /**
  20234. * Defines angle representation
  20235. */
  20236. class Angle {
  20237. private _radians;
  20238. /**
  20239. * Creates an Angle object of "radians" radians (float).
  20240. */
  20241. constructor(radians: number);
  20242. /**
  20243. * Get value in degrees
  20244. * @returns the Angle value in degrees (float)
  20245. */
  20246. degrees(): number;
  20247. /**
  20248. * Get value in radians
  20249. * @returns the Angle value in radians (float)
  20250. */
  20251. radians(): number;
  20252. /**
  20253. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  20254. * @param a defines first vector
  20255. * @param b defines second vector
  20256. * @returns a new Angle
  20257. */
  20258. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  20259. /**
  20260. * Gets a new Angle object from the given float in radians
  20261. * @param radians defines the angle value in radians
  20262. * @returns a new Angle
  20263. */
  20264. static FromRadians(radians: number): Angle;
  20265. /**
  20266. * Gets a new Angle object from the given float in degrees
  20267. * @param degrees defines the angle value in degrees
  20268. * @returns a new Angle
  20269. */
  20270. static FromDegrees(degrees: number): Angle;
  20271. }
  20272. /**
  20273. * This represents an arc in a 2d space.
  20274. */
  20275. class Arc2 {
  20276. /** Defines the start point of the arc */
  20277. startPoint: Vector2;
  20278. /** Defines the mid point of the arc */
  20279. midPoint: Vector2;
  20280. /** Defines the end point of the arc */
  20281. endPoint: Vector2;
  20282. /**
  20283. * Defines the center point of the arc.
  20284. */
  20285. centerPoint: Vector2;
  20286. /**
  20287. * Defines the radius of the arc.
  20288. */
  20289. radius: number;
  20290. /**
  20291. * Defines the angle of the arc (from mid point to end point).
  20292. */
  20293. angle: Angle;
  20294. /**
  20295. * Defines the start angle of the arc (from start point to middle point).
  20296. */
  20297. startAngle: Angle;
  20298. /**
  20299. * Defines the orientation of the arc (clock wise/counter clock wise).
  20300. */
  20301. orientation: Orientation;
  20302. /**
  20303. * Creates an Arc object from the three given points : start, middle and end.
  20304. * @param startPoint Defines the start point of the arc
  20305. * @param midPoint Defines the midlle point of the arc
  20306. * @param endPoint Defines the end point of the arc
  20307. */
  20308. constructor(
  20309. /** Defines the start point of the arc */
  20310. startPoint: Vector2,
  20311. /** Defines the mid point of the arc */
  20312. midPoint: Vector2,
  20313. /** Defines the end point of the arc */
  20314. endPoint: Vector2);
  20315. }
  20316. /**
  20317. * Represents a 2D path made up of multiple 2D points
  20318. */
  20319. class Path2 {
  20320. private _points;
  20321. private _length;
  20322. /**
  20323. * If the path start and end point are the same
  20324. */
  20325. closed: boolean;
  20326. /**
  20327. * Creates a Path2 object from the starting 2D coordinates x and y.
  20328. * @param x the starting points x value
  20329. * @param y the starting points y value
  20330. */
  20331. constructor(x: number, y: number);
  20332. /**
  20333. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  20334. * @param x the added points x value
  20335. * @param y the added points y value
  20336. * @returns the updated Path2.
  20337. */
  20338. addLineTo(x: number, y: number): Path2;
  20339. /**
  20340. * 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.
  20341. * @param midX middle point x value
  20342. * @param midY middle point y value
  20343. * @param endX end point x value
  20344. * @param endY end point y value
  20345. * @param numberOfSegments (default: 36)
  20346. * @returns the updated Path2.
  20347. */
  20348. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  20349. /**
  20350. * Closes the Path2.
  20351. * @returns the Path2.
  20352. */
  20353. close(): Path2;
  20354. /**
  20355. * Gets the sum of the distance between each sequential point in the path
  20356. * @returns the Path2 total length (float).
  20357. */
  20358. length(): number;
  20359. /**
  20360. * Gets the points which construct the path
  20361. * @returns the Path2 internal array of points.
  20362. */
  20363. getPoints(): Vector2[];
  20364. /**
  20365. * Retreives the point at the distance aways from the starting point
  20366. * @param normalizedLengthPosition the length along the path to retreive the point from
  20367. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  20368. */
  20369. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  20370. /**
  20371. * Creates a new path starting from an x and y position
  20372. * @param x starting x value
  20373. * @param y starting y value
  20374. * @returns a new Path2 starting at the coordinates (x, y).
  20375. */
  20376. static StartingAt(x: number, y: number): Path2;
  20377. }
  20378. /**
  20379. * Represents a 3D path made up of multiple 3D points
  20380. */
  20381. class Path3D {
  20382. /**
  20383. * an array of Vector3, the curve axis of the Path3D
  20384. */
  20385. path: Vector3[];
  20386. private _curve;
  20387. private _distances;
  20388. private _tangents;
  20389. private _normals;
  20390. private _binormals;
  20391. private _raw;
  20392. /**
  20393. * new Path3D(path, normal, raw)
  20394. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  20395. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  20396. * @param path an array of Vector3, the curve axis of the Path3D
  20397. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  20398. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  20399. */
  20400. constructor(
  20401. /**
  20402. * an array of Vector3, the curve axis of the Path3D
  20403. */
  20404. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  20405. /**
  20406. * Returns the Path3D array of successive Vector3 designing its curve.
  20407. * @returns the Path3D array of successive Vector3 designing its curve.
  20408. */
  20409. getCurve(): Vector3[];
  20410. /**
  20411. * Returns an array populated with tangent vectors on each Path3D curve point.
  20412. * @returns an array populated with tangent vectors on each Path3D curve point.
  20413. */
  20414. getTangents(): Vector3[];
  20415. /**
  20416. * Returns an array populated with normal vectors on each Path3D curve point.
  20417. * @returns an array populated with normal vectors on each Path3D curve point.
  20418. */
  20419. getNormals(): Vector3[];
  20420. /**
  20421. * Returns an array populated with binormal vectors on each Path3D curve point.
  20422. * @returns an array populated with binormal vectors on each Path3D curve point.
  20423. */
  20424. getBinormals(): Vector3[];
  20425. /**
  20426. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  20427. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  20428. */
  20429. getDistances(): number[];
  20430. /**
  20431. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  20432. * @param path path which all values are copied into the curves points
  20433. * @param firstNormal which should be projected onto the curve
  20434. * @returns the same object updated.
  20435. */
  20436. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  20437. private _compute;
  20438. private _getFirstNonNullVector;
  20439. private _getLastNonNullVector;
  20440. private _normalVector;
  20441. }
  20442. /**
  20443. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20444. * A Curve3 is designed from a series of successive Vector3.
  20445. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  20446. */
  20447. class Curve3 {
  20448. private _points;
  20449. private _length;
  20450. /**
  20451. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  20452. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  20453. * @param v1 (Vector3) the control point
  20454. * @param v2 (Vector3) the end point of the Quadratic Bezier
  20455. * @param nbPoints (integer) the wanted number of points in the curve
  20456. * @returns the created Curve3
  20457. */
  20458. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  20459. /**
  20460. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  20461. * @param v0 (Vector3) the origin point of the Cubic Bezier
  20462. * @param v1 (Vector3) the first control point
  20463. * @param v2 (Vector3) the second control point
  20464. * @param v3 (Vector3) the end point of the Cubic Bezier
  20465. * @param nbPoints (integer) the wanted number of points in the curve
  20466. * @returns the created Curve3
  20467. */
  20468. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  20469. /**
  20470. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  20471. * @param p1 (Vector3) the origin point of the Hermite Spline
  20472. * @param t1 (Vector3) the tangent vector at the origin point
  20473. * @param p2 (Vector3) the end point of the Hermite Spline
  20474. * @param t2 (Vector3) the tangent vector at the end point
  20475. * @param nbPoints (integer) the wanted number of points in the curve
  20476. * @returns the created Curve3
  20477. */
  20478. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  20479. /**
  20480. * Returns a Curve3 object along a CatmullRom Spline curve :
  20481. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  20482. * @param nbPoints (integer) the wanted number of points between each curve control points
  20483. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  20484. * @returns the created Curve3
  20485. */
  20486. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  20487. /**
  20488. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  20489. * A Curve3 is designed from a series of successive Vector3.
  20490. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  20491. * @param points points which make up the curve
  20492. */
  20493. constructor(points: Vector3[]);
  20494. /**
  20495. * @returns the Curve3 stored array of successive Vector3
  20496. */
  20497. getPoints(): Vector3[];
  20498. /**
  20499. * @returns the computed length (float) of the curve.
  20500. */
  20501. length(): number;
  20502. /**
  20503. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  20504. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  20505. * curveA and curveB keep unchanged.
  20506. * @param curve the curve to continue from this curve
  20507. * @returns the newly constructed curve
  20508. */
  20509. continue(curve: Curve3): Curve3;
  20510. private _computeLength;
  20511. }
  20512. /**
  20513. * Contains position and normal vectors for a vertex
  20514. */
  20515. class PositionNormalVertex {
  20516. /** the position of the vertex (defaut: 0,0,0) */
  20517. position: Vector3;
  20518. /** the normal of the vertex (defaut: 0,1,0) */
  20519. normal: Vector3;
  20520. /**
  20521. * Creates a PositionNormalVertex
  20522. * @param position the position of the vertex (defaut: 0,0,0)
  20523. * @param normal the normal of the vertex (defaut: 0,1,0)
  20524. */
  20525. constructor(
  20526. /** the position of the vertex (defaut: 0,0,0) */
  20527. position?: Vector3,
  20528. /** the normal of the vertex (defaut: 0,1,0) */
  20529. normal?: Vector3);
  20530. /**
  20531. * Clones the PositionNormalVertex
  20532. * @returns the cloned PositionNormalVertex
  20533. */
  20534. clone(): PositionNormalVertex;
  20535. }
  20536. /**
  20537. * Contains position, normal and uv vectors for a vertex
  20538. */
  20539. class PositionNormalTextureVertex {
  20540. /** the position of the vertex (defaut: 0,0,0) */
  20541. position: Vector3;
  20542. /** the normal of the vertex (defaut: 0,1,0) */
  20543. normal: Vector3;
  20544. /** the uv of the vertex (default: 0,0) */
  20545. uv: Vector2;
  20546. /**
  20547. * Creates a PositionNormalTextureVertex
  20548. * @param position the position of the vertex (defaut: 0,0,0)
  20549. * @param normal the normal of the vertex (defaut: 0,1,0)
  20550. * @param uv the uv of the vertex (default: 0,0)
  20551. */
  20552. constructor(
  20553. /** the position of the vertex (defaut: 0,0,0) */
  20554. position?: Vector3,
  20555. /** the normal of the vertex (defaut: 0,1,0) */
  20556. normal?: Vector3,
  20557. /** the uv of the vertex (default: 0,0) */
  20558. uv?: Vector2);
  20559. /**
  20560. * Clones the PositionNormalTextureVertex
  20561. * @returns the cloned PositionNormalTextureVertex
  20562. */
  20563. clone(): PositionNormalTextureVertex;
  20564. }
  20565. /**
  20566. * @hidden
  20567. */
  20568. class Tmp {
  20569. static Color3: Color3[];
  20570. static Color4: Color4[];
  20571. static Vector2: Vector2[];
  20572. static Vector3: Vector3[];
  20573. static Vector4: Vector4[];
  20574. static Quaternion: Quaternion[];
  20575. static Matrix: Matrix[];
  20576. }
  20577. }
  20578. declare module BABYLON {
  20579. /**
  20580. * Class representing spherical polynomial coefficients to the 3rd degree
  20581. */
  20582. class SphericalPolynomial {
  20583. /**
  20584. * The x coefficients of the spherical polynomial
  20585. */
  20586. x: Vector3;
  20587. /**
  20588. * The y coefficients of the spherical polynomial
  20589. */
  20590. y: Vector3;
  20591. /**
  20592. * The z coefficients of the spherical polynomial
  20593. */
  20594. z: Vector3;
  20595. /**
  20596. * The xx coefficients of the spherical polynomial
  20597. */
  20598. xx: Vector3;
  20599. /**
  20600. * The yy coefficients of the spherical polynomial
  20601. */
  20602. yy: Vector3;
  20603. /**
  20604. * The zz coefficients of the spherical polynomial
  20605. */
  20606. zz: Vector3;
  20607. /**
  20608. * The xy coefficients of the spherical polynomial
  20609. */
  20610. xy: Vector3;
  20611. /**
  20612. * The yz coefficients of the spherical polynomial
  20613. */
  20614. yz: Vector3;
  20615. /**
  20616. * The zx coefficients of the spherical polynomial
  20617. */
  20618. zx: Vector3;
  20619. /**
  20620. * Adds an ambient color to the spherical polynomial
  20621. * @param color the color to add
  20622. */
  20623. addAmbient(color: Color3): void;
  20624. /**
  20625. * Scales the spherical polynomial by the given amount
  20626. * @param scale the amount to scale
  20627. */
  20628. scale(scale: number): void;
  20629. /**
  20630. * Gets the spherical polynomial from harmonics
  20631. * @param harmonics the spherical harmonics
  20632. * @returns the spherical polynomial
  20633. */
  20634. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20635. /**
  20636. * Constructs a spherical polynomial from an array.
  20637. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20638. * @returns the spherical polynomial
  20639. */
  20640. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20641. }
  20642. /**
  20643. * Class representing spherical harmonics coefficients to the 3rd degree
  20644. */
  20645. class SphericalHarmonics {
  20646. /**
  20647. * The l0,0 coefficients of the spherical harmonics
  20648. */
  20649. l00: Vector3;
  20650. /**
  20651. * The l1,-1 coefficients of the spherical harmonics
  20652. */
  20653. l1_1: Vector3;
  20654. /**
  20655. * The l1,0 coefficients of the spherical harmonics
  20656. */
  20657. l10: Vector3;
  20658. /**
  20659. * The l1,1 coefficients of the spherical harmonics
  20660. */
  20661. l11: Vector3;
  20662. /**
  20663. * The l2,-2 coefficients of the spherical harmonics
  20664. */
  20665. l2_2: Vector3;
  20666. /**
  20667. * The l2,-1 coefficients of the spherical harmonics
  20668. */
  20669. l2_1: Vector3;
  20670. /**
  20671. * The l2,0 coefficients of the spherical harmonics
  20672. */
  20673. l20: Vector3;
  20674. /**
  20675. * The l2,1 coefficients of the spherical harmonics
  20676. */
  20677. l21: Vector3;
  20678. /**
  20679. * The l2,2 coefficients of the spherical harmonics
  20680. */
  20681. lL22: Vector3;
  20682. /**
  20683. * Adds a light to the spherical harmonics
  20684. * @param direction the direction of the light
  20685. * @param color the color of the light
  20686. * @param deltaSolidAngle the delta solid angle of the light
  20687. */
  20688. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20689. /**
  20690. * Scales the spherical harmonics by the given amount
  20691. * @param scale the amount to scale
  20692. */
  20693. scale(scale: number): void;
  20694. /**
  20695. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20696. *
  20697. * ```
  20698. * E_lm = A_l * L_lm
  20699. * ```
  20700. *
  20701. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20702. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20703. * the scaling factors are given in equation 9.
  20704. */
  20705. convertIncidentRadianceToIrradiance(): void;
  20706. /**
  20707. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20708. *
  20709. * ```
  20710. * L = (1/pi) * E * rho
  20711. * ```
  20712. *
  20713. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20714. */
  20715. convertIrradianceToLambertianRadiance(): void;
  20716. /**
  20717. * Gets the spherical harmonics from polynomial
  20718. * @param polynomial the spherical polynomial
  20719. * @returns the spherical harmonics
  20720. */
  20721. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20722. /**
  20723. * Constructs a spherical harmonics from an array.
  20724. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20725. * @returns the spherical harmonics
  20726. */
  20727. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20733. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20734. * 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;
  20735. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20736. */
  20737. class ColorCurves {
  20738. private _dirty;
  20739. private _tempColor;
  20740. private _globalCurve;
  20741. private _highlightsCurve;
  20742. private _midtonesCurve;
  20743. private _shadowsCurve;
  20744. private _positiveCurve;
  20745. private _negativeCurve;
  20746. private _globalHue;
  20747. private _globalDensity;
  20748. private _globalSaturation;
  20749. private _globalExposure;
  20750. /**
  20751. * Gets the global Hue value.
  20752. * 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).
  20753. */
  20754. /**
  20755. * Sets the global Hue value.
  20756. * 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).
  20757. */
  20758. globalHue: number;
  20759. /**
  20760. * Gets the global Density value.
  20761. * 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.
  20762. * Values less than zero provide a filter of opposite hue.
  20763. */
  20764. /**
  20765. * Sets the global Density value.
  20766. * 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.
  20767. * Values less than zero provide a filter of opposite hue.
  20768. */
  20769. globalDensity: number;
  20770. /**
  20771. * Gets the global Saturation value.
  20772. * 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.
  20773. */
  20774. /**
  20775. * Sets the global Saturation value.
  20776. * 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.
  20777. */
  20778. globalSaturation: number;
  20779. /**
  20780. * Gets the global Exposure value.
  20781. * 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.
  20782. */
  20783. /**
  20784. * Sets the global Exposure value.
  20785. * 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.
  20786. */
  20787. globalExposure: number;
  20788. private _highlightsHue;
  20789. private _highlightsDensity;
  20790. private _highlightsSaturation;
  20791. private _highlightsExposure;
  20792. /**
  20793. * Gets the highlights Hue value.
  20794. * 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).
  20795. */
  20796. /**
  20797. * Sets the highlights Hue value.
  20798. * 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).
  20799. */
  20800. highlightsHue: number;
  20801. /**
  20802. * Gets the highlights Density value.
  20803. * 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.
  20804. * Values less than zero provide a filter of opposite hue.
  20805. */
  20806. /**
  20807. * Sets the highlights Density value.
  20808. * 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.
  20809. * Values less than zero provide a filter of opposite hue.
  20810. */
  20811. highlightsDensity: number;
  20812. /**
  20813. * Gets the highlights Saturation value.
  20814. * 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.
  20815. */
  20816. /**
  20817. * Sets the highlights Saturation value.
  20818. * 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.
  20819. */
  20820. highlightsSaturation: number;
  20821. /**
  20822. * Gets the highlights Exposure value.
  20823. * 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.
  20824. */
  20825. /**
  20826. * Sets the highlights Exposure value.
  20827. * 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.
  20828. */
  20829. highlightsExposure: number;
  20830. private _midtonesHue;
  20831. private _midtonesDensity;
  20832. private _midtonesSaturation;
  20833. private _midtonesExposure;
  20834. /**
  20835. * Gets the midtones Hue value.
  20836. * 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).
  20837. */
  20838. /**
  20839. * Sets the midtones Hue value.
  20840. * 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).
  20841. */
  20842. midtonesHue: number;
  20843. /**
  20844. * Gets the midtones Density value.
  20845. * 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.
  20846. * Values less than zero provide a filter of opposite hue.
  20847. */
  20848. /**
  20849. * Sets the midtones Density value.
  20850. * 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.
  20851. * Values less than zero provide a filter of opposite hue.
  20852. */
  20853. midtonesDensity: number;
  20854. /**
  20855. * Gets the midtones Saturation value.
  20856. * 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.
  20857. */
  20858. /**
  20859. * Sets the midtones Saturation value.
  20860. * 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.
  20861. */
  20862. midtonesSaturation: number;
  20863. /**
  20864. * Gets the midtones Exposure value.
  20865. * 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.
  20866. */
  20867. /**
  20868. * Sets the midtones Exposure value.
  20869. * 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.
  20870. */
  20871. midtonesExposure: number;
  20872. private _shadowsHue;
  20873. private _shadowsDensity;
  20874. private _shadowsSaturation;
  20875. private _shadowsExposure;
  20876. /**
  20877. * Gets the shadows Hue value.
  20878. * 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).
  20879. */
  20880. /**
  20881. * Sets the shadows Hue value.
  20882. * 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).
  20883. */
  20884. shadowsHue: number;
  20885. /**
  20886. * Gets the shadows Density value.
  20887. * 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.
  20888. * Values less than zero provide a filter of opposite hue.
  20889. */
  20890. /**
  20891. * Sets the shadows Density value.
  20892. * 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.
  20893. * Values less than zero provide a filter of opposite hue.
  20894. */
  20895. shadowsDensity: number;
  20896. /**
  20897. * Gets the shadows Saturation value.
  20898. * 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.
  20899. */
  20900. /**
  20901. * Sets the shadows Saturation value.
  20902. * 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.
  20903. */
  20904. shadowsSaturation: number;
  20905. /**
  20906. * Gets the shadows Exposure value.
  20907. * 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.
  20908. */
  20909. /**
  20910. * Sets the shadows Exposure value.
  20911. * 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.
  20912. */
  20913. shadowsExposure: number;
  20914. /**
  20915. * Returns the class name
  20916. * @returns The class name
  20917. */
  20918. getClassName(): string;
  20919. /**
  20920. * Binds the color curves to the shader.
  20921. * @param colorCurves The color curve to bind
  20922. * @param effect The effect to bind to
  20923. * @param positiveUniform The positive uniform shader parameter
  20924. * @param neutralUniform The neutral uniform shader parameter
  20925. * @param negativeUniform The negative uniform shader parameter
  20926. */
  20927. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  20928. /**
  20929. * Prepare the list of uniforms associated with the ColorCurves effects.
  20930. * @param uniformsList The list of uniforms used in the effect
  20931. */
  20932. static PrepareUniforms(uniformsList: string[]): void;
  20933. /**
  20934. * Returns color grading data based on a hue, density, saturation and exposure value.
  20935. * @param filterHue The hue of the color filter.
  20936. * @param filterDensity The density of the color filter.
  20937. * @param saturation The saturation.
  20938. * @param exposure The exposure.
  20939. * @param result The result data container.
  20940. */
  20941. private getColorGradingDataToRef;
  20942. /**
  20943. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  20944. * @param value The input slider value in range [-100,100].
  20945. * @returns Adjusted value.
  20946. */
  20947. private static applyColorGradingSliderNonlinear;
  20948. /**
  20949. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  20950. * @param hue The hue (H) input.
  20951. * @param saturation The saturation (S) input.
  20952. * @param brightness The brightness (B) input.
  20953. * @result An RGBA color represented as Vector4.
  20954. */
  20955. private static fromHSBToRef;
  20956. /**
  20957. * Returns a value clamped between min and max
  20958. * @param value The value to clamp
  20959. * @param min The minimum of value
  20960. * @param max The maximum of value
  20961. * @returns The clamped value.
  20962. */
  20963. private static clamp;
  20964. /**
  20965. * Clones the current color curve instance.
  20966. * @return The cloned curves
  20967. */
  20968. clone(): ColorCurves;
  20969. /**
  20970. * Serializes the current color curve instance to a json representation.
  20971. * @return a JSON representation
  20972. */
  20973. serialize(): any;
  20974. /**
  20975. * Parses the color curve from a json representation.
  20976. * @param source the JSON source to parse
  20977. * @return The parsed curves
  20978. */
  20979. static Parse(source: any): ColorCurves;
  20980. }
  20981. }
  20982. declare module BABYLON {
  20983. /**
  20984. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  20985. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  20986. */
  20987. class EffectFallbacks {
  20988. private _defines;
  20989. private _currentRank;
  20990. private _maxRank;
  20991. private _mesh;
  20992. /**
  20993. * Removes the fallback from the bound mesh.
  20994. */
  20995. unBindMesh(): void;
  20996. /**
  20997. * Adds a fallback on the specified property.
  20998. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  20999. * @param define The name of the define in the shader
  21000. */
  21001. addFallback(rank: number, define: string): void;
  21002. /**
  21003. * Sets the mesh to use CPU skinning when needing to fallback.
  21004. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  21005. * @param mesh The mesh to use the fallbacks.
  21006. */
  21007. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  21008. /**
  21009. * Checks to see if more fallbacks are still availible.
  21010. */
  21011. readonly isMoreFallbacks: boolean;
  21012. /**
  21013. * Removes the defines that shoould be removed when falling back.
  21014. * @param currentDefines defines the current define statements for the shader.
  21015. * @param effect defines the current effect we try to compile
  21016. * @returns The resulting defines with defines of the current rank removed.
  21017. */
  21018. reduce(currentDefines: string, effect: Effect): string;
  21019. }
  21020. /**
  21021. * Options to be used when creating an effect.
  21022. */
  21023. class EffectCreationOptions {
  21024. /**
  21025. * Atrributes that will be used in the shader.
  21026. */
  21027. attributes: string[];
  21028. /**
  21029. * Uniform varible names that will be set in the shader.
  21030. */
  21031. uniformsNames: string[];
  21032. /**
  21033. * Uniform buffer varible names that will be set in the shader.
  21034. */
  21035. uniformBuffersNames: string[];
  21036. /**
  21037. * Sampler texture variable names that will be set in the shader.
  21038. */
  21039. samplers: string[];
  21040. /**
  21041. * Define statements that will be set in the shader.
  21042. */
  21043. defines: any;
  21044. /**
  21045. * Possible fallbacks for this effect to improve performance when needed.
  21046. */
  21047. fallbacks: Nullable<EffectFallbacks>;
  21048. /**
  21049. * Callback that will be called when the shader is compiled.
  21050. */
  21051. onCompiled: Nullable<(effect: Effect) => void>;
  21052. /**
  21053. * Callback that will be called if an error occurs during shader compilation.
  21054. */
  21055. onError: Nullable<(effect: Effect, errors: string) => void>;
  21056. /**
  21057. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21058. */
  21059. indexParameters: any;
  21060. /**
  21061. * Max number of lights that can be used in the shader.
  21062. */
  21063. maxSimultaneousLights: number;
  21064. /**
  21065. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  21066. */
  21067. transformFeedbackVaryings: Nullable<string[]>;
  21068. }
  21069. /**
  21070. * Effect containing vertex and fragment shader that can be executed on an object.
  21071. */
  21072. class Effect {
  21073. /**
  21074. * Name of the effect.
  21075. */
  21076. name: any;
  21077. /**
  21078. * String container all the define statements that should be set on the shader.
  21079. */
  21080. defines: string;
  21081. /**
  21082. * Callback that will be called when the shader is compiled.
  21083. */
  21084. onCompiled: Nullable<(effect: Effect) => void>;
  21085. /**
  21086. * Callback that will be called if an error occurs during shader compilation.
  21087. */
  21088. onError: Nullable<(effect: Effect, errors: string) => void>;
  21089. /**
  21090. * Callback that will be called when effect is bound.
  21091. */
  21092. onBind: Nullable<(effect: Effect) => void>;
  21093. /**
  21094. * Unique ID of the effect.
  21095. */
  21096. uniqueId: number;
  21097. /**
  21098. * Observable that will be called when the shader is compiled.
  21099. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  21100. */
  21101. onCompileObservable: Observable<Effect>;
  21102. /**
  21103. * Observable that will be called if an error occurs during shader compilation.
  21104. */
  21105. onErrorObservable: Observable<Effect>;
  21106. /** @hidden */
  21107. _onBindObservable: Nullable<Observable<Effect>>;
  21108. /**
  21109. * Observable that will be called when effect is bound.
  21110. */
  21111. readonly onBindObservable: Observable<Effect>;
  21112. /** @hidden */
  21113. _bonesComputationForcedToCPU: boolean;
  21114. private static _uniqueIdSeed;
  21115. private _engine;
  21116. private _uniformBuffersNames;
  21117. private _uniformsNames;
  21118. private _samplers;
  21119. private _isReady;
  21120. private _compilationError;
  21121. private _attributesNames;
  21122. private _attributes;
  21123. private _uniforms;
  21124. /**
  21125. * Key for the effect.
  21126. * @hidden
  21127. */
  21128. _key: string;
  21129. private _indexParameters;
  21130. private _fallbacks;
  21131. private _vertexSourceCode;
  21132. private _fragmentSourceCode;
  21133. private _vertexSourceCodeOverride;
  21134. private _fragmentSourceCodeOverride;
  21135. private _transformFeedbackVaryings;
  21136. /**
  21137. * Compiled shader to webGL program.
  21138. * @hidden
  21139. */
  21140. _program: WebGLProgram;
  21141. private _valueCache;
  21142. private static _baseCache;
  21143. /**
  21144. * Instantiates an effect.
  21145. * An effect can be used to create/manage/execute vertex and fragment shaders.
  21146. * @param baseName Name of the effect.
  21147. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  21148. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  21149. * @param samplers List of sampler variables that will be passed to the shader.
  21150. * @param engine Engine to be used to render the effect
  21151. * @param defines Define statements to be added to the shader.
  21152. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  21153. * @param onCompiled Callback that will be called when the shader is compiled.
  21154. * @param onError Callback that will be called if an error occurs during shader compilation.
  21155. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  21156. */
  21157. 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);
  21158. /**
  21159. * Unique key for this effect
  21160. */
  21161. readonly key: string;
  21162. /**
  21163. * If the effect has been compiled and prepared.
  21164. * @returns if the effect is compiled and prepared.
  21165. */
  21166. isReady(): boolean;
  21167. /**
  21168. * The engine the effect was initialized with.
  21169. * @returns the engine.
  21170. */
  21171. getEngine(): Engine;
  21172. /**
  21173. * The compiled webGL program for the effect
  21174. * @returns the webGL program.
  21175. */
  21176. getProgram(): WebGLProgram;
  21177. /**
  21178. * The set of names of attribute variables for the shader.
  21179. * @returns An array of attribute names.
  21180. */
  21181. getAttributesNames(): string[];
  21182. /**
  21183. * Returns the attribute at the given index.
  21184. * @param index The index of the attribute.
  21185. * @returns The location of the attribute.
  21186. */
  21187. getAttributeLocation(index: number): number;
  21188. /**
  21189. * Returns the attribute based on the name of the variable.
  21190. * @param name of the attribute to look up.
  21191. * @returns the attribute location.
  21192. */
  21193. getAttributeLocationByName(name: string): number;
  21194. /**
  21195. * The number of attributes.
  21196. * @returns the numnber of attributes.
  21197. */
  21198. getAttributesCount(): number;
  21199. /**
  21200. * Gets the index of a uniform variable.
  21201. * @param uniformName of the uniform to look up.
  21202. * @returns the index.
  21203. */
  21204. getUniformIndex(uniformName: string): number;
  21205. /**
  21206. * Returns the attribute based on the name of the variable.
  21207. * @param uniformName of the uniform to look up.
  21208. * @returns the location of the uniform.
  21209. */
  21210. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  21211. /**
  21212. * Returns an array of sampler variable names
  21213. * @returns The array of sampler variable neames.
  21214. */
  21215. getSamplers(): string[];
  21216. /**
  21217. * The error from the last compilation.
  21218. * @returns the error string.
  21219. */
  21220. getCompilationError(): string;
  21221. /**
  21222. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  21223. * @param func The callback to be used.
  21224. */
  21225. executeWhenCompiled(func: (effect: Effect) => void): void;
  21226. private _checkIsReady;
  21227. /** @hidden */
  21228. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  21229. /** @hidden */
  21230. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  21231. /** @hidden */
  21232. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  21233. private _processShaderConversion;
  21234. private _processIncludes;
  21235. private _processPrecision;
  21236. /**
  21237. * Recompiles the webGL program
  21238. * @param vertexSourceCode The source code for the vertex shader.
  21239. * @param fragmentSourceCode The source code for the fragment shader.
  21240. * @param onCompiled Callback called when completed.
  21241. * @param onError Callback called on error.
  21242. * @hidden
  21243. */
  21244. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  21245. /**
  21246. * Gets the uniform locations of the the specified variable names
  21247. * @param names THe names of the variables to lookup.
  21248. * @returns Array of locations in the same order as variable names.
  21249. */
  21250. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  21251. /**
  21252. * Prepares the effect
  21253. * @hidden
  21254. */
  21255. _prepareEffect(): void;
  21256. /**
  21257. * Checks if the effect is supported. (Must be called after compilation)
  21258. */
  21259. readonly isSupported: boolean;
  21260. /**
  21261. * Binds a texture to the engine to be used as output of the shader.
  21262. * @param channel Name of the output variable.
  21263. * @param texture Texture to bind.
  21264. * @hidden
  21265. */
  21266. _bindTexture(channel: string, texture: InternalTexture): void;
  21267. /**
  21268. * Sets a texture on the engine to be used in the shader.
  21269. * @param channel Name of the sampler variable.
  21270. * @param texture Texture to set.
  21271. */
  21272. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  21273. /**
  21274. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  21275. * @param channel Name of the sampler variable.
  21276. * @param texture Texture to set.
  21277. */
  21278. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  21279. /**
  21280. * Sets an array of textures on the engine to be used in the shader.
  21281. * @param channel Name of the variable.
  21282. * @param textures Textures to set.
  21283. */
  21284. setTextureArray(channel: string, textures: BaseTexture[]): void;
  21285. /**
  21286. * 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)
  21287. * @param channel Name of the sampler variable.
  21288. * @param postProcess Post process to get the input texture from.
  21289. */
  21290. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  21291. /**
  21292. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  21293. * 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)
  21294. * @param channel Name of the sampler variable.
  21295. * @param postProcess Post process to get the output texture from.
  21296. */
  21297. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  21298. /** @hidden */
  21299. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  21300. /** @hidden */
  21301. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  21302. /** @hidden */
  21303. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  21304. /** @hidden */
  21305. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  21306. /**
  21307. * Binds a buffer to a uniform.
  21308. * @param buffer Buffer to bind.
  21309. * @param name Name of the uniform variable to bind to.
  21310. */
  21311. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  21312. /**
  21313. * Binds block to a uniform.
  21314. * @param blockName Name of the block to bind.
  21315. * @param index Index to bind.
  21316. */
  21317. bindUniformBlock(blockName: string, index: number): void;
  21318. /**
  21319. * Sets an interger value on a uniform variable.
  21320. * @param uniformName Name of the variable.
  21321. * @param value Value to be set.
  21322. * @returns this effect.
  21323. */
  21324. setInt(uniformName: string, value: number): Effect;
  21325. /**
  21326. * Sets an int array on a uniform variable.
  21327. * @param uniformName Name of the variable.
  21328. * @param array array to be set.
  21329. * @returns this effect.
  21330. */
  21331. setIntArray(uniformName: string, array: Int32Array): Effect;
  21332. /**
  21333. * 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)
  21334. * @param uniformName Name of the variable.
  21335. * @param array array to be set.
  21336. * @returns this effect.
  21337. */
  21338. setIntArray2(uniformName: string, array: Int32Array): Effect;
  21339. /**
  21340. * 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)
  21341. * @param uniformName Name of the variable.
  21342. * @param array array to be set.
  21343. * @returns this effect.
  21344. */
  21345. setIntArray3(uniformName: string, array: Int32Array): Effect;
  21346. /**
  21347. * 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)
  21348. * @param uniformName Name of the variable.
  21349. * @param array array to be set.
  21350. * @returns this effect.
  21351. */
  21352. setIntArray4(uniformName: string, array: Int32Array): Effect;
  21353. /**
  21354. * Sets an float array on a uniform variable.
  21355. * @param uniformName Name of the variable.
  21356. * @param array array to be set.
  21357. * @returns this effect.
  21358. */
  21359. setFloatArray(uniformName: string, array: Float32Array): Effect;
  21360. /**
  21361. * 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)
  21362. * @param uniformName Name of the variable.
  21363. * @param array array to be set.
  21364. * @returns this effect.
  21365. */
  21366. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  21367. /**
  21368. * 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)
  21369. * @param uniformName Name of the variable.
  21370. * @param array array to be set.
  21371. * @returns this effect.
  21372. */
  21373. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  21374. /**
  21375. * 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)
  21376. * @param uniformName Name of the variable.
  21377. * @param array array to be set.
  21378. * @returns this effect.
  21379. */
  21380. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  21381. /**
  21382. * Sets an array on a uniform variable.
  21383. * @param uniformName Name of the variable.
  21384. * @param array array to be set.
  21385. * @returns this effect.
  21386. */
  21387. setArray(uniformName: string, array: number[]): Effect;
  21388. /**
  21389. * 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)
  21390. * @param uniformName Name of the variable.
  21391. * @param array array to be set.
  21392. * @returns this effect.
  21393. */
  21394. setArray2(uniformName: string, array: number[]): Effect;
  21395. /**
  21396. * 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)
  21397. * @param uniformName Name of the variable.
  21398. * @param array array to be set.
  21399. * @returns this effect.
  21400. */
  21401. setArray3(uniformName: string, array: number[]): Effect;
  21402. /**
  21403. * 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)
  21404. * @param uniformName Name of the variable.
  21405. * @param array array to be set.
  21406. * @returns this effect.
  21407. */
  21408. setArray4(uniformName: string, array: number[]): Effect;
  21409. /**
  21410. * Sets matrices on a uniform variable.
  21411. * @param uniformName Name of the variable.
  21412. * @param matrices matrices to be set.
  21413. * @returns this effect.
  21414. */
  21415. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  21416. /**
  21417. * Sets matrix on a uniform variable.
  21418. * @param uniformName Name of the variable.
  21419. * @param matrix matrix to be set.
  21420. * @returns this effect.
  21421. */
  21422. setMatrix(uniformName: string, matrix: Matrix): Effect;
  21423. /**
  21424. * 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)
  21425. * @param uniformName Name of the variable.
  21426. * @param matrix matrix to be set.
  21427. * @returns this effect.
  21428. */
  21429. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  21430. /**
  21431. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  21432. * @param uniformName Name of the variable.
  21433. * @param matrix matrix to be set.
  21434. * @returns this effect.
  21435. */
  21436. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  21437. /**
  21438. * Sets a float on a uniform variable.
  21439. * @param uniformName Name of the variable.
  21440. * @param value value to be set.
  21441. * @returns this effect.
  21442. */
  21443. setFloat(uniformName: string, value: number): Effect;
  21444. /**
  21445. * Sets a boolean on a uniform variable.
  21446. * @param uniformName Name of the variable.
  21447. * @param bool value to be set.
  21448. * @returns this effect.
  21449. */
  21450. setBool(uniformName: string, bool: boolean): Effect;
  21451. /**
  21452. * Sets a Vector2 on a uniform variable.
  21453. * @param uniformName Name of the variable.
  21454. * @param vector2 vector2 to be set.
  21455. * @returns this effect.
  21456. */
  21457. setVector2(uniformName: string, vector2: Vector2): Effect;
  21458. /**
  21459. * Sets a float2 on a uniform variable.
  21460. * @param uniformName Name of the variable.
  21461. * @param x First float in float2.
  21462. * @param y Second float in float2.
  21463. * @returns this effect.
  21464. */
  21465. setFloat2(uniformName: string, x: number, y: number): Effect;
  21466. /**
  21467. * Sets a Vector3 on a uniform variable.
  21468. * @param uniformName Name of the variable.
  21469. * @param vector3 Value to be set.
  21470. * @returns this effect.
  21471. */
  21472. setVector3(uniformName: string, vector3: Vector3): Effect;
  21473. /**
  21474. * Sets a float3 on a uniform variable.
  21475. * @param uniformName Name of the variable.
  21476. * @param x First float in float3.
  21477. * @param y Second float in float3.
  21478. * @param z Third float in float3.
  21479. * @returns this effect.
  21480. */
  21481. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  21482. /**
  21483. * Sets a Vector4 on a uniform variable.
  21484. * @param uniformName Name of the variable.
  21485. * @param vector4 Value to be set.
  21486. * @returns this effect.
  21487. */
  21488. setVector4(uniformName: string, vector4: Vector4): Effect;
  21489. /**
  21490. * Sets a float4 on a uniform variable.
  21491. * @param uniformName Name of the variable.
  21492. * @param x First float in float4.
  21493. * @param y Second float in float4.
  21494. * @param z Third float in float4.
  21495. * @param w Fourth float in float4.
  21496. * @returns this effect.
  21497. */
  21498. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  21499. /**
  21500. * Sets a Color3 on a uniform variable.
  21501. * @param uniformName Name of the variable.
  21502. * @param color3 Value to be set.
  21503. * @returns this effect.
  21504. */
  21505. setColor3(uniformName: string, color3: Color3): Effect;
  21506. /**
  21507. * Sets a Color4 on a uniform variable.
  21508. * @param uniformName Name of the variable.
  21509. * @param color3 Value to be set.
  21510. * @param alpha Alpha value to be set.
  21511. * @returns this effect.
  21512. */
  21513. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  21514. /**
  21515. * Sets a Color4 on a uniform variable
  21516. * @param uniformName defines the name of the variable
  21517. * @param color4 defines the value to be set
  21518. * @returns this effect.
  21519. */
  21520. setDirectColor4(uniformName: string, color4: Color4): Effect;
  21521. /**
  21522. * This function will add a new shader to the shader store
  21523. * @param name the name of the shader
  21524. * @param pixelShader optional pixel shader content
  21525. * @param vertexShader optional vertex shader content
  21526. */
  21527. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  21528. /**
  21529. * Store of each shader (The can be looked up using effect.key)
  21530. */
  21531. static ShadersStore: {
  21532. [key: string]: string;
  21533. };
  21534. /**
  21535. * Store of each included file for a shader (The can be looked up using effect.key)
  21536. */
  21537. static IncludesShadersStore: {
  21538. [key: string]: string;
  21539. };
  21540. /**
  21541. * Resets the cache of effects.
  21542. */
  21543. static ResetCache(): void;
  21544. }
  21545. }
  21546. declare module BABYLON {
  21547. /**
  21548. * This represents all the required information to add a fresnel effect on a material:
  21549. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  21550. */
  21551. class FresnelParameters {
  21552. private _isEnabled;
  21553. /**
  21554. * Define if the fresnel effect is enable or not.
  21555. */
  21556. isEnabled: boolean;
  21557. /**
  21558. * Define the color used on edges (grazing angle)
  21559. */
  21560. leftColor: Color3;
  21561. /**
  21562. * Define the color used on center
  21563. */
  21564. rightColor: Color3;
  21565. /**
  21566. * Define bias applied to computed fresnel term
  21567. */
  21568. bias: number;
  21569. /**
  21570. * Defined the power exponent applied to fresnel term
  21571. */
  21572. power: number;
  21573. /**
  21574. * Clones the current fresnel and its valuues
  21575. * @returns a clone fresnel configuration
  21576. */
  21577. clone(): FresnelParameters;
  21578. /**
  21579. * Serializes the current fresnel parameters to a JSON representation.
  21580. * @return the JSON serialization
  21581. */
  21582. serialize(): any;
  21583. /**
  21584. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  21585. * @param parsedFresnelParameters Define the JSON representation
  21586. * @returns the parsed parameters
  21587. */
  21588. static Parse(parsedFresnelParameters: any): FresnelParameters;
  21589. }
  21590. }
  21591. declare module BABYLON {
  21592. /**
  21593. * Interface to follow in your material defines to integrate easily the
  21594. * Image proccessing functions.
  21595. * @hidden
  21596. */
  21597. interface IImageProcessingConfigurationDefines {
  21598. IMAGEPROCESSING: boolean;
  21599. VIGNETTE: boolean;
  21600. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21601. VIGNETTEBLENDMODEOPAQUE: boolean;
  21602. TONEMAPPING: boolean;
  21603. TONEMAPPING_ACES: boolean;
  21604. CONTRAST: boolean;
  21605. EXPOSURE: boolean;
  21606. COLORCURVES: boolean;
  21607. COLORGRADING: boolean;
  21608. COLORGRADING3D: boolean;
  21609. SAMPLER3DGREENDEPTH: boolean;
  21610. SAMPLER3DBGRMAP: boolean;
  21611. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21612. }
  21613. /**
  21614. * @hidden
  21615. */
  21616. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21617. IMAGEPROCESSING: boolean;
  21618. VIGNETTE: boolean;
  21619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21620. VIGNETTEBLENDMODEOPAQUE: boolean;
  21621. TONEMAPPING: boolean;
  21622. TONEMAPPING_ACES: boolean;
  21623. CONTRAST: boolean;
  21624. COLORCURVES: boolean;
  21625. COLORGRADING: boolean;
  21626. COLORGRADING3D: boolean;
  21627. SAMPLER3DGREENDEPTH: boolean;
  21628. SAMPLER3DBGRMAP: boolean;
  21629. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21630. EXPOSURE: boolean;
  21631. constructor();
  21632. }
  21633. /**
  21634. * This groups together the common properties used for image processing either in direct forward pass
  21635. * or through post processing effect depending on the use of the image processing pipeline in your scene
  21636. * or not.
  21637. */
  21638. class ImageProcessingConfiguration {
  21639. /**
  21640. * Default tone mapping applied in BabylonJS.
  21641. */
  21642. static readonly TONEMAPPING_STANDARD: number;
  21643. /**
  21644. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  21645. * to other engines rendering to increase portability.
  21646. */
  21647. static readonly TONEMAPPING_ACES: number;
  21648. /**
  21649. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  21650. */
  21651. colorCurves: Nullable<ColorCurves>;
  21652. private _colorCurvesEnabled;
  21653. /**
  21654. * Gets wether the color curves effect is enabled.
  21655. */
  21656. /**
  21657. * Sets wether the color curves effect is enabled.
  21658. */
  21659. colorCurvesEnabled: boolean;
  21660. private _colorGradingTexture;
  21661. /**
  21662. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21663. */
  21664. /**
  21665. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  21666. */
  21667. colorGradingTexture: Nullable<BaseTexture>;
  21668. private _colorGradingEnabled;
  21669. /**
  21670. * Gets wether the color grading effect is enabled.
  21671. */
  21672. /**
  21673. * Sets wether the color grading effect is enabled.
  21674. */
  21675. colorGradingEnabled: boolean;
  21676. private _colorGradingWithGreenDepth;
  21677. /**
  21678. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  21679. */
  21680. /**
  21681. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  21682. */
  21683. colorGradingWithGreenDepth: boolean;
  21684. private _colorGradingBGR;
  21685. /**
  21686. * Gets wether the color grading texture contains BGR values.
  21687. */
  21688. /**
  21689. * Sets wether the color grading texture contains BGR values.
  21690. */
  21691. colorGradingBGR: boolean;
  21692. /** @hidden */
  21693. _exposure: number;
  21694. /**
  21695. * Gets the Exposure used in the effect.
  21696. */
  21697. /**
  21698. * Sets the Exposure used in the effect.
  21699. */
  21700. exposure: number;
  21701. private _toneMappingEnabled;
  21702. /**
  21703. * Gets wether the tone mapping effect is enabled.
  21704. */
  21705. /**
  21706. * Sets wether the tone mapping effect is enabled.
  21707. */
  21708. toneMappingEnabled: boolean;
  21709. private _toneMappingType;
  21710. /**
  21711. * Gets the type of tone mapping effect.
  21712. */
  21713. /**
  21714. * Sets the type of tone mapping effect used in BabylonJS.
  21715. */
  21716. toneMappingType: number;
  21717. protected _contrast: number;
  21718. /**
  21719. * Gets the contrast used in the effect.
  21720. */
  21721. /**
  21722. * Sets the contrast used in the effect.
  21723. */
  21724. contrast: number;
  21725. /**
  21726. * Vignette stretch size.
  21727. */
  21728. vignetteStretch: number;
  21729. /**
  21730. * Vignette centre X Offset.
  21731. */
  21732. vignetteCentreX: number;
  21733. /**
  21734. * Vignette centre Y Offset.
  21735. */
  21736. vignetteCentreY: number;
  21737. /**
  21738. * Vignette weight or intensity of the vignette effect.
  21739. */
  21740. vignetteWeight: number;
  21741. /**
  21742. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  21743. * if vignetteEnabled is set to true.
  21744. */
  21745. vignetteColor: Color4;
  21746. /**
  21747. * Camera field of view used by the Vignette effect.
  21748. */
  21749. vignetteCameraFov: number;
  21750. private _vignetteBlendMode;
  21751. /**
  21752. * Gets the vignette blend mode allowing different kind of effect.
  21753. */
  21754. /**
  21755. * Sets the vignette blend mode allowing different kind of effect.
  21756. */
  21757. vignetteBlendMode: number;
  21758. private _vignetteEnabled;
  21759. /**
  21760. * Gets wether the vignette effect is enabled.
  21761. */
  21762. /**
  21763. * Sets wether the vignette effect is enabled.
  21764. */
  21765. vignetteEnabled: boolean;
  21766. private _applyByPostProcess;
  21767. /**
  21768. * Gets wether the image processing is applied through a post process or not.
  21769. */
  21770. /**
  21771. * Sets wether the image processing is applied through a post process or not.
  21772. */
  21773. applyByPostProcess: boolean;
  21774. private _isEnabled;
  21775. /**
  21776. * Gets wether the image processing is enabled or not.
  21777. */
  21778. /**
  21779. * Sets wether the image processing is enabled or not.
  21780. */
  21781. isEnabled: boolean;
  21782. /**
  21783. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  21784. */
  21785. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  21786. /**
  21787. * Method called each time the image processing information changes requires to recompile the effect.
  21788. */
  21789. protected _updateParameters(): void;
  21790. /**
  21791. * Gets the current class name.
  21792. * @return "ImageProcessingConfiguration"
  21793. */
  21794. getClassName(): string;
  21795. /**
  21796. * Prepare the list of uniforms associated with the Image Processing effects.
  21797. * @param uniforms The list of uniforms used in the effect
  21798. * @param defines the list of defines currently in use
  21799. */
  21800. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  21801. /**
  21802. * Prepare the list of samplers associated with the Image Processing effects.
  21803. * @param samplersList The list of uniforms used in the effect
  21804. * @param defines the list of defines currently in use
  21805. */
  21806. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  21807. /**
  21808. * Prepare the list of defines associated to the shader.
  21809. * @param defines the list of defines to complete
  21810. * @param forPostProcess Define if we are currently in post process mode or not
  21811. */
  21812. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  21813. /**
  21814. * Returns true if all the image processing information are ready.
  21815. * @returns True if ready, otherwise, false
  21816. */
  21817. isReady(): boolean;
  21818. /**
  21819. * Binds the image processing to the shader.
  21820. * @param effect The effect to bind to
  21821. * @param aspectRatio Define the current aspect ratio of the effect
  21822. */
  21823. bind(effect: Effect, aspectRatio?: number): void;
  21824. /**
  21825. * Clones the current image processing instance.
  21826. * @return The cloned image processing
  21827. */
  21828. clone(): ImageProcessingConfiguration;
  21829. /**
  21830. * Serializes the current image processing instance to a json representation.
  21831. * @return a JSON representation
  21832. */
  21833. serialize(): any;
  21834. /**
  21835. * Parses the image processing from a json representation.
  21836. * @param source the JSON source to parse
  21837. * @return The parsed image processing
  21838. */
  21839. static Parse(source: any): ImageProcessingConfiguration;
  21840. private static _VIGNETTEMODE_MULTIPLY;
  21841. private static _VIGNETTEMODE_OPAQUE;
  21842. /**
  21843. * Used to apply the vignette as a mix with the pixel color.
  21844. */
  21845. static readonly VIGNETTEMODE_MULTIPLY: number;
  21846. /**
  21847. * Used to apply the vignette as a replacement of the pixel color.
  21848. */
  21849. static readonly VIGNETTEMODE_OPAQUE: number;
  21850. }
  21851. }
  21852. declare module BABYLON {
  21853. /**
  21854. * Manages the defines for the Material
  21855. */
  21856. class MaterialDefines {
  21857. private _keys;
  21858. private _isDirty;
  21859. /** @hidden */
  21860. _renderId: number;
  21861. /** @hidden */
  21862. _areLightsDirty: boolean;
  21863. /** @hidden */
  21864. _areAttributesDirty: boolean;
  21865. /** @hidden */
  21866. _areTexturesDirty: boolean;
  21867. /** @hidden */
  21868. _areFresnelDirty: boolean;
  21869. /** @hidden */
  21870. _areMiscDirty: boolean;
  21871. /** @hidden */
  21872. _areImageProcessingDirty: boolean;
  21873. /** @hidden */
  21874. _normals: boolean;
  21875. /** @hidden */
  21876. _uvs: boolean;
  21877. /** @hidden */
  21878. _needNormals: boolean;
  21879. /** @hidden */
  21880. _needUVs: boolean;
  21881. /**
  21882. * Specifies if the material needs to be re-calculated
  21883. */
  21884. readonly isDirty: boolean;
  21885. /**
  21886. * Marks the material to indicate that it has been re-calculated
  21887. */
  21888. markAsProcessed(): void;
  21889. /**
  21890. * Marks the material to indicate that it needs to be re-calculated
  21891. */
  21892. markAsUnprocessed(): void;
  21893. /**
  21894. * Marks the material to indicate all of its defines need to be re-calculated
  21895. */
  21896. markAllAsDirty(): void;
  21897. /**
  21898. * Marks the material to indicate that image processing needs to be re-calculated
  21899. */
  21900. markAsImageProcessingDirty(): void;
  21901. /**
  21902. * Marks the material to indicate the lights need to be re-calculated
  21903. */
  21904. markAsLightDirty(): void;
  21905. /**
  21906. * Marks the attribute state as changed
  21907. */
  21908. markAsAttributesDirty(): void;
  21909. /**
  21910. * Marks the texture state as changed
  21911. */
  21912. markAsTexturesDirty(): void;
  21913. /**
  21914. * Marks the fresnel state as changed
  21915. */
  21916. markAsFresnelDirty(): void;
  21917. /**
  21918. * Marks the misc state as changed
  21919. */
  21920. markAsMiscDirty(): void;
  21921. /**
  21922. * Rebuilds the material defines
  21923. */
  21924. rebuild(): void;
  21925. /**
  21926. * Specifies if two material defines are equal
  21927. * @param other - A material define instance to compare to
  21928. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  21929. */
  21930. isEqual(other: MaterialDefines): boolean;
  21931. /**
  21932. * Clones this instance's defines to another instance
  21933. * @param other - material defines to clone values to
  21934. */
  21935. cloneTo(other: MaterialDefines): void;
  21936. /**
  21937. * Resets the material define values
  21938. */
  21939. reset(): void;
  21940. /**
  21941. * Converts the material define values to a string
  21942. * @returns - String of material define information
  21943. */
  21944. toString(): string;
  21945. }
  21946. /**
  21947. * Base class for the main features of a material in Babylon.js
  21948. */
  21949. class Material implements IAnimatable {
  21950. private static _TriangleFillMode;
  21951. private static _WireFrameFillMode;
  21952. private static _PointFillMode;
  21953. private static _PointListDrawMode;
  21954. private static _LineListDrawMode;
  21955. private static _LineLoopDrawMode;
  21956. private static _LineStripDrawMode;
  21957. private static _TriangleStripDrawMode;
  21958. private static _TriangleFanDrawMode;
  21959. /**
  21960. * Returns the triangle fill mode
  21961. */
  21962. static readonly TriangleFillMode: number;
  21963. /**
  21964. * Returns the wireframe mode
  21965. */
  21966. static readonly WireFrameFillMode: number;
  21967. /**
  21968. * Returns the point fill mode
  21969. */
  21970. static readonly PointFillMode: number;
  21971. /**
  21972. * Returns the point list draw mode
  21973. */
  21974. static readonly PointListDrawMode: number;
  21975. /**
  21976. * Returns the line list draw mode
  21977. */
  21978. static readonly LineListDrawMode: number;
  21979. /**
  21980. * Returns the line loop draw mode
  21981. */
  21982. static readonly LineLoopDrawMode: number;
  21983. /**
  21984. * Returns the line strip draw mode
  21985. */
  21986. static readonly LineStripDrawMode: number;
  21987. /**
  21988. * Returns the triangle strip draw mode
  21989. */
  21990. static readonly TriangleStripDrawMode: number;
  21991. /**
  21992. * Returns the triangle fan draw mode
  21993. */
  21994. static readonly TriangleFanDrawMode: number;
  21995. /**
  21996. * Stores the clock-wise side orientation
  21997. */
  21998. private static _ClockWiseSideOrientation;
  21999. /**
  22000. * Stores the counter clock-wise side orientation
  22001. */
  22002. private static _CounterClockWiseSideOrientation;
  22003. /**
  22004. * Returns the clock-wise side orientation
  22005. */
  22006. static readonly ClockWiseSideOrientation: number;
  22007. /**
  22008. * Returns the counter clock-wise side orientation
  22009. */
  22010. static readonly CounterClockWiseSideOrientation: number;
  22011. /**
  22012. * The dirty texture flag value
  22013. */
  22014. static readonly TextureDirtyFlag: number;
  22015. /**
  22016. * The dirty light flag value
  22017. */
  22018. static readonly LightDirtyFlag: number;
  22019. /**
  22020. * The dirty fresnel flag value
  22021. */
  22022. static readonly FresnelDirtyFlag: number;
  22023. /**
  22024. * The dirty attribute flag value
  22025. */
  22026. static readonly AttributesDirtyFlag: number;
  22027. /**
  22028. * The dirty misc flag value
  22029. */
  22030. static readonly MiscDirtyFlag: number;
  22031. /**
  22032. * The all dirty flag value
  22033. */
  22034. static readonly AllDirtyFlag: number;
  22035. /**
  22036. * The ID of the material
  22037. */
  22038. id: string;
  22039. /**
  22040. * Gets or sets the unique id of the material
  22041. */
  22042. uniqueId: number;
  22043. /**
  22044. * The name of the material
  22045. */
  22046. name: string;
  22047. /**
  22048. * Specifies if the ready state should be checked on each call
  22049. */
  22050. checkReadyOnEveryCall: boolean;
  22051. /**
  22052. * Specifies if the ready state should be checked once
  22053. */
  22054. checkReadyOnlyOnce: boolean;
  22055. /**
  22056. * The state of the material
  22057. */
  22058. state: string;
  22059. /**
  22060. * The alpha value of the material
  22061. */
  22062. protected _alpha: number;
  22063. /**
  22064. * Sets the alpha value of the material
  22065. */
  22066. /**
  22067. * Gets the alpha value of the material
  22068. */
  22069. alpha: number;
  22070. /**
  22071. * Specifies if back face culling is enabled
  22072. */
  22073. protected _backFaceCulling: boolean;
  22074. /**
  22075. * Sets the back-face culling state
  22076. */
  22077. /**
  22078. * Gets the back-face culling state
  22079. */
  22080. backFaceCulling: boolean;
  22081. /**
  22082. * Stores the value for side orientation
  22083. */
  22084. sideOrientation: number;
  22085. /**
  22086. * Callback triggered when the material is compiled
  22087. */
  22088. onCompiled: (effect: Effect) => void;
  22089. /**
  22090. * Callback triggered when an error occurs
  22091. */
  22092. onError: (effect: Effect, errors: string) => void;
  22093. /**
  22094. * Callback triggered to get the render target textures
  22095. */
  22096. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22097. /**
  22098. * Gets a boolean indicating that current material needs to register RTT
  22099. */
  22100. readonly hasRenderTargetTextures: boolean;
  22101. /**
  22102. * Specifies if the material should be serialized
  22103. */
  22104. doNotSerialize: boolean;
  22105. /**
  22106. * @hidden
  22107. */
  22108. _storeEffectOnSubMeshes: boolean;
  22109. /**
  22110. * Stores the animations for the material
  22111. */
  22112. animations: Array<Animation>;
  22113. /**
  22114. * An event triggered when the material is disposed
  22115. */
  22116. onDisposeObservable: Observable<Material>;
  22117. /**
  22118. * An observer which watches for dispose events
  22119. */
  22120. private _onDisposeObserver;
  22121. private _onUnBindObservable;
  22122. /**
  22123. * Called during a dispose event
  22124. */
  22125. onDispose: () => void;
  22126. private _onBindObservable;
  22127. /**
  22128. * An event triggered when the material is bound
  22129. */
  22130. readonly onBindObservable: Observable<AbstractMesh>;
  22131. /**
  22132. * An observer which watches for bind events
  22133. */
  22134. private _onBindObserver;
  22135. /**
  22136. * Called during a bind event
  22137. */
  22138. onBind: (Mesh: AbstractMesh) => void;
  22139. /**
  22140. * An event triggered when the material is unbound
  22141. */
  22142. readonly onUnBindObservable: Observable<Material>;
  22143. /**
  22144. * Stores the value of the alpha mode
  22145. */
  22146. private _alphaMode;
  22147. /**
  22148. * Sets the value of the alpha mode.
  22149. *
  22150. * | Value | Type | Description |
  22151. * | --- | --- | --- |
  22152. * | 0 | ALPHA_DISABLE | |
  22153. * | 1 | ALPHA_ADD | |
  22154. * | 2 | ALPHA_COMBINE | |
  22155. * | 3 | ALPHA_SUBTRACT | |
  22156. * | 4 | ALPHA_MULTIPLY | |
  22157. * | 5 | ALPHA_MAXIMIZED | |
  22158. * | 6 | ALPHA_ONEONE | |
  22159. * | 7 | ALPHA_PREMULTIPLIED | |
  22160. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22161. * | 9 | ALPHA_INTERPOLATE | |
  22162. * | 10 | ALPHA_SCREENMODE | |
  22163. *
  22164. */
  22165. /**
  22166. * Gets the value of the alpha mode
  22167. */
  22168. alphaMode: number;
  22169. /**
  22170. * Stores the state of the need depth pre-pass value
  22171. */
  22172. private _needDepthPrePass;
  22173. /**
  22174. * Sets the need depth pre-pass value
  22175. */
  22176. /**
  22177. * Gets the depth pre-pass value
  22178. */
  22179. needDepthPrePass: boolean;
  22180. /**
  22181. * Specifies if depth writing should be disabled
  22182. */
  22183. disableDepthWrite: boolean;
  22184. /**
  22185. * Specifies if depth writing should be forced
  22186. */
  22187. forceDepthWrite: boolean;
  22188. /**
  22189. * Specifies if there should be a separate pass for culling
  22190. */
  22191. separateCullingPass: boolean;
  22192. /**
  22193. * Stores the state specifing if fog should be enabled
  22194. */
  22195. private _fogEnabled;
  22196. /**
  22197. * Sets the state for enabling fog
  22198. */
  22199. /**
  22200. * Gets the value of the fog enabled state
  22201. */
  22202. fogEnabled: boolean;
  22203. /**
  22204. * Stores the size of points
  22205. */
  22206. pointSize: number;
  22207. /**
  22208. * Stores the z offset value
  22209. */
  22210. zOffset: number;
  22211. /**
  22212. * Gets a value specifying if wireframe mode is enabled
  22213. */
  22214. /**
  22215. * Sets the state of wireframe mode
  22216. */
  22217. wireframe: boolean;
  22218. /**
  22219. * Gets the value specifying if point clouds are enabled
  22220. */
  22221. /**
  22222. * Sets the state of point cloud mode
  22223. */
  22224. pointsCloud: boolean;
  22225. /**
  22226. * Gets the material fill mode
  22227. */
  22228. /**
  22229. * Sets the material fill mode
  22230. */
  22231. fillMode: number;
  22232. /**
  22233. * @hidden
  22234. * Stores the effects for the material
  22235. */
  22236. _effect: Nullable<Effect>;
  22237. /**
  22238. * @hidden
  22239. * Specifies if the material was previously ready
  22240. */
  22241. _wasPreviouslyReady: boolean;
  22242. /**
  22243. * Specifies if uniform buffers should be used
  22244. */
  22245. private _useUBO;
  22246. /**
  22247. * Stores a reference to the scene
  22248. */
  22249. private _scene;
  22250. /**
  22251. * Stores the fill mode state
  22252. */
  22253. private _fillMode;
  22254. /**
  22255. * Specifies if the depth write state should be cached
  22256. */
  22257. private _cachedDepthWriteState;
  22258. /**
  22259. * Stores the uniform buffer
  22260. */
  22261. protected _uniformBuffer: UniformBuffer;
  22262. /** @hidden */
  22263. _indexInSceneMaterialArray: number;
  22264. /** @hidden */
  22265. meshMap: Nullable<{
  22266. [id: string]: AbstractMesh | undefined;
  22267. }>;
  22268. /**
  22269. * Creates a material instance
  22270. * @param name defines the name of the material
  22271. * @param scene defines the scene to reference
  22272. * @param doNotAdd specifies if the material should be added to the scene
  22273. */
  22274. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22275. /**
  22276. * Returns a string representation of the current material
  22277. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22278. * @returns a string with material information
  22279. */
  22280. toString(fullDetails?: boolean): string;
  22281. /**
  22282. * Gets the class name of the material
  22283. * @returns a string with the class name of the material
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Specifies if updates for the material been locked
  22288. */
  22289. readonly isFrozen: boolean;
  22290. /**
  22291. * Locks updates for the material
  22292. */
  22293. freeze(): void;
  22294. /**
  22295. * Unlocks updates for the material
  22296. */
  22297. unfreeze(): void;
  22298. /**
  22299. * Specifies if the material is ready to be used
  22300. * @param mesh defines the mesh to check
  22301. * @param useInstances specifies if instances should be used
  22302. * @returns a boolean indicating if the material is ready to be used
  22303. */
  22304. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22305. /**
  22306. * Specifies that the submesh is ready to be used
  22307. * @param mesh defines the mesh to check
  22308. * @param subMesh defines which submesh to check
  22309. * @param useInstances specifies that instances should be used
  22310. * @returns a boolean indicating that the submesh is ready or not
  22311. */
  22312. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22313. /**
  22314. * Returns the material effect
  22315. * @returns the effect associated with the material
  22316. */
  22317. getEffect(): Nullable<Effect>;
  22318. /**
  22319. * Returns the current scene
  22320. * @returns a Scene
  22321. */
  22322. getScene(): Scene;
  22323. /**
  22324. * Specifies if the material will require alpha blending
  22325. * @returns a boolean specifying if alpha blending is needed
  22326. */
  22327. needAlphaBlending(): boolean;
  22328. /**
  22329. * Specifies if the mesh will require alpha blending
  22330. * @param mesh defines the mesh to check
  22331. * @returns a boolean specifying if alpha blending is needed for the mesh
  22332. */
  22333. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22334. /**
  22335. * Specifies if this material should be rendered in alpha test mode
  22336. * @returns a boolean specifying if an alpha test is needed.
  22337. */
  22338. needAlphaTesting(): boolean;
  22339. /**
  22340. * Gets the texture used for the alpha test
  22341. * @returns the texture to use for alpha testing
  22342. */
  22343. getAlphaTestTexture(): Nullable<BaseTexture>;
  22344. /**
  22345. * Marks the material to indicate that it needs to be re-calculated
  22346. */
  22347. markDirty(): void;
  22348. /** @hidden */
  22349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22350. /**
  22351. * Binds the material to the mesh
  22352. * @param world defines the world transformation matrix
  22353. * @param mesh defines the mesh to bind the material to
  22354. */
  22355. bind(world: Matrix, mesh?: Mesh): void;
  22356. /**
  22357. * Binds the submesh to the material
  22358. * @param world defines the world transformation matrix
  22359. * @param mesh defines the mesh containing the submesh
  22360. * @param subMesh defines the submesh to bind the material to
  22361. */
  22362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22363. /**
  22364. * Binds the world matrix to the material
  22365. * @param world defines the world transformation matrix
  22366. */
  22367. bindOnlyWorldMatrix(world: Matrix): void;
  22368. /**
  22369. * Binds the scene's uniform buffer to the effect.
  22370. * @param effect defines the effect to bind to the scene uniform buffer
  22371. * @param sceneUbo defines the uniform buffer storing scene data
  22372. */
  22373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22374. /**
  22375. * Binds the view matrix to the effect
  22376. * @param effect defines the effect to bind the view matrix to
  22377. */
  22378. bindView(effect: Effect): void;
  22379. /**
  22380. * Binds the view projection matrix to the effect
  22381. * @param effect defines the effect to bind the view projection matrix to
  22382. */
  22383. bindViewProjection(effect: Effect): void;
  22384. /**
  22385. * Specifies if material alpha testing should be turned on for the mesh
  22386. * @param mesh defines the mesh to check
  22387. */
  22388. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22389. /**
  22390. * Processes to execute after binding the material to a mesh
  22391. * @param mesh defines the rendered mesh
  22392. */
  22393. protected _afterBind(mesh?: Mesh): void;
  22394. /**
  22395. * Unbinds the material from the mesh
  22396. */
  22397. unbind(): void;
  22398. /**
  22399. * Gets the active textures from the material
  22400. * @returns an array of textures
  22401. */
  22402. getActiveTextures(): BaseTexture[];
  22403. /**
  22404. * Specifies if the material uses a texture
  22405. * @param texture defines the texture to check against the material
  22406. * @returns a boolean specifying if the material uses the texture
  22407. */
  22408. hasTexture(texture: BaseTexture): boolean;
  22409. /**
  22410. * Makes a duplicate of the material, and gives it a new name
  22411. * @param name defines the new name for the duplicated material
  22412. * @returns the cloned material
  22413. */
  22414. clone(name: string): Nullable<Material>;
  22415. /**
  22416. * Gets the meshes bound to the material
  22417. * @returns an array of meshes bound to the material
  22418. */
  22419. getBindedMeshes(): AbstractMesh[];
  22420. /**
  22421. * Force shader compilation
  22422. * @param mesh defines the mesh associated with this material
  22423. * @param onCompiled defines a function to execute once the material is compiled
  22424. * @param options defines the options to configure the compilation
  22425. */
  22426. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22427. clipPlane: boolean;
  22428. }>): void;
  22429. /**
  22430. * Force shader compilation
  22431. * @param mesh defines the mesh that will use this material
  22432. * @param options defines additional options for compiling the shaders
  22433. * @returns a promise that resolves when the compilation completes
  22434. */
  22435. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22436. clipPlane: boolean;
  22437. }>): Promise<void>;
  22438. /**
  22439. * Marks a define in the material to indicate that it needs to be re-computed
  22440. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22441. */
  22442. markAsDirty(flag: number): void;
  22443. /**
  22444. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22445. * @param func defines a function which checks material defines against the submeshes
  22446. */
  22447. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22448. /**
  22449. * Indicates that image processing needs to be re-calculated for all submeshes
  22450. */
  22451. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22452. /**
  22453. * Indicates that textures need to be re-calculated for all submeshes
  22454. */
  22455. protected _markAllSubMeshesAsTexturesDirty(): void;
  22456. /**
  22457. * Indicates that fresnel needs to be re-calculated for all submeshes
  22458. */
  22459. protected _markAllSubMeshesAsFresnelDirty(): void;
  22460. /**
  22461. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22462. */
  22463. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22464. /**
  22465. * Indicates that lights need to be re-calculated for all submeshes
  22466. */
  22467. protected _markAllSubMeshesAsLightsDirty(): void;
  22468. /**
  22469. * Indicates that attributes need to be re-calculated for all submeshes
  22470. */
  22471. protected _markAllSubMeshesAsAttributesDirty(): void;
  22472. /**
  22473. * Indicates that misc needs to be re-calculated for all submeshes
  22474. */
  22475. protected _markAllSubMeshesAsMiscDirty(): void;
  22476. /**
  22477. * Indicates that textures and misc need to be re-calculated for all submeshes
  22478. */
  22479. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22480. /**
  22481. * Disposes the material
  22482. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22483. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22484. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22485. */
  22486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22487. /** @hidden */
  22488. private releaseVertexArrayObject;
  22489. /**
  22490. * Serializes this material
  22491. * @returns the serialized material object
  22492. */
  22493. serialize(): any;
  22494. /**
  22495. * Creates a MultiMaterial from parsed MultiMaterial data.
  22496. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22497. * @param scene defines the hosting scene
  22498. * @returns a new MultiMaterial
  22499. */
  22500. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22501. /**
  22502. * Creates a material from parsed material data
  22503. * @param parsedMaterial defines parsed material data
  22504. * @param scene defines the hosting scene
  22505. * @param rootUrl defines the root URL to use to load textures
  22506. * @returns a new material
  22507. */
  22508. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22509. }
  22510. }
  22511. declare module BABYLON {
  22512. /**
  22513. * "Static Class" containing the most commonly used helper while dealing with material for
  22514. * rendering purpose.
  22515. *
  22516. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  22517. *
  22518. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  22519. */
  22520. class MaterialHelper {
  22521. /**
  22522. * Bind the current view position to an effect.
  22523. * @param effect The effect to be bound
  22524. * @param scene The scene the eyes position is used from
  22525. */
  22526. static BindEyePosition(effect: Effect, scene: Scene): void;
  22527. /**
  22528. * Helps preparing the defines values about the UVs in used in the effect.
  22529. * UVs are shared as much as we can accross channels in the shaders.
  22530. * @param texture The texture we are preparing the UVs for
  22531. * @param defines The defines to update
  22532. * @param key The channel key "diffuse", "specular"... used in the shader
  22533. */
  22534. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  22535. /**
  22536. * Binds a texture matrix value to its corrsponding uniform
  22537. * @param texture The texture to bind the matrix for
  22538. * @param uniformBuffer The uniform buffer receivin the data
  22539. * @param key The channel key "diffuse", "specular"... used in the shader
  22540. */
  22541. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  22542. /**
  22543. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  22544. * @param mesh defines the current mesh
  22545. * @param scene defines the current scene
  22546. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  22547. * @param pointsCloud defines if point cloud rendering has to be turned on
  22548. * @param fogEnabled defines if fog has to be turned on
  22549. * @param alphaTest defines if alpha testing has to be turned on
  22550. * @param defines defines the current list of defines
  22551. */
  22552. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  22553. /**
  22554. * Helper used to prepare the list of defines associated with frame values for shader compilation
  22555. * @param scene defines the current scene
  22556. * @param engine defines the current engine
  22557. * @param defines specifies the list of active defines
  22558. * @param useInstances defines if instances have to be turned on
  22559. * @param useClipPlane defines if clip plane have to be turned on
  22560. */
  22561. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  22562. /**
  22563. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  22564. * @param mesh The mesh containing the geometry data we will draw
  22565. * @param defines The defines to update
  22566. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  22567. * @param useBones Precise whether bones should be used or not (override mesh info)
  22568. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  22569. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  22570. * @returns false if defines are considered not dirty and have not been checked
  22571. */
  22572. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  22573. /**
  22574. * Prepares the defines related to the light information passed in parameter
  22575. * @param scene The scene we are intending to draw
  22576. * @param mesh The mesh the effect is compiling for
  22577. * @param defines The defines to update
  22578. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  22579. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  22580. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  22581. * @returns true if normals will be required for the rest of the effect
  22582. */
  22583. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  22584. /**
  22585. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  22586. * that won t be acctive due to defines being turned off.
  22587. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  22588. * @param samplersList The samplers list
  22589. * @param defines The defines helping in the list generation
  22590. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  22591. */
  22592. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  22593. /**
  22594. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  22595. * @param defines The defines to update while falling back
  22596. * @param fallbacks The authorized effect fallbacks
  22597. * @param maxSimultaneousLights The maximum number of lights allowed
  22598. * @param rank the current rank of the Effect
  22599. * @returns The newly affected rank
  22600. */
  22601. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  22602. /**
  22603. * Prepares the list of attributes required for morph targets according to the effect defines.
  22604. * @param attribs The current list of supported attribs
  22605. * @param mesh The mesh to prepare the morph targets attributes for
  22606. * @param defines The current Defines of the effect
  22607. */
  22608. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  22609. /**
  22610. * Prepares the list of attributes required for bones according to the effect defines.
  22611. * @param attribs The current list of supported attribs
  22612. * @param mesh The mesh to prepare the bones attributes for
  22613. * @param defines The current Defines of the effect
  22614. * @param fallbacks The current efffect fallback strategy
  22615. */
  22616. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  22617. /**
  22618. * Prepares the list of attributes required for instances according to the effect defines.
  22619. * @param attribs The current list of supported attribs
  22620. * @param defines The current Defines of the effect
  22621. */
  22622. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  22623. /**
  22624. * Binds the light shadow information to the effect for the given mesh.
  22625. * @param light The light containing the generator
  22626. * @param scene The scene the lights belongs to
  22627. * @param mesh The mesh we are binding the information to render
  22628. * @param lightIndex The light index in the effect used to render the mesh
  22629. * @param effect The effect we are binding the data to
  22630. */
  22631. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  22632. /**
  22633. * Binds the light information to the effect.
  22634. * @param light The light containing the generator
  22635. * @param effect The effect we are binding the data to
  22636. * @param lightIndex The light index in the effect used to render
  22637. */
  22638. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  22639. /**
  22640. * Binds the lights information from the scene to the effect for the given mesh.
  22641. * @param scene The scene the lights belongs to
  22642. * @param mesh The mesh we are binding the information to render
  22643. * @param effect The effect we are binding the data to
  22644. * @param defines The generated defines for the effect
  22645. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  22646. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  22647. */
  22648. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  22649. private static _tempFogColor;
  22650. /**
  22651. * Binds the fog information from the scene to the effect for the given mesh.
  22652. * @param scene The scene the lights belongs to
  22653. * @param mesh The mesh we are binding the information to render
  22654. * @param effect The effect we are binding the data to
  22655. * @param linearSpace Defines if the fog effect is applied in linear space
  22656. */
  22657. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  22658. /**
  22659. * Binds the bones information from the mesh to the effect.
  22660. * @param mesh The mesh we are binding the information to render
  22661. * @param effect The effect we are binding the data to
  22662. */
  22663. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  22664. /**
  22665. * Binds the morph targets information from the mesh to the effect.
  22666. * @param abstractMesh The mesh we are binding the information to render
  22667. * @param effect The effect we are binding the data to
  22668. */
  22669. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  22670. /**
  22671. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  22672. * @param defines The generated defines used in the effect
  22673. * @param effect The effect we are binding the data to
  22674. * @param scene The scene we are willing to render with logarithmic scale for
  22675. */
  22676. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  22677. /**
  22678. * Binds the clip plane information from the scene to the effect.
  22679. * @param scene The scene the clip plane information are extracted from
  22680. * @param effect The effect we are binding the data to
  22681. */
  22682. static BindClipPlane(effect: Effect, scene: Scene): void;
  22683. }
  22684. }
  22685. declare module BABYLON {
  22686. /**
  22687. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22688. * separate meshes. This can be use to improve performances.
  22689. * @see http://doc.babylonjs.com/how_to/multi_materials
  22690. */
  22691. class MultiMaterial extends Material {
  22692. private _subMaterials;
  22693. /**
  22694. * Gets or Sets the list of Materials used within the multi material.
  22695. * They need to be ordered according to the submeshes order in the associated mesh
  22696. */
  22697. subMaterials: Nullable<Material>[];
  22698. /**
  22699. * Instantiates a new Multi Material
  22700. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22701. * separate meshes. This can be use to improve performances.
  22702. * @see http://doc.babylonjs.com/how_to/multi_materials
  22703. * @param name Define the name in the scene
  22704. * @param scene Define the scene the material belongs to
  22705. */
  22706. constructor(name: string, scene: Scene);
  22707. private _hookArray;
  22708. /**
  22709. * Get one of the submaterial by its index in the submaterials array
  22710. * @param index The index to look the sub material at
  22711. * @returns The Material if the index has been defined
  22712. */
  22713. getSubMaterial(index: number): Nullable<Material>;
  22714. /**
  22715. * Get the list of active textures for the whole sub materials list.
  22716. * @returns All the textures that will be used during the rendering
  22717. */
  22718. getActiveTextures(): BaseTexture[];
  22719. /**
  22720. * Gets the current class name of the material e.g. "MultiMaterial"
  22721. * Mainly use in serialization.
  22722. * @returns the class name
  22723. */
  22724. getClassName(): string;
  22725. /**
  22726. * Checks if the material is ready to render the requested sub mesh
  22727. * @param mesh Define the mesh the submesh belongs to
  22728. * @param subMesh Define the sub mesh to look readyness for
  22729. * @param useInstances Define whether or not the material is used with instances
  22730. * @returns true if ready, otherwise false
  22731. */
  22732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22733. /**
  22734. * Clones the current material and its related sub materials
  22735. * @param name Define the name of the newly cloned material
  22736. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22737. * @returns the cloned material
  22738. */
  22739. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22740. /**
  22741. * Serializes the materials into a JSON representation.
  22742. * @returns the JSON representation
  22743. */
  22744. serialize(): any;
  22745. /**
  22746. * Dispose the material and release its associated resources
  22747. * @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)
  22748. * @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)
  22749. */
  22750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22751. }
  22752. }
  22753. declare module BABYLON {
  22754. /**
  22755. * Base class of materials working in push mode in babylon JS
  22756. * @hidden
  22757. */
  22758. class PushMaterial extends Material {
  22759. protected _activeEffect: Effect;
  22760. protected _normalMatrix: Matrix;
  22761. /**
  22762. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  22763. * This means that the material can keep using a previous shader while a new one is being compiled.
  22764. * This is mostly used when shader parallel compilation is supported (true by default)
  22765. */
  22766. allowShaderHotSwapping: boolean;
  22767. constructor(name: string, scene: Scene);
  22768. getEffect(): Effect;
  22769. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22770. /**
  22771. * Binds the given world matrix to the active effect
  22772. *
  22773. * @param world the matrix to bind
  22774. */
  22775. bindOnlyWorldMatrix(world: Matrix): void;
  22776. /**
  22777. * Binds the given normal matrix to the active effect
  22778. *
  22779. * @param normalMatrix the matrix to bind
  22780. */
  22781. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22782. bind(world: Matrix, mesh?: Mesh): void;
  22783. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22784. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22785. }
  22786. }
  22787. declare module BABYLON {
  22788. /**
  22789. * Defines the options associated with the creation of a shader material.
  22790. */
  22791. interface IShaderMaterialOptions {
  22792. /**
  22793. * Does the material work in alpha blend mode
  22794. */
  22795. needAlphaBlending: boolean;
  22796. /**
  22797. * Does the material work in alpha test mode
  22798. */
  22799. needAlphaTesting: boolean;
  22800. /**
  22801. * The list of attribute names used in the shader
  22802. */
  22803. attributes: string[];
  22804. /**
  22805. * The list of unifrom names used in the shader
  22806. */
  22807. uniforms: string[];
  22808. /**
  22809. * The list of UBO names used in the shader
  22810. */
  22811. uniformBuffers: string[];
  22812. /**
  22813. * The list of sampler names used in the shader
  22814. */
  22815. samplers: string[];
  22816. /**
  22817. * The list of defines used in the shader
  22818. */
  22819. defines: string[];
  22820. }
  22821. /**
  22822. * 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.
  22823. *
  22824. * This returned material effects how the mesh will look based on the code in the shaders.
  22825. *
  22826. * @see http://doc.babylonjs.com/how_to/shader_material
  22827. */
  22828. class ShaderMaterial extends Material {
  22829. private _shaderPath;
  22830. private _options;
  22831. private _textures;
  22832. private _textureArrays;
  22833. private _floats;
  22834. private _ints;
  22835. private _floatsArrays;
  22836. private _colors3;
  22837. private _colors3Arrays;
  22838. private _colors4;
  22839. private _vectors2;
  22840. private _vectors3;
  22841. private _vectors4;
  22842. private _matrices;
  22843. private _matrices3x3;
  22844. private _matrices2x2;
  22845. private _vectors2Arrays;
  22846. private _vectors3Arrays;
  22847. private _cachedWorldViewMatrix;
  22848. private _renderId;
  22849. /**
  22850. * Instantiate a new shader material.
  22851. * 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.
  22852. * This returned material effects how the mesh will look based on the code in the shaders.
  22853. * @see http://doc.babylonjs.com/how_to/shader_material
  22854. * @param name Define the name of the material in the scene
  22855. * @param scene Define the scene the material belongs to
  22856. * @param shaderPath Defines the route to the shader code in one of three ways:
  22857. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  22858. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  22859. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  22860. * @param options Define the options used to create the shader
  22861. */
  22862. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  22863. /**
  22864. * Gets the current class name of the material e.g. "ShaderMaterial"
  22865. * Mainly use in serialization.
  22866. * @returns the class name
  22867. */
  22868. getClassName(): string;
  22869. /**
  22870. * Specifies if the material will require alpha blending
  22871. * @returns a boolean specifying if alpha blending is needed
  22872. */
  22873. needAlphaBlending(): boolean;
  22874. /**
  22875. * Specifies if this material should be rendered in alpha test mode
  22876. * @returns a boolean specifying if an alpha test is needed.
  22877. */
  22878. needAlphaTesting(): boolean;
  22879. private _checkUniform;
  22880. /**
  22881. * Set a texture in the shader.
  22882. * @param name Define the name of the uniform samplers as defined in the shader
  22883. * @param texture Define the texture to bind to this sampler
  22884. * @return the material itself allowing "fluent" like uniform updates
  22885. */
  22886. setTexture(name: string, texture: Texture): ShaderMaterial;
  22887. /**
  22888. * Set a texture array in the shader.
  22889. * @param name Define the name of the uniform sampler array as defined in the shader
  22890. * @param textures Define the list of textures to bind to this sampler
  22891. * @return the material itself allowing "fluent" like uniform updates
  22892. */
  22893. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  22894. /**
  22895. * Set a float in the shader.
  22896. * @param name Define the name of the uniform as defined in the shader
  22897. * @param value Define the value to give to the uniform
  22898. * @return the material itself allowing "fluent" like uniform updates
  22899. */
  22900. setFloat(name: string, value: number): ShaderMaterial;
  22901. /**
  22902. * Set a int in the shader.
  22903. * @param name Define the name of the uniform as defined in the shader
  22904. * @param value Define the value to give to the uniform
  22905. * @return the material itself allowing "fluent" like uniform updates
  22906. */
  22907. setInt(name: string, value: number): ShaderMaterial;
  22908. /**
  22909. * Set an array of floats in the shader.
  22910. * @param name Define the name of the uniform as defined in the shader
  22911. * @param value Define the value to give to the uniform
  22912. * @return the material itself allowing "fluent" like uniform updates
  22913. */
  22914. setFloats(name: string, value: number[]): ShaderMaterial;
  22915. /**
  22916. * Set a vec3 in the shader from a Color3.
  22917. * @param name Define the name of the uniform as defined in the shader
  22918. * @param value Define the value to give to the uniform
  22919. * @return the material itself allowing "fluent" like uniform updates
  22920. */
  22921. setColor3(name: string, value: Color3): ShaderMaterial;
  22922. /**
  22923. * Set a vec3 array in the shader from a Color3 array.
  22924. * @param name Define the name of the uniform as defined in the shader
  22925. * @param value Define the value to give to the uniform
  22926. * @return the material itself allowing "fluent" like uniform updates
  22927. */
  22928. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  22929. /**
  22930. * Set a vec4 in the shader from a Color4.
  22931. * @param name Define the name of the uniform as defined in the shader
  22932. * @param value Define the value to give to the uniform
  22933. * @return the material itself allowing "fluent" like uniform updates
  22934. */
  22935. setColor4(name: string, value: Color4): ShaderMaterial;
  22936. /**
  22937. * Set a vec2 in the shader from a Vector2.
  22938. * @param name Define the name of the uniform as defined in the shader
  22939. * @param value Define the value to give to the uniform
  22940. * @return the material itself allowing "fluent" like uniform updates
  22941. */
  22942. setVector2(name: string, value: Vector2): ShaderMaterial;
  22943. /**
  22944. * Set a vec3 in the shader from a Vector3.
  22945. * @param name Define the name of the uniform as defined in the shader
  22946. * @param value Define the value to give to the uniform
  22947. * @return the material itself allowing "fluent" like uniform updates
  22948. */
  22949. setVector3(name: string, value: Vector3): ShaderMaterial;
  22950. /**
  22951. * Set a vec4 in the shader from a Vector4.
  22952. * @param name Define the name of the uniform as defined in the shader
  22953. * @param value Define the value to give to the uniform
  22954. * @return the material itself allowing "fluent" like uniform updates
  22955. */
  22956. setVector4(name: string, value: Vector4): ShaderMaterial;
  22957. /**
  22958. * Set a mat4 in the shader from a Matrix.
  22959. * @param name Define the name of the uniform as defined in the shader
  22960. * @param value Define the value to give to the uniform
  22961. * @return the material itself allowing "fluent" like uniform updates
  22962. */
  22963. setMatrix(name: string, value: Matrix): ShaderMaterial;
  22964. /**
  22965. * Set a mat3 in the shader from a Float32Array.
  22966. * @param name Define the name of the uniform as defined in the shader
  22967. * @param value Define the value to give to the uniform
  22968. * @return the material itself allowing "fluent" like uniform updates
  22969. */
  22970. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  22971. /**
  22972. * Set a mat2 in the shader from a Float32Array.
  22973. * @param name Define the name of the uniform as defined in the shader
  22974. * @param value Define the value to give to the uniform
  22975. * @return the material itself allowing "fluent" like uniform updates
  22976. */
  22977. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  22978. /**
  22979. * Set a vec2 array in the shader from a number array.
  22980. * @param name Define the name of the uniform as defined in the shader
  22981. * @param value Define the value to give to the uniform
  22982. * @return the material itself allowing "fluent" like uniform updates
  22983. */
  22984. setArray2(name: string, value: number[]): ShaderMaterial;
  22985. /**
  22986. * Set a vec3 array in the shader from a number array.
  22987. * @param name Define the name of the uniform as defined in the shader
  22988. * @param value Define the value to give to the uniform
  22989. * @return the material itself allowing "fluent" like uniform updates
  22990. */
  22991. setArray3(name: string, value: number[]): ShaderMaterial;
  22992. private _checkCache;
  22993. /**
  22994. * Checks if the material is ready to render the requested mesh
  22995. * @param mesh Define the mesh to render
  22996. * @param useInstances Define whether or not the material is used with instances
  22997. * @returns true if ready, otherwise false
  22998. */
  22999. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23000. /**
  23001. * Binds the world matrix to the material
  23002. * @param world defines the world transformation matrix
  23003. */
  23004. bindOnlyWorldMatrix(world: Matrix): void;
  23005. /**
  23006. * Binds the material to the mesh
  23007. * @param world defines the world transformation matrix
  23008. * @param mesh defines the mesh to bind the material to
  23009. */
  23010. bind(world: Matrix, mesh?: Mesh): void;
  23011. /**
  23012. * Gets the active textures from the material
  23013. * @returns an array of textures
  23014. */
  23015. getActiveTextures(): BaseTexture[];
  23016. /**
  23017. * Specifies if the material uses a texture
  23018. * @param texture defines the texture to check against the material
  23019. * @returns a boolean specifying if the material uses the texture
  23020. */
  23021. hasTexture(texture: BaseTexture): boolean;
  23022. /**
  23023. * Makes a duplicate of the material, and gives it a new name
  23024. * @param name defines the new name for the duplicated material
  23025. * @returns the cloned material
  23026. */
  23027. clone(name: string): ShaderMaterial;
  23028. /**
  23029. * Disposes the material
  23030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23032. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23033. */
  23034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23035. /**
  23036. * Serializes this material in a JSON representation
  23037. * @returns the serialized material object
  23038. */
  23039. serialize(): any;
  23040. /**
  23041. * Creates a shader material from parsed shader material data
  23042. * @param source defines the JSON represnetation of the material
  23043. * @param scene defines the hosting scene
  23044. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23045. * @returns a new material
  23046. */
  23047. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  23048. }
  23049. }
  23050. declare module BABYLON {
  23051. /** @hidden */
  23052. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23053. MAINUV1: boolean;
  23054. MAINUV2: boolean;
  23055. DIFFUSE: boolean;
  23056. DIFFUSEDIRECTUV: number;
  23057. AMBIENT: boolean;
  23058. AMBIENTDIRECTUV: number;
  23059. OPACITY: boolean;
  23060. OPACITYDIRECTUV: number;
  23061. OPACITYRGB: boolean;
  23062. REFLECTION: boolean;
  23063. EMISSIVE: boolean;
  23064. EMISSIVEDIRECTUV: number;
  23065. SPECULAR: boolean;
  23066. SPECULARDIRECTUV: number;
  23067. BUMP: boolean;
  23068. BUMPDIRECTUV: number;
  23069. PARALLAX: boolean;
  23070. PARALLAXOCCLUSION: boolean;
  23071. SPECULAROVERALPHA: boolean;
  23072. CLIPPLANE: boolean;
  23073. CLIPPLANE2: boolean;
  23074. CLIPPLANE3: boolean;
  23075. CLIPPLANE4: boolean;
  23076. ALPHATEST: boolean;
  23077. DEPTHPREPASS: boolean;
  23078. ALPHAFROMDIFFUSE: boolean;
  23079. POINTSIZE: boolean;
  23080. FOG: boolean;
  23081. SPECULARTERM: boolean;
  23082. DIFFUSEFRESNEL: boolean;
  23083. OPACITYFRESNEL: boolean;
  23084. REFLECTIONFRESNEL: boolean;
  23085. REFRACTIONFRESNEL: boolean;
  23086. EMISSIVEFRESNEL: boolean;
  23087. FRESNEL: boolean;
  23088. NORMAL: boolean;
  23089. UV1: boolean;
  23090. UV2: boolean;
  23091. VERTEXCOLOR: boolean;
  23092. VERTEXALPHA: boolean;
  23093. NUM_BONE_INFLUENCERS: number;
  23094. BonesPerMesh: number;
  23095. INSTANCES: boolean;
  23096. GLOSSINESS: boolean;
  23097. ROUGHNESS: boolean;
  23098. EMISSIVEASILLUMINATION: boolean;
  23099. LINKEMISSIVEWITHDIFFUSE: boolean;
  23100. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23101. LIGHTMAP: boolean;
  23102. LIGHTMAPDIRECTUV: number;
  23103. OBJECTSPACE_NORMALMAP: boolean;
  23104. USELIGHTMAPASSHADOWMAP: boolean;
  23105. REFLECTIONMAP_3D: boolean;
  23106. REFLECTIONMAP_SPHERICAL: boolean;
  23107. REFLECTIONMAP_PLANAR: boolean;
  23108. REFLECTIONMAP_CUBIC: boolean;
  23109. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23110. REFLECTIONMAP_PROJECTION: boolean;
  23111. REFLECTIONMAP_SKYBOX: boolean;
  23112. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  23113. REFLECTIONMAP_EXPLICIT: boolean;
  23114. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23115. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23116. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23117. INVERTCUBICMAP: boolean;
  23118. LOGARITHMICDEPTH: boolean;
  23119. REFRACTION: boolean;
  23120. REFRACTIONMAP_3D: boolean;
  23121. REFLECTIONOVERALPHA: boolean;
  23122. TWOSIDEDLIGHTING: boolean;
  23123. SHADOWFLOAT: boolean;
  23124. MORPHTARGETS: boolean;
  23125. MORPHTARGETS_NORMAL: boolean;
  23126. MORPHTARGETS_TANGENT: boolean;
  23127. NUM_MORPH_INFLUENCERS: number;
  23128. NONUNIFORMSCALING: boolean;
  23129. PREMULTIPLYALPHA: boolean;
  23130. IMAGEPROCESSING: boolean;
  23131. VIGNETTE: boolean;
  23132. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23133. VIGNETTEBLENDMODEOPAQUE: boolean;
  23134. TONEMAPPING: boolean;
  23135. TONEMAPPING_ACES: boolean;
  23136. CONTRAST: boolean;
  23137. COLORCURVES: boolean;
  23138. COLORGRADING: boolean;
  23139. COLORGRADING3D: boolean;
  23140. SAMPLER3DGREENDEPTH: boolean;
  23141. SAMPLER3DBGRMAP: boolean;
  23142. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23143. /**
  23144. * If the reflection texture on this material is in linear color space
  23145. * @hidden
  23146. */
  23147. IS_REFLECTION_LINEAR: boolean;
  23148. /**
  23149. * If the refraction texture on this material is in linear color space
  23150. * @hidden
  23151. */
  23152. IS_REFRACTION_LINEAR: boolean;
  23153. EXPOSURE: boolean;
  23154. constructor();
  23155. setReflectionMode(modeToEnable: string): void;
  23156. }
  23157. /**
  23158. * This is the default material used in Babylon. It is the best trade off between quality
  23159. * and performances.
  23160. * @see http://doc.babylonjs.com/babylon101/materials
  23161. */
  23162. class StandardMaterial extends PushMaterial {
  23163. private _diffuseTexture;
  23164. /**
  23165. * The basic texture of the material as viewed under a light.
  23166. */
  23167. diffuseTexture: Nullable<BaseTexture>;
  23168. private _ambientTexture;
  23169. /**
  23170. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23171. */
  23172. ambientTexture: Nullable<BaseTexture>;
  23173. private _opacityTexture;
  23174. /**
  23175. * Define the transparency of the material from a texture.
  23176. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23177. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23178. */
  23179. opacityTexture: Nullable<BaseTexture>;
  23180. private _reflectionTexture;
  23181. /**
  23182. * Define the texture used to display the reflection.
  23183. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23184. */
  23185. reflectionTexture: Nullable<BaseTexture>;
  23186. private _emissiveTexture;
  23187. /**
  23188. * Define texture of the material as if self lit.
  23189. * This will be mixed in the final result even in the absence of light.
  23190. */
  23191. emissiveTexture: Nullable<BaseTexture>;
  23192. private _specularTexture;
  23193. /**
  23194. * Define how the color and intensity of the highlight given by the light in the material.
  23195. */
  23196. specularTexture: Nullable<BaseTexture>;
  23197. private _bumpTexture;
  23198. /**
  23199. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23200. * 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.
  23201. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  23202. */
  23203. bumpTexture: Nullable<BaseTexture>;
  23204. private _lightmapTexture;
  23205. /**
  23206. * Complex lighting can be computationally expensive to compute at runtime.
  23207. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23208. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  23209. */
  23210. lightmapTexture: Nullable<BaseTexture>;
  23211. private _refractionTexture;
  23212. /**
  23213. * Define the texture used to display the refraction.
  23214. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23215. */
  23216. refractionTexture: Nullable<BaseTexture>;
  23217. /**
  23218. * The color of the material lit by the environmental background lighting.
  23219. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23220. */
  23221. ambientColor: Color3;
  23222. /**
  23223. * The basic color of the material as viewed under a light.
  23224. */
  23225. diffuseColor: Color3;
  23226. /**
  23227. * Define how the color and intensity of the highlight given by the light in the material.
  23228. */
  23229. specularColor: Color3;
  23230. /**
  23231. * Define the color of the material as if self lit.
  23232. * This will be mixed in the final result even in the absence of light.
  23233. */
  23234. emissiveColor: Color3;
  23235. /**
  23236. * Defines how sharp are the highlights in the material.
  23237. * The bigger the value the sharper giving a more glossy feeling to the result.
  23238. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  23239. */
  23240. specularPower: number;
  23241. private _useAlphaFromDiffuseTexture;
  23242. /**
  23243. * Does the transparency come from the diffuse texture alpha channel.
  23244. */
  23245. useAlphaFromDiffuseTexture: boolean;
  23246. private _useEmissiveAsIllumination;
  23247. /**
  23248. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  23249. */
  23250. useEmissiveAsIllumination: boolean;
  23251. private _linkEmissiveWithDiffuse;
  23252. /**
  23253. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  23254. * the emissive level when the final color is close to one.
  23255. */
  23256. linkEmissiveWithDiffuse: boolean;
  23257. private _useSpecularOverAlpha;
  23258. /**
  23259. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  23260. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  23261. */
  23262. useSpecularOverAlpha: boolean;
  23263. private _useReflectionOverAlpha;
  23264. /**
  23265. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  23266. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  23267. */
  23268. useReflectionOverAlpha: boolean;
  23269. private _disableLighting;
  23270. /**
  23271. * Does lights from the scene impacts this material.
  23272. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  23273. */
  23274. disableLighting: boolean;
  23275. private _useObjectSpaceNormalMap;
  23276. /**
  23277. * Allows using an object space normal map (instead of tangent space).
  23278. */
  23279. useObjectSpaceNormalMap: boolean;
  23280. private _useParallax;
  23281. /**
  23282. * Is parallax enabled or not.
  23283. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23284. */
  23285. useParallax: boolean;
  23286. private _useParallaxOcclusion;
  23287. /**
  23288. * Is parallax occlusion enabled or not.
  23289. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  23290. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  23291. */
  23292. useParallaxOcclusion: boolean;
  23293. /**
  23294. * 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.
  23295. */
  23296. parallaxScaleBias: number;
  23297. private _roughness;
  23298. /**
  23299. * Helps to define how blurry the reflections should appears in the material.
  23300. */
  23301. roughness: number;
  23302. /**
  23303. * In case of refraction, define the value of the indice of refraction.
  23304. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23305. */
  23306. indexOfRefraction: number;
  23307. /**
  23308. * Invert the refraction texture alongside the y axis.
  23309. * It can be usefull with procedural textures or probe for instance.
  23310. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23311. */
  23312. invertRefractionY: boolean;
  23313. /**
  23314. * Defines the alpha limits in alpha test mode.
  23315. */
  23316. alphaCutOff: number;
  23317. private _useLightmapAsShadowmap;
  23318. /**
  23319. * In case of light mapping, define whether the map contains light or shadow informations.
  23320. */
  23321. useLightmapAsShadowmap: boolean;
  23322. private _diffuseFresnelParameters;
  23323. /**
  23324. * Define the diffuse fresnel parameters of the material.
  23325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23326. */
  23327. diffuseFresnelParameters: FresnelParameters;
  23328. private _opacityFresnelParameters;
  23329. /**
  23330. * Define the opacity fresnel parameters of the material.
  23331. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23332. */
  23333. opacityFresnelParameters: FresnelParameters;
  23334. private _reflectionFresnelParameters;
  23335. /**
  23336. * Define the reflection fresnel parameters of the material.
  23337. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23338. */
  23339. reflectionFresnelParameters: FresnelParameters;
  23340. private _refractionFresnelParameters;
  23341. /**
  23342. * Define the refraction fresnel parameters of the material.
  23343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23344. */
  23345. refractionFresnelParameters: FresnelParameters;
  23346. private _emissiveFresnelParameters;
  23347. /**
  23348. * Define the emissive fresnel parameters of the material.
  23349. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23350. */
  23351. emissiveFresnelParameters: FresnelParameters;
  23352. private _useReflectionFresnelFromSpecular;
  23353. /**
  23354. * If true automatically deducts the fresnels values from the material specularity.
  23355. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23356. */
  23357. useReflectionFresnelFromSpecular: boolean;
  23358. private _useGlossinessFromSpecularMapAlpha;
  23359. /**
  23360. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  23361. */
  23362. useGlossinessFromSpecularMapAlpha: boolean;
  23363. private _maxSimultaneousLights;
  23364. /**
  23365. * Defines the maximum number of lights that can be used in the material
  23366. */
  23367. maxSimultaneousLights: number;
  23368. private _invertNormalMapX;
  23369. /**
  23370. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  23371. */
  23372. invertNormalMapX: boolean;
  23373. private _invertNormalMapY;
  23374. /**
  23375. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  23376. */
  23377. invertNormalMapY: boolean;
  23378. private _twoSidedLighting;
  23379. /**
  23380. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  23381. */
  23382. twoSidedLighting: boolean;
  23383. /**
  23384. * Default configuration related to image processing available in the standard Material.
  23385. */
  23386. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23387. /**
  23388. * Gets the image processing configuration used either in this material.
  23389. */
  23390. /**
  23391. * Sets the Default image processing configuration used either in the this material.
  23392. *
  23393. * If sets to null, the scene one is in use.
  23394. */
  23395. imageProcessingConfiguration: ImageProcessingConfiguration;
  23396. /**
  23397. * Keep track of the image processing observer to allow dispose and replace.
  23398. */
  23399. private _imageProcessingObserver;
  23400. /**
  23401. * Attaches a new image processing configuration to the Standard Material.
  23402. * @param configuration
  23403. */
  23404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23405. /**
  23406. * Gets wether the color curves effect is enabled.
  23407. */
  23408. /**
  23409. * Sets wether the color curves effect is enabled.
  23410. */
  23411. cameraColorCurvesEnabled: boolean;
  23412. /**
  23413. * Gets wether the color grading effect is enabled.
  23414. */
  23415. /**
  23416. * Gets wether the color grading effect is enabled.
  23417. */
  23418. cameraColorGradingEnabled: boolean;
  23419. /**
  23420. * Gets wether tonemapping is enabled or not.
  23421. */
  23422. /**
  23423. * Sets wether tonemapping is enabled or not
  23424. */
  23425. cameraToneMappingEnabled: boolean;
  23426. /**
  23427. * The camera exposure used on this material.
  23428. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23429. * This corresponds to a photographic exposure.
  23430. */
  23431. /**
  23432. * The camera exposure used on this material.
  23433. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  23434. * This corresponds to a photographic exposure.
  23435. */
  23436. cameraExposure: number;
  23437. /**
  23438. * Gets The camera contrast used on this material.
  23439. */
  23440. /**
  23441. * Sets The camera contrast used on this material.
  23442. */
  23443. cameraContrast: number;
  23444. /**
  23445. * Gets the Color Grading 2D Lookup Texture.
  23446. */
  23447. /**
  23448. * Sets the Color Grading 2D Lookup Texture.
  23449. */
  23450. cameraColorGradingTexture: Nullable<BaseTexture>;
  23451. /**
  23452. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23453. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23454. * 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;
  23455. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23456. */
  23457. /**
  23458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  23459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  23460. * 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;
  23461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  23462. */
  23463. cameraColorCurves: Nullable<ColorCurves>;
  23464. /**
  23465. * Custom callback helping to override the default shader used in the material.
  23466. */
  23467. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  23468. protected _renderTargets: SmartArray<RenderTargetTexture>;
  23469. protected _worldViewProjectionMatrix: Matrix;
  23470. protected _globalAmbientColor: Color3;
  23471. protected _useLogarithmicDepth: boolean;
  23472. /**
  23473. * Instantiates a new standard material.
  23474. * This is the default material used in Babylon. It is the best trade off between quality
  23475. * and performances.
  23476. * @see http://doc.babylonjs.com/babylon101/materials
  23477. * @param name Define the name of the material in the scene
  23478. * @param scene Define the scene the material belong to
  23479. */
  23480. constructor(name: string, scene: Scene);
  23481. /**
  23482. * Gets a boolean indicating that current material needs to register RTT
  23483. */
  23484. readonly hasRenderTargetTextures: boolean;
  23485. /**
  23486. * Gets the current class name of the material e.g. "StandardMaterial"
  23487. * Mainly use in serialization.
  23488. * @returns the class name
  23489. */
  23490. getClassName(): string;
  23491. /**
  23492. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  23493. * You can try switching to logarithmic depth.
  23494. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  23495. */
  23496. useLogarithmicDepth: boolean;
  23497. /**
  23498. * Specifies if the material will require alpha blending
  23499. * @returns a boolean specifying if alpha blending is needed
  23500. */
  23501. needAlphaBlending(): boolean;
  23502. /**
  23503. * Specifies if this material should be rendered in alpha test mode
  23504. * @returns a boolean specifying if an alpha test is needed.
  23505. */
  23506. needAlphaTesting(): boolean;
  23507. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  23508. /**
  23509. * Get the texture used for alpha test purpose.
  23510. * @returns the diffuse texture in case of the standard material.
  23511. */
  23512. getAlphaTestTexture(): Nullable<BaseTexture>;
  23513. /**
  23514. * Get if the submesh is ready to be used and all its information available.
  23515. * Child classes can use it to update shaders
  23516. * @param mesh defines the mesh to check
  23517. * @param subMesh defines which submesh to check
  23518. * @param useInstances specifies that instances should be used
  23519. * @returns a boolean indicating that the submesh is ready or not
  23520. */
  23521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23522. /**
  23523. * Builds the material UBO layouts.
  23524. * Used internally during the effect preparation.
  23525. */
  23526. buildUniformLayout(): void;
  23527. /**
  23528. * Unbinds the material from the mesh
  23529. */
  23530. unbind(): void;
  23531. /**
  23532. * Binds the submesh to this material by preparing the effect and shader to draw
  23533. * @param world defines the world transformation matrix
  23534. * @param mesh defines the mesh containing the submesh
  23535. * @param subMesh defines the submesh to bind the material to
  23536. */
  23537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23538. /**
  23539. * Get the list of animatables in the material.
  23540. * @returns the list of animatables object used in the material
  23541. */
  23542. getAnimatables(): IAnimatable[];
  23543. /**
  23544. * Gets the active textures from the material
  23545. * @returns an array of textures
  23546. */
  23547. getActiveTextures(): BaseTexture[];
  23548. /**
  23549. * Specifies if the material uses a texture
  23550. * @param texture defines the texture to check against the material
  23551. * @returns a boolean specifying if the material uses the texture
  23552. */
  23553. hasTexture(texture: BaseTexture): boolean;
  23554. /**
  23555. * Disposes the material
  23556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23558. */
  23559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  23560. /**
  23561. * Makes a duplicate of the material, and gives it a new name
  23562. * @param name defines the new name for the duplicated material
  23563. * @returns the cloned material
  23564. */
  23565. clone(name: string): StandardMaterial;
  23566. /**
  23567. * Serializes this material in a JSON representation
  23568. * @returns the serialized material object
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * Creates a standard material from parsed material data
  23573. * @param source defines the JSON represnetation of the material
  23574. * @param scene defines the hosting scene
  23575. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23576. * @returns a new material
  23577. */
  23578. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  23579. private static _DiffuseTextureEnabled;
  23580. /**
  23581. * Are diffuse textures enabled in the application.
  23582. */
  23583. static DiffuseTextureEnabled: boolean;
  23584. private static _AmbientTextureEnabled;
  23585. /**
  23586. * Are ambient textures enabled in the application.
  23587. */
  23588. static AmbientTextureEnabled: boolean;
  23589. private static _OpacityTextureEnabled;
  23590. /**
  23591. * Are opacity textures enabled in the application.
  23592. */
  23593. static OpacityTextureEnabled: boolean;
  23594. private static _ReflectionTextureEnabled;
  23595. /**
  23596. * Are reflection textures enabled in the application.
  23597. */
  23598. static ReflectionTextureEnabled: boolean;
  23599. private static _EmissiveTextureEnabled;
  23600. /**
  23601. * Are emissive textures enabled in the application.
  23602. */
  23603. static EmissiveTextureEnabled: boolean;
  23604. private static _SpecularTextureEnabled;
  23605. /**
  23606. * Are specular textures enabled in the application.
  23607. */
  23608. static SpecularTextureEnabled: boolean;
  23609. private static _BumpTextureEnabled;
  23610. /**
  23611. * Are bump textures enabled in the application.
  23612. */
  23613. static BumpTextureEnabled: boolean;
  23614. private static _LightmapTextureEnabled;
  23615. /**
  23616. * Are lightmap textures enabled in the application.
  23617. */
  23618. static LightmapTextureEnabled: boolean;
  23619. private static _RefractionTextureEnabled;
  23620. /**
  23621. * Are refraction textures enabled in the application.
  23622. */
  23623. static RefractionTextureEnabled: boolean;
  23624. private static _ColorGradingTextureEnabled;
  23625. /**
  23626. * Are color grading textures enabled in the application.
  23627. */
  23628. static ColorGradingTextureEnabled: boolean;
  23629. private static _FresnelEnabled;
  23630. /**
  23631. * Are fresnels enabled in the application.
  23632. */
  23633. static FresnelEnabled: boolean;
  23634. }
  23635. }
  23636. declare module BABYLON {
  23637. /**
  23638. * Uniform buffer objects.
  23639. *
  23640. * Handles blocks of uniform on the GPU.
  23641. *
  23642. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  23643. *
  23644. * For more information, please refer to :
  23645. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  23646. */
  23647. class UniformBuffer {
  23648. private _engine;
  23649. private _buffer;
  23650. private _data;
  23651. private _bufferData;
  23652. private _dynamic?;
  23653. private _uniformLocations;
  23654. private _uniformSizes;
  23655. private _uniformLocationPointer;
  23656. private _needSync;
  23657. private _noUBO;
  23658. private _currentEffect;
  23659. private static _MAX_UNIFORM_SIZE;
  23660. private static _tempBuffer;
  23661. /**
  23662. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  23663. * This is dynamic to allow compat with webgl 1 and 2.
  23664. * You will need to pass the name of the uniform as well as the value.
  23665. */
  23666. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  23667. /**
  23668. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  23669. * This is dynamic to allow compat with webgl 1 and 2.
  23670. * You will need to pass the name of the uniform as well as the value.
  23671. */
  23672. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  23673. /**
  23674. * Lambda to Update a single float in a uniform buffer.
  23675. * This is dynamic to allow compat with webgl 1 and 2.
  23676. * You will need to pass the name of the uniform as well as the value.
  23677. */
  23678. updateFloat: (name: string, x: number) => void;
  23679. /**
  23680. * Lambda to Update a vec2 of float in a uniform buffer.
  23681. * This is dynamic to allow compat with webgl 1 and 2.
  23682. * You will need to pass the name of the uniform as well as the value.
  23683. */
  23684. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  23685. /**
  23686. * Lambda to Update a vec3 of float in a uniform buffer.
  23687. * This is dynamic to allow compat with webgl 1 and 2.
  23688. * You will need to pass the name of the uniform as well as the value.
  23689. */
  23690. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  23691. /**
  23692. * Lambda to Update a vec4 of float in a uniform buffer.
  23693. * This is dynamic to allow compat with webgl 1 and 2.
  23694. * You will need to pass the name of the uniform as well as the value.
  23695. */
  23696. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  23697. /**
  23698. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  23699. * This is dynamic to allow compat with webgl 1 and 2.
  23700. * You will need to pass the name of the uniform as well as the value.
  23701. */
  23702. updateMatrix: (name: string, mat: Matrix) => void;
  23703. /**
  23704. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  23705. * This is dynamic to allow compat with webgl 1 and 2.
  23706. * You will need to pass the name of the uniform as well as the value.
  23707. */
  23708. updateVector3: (name: string, vector: Vector3) => void;
  23709. /**
  23710. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  23711. * This is dynamic to allow compat with webgl 1 and 2.
  23712. * You will need to pass the name of the uniform as well as the value.
  23713. */
  23714. updateVector4: (name: string, vector: Vector4) => void;
  23715. /**
  23716. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  23717. * This is dynamic to allow compat with webgl 1 and 2.
  23718. * You will need to pass the name of the uniform as well as the value.
  23719. */
  23720. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  23721. /**
  23722. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  23723. * This is dynamic to allow compat with webgl 1 and 2.
  23724. * You will need to pass the name of the uniform as well as the value.
  23725. */
  23726. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  23727. /**
  23728. * Instantiates a new Uniform buffer objects.
  23729. *
  23730. * Handles blocks of uniform on the GPU.
  23731. *
  23732. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  23733. *
  23734. * For more information, please refer to :
  23735. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  23736. * @param engine Define the engine the buffer is associated with
  23737. * @param data Define the data contained in the buffer
  23738. * @param dynamic Define if the buffer is updatable
  23739. */
  23740. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  23741. /**
  23742. * Indicates if the buffer is using the WebGL2 UBO implementation,
  23743. * or just falling back on setUniformXXX calls.
  23744. */
  23745. readonly useUbo: boolean;
  23746. /**
  23747. * Indicates if the WebGL underlying uniform buffer is in sync
  23748. * with the javascript cache data.
  23749. */
  23750. readonly isSync: boolean;
  23751. /**
  23752. * Indicates if the WebGL underlying uniform buffer is dynamic.
  23753. * Also, a dynamic UniformBuffer will disable cache verification and always
  23754. * update the underlying WebGL uniform buffer to the GPU.
  23755. * @returns if Dynamic, otherwise false
  23756. */
  23757. isDynamic(): boolean;
  23758. /**
  23759. * The data cache on JS side.
  23760. * @returns the underlying data as a float array
  23761. */
  23762. getData(): Float32Array;
  23763. /**
  23764. * The underlying WebGL Uniform buffer.
  23765. * @returns the webgl buffer
  23766. */
  23767. getBuffer(): Nullable<WebGLBuffer>;
  23768. /**
  23769. * std140 layout specifies how to align data within an UBO structure.
  23770. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  23771. * for specs.
  23772. */
  23773. private _fillAlignment;
  23774. /**
  23775. * Adds an uniform in the buffer.
  23776. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  23777. * for the layout to be correct !
  23778. * @param name Name of the uniform, as used in the uniform block in the shader.
  23779. * @param size Data size, or data directly.
  23780. */
  23781. addUniform(name: string, size: number | number[]): void;
  23782. /**
  23783. * Adds a Matrix 4x4 to the uniform buffer.
  23784. * @param name Name of the uniform, as used in the uniform block in the shader.
  23785. * @param mat A 4x4 matrix.
  23786. */
  23787. addMatrix(name: string, mat: Matrix): void;
  23788. /**
  23789. * Adds a vec2 to the uniform buffer.
  23790. * @param name Name of the uniform, as used in the uniform block in the shader.
  23791. * @param x Define the x component value of the vec2
  23792. * @param y Define the y component value of the vec2
  23793. */
  23794. addFloat2(name: string, x: number, y: number): void;
  23795. /**
  23796. * Adds a vec3 to the uniform buffer.
  23797. * @param name Name of the uniform, as used in the uniform block in the shader.
  23798. * @param x Define the x component value of the vec3
  23799. * @param y Define the y component value of the vec3
  23800. * @param z Define the z component value of the vec3
  23801. */
  23802. addFloat3(name: string, x: number, y: number, z: number): void;
  23803. /**
  23804. * Adds a vec3 to the uniform buffer.
  23805. * @param name Name of the uniform, as used in the uniform block in the shader.
  23806. * @param color Define the vec3 from a Color
  23807. */
  23808. addColor3(name: string, color: Color3): void;
  23809. /**
  23810. * Adds a vec4 to the uniform buffer.
  23811. * @param name Name of the uniform, as used in the uniform block in the shader.
  23812. * @param color Define the rgb components from a Color
  23813. * @param alpha Define the a component of the vec4
  23814. */
  23815. addColor4(name: string, color: Color3, alpha: number): void;
  23816. /**
  23817. * Adds a vec3 to the uniform buffer.
  23818. * @param name Name of the uniform, as used in the uniform block in the shader.
  23819. * @param vector Define the vec3 components from a Vector
  23820. */
  23821. addVector3(name: string, vector: Vector3): void;
  23822. /**
  23823. * Adds a Matrix 3x3 to the uniform buffer.
  23824. * @param name Name of the uniform, as used in the uniform block in the shader.
  23825. */
  23826. addMatrix3x3(name: string): void;
  23827. /**
  23828. * Adds a Matrix 2x2 to the uniform buffer.
  23829. * @param name Name of the uniform, as used in the uniform block in the shader.
  23830. */
  23831. addMatrix2x2(name: string): void;
  23832. /**
  23833. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  23834. */
  23835. create(): void;
  23836. /** @hidden */
  23837. _rebuild(): void;
  23838. /**
  23839. * Updates the WebGL Uniform Buffer on the GPU.
  23840. * If the `dynamic` flag is set to true, no cache comparison is done.
  23841. * Otherwise, the buffer will be updated only if the cache differs.
  23842. */
  23843. update(): void;
  23844. /**
  23845. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  23846. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  23847. * @param data Define the flattened data
  23848. * @param size Define the size of the data.
  23849. */
  23850. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  23851. private _updateMatrix3x3ForUniform;
  23852. private _updateMatrix3x3ForEffect;
  23853. private _updateMatrix2x2ForEffect;
  23854. private _updateMatrix2x2ForUniform;
  23855. private _updateFloatForEffect;
  23856. private _updateFloatForUniform;
  23857. private _updateFloat2ForEffect;
  23858. private _updateFloat2ForUniform;
  23859. private _updateFloat3ForEffect;
  23860. private _updateFloat3ForUniform;
  23861. private _updateFloat4ForEffect;
  23862. private _updateFloat4ForUniform;
  23863. private _updateMatrixForEffect;
  23864. private _updateMatrixForUniform;
  23865. private _updateVector3ForEffect;
  23866. private _updateVector3ForUniform;
  23867. private _updateVector4ForEffect;
  23868. private _updateVector4ForUniform;
  23869. private _updateColor3ForEffect;
  23870. private _updateColor3ForUniform;
  23871. private _updateColor4ForEffect;
  23872. private _updateColor4ForUniform;
  23873. /**
  23874. * Sets a sampler uniform on the effect.
  23875. * @param name Define the name of the sampler.
  23876. * @param texture Define the texture to set in the sampler
  23877. */
  23878. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  23879. /**
  23880. * Directly updates the value of the uniform in the cache AND on the GPU.
  23881. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  23882. * @param data Define the flattened data
  23883. */
  23884. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  23885. /**
  23886. * Binds this uniform buffer to an effect.
  23887. * @param effect Define the effect to bind the buffer to
  23888. * @param name Name of the uniform block in the shader.
  23889. */
  23890. bindToEffect(effect: Effect, name: string): void;
  23891. /**
  23892. * Disposes the uniform buffer.
  23893. */
  23894. dispose(): void;
  23895. }
  23896. }
  23897. declare module BABYLON {
  23898. /**
  23899. * Defines a target to use with MorphTargetManager
  23900. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23901. */
  23902. class MorphTarget implements IAnimatable {
  23903. /** defines the name of the target */
  23904. name: string;
  23905. /**
  23906. * Gets or sets the list of animations
  23907. */
  23908. animations: Animation[];
  23909. private _scene;
  23910. private _positions;
  23911. private _normals;
  23912. private _tangents;
  23913. private _influence;
  23914. /**
  23915. * Observable raised when the influence changes
  23916. */
  23917. onInfluenceChanged: Observable<boolean>;
  23918. /** @hidden */
  23919. _onDataLayoutChanged: Observable<void>;
  23920. /**
  23921. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23922. */
  23923. influence: number;
  23924. private _animationPropertiesOverride;
  23925. /**
  23926. * Gets or sets the animation properties override
  23927. */
  23928. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23929. /**
  23930. * Creates a new MorphTarget
  23931. * @param name defines the name of the target
  23932. * @param influence defines the influence to use
  23933. */
  23934. constructor(
  23935. /** defines the name of the target */
  23936. name: string, influence?: number, scene?: Nullable<Scene>);
  23937. /**
  23938. * Gets a boolean defining if the target contains position data
  23939. */
  23940. readonly hasPositions: boolean;
  23941. /**
  23942. * Gets a boolean defining if the target contains normal data
  23943. */
  23944. readonly hasNormals: boolean;
  23945. /**
  23946. * Gets a boolean defining if the target contains tangent data
  23947. */
  23948. readonly hasTangents: boolean;
  23949. /**
  23950. * Affects position data to this target
  23951. * @param data defines the position data to use
  23952. */
  23953. setPositions(data: Nullable<FloatArray>): void;
  23954. /**
  23955. * Gets the position data stored in this target
  23956. * @returns a FloatArray containing the position data (or null if not present)
  23957. */
  23958. getPositions(): Nullable<FloatArray>;
  23959. /**
  23960. * Affects normal data to this target
  23961. * @param data defines the normal data to use
  23962. */
  23963. setNormals(data: Nullable<FloatArray>): void;
  23964. /**
  23965. * Gets the normal data stored in this target
  23966. * @returns a FloatArray containing the normal data (or null if not present)
  23967. */
  23968. getNormals(): Nullable<FloatArray>;
  23969. /**
  23970. * Affects tangent data to this target
  23971. * @param data defines the tangent data to use
  23972. */
  23973. setTangents(data: Nullable<FloatArray>): void;
  23974. /**
  23975. * Gets the tangent data stored in this target
  23976. * @returns a FloatArray containing the tangent data (or null if not present)
  23977. */
  23978. getTangents(): Nullable<FloatArray>;
  23979. /**
  23980. * Serializes the current target into a Serialization object
  23981. * @returns the serialized object
  23982. */
  23983. serialize(): any;
  23984. /**
  23985. * Creates a new target from serialized data
  23986. * @param serializationObject defines the serialized data to use
  23987. * @returns a new MorphTarget
  23988. */
  23989. static Parse(serializationObject: any): MorphTarget;
  23990. /**
  23991. * Creates a MorphTarget from mesh data
  23992. * @param mesh defines the source mesh
  23993. * @param name defines the name to use for the new target
  23994. * @param influence defines the influence to attach to the target
  23995. * @returns a new MorphTarget
  23996. */
  23997. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23998. }
  23999. }
  24000. declare module BABYLON {
  24001. /**
  24002. * This class is used to deform meshes using morphing between different targets
  24003. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24004. */
  24005. class MorphTargetManager {
  24006. private _targets;
  24007. private _targetInfluenceChangedObservers;
  24008. private _targetDataLayoutChangedObservers;
  24009. private _activeTargets;
  24010. private _scene;
  24011. private _influences;
  24012. private _supportsNormals;
  24013. private _supportsTangents;
  24014. private _vertexCount;
  24015. private _uniqueId;
  24016. private _tempInfluences;
  24017. /**
  24018. * Creates a new MorphTargetManager
  24019. * @param scene defines the current scene
  24020. */
  24021. constructor(scene?: Nullable<Scene>);
  24022. /**
  24023. * Gets the unique ID of this manager
  24024. */
  24025. readonly uniqueId: number;
  24026. /**
  24027. * Gets the number of vertices handled by this manager
  24028. */
  24029. readonly vertexCount: number;
  24030. /**
  24031. * Gets a boolean indicating if this manager supports morphing of normals
  24032. */
  24033. readonly supportsNormals: boolean;
  24034. /**
  24035. * Gets a boolean indicating if this manager supports morphing of tangents
  24036. */
  24037. readonly supportsTangents: boolean;
  24038. /**
  24039. * Gets the number of targets stored in this manager
  24040. */
  24041. readonly numTargets: number;
  24042. /**
  24043. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24044. */
  24045. readonly numInfluencers: number;
  24046. /**
  24047. * Gets the list of influences (one per target)
  24048. */
  24049. readonly influences: Float32Array;
  24050. /**
  24051. * Gets the active target at specified index. An active target is a target with an influence > 0
  24052. * @param index defines the index to check
  24053. * @returns the requested target
  24054. */
  24055. getActiveTarget(index: number): MorphTarget;
  24056. /**
  24057. * Gets the target at specified index
  24058. * @param index defines the index to check
  24059. * @returns the requested target
  24060. */
  24061. getTarget(index: number): MorphTarget;
  24062. /**
  24063. * Add a new target to this manager
  24064. * @param target defines the target to add
  24065. */
  24066. addTarget(target: MorphTarget): void;
  24067. /**
  24068. * Removes a target from the manager
  24069. * @param target defines the target to remove
  24070. */
  24071. removeTarget(target: MorphTarget): void;
  24072. /**
  24073. * Serializes the current manager into a Serialization object
  24074. * @returns the serialized object
  24075. */
  24076. serialize(): any;
  24077. private _syncActiveTargets;
  24078. /**
  24079. * Syncrhonize the targets with all the meshes using this morph target manager
  24080. */
  24081. synchronize(): void;
  24082. /**
  24083. * Creates a new MorphTargetManager from serialized data
  24084. * @param serializationObject defines the serialized data
  24085. * @param scene defines the hosting scene
  24086. * @returns the new MorphTargetManager
  24087. */
  24088. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24089. }
  24090. }
  24091. declare module BABYLON {
  24092. /**
  24093. * Class used to store all common mesh properties
  24094. */
  24095. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24096. /** No occlusion */
  24097. static OCCLUSION_TYPE_NONE: number;
  24098. /** Occlusion set to optimisitic */
  24099. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24100. /** Occlusion set to strict */
  24101. static OCCLUSION_TYPE_STRICT: number;
  24102. /** Use an accurante occlusion algorithm */
  24103. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24104. /** Use a conservative occlusion algorithm */
  24105. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24106. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24107. static readonly CULLINGSTRATEGY_STANDARD: number;
  24108. /** Culling strategy with bounding sphere only and then frustum culling */
  24109. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24110. /**
  24111. * No billboard
  24112. */
  24113. static readonly BILLBOARDMODE_NONE: number;
  24114. /** Billboard on X axis */
  24115. static readonly BILLBOARDMODE_X: number;
  24116. /** Billboard on Y axis */
  24117. static readonly BILLBOARDMODE_Y: number;
  24118. /** Billboard on Z axis */
  24119. static readonly BILLBOARDMODE_Z: number;
  24120. /** Billboard on all axes */
  24121. static readonly BILLBOARDMODE_ALL: number;
  24122. private _facetData;
  24123. /** Gets ot sets the culling strategy to use to find visible meshes */
  24124. cullingStrategy: number;
  24125. /**
  24126. * Gets the number of facets in the mesh
  24127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24128. */
  24129. readonly facetNb: number;
  24130. /**
  24131. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24133. */
  24134. partitioningSubdivisions: number;
  24135. /**
  24136. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24137. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24139. */
  24140. partitioningBBoxRatio: number;
  24141. /**
  24142. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24143. * Works only for updatable meshes.
  24144. * Doesn't work with multi-materials
  24145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24146. */
  24147. mustDepthSortFacets: boolean;
  24148. /**
  24149. * The location (Vector3) where the facet depth sort must be computed from.
  24150. * By default, the active camera position.
  24151. * Used only when facet depth sort is enabled
  24152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24153. */
  24154. facetDepthSortFrom: Vector3;
  24155. /**
  24156. * gets a boolean indicating if facetData is enabled
  24157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24158. */
  24159. readonly isFacetDataEnabled: boolean;
  24160. /** @hidden */
  24161. _updateNonUniformScalingState(value: boolean): boolean;
  24162. /**
  24163. * An event triggered when this mesh collides with another one
  24164. */
  24165. onCollideObservable: Observable<AbstractMesh>;
  24166. private _onCollideObserver;
  24167. /** Set a function to call when this mesh collides with another one */
  24168. onCollide: () => void;
  24169. /**
  24170. * An event triggered when the collision's position changes
  24171. */
  24172. onCollisionPositionChangeObservable: Observable<Vector3>;
  24173. private _onCollisionPositionChangeObserver;
  24174. /** Set a function to call when the collision's position changes */
  24175. onCollisionPositionChange: () => void;
  24176. /**
  24177. * An event triggered when material is changed
  24178. */
  24179. onMaterialChangedObservable: Observable<AbstractMesh>;
  24180. /**
  24181. * Gets or sets the orientation for POV movement & rotation
  24182. */
  24183. definedFacingForward: boolean;
  24184. /** @hidden */
  24185. _occlusionQuery: Nullable<WebGLQuery>;
  24186. private _visibility;
  24187. /**
  24188. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24189. */
  24190. /**
  24191. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24192. */
  24193. visibility: number;
  24194. /** Gets or sets the alpha index used to sort transparent meshes
  24195. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24196. */
  24197. alphaIndex: number;
  24198. /**
  24199. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24200. */
  24201. isVisible: boolean;
  24202. /**
  24203. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24204. */
  24205. isPickable: boolean;
  24206. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24207. showSubMeshesBoundingBox: boolean;
  24208. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24209. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24210. */
  24211. isBlocker: boolean;
  24212. /**
  24213. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24214. */
  24215. enablePointerMoveEvents: boolean;
  24216. /**
  24217. * Specifies the rendering group id for this mesh (0 by default)
  24218. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24219. */
  24220. renderingGroupId: number;
  24221. private _material;
  24222. /** Gets or sets current material */
  24223. material: Nullable<Material>;
  24224. private _receiveShadows;
  24225. /**
  24226. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24227. * @see http://doc.babylonjs.com/babylon101/shadows
  24228. */
  24229. receiveShadows: boolean;
  24230. /** Defines color to use when rendering outline */
  24231. outlineColor: Color3;
  24232. /** Define width to use when rendering outline */
  24233. outlineWidth: number;
  24234. /** Defines color to use when rendering overlay */
  24235. overlayColor: Color3;
  24236. /** Defines alpha to use when rendering overlay */
  24237. overlayAlpha: number;
  24238. private _hasVertexAlpha;
  24239. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24240. hasVertexAlpha: boolean;
  24241. private _useVertexColors;
  24242. /** 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) */
  24243. useVertexColors: boolean;
  24244. private _computeBonesUsingShaders;
  24245. /**
  24246. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24247. */
  24248. computeBonesUsingShaders: boolean;
  24249. private _numBoneInfluencers;
  24250. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24251. numBoneInfluencers: number;
  24252. private _applyFog;
  24253. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24254. applyFog: boolean;
  24255. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24256. useOctreeForRenderingSelection: boolean;
  24257. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24258. useOctreeForPicking: boolean;
  24259. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24260. useOctreeForCollisions: boolean;
  24261. private _layerMask;
  24262. /**
  24263. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24264. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24265. */
  24266. layerMask: number;
  24267. /**
  24268. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24269. */
  24270. alwaysSelectAsActiveMesh: boolean;
  24271. /**
  24272. * Gets or sets the current action manager
  24273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24274. */
  24275. actionManager: Nullable<ActionManager>;
  24276. private _checkCollisions;
  24277. private _collisionMask;
  24278. private _collisionGroup;
  24279. /**
  24280. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24282. */
  24283. ellipsoid: Vector3;
  24284. /**
  24285. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24287. */
  24288. ellipsoidOffset: Vector3;
  24289. private _collider;
  24290. private _oldPositionForCollisions;
  24291. private _diffPositionForCollisions;
  24292. /**
  24293. * Gets or sets a collision mask used to mask collisions (default is -1).
  24294. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24295. */
  24296. collisionMask: number;
  24297. /**
  24298. * Gets or sets the current collision group mask (-1 by default).
  24299. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24300. */
  24301. collisionGroup: number;
  24302. /**
  24303. * Defines edge width used when edgesRenderer is enabled
  24304. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24305. */
  24306. edgesWidth: number;
  24307. /**
  24308. * Defines edge color used when edgesRenderer is enabled
  24309. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24310. */
  24311. edgesColor: Color4;
  24312. /** @hidden */
  24313. _edgesRenderer: Nullable<IEdgesRenderer>;
  24314. /** @hidden */
  24315. _masterMesh: Nullable<AbstractMesh>;
  24316. /** @hidden */
  24317. _boundingInfo: Nullable<BoundingInfo>;
  24318. /** @hidden */
  24319. _renderId: number;
  24320. /**
  24321. * Gets or sets the list of subMeshes
  24322. * @see http://doc.babylonjs.com/how_to/multi_materials
  24323. */
  24324. subMeshes: SubMesh[];
  24325. /** @hidden */
  24326. _intersectionsInProgress: AbstractMesh[];
  24327. /** @hidden */
  24328. _unIndexed: boolean;
  24329. /** @hidden */
  24330. _lightSources: Light[];
  24331. /** @hidden */
  24332. readonly _positions: Nullable<Vector3[]>;
  24333. /** @hidden */
  24334. _waitingActions: any;
  24335. /** @hidden */
  24336. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24337. private _skeleton;
  24338. /** @hidden */
  24339. _bonesTransformMatrices: Nullable<Float32Array>;
  24340. /**
  24341. * Gets or sets a skeleton to apply skining transformations
  24342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24343. */
  24344. skeleton: Nullable<Skeleton>;
  24345. /**
  24346. * An event triggered when the mesh is rebuilt.
  24347. */
  24348. onRebuildObservable: Observable<AbstractMesh>;
  24349. /**
  24350. * Creates a new AbstractMesh
  24351. * @param name defines the name of the mesh
  24352. * @param scene defines the hosting scene
  24353. */
  24354. constructor(name: string, scene?: Nullable<Scene>);
  24355. /**
  24356. * Returns the string "AbstractMesh"
  24357. * @returns "AbstractMesh"
  24358. */
  24359. getClassName(): string;
  24360. /**
  24361. * Gets a string representation of the current mesh
  24362. * @param fullDetails defines a boolean indicating if full details must be included
  24363. * @returns a string representation of the current mesh
  24364. */
  24365. toString(fullDetails?: boolean): string;
  24366. /** @hidden */
  24367. _rebuild(): void;
  24368. /** @hidden */
  24369. _resyncLightSources(): void;
  24370. /** @hidden */
  24371. _resyncLighSource(light: Light): void;
  24372. /** @hidden */
  24373. _unBindEffect(): void;
  24374. /** @hidden */
  24375. _removeLightSource(light: Light): void;
  24376. private _markSubMeshesAsDirty;
  24377. /** @hidden */
  24378. _markSubMeshesAsLightDirty(): void;
  24379. /** @hidden */
  24380. _markSubMeshesAsAttributesDirty(): void;
  24381. /** @hidden */
  24382. _markSubMeshesAsMiscDirty(): void;
  24383. /**
  24384. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24385. */
  24386. scaling: Vector3;
  24387. /**
  24388. * Returns true if the mesh is blocked. Implemented by child classes
  24389. */
  24390. readonly isBlocked: boolean;
  24391. /**
  24392. * Returns the mesh itself by default. Implemented by child classes
  24393. * @param camera defines the camera to use to pick the right LOD level
  24394. * @returns the currentAbstractMesh
  24395. */
  24396. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24397. /**
  24398. * Returns 0 by default. Implemented by child classes
  24399. * @returns an integer
  24400. */
  24401. getTotalVertices(): number;
  24402. /**
  24403. * Returns null by default. Implemented by child classes
  24404. * @returns null
  24405. */
  24406. getIndices(): Nullable<IndicesArray>;
  24407. /**
  24408. * Returns the array of the requested vertex data kind. Implemented by child classes
  24409. * @param kind defines the vertex data kind to use
  24410. * @returns null
  24411. */
  24412. getVerticesData(kind: string): Nullable<FloatArray>;
  24413. /**
  24414. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24415. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24416. * Note that a new underlying VertexBuffer object is created each call.
  24417. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24418. * @param kind defines vertex data kind:
  24419. * * BABYLON.VertexBuffer.PositionKind
  24420. * * BABYLON.VertexBuffer.UVKind
  24421. * * BABYLON.VertexBuffer.UV2Kind
  24422. * * BABYLON.VertexBuffer.UV3Kind
  24423. * * BABYLON.VertexBuffer.UV4Kind
  24424. * * BABYLON.VertexBuffer.UV5Kind
  24425. * * BABYLON.VertexBuffer.UV6Kind
  24426. * * BABYLON.VertexBuffer.ColorKind
  24427. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24428. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24429. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24430. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24431. * @param data defines the data source
  24432. * @param updatable defines if the data must be flagged as updatable (or static)
  24433. * @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
  24434. * @returns the current mesh
  24435. */
  24436. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24437. /**
  24438. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24439. * If the mesh has no geometry, it is simply returned as it is.
  24440. * @param kind defines vertex data kind:
  24441. * * BABYLON.VertexBuffer.PositionKind
  24442. * * BABYLON.VertexBuffer.UVKind
  24443. * * BABYLON.VertexBuffer.UV2Kind
  24444. * * BABYLON.VertexBuffer.UV3Kind
  24445. * * BABYLON.VertexBuffer.UV4Kind
  24446. * * BABYLON.VertexBuffer.UV5Kind
  24447. * * BABYLON.VertexBuffer.UV6Kind
  24448. * * BABYLON.VertexBuffer.ColorKind
  24449. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24450. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24451. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24452. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24453. * @param data defines the data source
  24454. * @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
  24455. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24456. * @returns the current mesh
  24457. */
  24458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24459. /**
  24460. * Sets the mesh indices,
  24461. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24462. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24463. * @param totalVertices Defines the total number of vertices
  24464. * @returns the current mesh
  24465. */
  24466. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24467. /**
  24468. * Gets a boolean indicating if specific vertex data is present
  24469. * @param kind defines the vertex data kind to use
  24470. * @returns true is data kind is present
  24471. */
  24472. isVerticesDataPresent(kind: string): boolean;
  24473. /**
  24474. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24475. * @returns a BoundingInfo
  24476. */
  24477. getBoundingInfo(): BoundingInfo;
  24478. /**
  24479. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24480. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24481. * @returns the current mesh
  24482. */
  24483. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24484. /**
  24485. * Overwrite the current bounding info
  24486. * @param boundingInfo defines the new bounding info
  24487. * @returns the current mesh
  24488. */
  24489. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24490. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24491. readonly useBones: boolean;
  24492. /** @hidden */
  24493. _preActivate(): void;
  24494. /** @hidden */
  24495. _preActivateForIntermediateRendering(renderId: number): void;
  24496. /** @hidden */
  24497. _activate(renderId: number): void;
  24498. /**
  24499. * Gets the current world matrix
  24500. * @returns a Matrix
  24501. */
  24502. getWorldMatrix(): Matrix;
  24503. /** @hidden */
  24504. _getWorldMatrixDeterminant(): number;
  24505. /**
  24506. * Perform relative position change from the point of view of behind the front of the mesh.
  24507. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24508. * Supports definition of mesh facing forward or backward
  24509. * @param amountRight defines the distance on the right axis
  24510. * @param amountUp defines the distance on the up axis
  24511. * @param amountForward defines the distance on the forward axis
  24512. * @returns the current mesh
  24513. */
  24514. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24515. /**
  24516. * Calculate relative position change from the point of view of behind the front of the mesh.
  24517. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24518. * Supports definition of mesh facing forward or backward
  24519. * @param amountRight defines the distance on the right axis
  24520. * @param amountUp defines the distance on the up axis
  24521. * @param amountForward defines the distance on the forward axis
  24522. * @returns the new displacement vector
  24523. */
  24524. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24525. /**
  24526. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24527. * Supports definition of mesh facing forward or backward
  24528. * @param flipBack defines the flip
  24529. * @param twirlClockwise defines the twirl
  24530. * @param tiltRight defines the tilt
  24531. * @returns the current mesh
  24532. */
  24533. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24534. /**
  24535. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24536. * Supports definition of mesh facing forward or backward.
  24537. * @param flipBack defines the flip
  24538. * @param twirlClockwise defines the twirl
  24539. * @param tiltRight defines the tilt
  24540. * @returns the new rotation vector
  24541. */
  24542. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24543. /**
  24544. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24545. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24546. * @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
  24547. * @returns the new bounding vectors
  24548. */
  24549. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24550. min: Vector3;
  24551. max: Vector3;
  24552. };
  24553. /** @hidden */
  24554. _updateBoundingInfo(): AbstractMesh;
  24555. /** @hidden */
  24556. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24557. /** @hidden */
  24558. protected _afterComputeWorldMatrix(): void;
  24559. /**
  24560. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24561. * A mesh is in the frustum if its bounding box intersects the frustum
  24562. * @param frustumPlanes defines the frustum to test
  24563. * @returns true if the mesh is in the frustum planes
  24564. */
  24565. isInFrustum(frustumPlanes: Plane[]): boolean;
  24566. /**
  24567. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24568. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24569. * @param frustumPlanes defines the frustum to test
  24570. * @returns true if the mesh is completely in the frustum planes
  24571. */
  24572. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24573. /**
  24574. * True if the mesh intersects another mesh or a SolidParticle object
  24575. * @param mesh defines a target mesh or SolidParticle to test
  24576. * @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)
  24577. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24578. * @returns true if there is an intersection
  24579. */
  24580. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24581. /**
  24582. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24583. * @param point defines the point to test
  24584. * @returns true if there is an intersection
  24585. */
  24586. intersectsPoint(point: Vector3): boolean;
  24587. /**
  24588. * Gets the position of the current mesh in camera space
  24589. * @param camera defines the camera to use
  24590. * @returns a position
  24591. */
  24592. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24593. /**
  24594. * Returns the distance from the mesh to the active camera
  24595. * @param camera defines the camera to use
  24596. * @returns the distance
  24597. */
  24598. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24599. /**
  24600. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24602. */
  24603. checkCollisions: boolean;
  24604. /**
  24605. * Gets Collider object used to compute collisions (not physics)
  24606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24607. */
  24608. readonly collider: Collider;
  24609. /**
  24610. * Move the mesh using collision engine
  24611. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24612. * @param displacement defines the requested displacement vector
  24613. * @returns the current mesh
  24614. */
  24615. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24616. private _onCollisionPositionChange;
  24617. /** @hidden */
  24618. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24619. /** @hidden */
  24620. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24621. /** @hidden */
  24622. _checkCollision(collider: Collider): AbstractMesh;
  24623. /** @hidden */
  24624. _generatePointsArray(): boolean;
  24625. /**
  24626. * Checks if the passed Ray intersects with the mesh
  24627. * @param ray defines the ray to use
  24628. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24629. * @returns the picking info
  24630. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24631. */
  24632. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24633. /**
  24634. * Clones the current mesh
  24635. * @param name defines the mesh name
  24636. * @param newParent defines the new mesh parent
  24637. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24638. * @returns the new mesh
  24639. */
  24640. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24641. /**
  24642. * Disposes all the submeshes of the current meshnp
  24643. * @returns the current mesh
  24644. */
  24645. releaseSubMeshes(): AbstractMesh;
  24646. /**
  24647. * Releases resources associated with this abstract mesh.
  24648. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24649. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24650. */
  24651. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24652. /**
  24653. * Adds the passed mesh as a child to the current mesh
  24654. * @param mesh defines the child mesh
  24655. * @returns the current mesh
  24656. */
  24657. addChild(mesh: AbstractMesh): AbstractMesh;
  24658. /**
  24659. * Removes the passed mesh from the current mesh children list
  24660. * @param mesh defines the child mesh
  24661. * @returns the current mesh
  24662. */
  24663. removeChild(mesh: AbstractMesh): AbstractMesh;
  24664. /** @hidden */
  24665. private _initFacetData;
  24666. /**
  24667. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24668. * This method can be called within the render loop.
  24669. * 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
  24670. * @returns the current mesh
  24671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24672. */
  24673. updateFacetData(): AbstractMesh;
  24674. /**
  24675. * Returns the facetLocalNormals array.
  24676. * The normals are expressed in the mesh local spac
  24677. * @returns an array of Vector3
  24678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24679. */
  24680. getFacetLocalNormals(): Vector3[];
  24681. /**
  24682. * Returns the facetLocalPositions array.
  24683. * The facet positions are expressed in the mesh local space
  24684. * @returns an array of Vector3
  24685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24686. */
  24687. getFacetLocalPositions(): Vector3[];
  24688. /**
  24689. * Returns the facetLocalPartioning array
  24690. * @returns an array of array of numbers
  24691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24692. */
  24693. getFacetLocalPartitioning(): number[][];
  24694. /**
  24695. * Returns the i-th facet position in the world system.
  24696. * This method allocates a new Vector3 per call
  24697. * @param i defines the facet index
  24698. * @returns a new Vector3
  24699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24700. */
  24701. getFacetPosition(i: number): Vector3;
  24702. /**
  24703. * Sets the reference Vector3 with the i-th facet position in the world system
  24704. * @param i defines the facet index
  24705. * @param ref defines the target vector
  24706. * @returns the current mesh
  24707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24708. */
  24709. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24710. /**
  24711. * Returns the i-th facet normal in the world system.
  24712. * This method allocates a new Vector3 per call
  24713. * @param i defines the facet index
  24714. * @returns a new Vector3
  24715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24716. */
  24717. getFacetNormal(i: number): Vector3;
  24718. /**
  24719. * Sets the reference Vector3 with the i-th facet normal in the world system
  24720. * @param i defines the facet index
  24721. * @param ref defines the target vector
  24722. * @returns the current mesh
  24723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24724. */
  24725. getFacetNormalToRef(i: number, ref: Vector3): this;
  24726. /**
  24727. * 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)
  24728. * @param x defines x coordinate
  24729. * @param y defines y coordinate
  24730. * @param z defines z coordinate
  24731. * @returns the array of facet indexes
  24732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24733. */
  24734. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24735. /**
  24736. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24737. * @param projected sets as the (x,y,z) world projection on the facet
  24738. * @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
  24739. * @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
  24740. * @param x defines x coordinate
  24741. * @param y defines y coordinate
  24742. * @param z defines z coordinate
  24743. * @returns the face index if found (or null instead)
  24744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24745. */
  24746. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24747. /**
  24748. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24749. * @param projected sets as the (x,y,z) local projection on the facet
  24750. * @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
  24751. * @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
  24752. * @param x defines x coordinate
  24753. * @param y defines y coordinate
  24754. * @param z defines z coordinate
  24755. * @returns the face index if found (or null instead)
  24756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24757. */
  24758. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24759. /**
  24760. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24761. * @returns the parameters
  24762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24763. */
  24764. getFacetDataParameters(): any;
  24765. /**
  24766. * Disables the feature FacetData and frees the related memory
  24767. * @returns the current mesh
  24768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24769. */
  24770. disableFacetData(): AbstractMesh;
  24771. /**
  24772. * Updates the AbstractMesh indices array
  24773. * @param indices defines the data source
  24774. * @returns the current mesh
  24775. */
  24776. updateIndices(indices: IndicesArray): AbstractMesh;
  24777. /**
  24778. * Creates new normals data for the mesh
  24779. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24780. * @returns the current mesh
  24781. */
  24782. createNormals(updatable: boolean): AbstractMesh;
  24783. /**
  24784. * Align the mesh with a normal
  24785. * @param normal defines the normal to use
  24786. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24787. * @returns the current mesh
  24788. */
  24789. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24790. /** @hidden */
  24791. _checkOcclusionQuery(): boolean;
  24792. }
  24793. }
  24794. declare module BABYLON {
  24795. /**
  24796. * Class used to store data that will be store in GPU memory
  24797. */
  24798. class Buffer {
  24799. private _engine;
  24800. private _buffer;
  24801. /** @hidden */
  24802. _data: Nullable<DataArray>;
  24803. private _updatable;
  24804. private _instanced;
  24805. /**
  24806. * Gets the byte stride.
  24807. */
  24808. readonly byteStride: number;
  24809. /**
  24810. * Constructor
  24811. * @param engine the engine
  24812. * @param data the data to use for this buffer
  24813. * @param updatable whether the data is updatable
  24814. * @param stride the stride (optional)
  24815. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24816. * @param instanced whether the buffer is instanced (optional)
  24817. * @param useBytes set to true if the stride in in bytes (optional)
  24818. */
  24819. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24820. /**
  24821. * Create a new VertexBuffer based on the current buffer
  24822. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24823. * @param offset defines offset in the buffer (0 by default)
  24824. * @param size defines the size in floats of attributes (position is 3 for instance)
  24825. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24826. * @param instanced defines if the vertex buffer contains indexed data
  24827. * @param useBytes defines if the offset and stride are in bytes
  24828. * @returns the new vertex buffer
  24829. */
  24830. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24831. /**
  24832. * Gets a boolean indicating if the Buffer is updatable?
  24833. * @returns true if the buffer is updatable
  24834. */
  24835. isUpdatable(): boolean;
  24836. /**
  24837. * Gets current buffer's data
  24838. * @returns a DataArray or null
  24839. */
  24840. getData(): Nullable<DataArray>;
  24841. /**
  24842. * Gets underlying native buffer
  24843. * @returns underlying native buffer
  24844. */
  24845. getBuffer(): Nullable<WebGLBuffer>;
  24846. /**
  24847. * Gets the stride in float32 units (i.e. byte stride / 4).
  24848. * May not be an integer if the byte stride is not divisible by 4.
  24849. * DEPRECATED. Use byteStride instead.
  24850. * @returns the stride in float32 units
  24851. */
  24852. getStrideSize(): number;
  24853. /**
  24854. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24855. * @param data defines the data to store
  24856. */
  24857. create(data?: Nullable<DataArray>): void;
  24858. /** @hidden */
  24859. _rebuild(): void;
  24860. /**
  24861. * Update current buffer data
  24862. * @param data defines the data to store
  24863. */
  24864. update(data: DataArray): void;
  24865. /**
  24866. * Updates the data directly.
  24867. * @param data the new data
  24868. * @param offset the new offset
  24869. * @param vertexCount the vertex count (optional)
  24870. * @param useBytes set to true if the offset is in bytes
  24871. */
  24872. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24873. /**
  24874. * Release all resources
  24875. */
  24876. dispose(): void;
  24877. }
  24878. }
  24879. declare module BABYLON {
  24880. /**
  24881. * Class for building Constructive Solid Geometry
  24882. */
  24883. class CSG {
  24884. private polygons;
  24885. /**
  24886. * The world matrix
  24887. */
  24888. matrix: Matrix;
  24889. /**
  24890. * Stores the position
  24891. */
  24892. position: Vector3;
  24893. /**
  24894. * Stores the rotation
  24895. */
  24896. rotation: Vector3;
  24897. /**
  24898. * Stores the rotation quaternion
  24899. */
  24900. rotationQuaternion: Nullable<Quaternion>;
  24901. /**
  24902. * Stores the scaling vector
  24903. */
  24904. scaling: Vector3;
  24905. /**
  24906. * Convert the BABYLON.Mesh to BABYLON.CSG
  24907. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24908. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24909. */
  24910. static FromMesh(mesh: Mesh): CSG;
  24911. /**
  24912. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24913. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24914. */
  24915. private static FromPolygons;
  24916. /**
  24917. * Clones, or makes a deep copy, of the BABYLON.CSG
  24918. * @returns A new BABYLON.CSG
  24919. */
  24920. clone(): CSG;
  24921. /**
  24922. * Unions this CSG with another CSG
  24923. * @param csg The CSG to union against this CSG
  24924. * @returns The unioned CSG
  24925. */
  24926. union(csg: CSG): CSG;
  24927. /**
  24928. * Unions this CSG with another CSG in place
  24929. * @param csg The CSG to union against this CSG
  24930. */
  24931. unionInPlace(csg: CSG): void;
  24932. /**
  24933. * Subtracts this CSG with another CSG
  24934. * @param csg The CSG to subtract against this CSG
  24935. * @returns A new BABYLON.CSG
  24936. */
  24937. subtract(csg: CSG): CSG;
  24938. /**
  24939. * Subtracts this CSG with another CSG in place
  24940. * @param csg The CSG to subtact against this CSG
  24941. */
  24942. subtractInPlace(csg: CSG): void;
  24943. /**
  24944. * Intersect this CSG with another CSG
  24945. * @param csg The CSG to intersect against this CSG
  24946. * @returns A new BABYLON.CSG
  24947. */
  24948. intersect(csg: CSG): CSG;
  24949. /**
  24950. * Intersects this CSG with another CSG in place
  24951. * @param csg The CSG to intersect against this CSG
  24952. */
  24953. intersectInPlace(csg: CSG): void;
  24954. /**
  24955. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24956. * not modified.
  24957. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24958. */
  24959. inverse(): CSG;
  24960. /**
  24961. * Inverses the BABYLON.CSG in place
  24962. */
  24963. inverseInPlace(): void;
  24964. /**
  24965. * This is used to keep meshes transformations so they can be restored
  24966. * when we build back a Babylon Mesh
  24967. * NB : All CSG operations are performed in world coordinates
  24968. * @param csg The BABYLON.CSG to copy the transform attributes from
  24969. * @returns This BABYLON.CSG
  24970. */
  24971. copyTransformAttributes(csg: CSG): CSG;
  24972. /**
  24973. * Build Raw mesh from CSG
  24974. * Coordinates here are in world space
  24975. * @param name The name of the mesh geometry
  24976. * @param scene The BABYLON.Scene
  24977. * @param keepSubMeshes Specifies if the submeshes should be kept
  24978. * @returns A new BABYLON.Mesh
  24979. */
  24980. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24981. /**
  24982. * Build Mesh from CSG taking material and transforms into account
  24983. * @param name The name of the BABYLON.Mesh
  24984. * @param material The material of the BABYLON.Mesh
  24985. * @param scene The BABYLON.Scene
  24986. * @param keepSubMeshes Specifies if submeshes should be kept
  24987. * @returns The new BABYLON.Mesh
  24988. */
  24989. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24990. }
  24991. }
  24992. declare module BABYLON {
  24993. /**
  24994. * Class used to store geometry data (vertex buffers + index buffer)
  24995. */
  24996. class Geometry implements IGetSetVerticesData {
  24997. /**
  24998. * Gets or sets the unique ID of the geometry
  24999. */
  25000. id: string;
  25001. /**
  25002. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25003. */
  25004. delayLoadState: number;
  25005. /**
  25006. * Gets the file containing the data to load when running in delay load state
  25007. */
  25008. delayLoadingFile: Nullable<string>;
  25009. /**
  25010. * Callback called when the geometry is updated
  25011. */
  25012. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25013. private _scene;
  25014. private _engine;
  25015. private _meshes;
  25016. private _totalVertices;
  25017. /** @hidden */
  25018. _indices: IndicesArray;
  25019. /** @hidden */
  25020. _vertexBuffers: {
  25021. [key: string]: VertexBuffer;
  25022. };
  25023. private _isDisposed;
  25024. private _extend;
  25025. private _boundingBias;
  25026. /** @hidden */
  25027. _delayInfo: Array<string>;
  25028. private _indexBuffer;
  25029. private _indexBufferIsUpdatable;
  25030. /** @hidden */
  25031. _boundingInfo: Nullable<BoundingInfo>;
  25032. /** @hidden */
  25033. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25034. /** @hidden */
  25035. _softwareSkinningFrameId: number;
  25036. private _vertexArrayObjects;
  25037. private _updatable;
  25038. /** @hidden */
  25039. _positions: Nullable<Vector3[]>;
  25040. /**
  25041. * 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
  25042. */
  25043. /**
  25044. * 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
  25045. */
  25046. boundingBias: Vector2;
  25047. /**
  25048. * Static function used to attach a new empty geometry to a mesh
  25049. * @param mesh defines the mesh to attach the geometry to
  25050. * @returns the new Geometry
  25051. */
  25052. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25053. /**
  25054. * Creates a new geometry
  25055. * @param id defines the unique ID
  25056. * @param scene defines the hosting scene
  25057. * @param vertexData defines the VertexData used to get geometry data
  25058. * @param updatable defines if geometry must be updatable (false by default)
  25059. * @param mesh defines the mesh that will be associated with the geometry
  25060. */
  25061. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25062. /**
  25063. * Gets the current extend of the geometry
  25064. */
  25065. readonly extend: {
  25066. minimum: Vector3;
  25067. maximum: Vector3;
  25068. };
  25069. /**
  25070. * Gets the hosting scene
  25071. * @returns the hosting Scene
  25072. */
  25073. getScene(): Scene;
  25074. /**
  25075. * Gets the hosting engine
  25076. * @returns the hosting Engine
  25077. */
  25078. getEngine(): Engine;
  25079. /**
  25080. * Defines if the geometry is ready to use
  25081. * @returns true if the geometry is ready to be used
  25082. */
  25083. isReady(): boolean;
  25084. /**
  25085. * Gets a value indicating that the geometry should not be serialized
  25086. */
  25087. readonly doNotSerialize: boolean;
  25088. /** @hidden */
  25089. _rebuild(): void;
  25090. /**
  25091. * Affects all geometry data in one call
  25092. * @param vertexData defines the geometry data
  25093. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25094. */
  25095. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25096. /**
  25097. * Set specific vertex data
  25098. * @param kind defines the data kind (Position, normal, etc...)
  25099. * @param data defines the vertex data to use
  25100. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25101. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25102. */
  25103. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25104. /**
  25105. * Removes a specific vertex data
  25106. * @param kind defines the data kind (Position, normal, etc...)
  25107. */
  25108. removeVerticesData(kind: string): void;
  25109. /**
  25110. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25111. * @param buffer defines the vertex buffer to use
  25112. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25113. */
  25114. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25115. /**
  25116. * Update a specific vertex buffer
  25117. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25118. * It will do nothing if the buffer is not updatable
  25119. * @param kind defines the data kind (Position, normal, etc...)
  25120. * @param data defines the data to use
  25121. * @param offset defines the offset in the target buffer where to store the data
  25122. * @param useBytes set to true if the offset is in bytes
  25123. */
  25124. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25125. /**
  25126. * Update a specific vertex buffer
  25127. * This function will create a new buffer if the current one is not updatable
  25128. * @param kind defines the data kind (Position, normal, etc...)
  25129. * @param data defines the data to use
  25130. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25131. */
  25132. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25133. private _updateBoundingInfo;
  25134. /** @hidden */
  25135. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25136. /**
  25137. * Gets total number of vertices
  25138. * @returns the total number of vertices
  25139. */
  25140. getTotalVertices(): number;
  25141. /**
  25142. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25143. * @param kind defines the data kind (Position, normal, etc...)
  25144. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25145. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25146. * @returns a float array containing vertex data
  25147. */
  25148. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25149. /**
  25150. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25151. * @param kind defines the data kind (Position, normal, etc...)
  25152. * @returns true if the vertex buffer with the specified kind is updatable
  25153. */
  25154. isVertexBufferUpdatable(kind: string): boolean;
  25155. /**
  25156. * Gets a specific vertex buffer
  25157. * @param kind defines the data kind (Position, normal, etc...)
  25158. * @returns a VertexBuffer
  25159. */
  25160. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25161. /**
  25162. * Returns all vertex buffers
  25163. * @return an object holding all vertex buffers indexed by kind
  25164. */
  25165. getVertexBuffers(): Nullable<{
  25166. [key: string]: VertexBuffer;
  25167. }>;
  25168. /**
  25169. * Gets a boolean indicating if specific vertex buffer is present
  25170. * @param kind defines the data kind (Position, normal, etc...)
  25171. * @returns true if data is present
  25172. */
  25173. isVerticesDataPresent(kind: string): boolean;
  25174. /**
  25175. * Gets a list of all attached data kinds (Position, normal, etc...)
  25176. * @returns a list of string containing all kinds
  25177. */
  25178. getVerticesDataKinds(): string[];
  25179. /**
  25180. * Update index buffer
  25181. * @param indices defines the indices to store in the index buffer
  25182. * @param offset defines the offset in the target buffer where to store the data
  25183. */
  25184. updateIndices(indices: IndicesArray, offset?: number): void;
  25185. /**
  25186. * Creates a new index buffer
  25187. * @param indices defines the indices to store in the index buffer
  25188. * @param totalVertices defines the total number of vertices (could be null)
  25189. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25190. */
  25191. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25192. /**
  25193. * Return the total number of indices
  25194. * @returns the total number of indices
  25195. */
  25196. getTotalIndices(): number;
  25197. /**
  25198. * Gets the index buffer array
  25199. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25200. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25201. * @returns the index buffer array
  25202. */
  25203. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25204. /**
  25205. * Gets the index buffer
  25206. * @return the index buffer
  25207. */
  25208. getIndexBuffer(): Nullable<WebGLBuffer>;
  25209. /** @hidden */
  25210. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25211. /**
  25212. * Release the associated resources for a specific mesh
  25213. * @param mesh defines the source mesh
  25214. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25215. */
  25216. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25217. /**
  25218. * Apply current geometry to a given mesh
  25219. * @param mesh defines the mesh to apply geometry to
  25220. */
  25221. applyToMesh(mesh: Mesh): void;
  25222. private _updateExtend;
  25223. private _applyToMesh;
  25224. private notifyUpdate;
  25225. /**
  25226. * Load the geometry if it was flagged as delay loaded
  25227. * @param scene defines the hosting scene
  25228. * @param onLoaded defines a callback called when the geometry is loaded
  25229. */
  25230. load(scene: Scene, onLoaded?: () => void): void;
  25231. private _queueLoad;
  25232. /**
  25233. * Invert the geometry to move from a right handed system to a left handed one.
  25234. */
  25235. toLeftHanded(): void;
  25236. /** @hidden */
  25237. _resetPointsArrayCache(): void;
  25238. /** @hidden */
  25239. _generatePointsArray(): boolean;
  25240. /**
  25241. * Gets a value indicating if the geometry is disposed
  25242. * @returns true if the geometry was disposed
  25243. */
  25244. isDisposed(): boolean;
  25245. private _disposeVertexArrayObjects;
  25246. /**
  25247. * Free all associated resources
  25248. */
  25249. dispose(): void;
  25250. /**
  25251. * Clone the current geometry into a new geometry
  25252. * @param id defines the unique ID of the new geometry
  25253. * @returns a new geometry object
  25254. */
  25255. copy(id: string): Geometry;
  25256. /**
  25257. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25258. * @return a JSON representation of the current geometry data (without the vertices data)
  25259. */
  25260. serialize(): any;
  25261. private toNumberArray;
  25262. /**
  25263. * Serialize all vertices data into a JSON oject
  25264. * @returns a JSON representation of the current geometry data
  25265. */
  25266. serializeVerticeData(): any;
  25267. /**
  25268. * Extracts a clone of a mesh geometry
  25269. * @param mesh defines the source mesh
  25270. * @param id defines the unique ID of the new geometry object
  25271. * @returns the new geometry object
  25272. */
  25273. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25274. /**
  25275. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25276. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25277. * Be aware Math.random() could cause collisions, but:
  25278. * "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"
  25279. * @returns a string containing a new GUID
  25280. */
  25281. static RandomId(): string;
  25282. /** @hidden */
  25283. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25284. private static _CleanMatricesWeights;
  25285. /**
  25286. * Create a new geometry from persisted data (Using .babylon file format)
  25287. * @param parsedVertexData defines the persisted data
  25288. * @param scene defines the hosting scene
  25289. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25290. * @returns the new geometry object
  25291. */
  25292. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25293. }
  25294. /**
  25295. * Abstract class used to provide common services for all typed geometries
  25296. * @hidden
  25297. */
  25298. class _PrimitiveGeometry extends Geometry {
  25299. private _canBeRegenerated;
  25300. private _beingRegenerated;
  25301. /**
  25302. * Creates a new typed geometry
  25303. * @param id defines the unique ID of the geometry
  25304. * @param scene defines the hosting scene
  25305. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25306. * @param mesh defines the hosting mesh (can be null)
  25307. */
  25308. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25309. /**
  25310. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25311. * @returns true if the geometry can be regenerated
  25312. */
  25313. canBeRegenerated(): boolean;
  25314. /**
  25315. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25316. */
  25317. regenerate(): void;
  25318. /**
  25319. * Clone the geometry
  25320. * @param id defines the unique ID of the new geometry
  25321. * @returns the new geometry
  25322. */
  25323. asNewGeometry(id: string): Geometry;
  25324. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25325. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25326. /** @hidden */
  25327. _regenerateVertexData(): VertexData;
  25328. copy(id: string): Geometry;
  25329. serialize(): any;
  25330. }
  25331. /**
  25332. * Creates a ribbon geometry
  25333. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25334. */
  25335. class RibbonGeometry extends _PrimitiveGeometry {
  25336. /**
  25337. * Defines the array of paths to use
  25338. */
  25339. pathArray: Vector3[][];
  25340. /**
  25341. * Defines if the last and first points of each path in your pathArray must be joined
  25342. */
  25343. closeArray: boolean;
  25344. /**
  25345. * Defines if the last and first points of each path in your pathArray must be joined
  25346. */
  25347. closePath: boolean;
  25348. /**
  25349. * Defines the offset between points
  25350. */
  25351. offset: number;
  25352. /**
  25353. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25354. */
  25355. side: number;
  25356. /**
  25357. * Creates a ribbon geometry
  25358. * @param id defines the unique ID of the geometry
  25359. * @param scene defines the hosting scene
  25360. * @param pathArray defines the array of paths to use
  25361. * @param closeArray defines if the last path and the first path must be joined
  25362. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25363. * @param offset defines the offset between points
  25364. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25365. * @param mesh defines the hosting mesh (can be null)
  25366. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25367. */
  25368. constructor(id: string, scene: Scene,
  25369. /**
  25370. * Defines the array of paths to use
  25371. */
  25372. pathArray: Vector3[][],
  25373. /**
  25374. * Defines if the last and first points of each path in your pathArray must be joined
  25375. */
  25376. closeArray: boolean,
  25377. /**
  25378. * Defines if the last and first points of each path in your pathArray must be joined
  25379. */
  25380. closePath: boolean,
  25381. /**
  25382. * Defines the offset between points
  25383. */
  25384. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25385. /**
  25386. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25387. */
  25388. side?: number);
  25389. /** @hidden */
  25390. _regenerateVertexData(): VertexData;
  25391. copy(id: string): Geometry;
  25392. }
  25393. /**
  25394. * Creates a box geometry
  25395. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25396. */
  25397. class BoxGeometry extends _PrimitiveGeometry {
  25398. /**
  25399. * Defines the zise of the box (width, height and depth are the same)
  25400. */
  25401. size: number;
  25402. /**
  25403. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25404. */
  25405. side: number;
  25406. /**
  25407. * Creates a box geometry
  25408. * @param id defines the unique ID of the geometry
  25409. * @param scene defines the hosting scene
  25410. * @param size defines the zise of the box (width, height and depth are the same)
  25411. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25412. * @param mesh defines the hosting mesh (can be null)
  25413. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25414. */
  25415. constructor(id: string, scene: Scene,
  25416. /**
  25417. * Defines the zise of the box (width, height and depth are the same)
  25418. */
  25419. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25420. /**
  25421. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25422. */
  25423. side?: number);
  25424. /** @hidden */
  25425. _regenerateVertexData(): VertexData;
  25426. copy(id: string): Geometry;
  25427. serialize(): any;
  25428. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25429. }
  25430. /**
  25431. * Creates a sphere geometry
  25432. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25433. */
  25434. class SphereGeometry extends _PrimitiveGeometry {
  25435. /**
  25436. * Defines the number of segments to use to create the sphere
  25437. */
  25438. segments: number;
  25439. /**
  25440. * Defines the diameter of the sphere
  25441. */
  25442. diameter: number;
  25443. /**
  25444. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25445. */
  25446. side: number;
  25447. /**
  25448. * Create a new sphere geometry
  25449. * @param id defines the unique ID of the geometry
  25450. * @param scene defines the hosting scene
  25451. * @param segments defines the number of segments to use to create the sphere
  25452. * @param diameter defines the diameter of the sphere
  25453. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25454. * @param mesh defines the hosting mesh (can be null)
  25455. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25456. */
  25457. constructor(id: string, scene: Scene,
  25458. /**
  25459. * Defines the number of segments to use to create the sphere
  25460. */
  25461. segments: number,
  25462. /**
  25463. * Defines the diameter of the sphere
  25464. */
  25465. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25466. /**
  25467. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25468. */
  25469. side?: number);
  25470. /** @hidden */
  25471. _regenerateVertexData(): VertexData;
  25472. copy(id: string): Geometry;
  25473. serialize(): any;
  25474. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25475. }
  25476. /**
  25477. * Creates a disc geometry
  25478. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25479. */
  25480. class DiscGeometry extends _PrimitiveGeometry {
  25481. /**
  25482. * Defines the radius of the disc
  25483. */
  25484. radius: number;
  25485. /**
  25486. * Defines the tesselation factor to apply to the disc
  25487. */
  25488. tessellation: number;
  25489. /**
  25490. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25491. */
  25492. side: number;
  25493. /**
  25494. * Creates a new disc geometry
  25495. * @param id defines the unique ID of the geometry
  25496. * @param scene defines the hosting scene
  25497. * @param radius defines the radius of the disc
  25498. * @param tessellation defines the tesselation factor to apply to the disc
  25499. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25500. * @param mesh defines the hosting mesh (can be null)
  25501. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25502. */
  25503. constructor(id: string, scene: Scene,
  25504. /**
  25505. * Defines the radius of the disc
  25506. */
  25507. radius: number,
  25508. /**
  25509. * Defines the tesselation factor to apply to the disc
  25510. */
  25511. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25512. /**
  25513. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25514. */
  25515. side?: number);
  25516. /** @hidden */
  25517. _regenerateVertexData(): VertexData;
  25518. copy(id: string): Geometry;
  25519. }
  25520. /**
  25521. * Creates a new cylinder geometry
  25522. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25523. */
  25524. class CylinderGeometry extends _PrimitiveGeometry {
  25525. /**
  25526. * Defines the height of the cylinder
  25527. */
  25528. height: number;
  25529. /**
  25530. * Defines the diameter of the cylinder's top cap
  25531. */
  25532. diameterTop: number;
  25533. /**
  25534. * Defines the diameter of the cylinder's bottom cap
  25535. */
  25536. diameterBottom: number;
  25537. /**
  25538. * Defines the tessellation factor to apply to the cylinder
  25539. */
  25540. tessellation: number;
  25541. /**
  25542. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25543. */
  25544. subdivisions: number;
  25545. /**
  25546. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25547. */
  25548. side: number;
  25549. /**
  25550. * Creates a new cylinder geometry
  25551. * @param id defines the unique ID of the geometry
  25552. * @param scene defines the hosting scene
  25553. * @param height defines the height of the cylinder
  25554. * @param diameterTop defines the diameter of the cylinder's top cap
  25555. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25556. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25557. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25558. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25559. * @param mesh defines the hosting mesh (can be null)
  25560. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25561. */
  25562. constructor(id: string, scene: Scene,
  25563. /**
  25564. * Defines the height of the cylinder
  25565. */
  25566. height: number,
  25567. /**
  25568. * Defines the diameter of the cylinder's top cap
  25569. */
  25570. diameterTop: number,
  25571. /**
  25572. * Defines the diameter of the cylinder's bottom cap
  25573. */
  25574. diameterBottom: number,
  25575. /**
  25576. * Defines the tessellation factor to apply to the cylinder
  25577. */
  25578. tessellation: number,
  25579. /**
  25580. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25581. */
  25582. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25583. /**
  25584. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25585. */
  25586. side?: number);
  25587. /** @hidden */
  25588. _regenerateVertexData(): VertexData;
  25589. copy(id: string): Geometry;
  25590. serialize(): any;
  25591. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25592. }
  25593. /**
  25594. * Creates a new torus geometry
  25595. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25596. */
  25597. class TorusGeometry extends _PrimitiveGeometry {
  25598. /**
  25599. * Defines the diameter of the torus
  25600. */
  25601. diameter: number;
  25602. /**
  25603. * Defines the thickness of the torus (ie. internal diameter)
  25604. */
  25605. thickness: number;
  25606. /**
  25607. * Defines the tesselation factor to apply to the torus
  25608. */
  25609. tessellation: number;
  25610. /**
  25611. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25612. */
  25613. side: number;
  25614. /**
  25615. * Creates a new torus geometry
  25616. * @param id defines the unique ID of the geometry
  25617. * @param scene defines the hosting scene
  25618. * @param diameter defines the diameter of the torus
  25619. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25620. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25621. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25622. * @param mesh defines the hosting mesh (can be null)
  25623. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25624. */
  25625. constructor(id: string, scene: Scene,
  25626. /**
  25627. * Defines the diameter of the torus
  25628. */
  25629. diameter: number,
  25630. /**
  25631. * Defines the thickness of the torus (ie. internal diameter)
  25632. */
  25633. thickness: number,
  25634. /**
  25635. * Defines the tesselation factor to apply to the torus
  25636. */
  25637. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25638. /**
  25639. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25640. */
  25641. side?: number);
  25642. /** @hidden */
  25643. _regenerateVertexData(): VertexData;
  25644. copy(id: string): Geometry;
  25645. serialize(): any;
  25646. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25647. }
  25648. /**
  25649. * Creates a new ground geometry
  25650. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25651. */
  25652. class GroundGeometry extends _PrimitiveGeometry {
  25653. /**
  25654. * Defines the width of the ground
  25655. */
  25656. width: number;
  25657. /**
  25658. * Defines the height of the ground
  25659. */
  25660. height: number;
  25661. /**
  25662. * Defines the subdivisions to apply to the ground
  25663. */
  25664. subdivisions: number;
  25665. /**
  25666. * Creates a new ground geometry
  25667. * @param id defines the unique ID of the geometry
  25668. * @param scene defines the hosting scene
  25669. * @param width defines the width of the ground
  25670. * @param height defines the height of the ground
  25671. * @param subdivisions defines the subdivisions to apply to the ground
  25672. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25673. * @param mesh defines the hosting mesh (can be null)
  25674. */
  25675. constructor(id: string, scene: Scene,
  25676. /**
  25677. * Defines the width of the ground
  25678. */
  25679. width: number,
  25680. /**
  25681. * Defines the height of the ground
  25682. */
  25683. height: number,
  25684. /**
  25685. * Defines the subdivisions to apply to the ground
  25686. */
  25687. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25688. /** @hidden */
  25689. _regenerateVertexData(): VertexData;
  25690. copy(id: string): Geometry;
  25691. serialize(): any;
  25692. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25693. }
  25694. /**
  25695. * Creates a tiled ground geometry
  25696. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25697. */
  25698. class TiledGroundGeometry extends _PrimitiveGeometry {
  25699. /**
  25700. * Defines the minimum value on X axis
  25701. */
  25702. xmin: number;
  25703. /**
  25704. * Defines the minimum value on Z axis
  25705. */
  25706. zmin: number;
  25707. /**
  25708. * Defines the maximum value on X axis
  25709. */
  25710. xmax: number;
  25711. /**
  25712. * Defines the maximum value on Z axis
  25713. */
  25714. zmax: number;
  25715. /**
  25716. * Defines the subdivisions to apply to the ground
  25717. */
  25718. subdivisions: {
  25719. w: number;
  25720. h: number;
  25721. };
  25722. /**
  25723. * Defines the precision to use when computing the tiles
  25724. */
  25725. precision: {
  25726. w: number;
  25727. h: number;
  25728. };
  25729. /**
  25730. * Creates a tiled ground geometry
  25731. * @param id defines the unique ID of the geometry
  25732. * @param scene defines the hosting scene
  25733. * @param xmin defines the minimum value on X axis
  25734. * @param zmin defines the minimum value on Z axis
  25735. * @param xmax defines the maximum value on X axis
  25736. * @param zmax defines the maximum value on Z axis
  25737. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25738. * @param precision defines the precision to use when computing the tiles
  25739. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25740. * @param mesh defines the hosting mesh (can be null)
  25741. */
  25742. constructor(id: string, scene: Scene,
  25743. /**
  25744. * Defines the minimum value on X axis
  25745. */
  25746. xmin: number,
  25747. /**
  25748. * Defines the minimum value on Z axis
  25749. */
  25750. zmin: number,
  25751. /**
  25752. * Defines the maximum value on X axis
  25753. */
  25754. xmax: number,
  25755. /**
  25756. * Defines the maximum value on Z axis
  25757. */
  25758. zmax: number,
  25759. /**
  25760. * Defines the subdivisions to apply to the ground
  25761. */
  25762. subdivisions: {
  25763. w: number;
  25764. h: number;
  25765. },
  25766. /**
  25767. * Defines the precision to use when computing the tiles
  25768. */
  25769. precision: {
  25770. w: number;
  25771. h: number;
  25772. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25773. /** @hidden */
  25774. _regenerateVertexData(): VertexData;
  25775. copy(id: string): Geometry;
  25776. }
  25777. /**
  25778. * Creates a plane geometry
  25779. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25780. */
  25781. class PlaneGeometry extends _PrimitiveGeometry {
  25782. /**
  25783. * Defines the size of the plane (width === height)
  25784. */
  25785. size: number;
  25786. /**
  25787. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25788. */
  25789. side: number;
  25790. /**
  25791. * Creates a plane geometry
  25792. * @param id defines the unique ID of the geometry
  25793. * @param scene defines the hosting scene
  25794. * @param size defines the size of the plane (width === height)
  25795. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25796. * @param mesh defines the hosting mesh (can be null)
  25797. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25798. */
  25799. constructor(id: string, scene: Scene,
  25800. /**
  25801. * Defines the size of the plane (width === height)
  25802. */
  25803. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25804. /**
  25805. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25806. */
  25807. side?: number);
  25808. /** @hidden */
  25809. _regenerateVertexData(): VertexData;
  25810. copy(id: string): Geometry;
  25811. serialize(): any;
  25812. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25813. }
  25814. /**
  25815. * Creates a torus knot geometry
  25816. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25817. */
  25818. class TorusKnotGeometry extends _PrimitiveGeometry {
  25819. /**
  25820. * Defines the radius of the torus knot
  25821. */
  25822. radius: number;
  25823. /**
  25824. * Defines the thickness of the torus knot tube
  25825. */
  25826. tube: number;
  25827. /**
  25828. * Defines the number of radial segments
  25829. */
  25830. radialSegments: number;
  25831. /**
  25832. * Defines the number of tubular segments
  25833. */
  25834. tubularSegments: number;
  25835. /**
  25836. * Defines the first number of windings
  25837. */
  25838. p: number;
  25839. /**
  25840. * Defines the second number of windings
  25841. */
  25842. q: number;
  25843. /**
  25844. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25845. */
  25846. side: number;
  25847. /**
  25848. * Creates a torus knot geometry
  25849. * @param id defines the unique ID of the geometry
  25850. * @param scene defines the hosting scene
  25851. * @param radius defines the radius of the torus knot
  25852. * @param tube defines the thickness of the torus knot tube
  25853. * @param radialSegments defines the number of radial segments
  25854. * @param tubularSegments defines the number of tubular segments
  25855. * @param p defines the first number of windings
  25856. * @param q defines the second number of windings
  25857. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25858. * @param mesh defines the hosting mesh (can be null)
  25859. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25860. */
  25861. constructor(id: string, scene: Scene,
  25862. /**
  25863. * Defines the radius of the torus knot
  25864. */
  25865. radius: number,
  25866. /**
  25867. * Defines the thickness of the torus knot tube
  25868. */
  25869. tube: number,
  25870. /**
  25871. * Defines the number of radial segments
  25872. */
  25873. radialSegments: number,
  25874. /**
  25875. * Defines the number of tubular segments
  25876. */
  25877. tubularSegments: number,
  25878. /**
  25879. * Defines the first number of windings
  25880. */
  25881. p: number,
  25882. /**
  25883. * Defines the second number of windings
  25884. */
  25885. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25886. /**
  25887. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25888. */
  25889. side?: number);
  25890. /** @hidden */
  25891. _regenerateVertexData(): VertexData;
  25892. copy(id: string): Geometry;
  25893. serialize(): any;
  25894. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25895. }
  25896. }
  25897. declare module BABYLON {
  25898. /**
  25899. * Mesh representing the gorund
  25900. */
  25901. class GroundMesh extends Mesh {
  25902. /** If octree should be generated */
  25903. generateOctree: boolean;
  25904. private _heightQuads;
  25905. /** @hidden */
  25906. _subdivisionsX: number;
  25907. /** @hidden */
  25908. _subdivisionsY: number;
  25909. /** @hidden */
  25910. _width: number;
  25911. /** @hidden */
  25912. _height: number;
  25913. /** @hidden */
  25914. _minX: number;
  25915. /** @hidden */
  25916. _maxX: number;
  25917. /** @hidden */
  25918. _minZ: number;
  25919. /** @hidden */
  25920. _maxZ: number;
  25921. constructor(name: string, scene: Scene);
  25922. /**
  25923. * "GroundMesh"
  25924. * @returns "GroundMesh"
  25925. */
  25926. getClassName(): string;
  25927. /**
  25928. * The minimum of x and y subdivisions
  25929. */
  25930. readonly subdivisions: number;
  25931. /**
  25932. * X subdivisions
  25933. */
  25934. readonly subdivisionsX: number;
  25935. /**
  25936. * Y subdivisions
  25937. */
  25938. readonly subdivisionsY: number;
  25939. /**
  25940. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25941. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25942. * @param chunksCount the number of subdivisions for x and y
  25943. * @param octreeBlocksSize (Default: 32)
  25944. */
  25945. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25946. /**
  25947. * Returns a height (y) value in the Worl system :
  25948. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25949. * @param x x coordinate
  25950. * @param z z coordinate
  25951. * @returns the ground y position if (x, z) are outside the ground surface.
  25952. */
  25953. getHeightAtCoordinates(x: number, z: number): number;
  25954. /**
  25955. * Returns a normalized vector (Vector3) orthogonal to the ground
  25956. * at the ground coordinates (x, z) expressed in the World system.
  25957. * @param x x coordinate
  25958. * @param z z coordinate
  25959. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25960. */
  25961. getNormalAtCoordinates(x: number, z: number): Vector3;
  25962. /**
  25963. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25964. * at the ground coordinates (x, z) expressed in the World system.
  25965. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25966. * @param x x coordinate
  25967. * @param z z coordinate
  25968. * @param ref vector to store the result
  25969. * @returns the GroundMesh.
  25970. */
  25971. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25972. /**
  25973. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25974. * if the ground has been updated.
  25975. * This can be used in the render loop.
  25976. * @returns the GroundMesh.
  25977. */
  25978. updateCoordinateHeights(): GroundMesh;
  25979. private _getFacetAt;
  25980. private _initHeightQuads;
  25981. private _computeHeightQuads;
  25982. /**
  25983. * Serializes this ground mesh
  25984. * @param serializationObject object to write serialization to
  25985. */
  25986. serialize(serializationObject: any): void;
  25987. /**
  25988. * Parses a serialized ground mesh
  25989. * @param parsedMesh the serialized mesh
  25990. * @param scene the scene to create the ground mesh in
  25991. * @returns the created ground mesh
  25992. */
  25993. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25994. }
  25995. }
  25996. declare module BABYLON {
  25997. /**
  25998. * Creates an instance based on a source mesh.
  25999. */
  26000. class InstancedMesh extends AbstractMesh {
  26001. private _sourceMesh;
  26002. private _currentLOD;
  26003. /** @hidden */
  26004. _indexInSourceMeshInstanceArray: number;
  26005. constructor(name: string, source: Mesh);
  26006. /**
  26007. * Returns the string "InstancedMesh".
  26008. */
  26009. getClassName(): string;
  26010. /**
  26011. * If the source mesh receives shadows
  26012. */
  26013. readonly receiveShadows: boolean;
  26014. /**
  26015. * The material of the source mesh
  26016. */
  26017. readonly material: Nullable<Material>;
  26018. /**
  26019. * Visibility of the source mesh
  26020. */
  26021. readonly visibility: number;
  26022. /**
  26023. * Skeleton of the source mesh
  26024. */
  26025. readonly skeleton: Nullable<Skeleton>;
  26026. /**
  26027. * Rendering ground id of the source mesh
  26028. */
  26029. renderingGroupId: number;
  26030. /**
  26031. * Returns the total number of vertices (integer).
  26032. */
  26033. getTotalVertices(): number;
  26034. /**
  26035. * The source mesh of the instance
  26036. */
  26037. readonly sourceMesh: Mesh;
  26038. /**
  26039. * Is this node ready to be used/rendered
  26040. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26041. * @return {boolean} is it ready
  26042. */
  26043. isReady(completeCheck?: boolean): boolean;
  26044. /**
  26045. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26046. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26047. * @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.
  26048. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26049. */
  26050. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26051. /**
  26052. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26053. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26054. * The `data` are either a numeric array either a Float32Array.
  26055. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26056. * 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).
  26057. * Note that a new underlying VertexBuffer object is created each call.
  26058. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26059. *
  26060. * Possible `kind` values :
  26061. * - BABYLON.VertexBuffer.PositionKind
  26062. * - BABYLON.VertexBuffer.UVKind
  26063. * - BABYLON.VertexBuffer.UV2Kind
  26064. * - BABYLON.VertexBuffer.UV3Kind
  26065. * - BABYLON.VertexBuffer.UV4Kind
  26066. * - BABYLON.VertexBuffer.UV5Kind
  26067. * - BABYLON.VertexBuffer.UV6Kind
  26068. * - BABYLON.VertexBuffer.ColorKind
  26069. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26070. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26071. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26072. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26073. *
  26074. * Returns the Mesh.
  26075. */
  26076. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26077. /**
  26078. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26079. * If the mesh has no geometry, it is simply returned as it is.
  26080. * The `data` are either a numeric array either a Float32Array.
  26081. * No new underlying VertexBuffer object is created.
  26082. * 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.
  26083. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26084. *
  26085. * Possible `kind` values :
  26086. * - BABYLON.VertexBuffer.PositionKind
  26087. * - BABYLON.VertexBuffer.UVKind
  26088. * - BABYLON.VertexBuffer.UV2Kind
  26089. * - BABYLON.VertexBuffer.UV3Kind
  26090. * - BABYLON.VertexBuffer.UV4Kind
  26091. * - BABYLON.VertexBuffer.UV5Kind
  26092. * - BABYLON.VertexBuffer.UV6Kind
  26093. * - BABYLON.VertexBuffer.ColorKind
  26094. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26095. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26096. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26097. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26098. *
  26099. * Returns the Mesh.
  26100. */
  26101. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26102. /**
  26103. * Sets the mesh indices.
  26104. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26105. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26106. * This method creates a new index buffer each call.
  26107. * Returns the Mesh.
  26108. */
  26109. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26110. /**
  26111. * Boolean : True if the mesh owns the requested kind of data.
  26112. */
  26113. isVerticesDataPresent(kind: string): boolean;
  26114. /**
  26115. * Returns an array of indices (IndicesArray).
  26116. */
  26117. getIndices(): Nullable<IndicesArray>;
  26118. readonly _positions: Nullable<Vector3[]>;
  26119. /**
  26120. * Sets a new updated BoundingInfo to the mesh.
  26121. * @returns the mesh.
  26122. */
  26123. refreshBoundingInfo(): InstancedMesh;
  26124. /** @hidden */
  26125. _preActivate(): InstancedMesh;
  26126. /** @hidden */
  26127. _activate(renderId: number): InstancedMesh;
  26128. /**
  26129. * Returns the current associated LOD AbstractMesh.
  26130. */
  26131. getLOD(camera: Camera): AbstractMesh;
  26132. /** @hidden */
  26133. _syncSubMeshes(): InstancedMesh;
  26134. /** @hidden */
  26135. _generatePointsArray(): boolean;
  26136. /**
  26137. * Creates a new InstancedMesh from the current mesh.
  26138. * - name (string) : the cloned mesh name
  26139. * - newParent (optional Node) : the optional Node to parent the clone to.
  26140. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26141. *
  26142. * Returns the clone.
  26143. */
  26144. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26145. /**
  26146. * Disposes the InstancedMesh.
  26147. * Returns nothing.
  26148. */
  26149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26150. }
  26151. }
  26152. declare module BABYLON {
  26153. /**
  26154. * Line mesh
  26155. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26156. */
  26157. class LinesMesh extends Mesh {
  26158. /**
  26159. * If vertex color should be applied to the mesh
  26160. */
  26161. useVertexColor?: boolean | undefined;
  26162. /**
  26163. * If vertex alpha should be applied to the mesh
  26164. */
  26165. useVertexAlpha?: boolean | undefined;
  26166. /**
  26167. * Color of the line (Default: White)
  26168. */
  26169. color: Color3;
  26170. /**
  26171. * Alpha of the line (Default: 1)
  26172. */
  26173. alpha: number;
  26174. /**
  26175. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26176. * This margin is expressed in world space coordinates, so its value may vary.
  26177. * Default value is 0.1
  26178. * @returns the intersection Threshold value.
  26179. */
  26180. /**
  26181. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26182. * This margin is expressed in world space coordinates, so its value may vary.
  26183. */
  26184. intersectionThreshold: number;
  26185. private _intersectionThreshold;
  26186. private _colorShader;
  26187. /**
  26188. * Creates a new LinesMesh
  26189. * @param name defines the name
  26190. * @param scene defines the hosting scene
  26191. * @param parent defines the parent mesh if any
  26192. * @param source defines the optional source LinesMesh used to clone data from
  26193. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26194. * When false, achieved by calling a clone(), also passing False.
  26195. * This will make creation of children, recursive.
  26196. * @param useVertexColor defines if this LinesMesh supports vertex color
  26197. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26198. */
  26199. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26200. /**
  26201. * If vertex color should be applied to the mesh
  26202. */
  26203. useVertexColor?: boolean | undefined,
  26204. /**
  26205. * If vertex alpha should be applied to the mesh
  26206. */
  26207. useVertexAlpha?: boolean | undefined);
  26208. /**
  26209. * Returns the string "LineMesh"
  26210. */
  26211. getClassName(): string;
  26212. /**
  26213. * @hidden
  26214. */
  26215. /**
  26216. * @hidden
  26217. */
  26218. material: Material;
  26219. /**
  26220. * @hidden
  26221. */
  26222. readonly checkCollisions: boolean;
  26223. /** @hidden */
  26224. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26225. /** @hidden */
  26226. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26227. /**
  26228. * Disposes of the line mesh
  26229. * @param doNotRecurse If children should be disposed
  26230. */
  26231. dispose(doNotRecurse?: boolean): void;
  26232. /**
  26233. * Returns a new LineMesh object cloned from the current one.
  26234. */
  26235. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26236. }
  26237. }
  26238. declare module BABYLON {
  26239. /**
  26240. * @hidden
  26241. **/
  26242. class _CreationDataStorage {
  26243. closePath?: boolean;
  26244. closeArray?: boolean;
  26245. idx: number[];
  26246. dashSize: number;
  26247. gapSize: number;
  26248. path3D: Path3D;
  26249. pathArray: Vector3[][];
  26250. arc: number;
  26251. radius: number;
  26252. cap: number;
  26253. tessellation: number;
  26254. }
  26255. /**
  26256. * @hidden
  26257. **/
  26258. class _InstanceDataStorage {
  26259. visibleInstances: any;
  26260. renderIdForInstances: number[];
  26261. batchCache: _InstancesBatch;
  26262. instancesBufferSize: number;
  26263. instancesBuffer: Nullable<Buffer>;
  26264. instancesData: Float32Array;
  26265. overridenInstanceCount: number;
  26266. }
  26267. /**
  26268. * @hidden
  26269. **/
  26270. class _InstancesBatch {
  26271. mustReturn: boolean;
  26272. visibleInstances: Nullable<InstancedMesh[]>[];
  26273. renderSelf: boolean[];
  26274. }
  26275. /**
  26276. * Class used to represent renderable models
  26277. */
  26278. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26279. /**
  26280. * Mesh side orientation : usually the external or front surface
  26281. */
  26282. static readonly FRONTSIDE: number;
  26283. /**
  26284. * Mesh side orientation : usually the internal or back surface
  26285. */
  26286. static readonly BACKSIDE: number;
  26287. /**
  26288. * Mesh side orientation : both internal and external or front and back surfaces
  26289. */
  26290. static readonly DOUBLESIDE: number;
  26291. /**
  26292. * Mesh side orientation : by default, `FRONTSIDE`
  26293. */
  26294. static readonly DEFAULTSIDE: number;
  26295. /**
  26296. * Mesh cap setting : no cap
  26297. */
  26298. static readonly NO_CAP: number;
  26299. /**
  26300. * Mesh cap setting : one cap at the beginning of the mesh
  26301. */
  26302. static readonly CAP_START: number;
  26303. /**
  26304. * Mesh cap setting : one cap at the end of the mesh
  26305. */
  26306. static readonly CAP_END: number;
  26307. /**
  26308. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26309. */
  26310. static readonly CAP_ALL: number;
  26311. private _onBeforeRenderObservable;
  26312. private _onAfterRenderObservable;
  26313. private _onBeforeDrawObservable;
  26314. /**
  26315. * An event triggered before rendering the mesh
  26316. */
  26317. readonly onBeforeRenderObservable: Observable<Mesh>;
  26318. /**
  26319. * An event triggered after rendering the mesh
  26320. */
  26321. readonly onAfterRenderObservable: Observable<Mesh>;
  26322. /**
  26323. * An event triggered before drawing the mesh
  26324. */
  26325. readonly onBeforeDrawObservable: Observable<Mesh>;
  26326. private _onBeforeDrawObserver;
  26327. /**
  26328. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26329. */
  26330. onBeforeDraw: () => void;
  26331. /**
  26332. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26333. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26334. */
  26335. delayLoadState: number;
  26336. /**
  26337. * Gets the list of instances created from this mesh
  26338. * it is not supposed to be modified manually.
  26339. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26340. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26341. */
  26342. instances: InstancedMesh[];
  26343. /**
  26344. * Gets the file containing delay loading data for this mesh
  26345. */
  26346. delayLoadingFile: string;
  26347. /** @hidden */
  26348. _binaryInfo: any;
  26349. private _LODLevels;
  26350. /**
  26351. * User defined function used to change how LOD level selection is done
  26352. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26353. */
  26354. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26355. private _morphTargetManager;
  26356. /**
  26357. * Gets or sets the morph target manager
  26358. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26359. */
  26360. morphTargetManager: Nullable<MorphTargetManager>;
  26361. /** @hidden */
  26362. _creationDataStorage: Nullable<_CreationDataStorage>;
  26363. /** @hidden */
  26364. _geometry: Nullable<Geometry>;
  26365. /** @hidden */
  26366. _delayInfo: Array<string>;
  26367. /** @hidden */
  26368. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26369. /** @hidden */
  26370. _instanceDataStorage: _InstanceDataStorage;
  26371. private _effectiveMaterial;
  26372. /** @hidden */
  26373. _shouldGenerateFlatShading: boolean;
  26374. private _preActivateId;
  26375. /** @hidden */
  26376. _originalBuilderSideOrientation: number;
  26377. /**
  26378. * Use this property to change the original side orientation defined at construction time
  26379. */
  26380. overrideMaterialSideOrientation: Nullable<number>;
  26381. private _areNormalsFrozen;
  26382. private _sourcePositions;
  26383. private _sourceNormals;
  26384. private _source;
  26385. private meshMap;
  26386. /**
  26387. * Gets the source mesh (the one used to clone this one from)
  26388. */
  26389. readonly source: Nullable<Mesh>;
  26390. /**
  26391. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26392. */
  26393. isUnIndexed: boolean;
  26394. /**
  26395. * @constructor
  26396. * @param name The value used by scene.getMeshByName() to do a lookup.
  26397. * @param scene The scene to add this mesh to.
  26398. * @param parent The parent of this mesh, if it has one
  26399. * @param source An optional Mesh from which geometry is shared, cloned.
  26400. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26401. * When false, achieved by calling a clone(), also passing False.
  26402. * This will make creation of children, recursive.
  26403. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26404. */
  26405. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26406. /**
  26407. * Gets the class name
  26408. * @returns the string "Mesh".
  26409. */
  26410. getClassName(): string;
  26411. /**
  26412. * Returns a description of this mesh
  26413. * @param fullDetails define if full details about this mesh must be used
  26414. * @returns a descriptive string representing this mesh
  26415. */
  26416. toString(fullDetails?: boolean): string;
  26417. /** @hidden */
  26418. _unBindEffect(): void;
  26419. /**
  26420. * Gets a boolean indicating if this mesh has LOD
  26421. */
  26422. readonly hasLODLevels: boolean;
  26423. /**
  26424. * Gets the list of MeshLODLevel associated with the current mesh
  26425. * @returns an array of MeshLODLevel
  26426. */
  26427. getLODLevels(): MeshLODLevel[];
  26428. private _sortLODLevels;
  26429. /**
  26430. * Add a mesh as LOD level triggered at the given distance.
  26431. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26432. * @param distance The distance from the center of the object to show this level
  26433. * @param mesh The mesh to be added as LOD level (can be null)
  26434. * @return This mesh (for chaining)
  26435. */
  26436. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26437. /**
  26438. * Returns the LOD level mesh at the passed distance or null if not found.
  26439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26440. * @param distance The distance from the center of the object to show this level
  26441. * @returns a Mesh or `null`
  26442. */
  26443. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26444. /**
  26445. * Remove a mesh from the LOD array
  26446. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26447. * @param mesh defines the mesh to be removed
  26448. * @return This mesh (for chaining)
  26449. */
  26450. removeLODLevel(mesh: Mesh): Mesh;
  26451. /**
  26452. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26454. * @param camera defines the camera to use to compute distance
  26455. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26456. * @return This mesh (for chaining)
  26457. */
  26458. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26459. /**
  26460. * Gets the mesh internal Geometry object
  26461. */
  26462. readonly geometry: Nullable<Geometry>;
  26463. /**
  26464. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26465. * @returns the total number of vertices
  26466. */
  26467. getTotalVertices(): number;
  26468. /**
  26469. * Returns the content of an associated vertex buffer
  26470. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26471. * - BABYLON.VertexBuffer.PositionKind
  26472. * - BABYLON.VertexBuffer.UVKind
  26473. * - BABYLON.VertexBuffer.UV2Kind
  26474. * - BABYLON.VertexBuffer.UV3Kind
  26475. * - BABYLON.VertexBuffer.UV4Kind
  26476. * - BABYLON.VertexBuffer.UV5Kind
  26477. * - BABYLON.VertexBuffer.UV6Kind
  26478. * - BABYLON.VertexBuffer.ColorKind
  26479. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26480. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26481. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26482. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26483. * @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
  26484. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26485. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26486. */
  26487. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26488. /**
  26489. * Returns the mesh VertexBuffer object from the requested `kind`
  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. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26504. */
  26505. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26506. /**
  26507. * Tests if a specific vertex buffer is associated with this mesh
  26508. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26509. * - BABYLON.VertexBuffer.PositionKind
  26510. * - BABYLON.VertexBuffer.UVKind
  26511. * - BABYLON.VertexBuffer.UV2Kind
  26512. * - BABYLON.VertexBuffer.UV3Kind
  26513. * - BABYLON.VertexBuffer.UV4Kind
  26514. * - BABYLON.VertexBuffer.UV5Kind
  26515. * - BABYLON.VertexBuffer.UV6Kind
  26516. * - BABYLON.VertexBuffer.ColorKind
  26517. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26518. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26519. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26520. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26521. * @returns a boolean
  26522. */
  26523. isVerticesDataPresent(kind: string): boolean;
  26524. /**
  26525. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26526. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26527. * - BABYLON.VertexBuffer.PositionKind
  26528. * - BABYLON.VertexBuffer.UVKind
  26529. * - BABYLON.VertexBuffer.UV2Kind
  26530. * - BABYLON.VertexBuffer.UV3Kind
  26531. * - BABYLON.VertexBuffer.UV4Kind
  26532. * - BABYLON.VertexBuffer.UV5Kind
  26533. * - BABYLON.VertexBuffer.UV6Kind
  26534. * - BABYLON.VertexBuffer.ColorKind
  26535. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26536. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26537. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26538. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26539. * @returns a boolean
  26540. */
  26541. isVertexBufferUpdatable(kind: string): boolean;
  26542. /**
  26543. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26544. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26545. * - BABYLON.VertexBuffer.PositionKind
  26546. * - BABYLON.VertexBuffer.UVKind
  26547. * - BABYLON.VertexBuffer.UV2Kind
  26548. * - BABYLON.VertexBuffer.UV3Kind
  26549. * - BABYLON.VertexBuffer.UV4Kind
  26550. * - BABYLON.VertexBuffer.UV5Kind
  26551. * - BABYLON.VertexBuffer.UV6Kind
  26552. * - BABYLON.VertexBuffer.ColorKind
  26553. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26554. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26555. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26556. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26557. * @returns an array of strings
  26558. */
  26559. getVerticesDataKinds(): string[];
  26560. /**
  26561. * Returns a positive integer : the total number of indices in this mesh geometry.
  26562. * @returns the numner of indices or zero if the mesh has no geometry.
  26563. */
  26564. getTotalIndices(): number;
  26565. /**
  26566. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26567. * @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.
  26568. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26569. * @returns the indices array or an empty array if the mesh has no geometry
  26570. */
  26571. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26572. readonly isBlocked: boolean;
  26573. /**
  26574. * Determine if the current mesh is ready to be rendered
  26575. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26576. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26577. * @returns true if all associated assets are ready (material, textures, shaders)
  26578. */
  26579. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26580. /**
  26581. * 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.
  26582. */
  26583. readonly areNormalsFrozen: boolean;
  26584. /**
  26585. * 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.
  26586. * @returns the current mesh
  26587. */
  26588. freezeNormals(): Mesh;
  26589. /**
  26590. * 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
  26591. * @returns the current mesh
  26592. */
  26593. unfreezeNormals(): Mesh;
  26594. /**
  26595. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26596. */
  26597. overridenInstanceCount: number;
  26598. /** @hidden */
  26599. _preActivate(): Mesh;
  26600. /** @hidden */
  26601. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26602. /** @hidden */
  26603. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26604. /**
  26605. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26606. * This means the mesh underlying bounding box and sphere are recomputed.
  26607. * @returns the current mesh
  26608. */
  26609. refreshBoundingInfo(): Mesh;
  26610. /** @hidden */
  26611. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26612. private _getPositionData;
  26613. /** @hidden */
  26614. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26615. /**
  26616. * This function will subdivide the mesh into multiple submeshes
  26617. * @param count defines the expected number of submeshes
  26618. */
  26619. subdivide(count: number): void;
  26620. /**
  26621. * Copy a FloatArray into a specific associated vertex buffer
  26622. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26623. * - BABYLON.VertexBuffer.PositionKind
  26624. * - BABYLON.VertexBuffer.UVKind
  26625. * - BABYLON.VertexBuffer.UV2Kind
  26626. * - BABYLON.VertexBuffer.UV3Kind
  26627. * - BABYLON.VertexBuffer.UV4Kind
  26628. * - BABYLON.VertexBuffer.UV5Kind
  26629. * - BABYLON.VertexBuffer.UV6Kind
  26630. * - BABYLON.VertexBuffer.ColorKind
  26631. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26632. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26633. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26634. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26635. * @param data defines the data source
  26636. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26637. * @param stride defines the data stride size (can be null)
  26638. * @returns the current mesh
  26639. */
  26640. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26641. /**
  26642. * Flags an associated vertex buffer as updatable
  26643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26644. * - BABYLON.VertexBuffer.PositionKind
  26645. * - BABYLON.VertexBuffer.UVKind
  26646. * - BABYLON.VertexBuffer.UV2Kind
  26647. * - BABYLON.VertexBuffer.UV3Kind
  26648. * - BABYLON.VertexBuffer.UV4Kind
  26649. * - BABYLON.VertexBuffer.UV5Kind
  26650. * - BABYLON.VertexBuffer.UV6Kind
  26651. * - BABYLON.VertexBuffer.ColorKind
  26652. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26653. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26654. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26655. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26657. */
  26658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26659. /**
  26660. * Sets the mesh global Vertex Buffer
  26661. * @param buffer defines the buffer to use
  26662. * @returns the current mesh
  26663. */
  26664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26665. /**
  26666. * Update a specific associated vertex buffer
  26667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26668. * - BABYLON.VertexBuffer.PositionKind
  26669. * - BABYLON.VertexBuffer.UVKind
  26670. * - BABYLON.VertexBuffer.UV2Kind
  26671. * - BABYLON.VertexBuffer.UV3Kind
  26672. * - BABYLON.VertexBuffer.UV4Kind
  26673. * - BABYLON.VertexBuffer.UV5Kind
  26674. * - BABYLON.VertexBuffer.UV6Kind
  26675. * - BABYLON.VertexBuffer.ColorKind
  26676. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26677. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26678. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26679. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26680. * @param data defines the data source
  26681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26682. * @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)
  26683. * @returns the current mesh
  26684. */
  26685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26686. /**
  26687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26691. * @returns the current mesh
  26692. */
  26693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26694. /**
  26695. * Creates a un-shared specific occurence of the geometry for the mesh.
  26696. * @returns the current mesh
  26697. */
  26698. makeGeometryUnique(): Mesh;
  26699. /**
  26700. * Set the index buffer of this mesh
  26701. * @param indices defines the source data
  26702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26704. * @returns the current mesh
  26705. */
  26706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26707. /**
  26708. * Update the current index buffer
  26709. * @param indices defines the source data
  26710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26711. * @returns the current mesh
  26712. */
  26713. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26714. /**
  26715. * Invert the geometry to move from a right handed system to a left handed one.
  26716. * @returns the current mesh
  26717. */
  26718. toLeftHanded(): Mesh;
  26719. /** @hidden */
  26720. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26721. /** @hidden */
  26722. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26723. /**
  26724. * Registers for this mesh a javascript function called just before the rendering process
  26725. * @param func defines the function to call before rendering this mesh
  26726. * @returns the current mesh
  26727. */
  26728. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26729. /**
  26730. * Disposes a previously registered javascript function called before the rendering
  26731. * @param func defines the function to remove
  26732. * @returns the current mesh
  26733. */
  26734. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26735. /**
  26736. * Registers for this mesh a javascript function called just after the rendering is complete
  26737. * @param func defines the function to call after rendering this mesh
  26738. * @returns the current mesh
  26739. */
  26740. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26741. /**
  26742. * Disposes a previously registered javascript function called after the rendering.
  26743. * @param func defines the function to remove
  26744. * @returns the current mesh
  26745. */
  26746. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26747. /** @hidden */
  26748. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26749. /** @hidden */
  26750. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26751. /** @hidden */
  26752. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26753. /**
  26754. * 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
  26755. * @param subMesh defines the subMesh to render
  26756. * @param enableAlphaMode defines if alpha mode can be changed
  26757. * @returns the current mesh
  26758. */
  26759. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26760. private _onBeforeDraw;
  26761. /**
  26762. * Renormalize the mesh and patch it up if there are no weights
  26763. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26764. * However in the case of zero weights then we set just a single influence to 1.
  26765. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26766. */
  26767. cleanMatrixWeights(): void;
  26768. private normalizeSkinFourWeights;
  26769. private normalizeSkinWeightsAndExtra;
  26770. /**
  26771. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26772. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26773. * the user know there was an issue with importing the mesh
  26774. * @returns a validation object with skinned, valid and report string
  26775. */
  26776. validateSkinning(): {
  26777. skinned: boolean;
  26778. valid: boolean;
  26779. report: string;
  26780. };
  26781. /** @hidden */
  26782. _checkDelayState(): Mesh;
  26783. private _queueLoad;
  26784. /**
  26785. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26786. * A mesh is in the frustum if its bounding box intersects the frustum
  26787. * @param frustumPlanes defines the frustum to test
  26788. * @returns true if the mesh is in the frustum planes
  26789. */
  26790. isInFrustum(frustumPlanes: Plane[]): boolean;
  26791. /**
  26792. * Sets the mesh material by the material or multiMaterial `id` property
  26793. * @param id is a string identifying the material or the multiMaterial
  26794. * @returns the current mesh
  26795. */
  26796. setMaterialByID(id: string): Mesh;
  26797. /**
  26798. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26799. * @returns an array of IAnimatable
  26800. */
  26801. getAnimatables(): IAnimatable[];
  26802. /**
  26803. * Modifies the mesh geometry according to the passed transformation matrix.
  26804. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26805. * The mesh normals are modified using the same transformation.
  26806. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26807. * @param transform defines the transform matrix to use
  26808. * @see http://doc.babylonjs.com/resources/baking_transformations
  26809. * @returns the current mesh
  26810. */
  26811. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26812. /**
  26813. * Modifies the mesh geometry according to its own current World Matrix.
  26814. * The mesh World Matrix is then reset.
  26815. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26817. * @see http://doc.babylonjs.com/resources/baking_transformations
  26818. * @returns the current mesh
  26819. */
  26820. bakeCurrentTransformIntoVertices(): Mesh;
  26821. /** @hidden */
  26822. readonly _positions: Nullable<Vector3[]>;
  26823. /** @hidden */
  26824. _resetPointsArrayCache(): Mesh;
  26825. /** @hidden */
  26826. _generatePointsArray(): boolean;
  26827. /**
  26828. * Returns a new Mesh object generated from the current mesh properties.
  26829. * This method must not get confused with createInstance()
  26830. * @param name is a string, the name given to the new mesh
  26831. * @param newParent can be any Node object (default `null`)
  26832. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26833. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26834. * @returns a new mesh
  26835. */
  26836. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26837. /**
  26838. * Releases resources associated with this mesh.
  26839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26841. */
  26842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26843. /**
  26844. * Modifies the mesh geometry according to a displacement map.
  26845. * 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.
  26846. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26847. * @param url is a string, the URL from the image file is to be downloaded.
  26848. * @param minHeight is the lower limit of the displacement.
  26849. * @param maxHeight is the upper limit of the displacement.
  26850. * @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.
  26851. * @param uvOffset is an optional vector2 used to offset UV.
  26852. * @param uvScale is an optional vector2 used to scale UV.
  26853. * @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.
  26854. * @returns the Mesh.
  26855. */
  26856. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26857. /**
  26858. * Modifies the mesh geometry according to a displacementMap buffer.
  26859. * 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.
  26860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26861. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26862. * @param heightMapWidth is the width of the buffer image.
  26863. * @param heightMapHeight is the height of the buffer image.
  26864. * @param minHeight is the lower limit of the displacement.
  26865. * @param maxHeight is the upper limit of the displacement.
  26866. * @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.
  26867. * @param uvOffset is an optional vector2 used to offset UV.
  26868. * @param uvScale is an optional vector2 used to scale UV.
  26869. * @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.
  26870. * @returns the Mesh.
  26871. */
  26872. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26873. /**
  26874. * Modify the mesh to get a flat shading rendering.
  26875. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26876. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26877. * @returns current mesh
  26878. */
  26879. convertToFlatShadedMesh(): Mesh;
  26880. /**
  26881. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26882. * In other words, more vertices, no more indices and a single bigger VBO.
  26883. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26884. * @returns current mesh
  26885. */
  26886. convertToUnIndexedMesh(): Mesh;
  26887. /**
  26888. * Inverses facet orientations.
  26889. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26890. * @param flipNormals will also inverts the normals
  26891. * @returns current mesh
  26892. */
  26893. flipFaces(flipNormals?: boolean): Mesh;
  26894. /**
  26895. * Creates a new InstancedMesh object from the mesh model.
  26896. * Warning : this method is not supported for Line mesh and LineSystem
  26897. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26898. * @param name defines the name of the new instance
  26899. * @returns a new InstancedMesh
  26900. */
  26901. createInstance(name: string): InstancedMesh;
  26902. /**
  26903. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26904. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26905. * @returns the current mesh
  26906. */
  26907. synchronizeInstances(): Mesh;
  26908. /**
  26909. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26910. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26911. * This should be used together with the simplification to avoid disappearing triangles.
  26912. * @param successCallback an optional success callback to be called after the optimization finished.
  26913. * @returns the current mesh
  26914. */
  26915. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26916. /**
  26917. * Serialize current mesh
  26918. * @param serializationObject defines the object which will receive the serialization data
  26919. */
  26920. serialize(serializationObject: any): void;
  26921. /** @hidden */
  26922. _syncGeometryWithMorphTargetManager(): void;
  26923. /**
  26924. * Returns a new Mesh object parsed from the source provided.
  26925. * @param parsedMesh is the source
  26926. * @param scene defines the hosting scene
  26927. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26928. * @returns a new Mesh
  26929. */
  26930. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26931. /**
  26932. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26933. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26934. * @param name defines the name of the mesh to create
  26935. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26936. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26937. * @param closePath creates a seam between the first and the last points of each path of the path array
  26938. * @param offset is taken in account only if the `pathArray` is containing a single path
  26939. * @param scene defines the hosting scene
  26940. * @param updatable defines if the mesh must be flagged as updatable
  26941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26942. * @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)
  26943. * @returns a new Mesh
  26944. */
  26945. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26946. /**
  26947. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26948. * @param name defines the name of the mesh to create
  26949. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26950. * @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
  26951. * @param scene defines the hosting scene
  26952. * @param updatable defines if the mesh must be flagged as updatable
  26953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26954. * @returns a new Mesh
  26955. */
  26956. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26957. /**
  26958. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26959. * @param name defines the name of the mesh to create
  26960. * @param size sets the size (float) of each box side (default 1)
  26961. * @param scene defines the hosting scene
  26962. * @param updatable defines if the mesh must be flagged as updatable
  26963. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26964. * @returns a new Mesh
  26965. */
  26966. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26967. /**
  26968. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26969. * @param name defines the name of the mesh to create
  26970. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26971. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26972. * @param scene defines the hosting scene
  26973. * @param updatable defines if the mesh must be flagged as updatable
  26974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26975. * @returns a new Mesh
  26976. */
  26977. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26978. /**
  26979. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26980. * @param name defines the name of the mesh to create
  26981. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26982. * @param diameterTop set the top cap diameter (floats, default 1)
  26983. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26984. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26985. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26986. * @param scene defines the hosting scene
  26987. * @param updatable defines if the mesh must be flagged as updatable
  26988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26989. * @returns a new Mesh
  26990. */
  26991. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26992. /**
  26993. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26994. * @param name defines the name of the mesh to create
  26995. * @param diameter sets the diameter size (float) of the torus (default 1)
  26996. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26997. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26998. * @param scene defines the hosting scene
  26999. * @param updatable defines if the mesh must be flagged as updatable
  27000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27001. * @returns a new Mesh
  27002. */
  27003. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27004. /**
  27005. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27006. * @param name defines the name of the mesh to create
  27007. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27008. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27009. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27010. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27011. * @param p the number of windings on X axis (positive integers, default 2)
  27012. * @param q the number of windings on Y axis (positive integers, default 3)
  27013. * @param scene defines the hosting scene
  27014. * @param updatable defines if the mesh must be flagged as updatable
  27015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27016. * @returns a new Mesh
  27017. */
  27018. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27019. /**
  27020. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27021. * @param name defines the name of the mesh to create
  27022. * @param points is an array successive Vector3
  27023. * @param scene defines the hosting scene
  27024. * @param updatable defines if the mesh must be flagged as updatable
  27025. * @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).
  27026. * @returns a new Mesh
  27027. */
  27028. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27029. /**
  27030. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27031. * @param name defines the name of the mesh to create
  27032. * @param points is an array successive Vector3
  27033. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27034. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27035. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27036. * @param scene defines the hosting scene
  27037. * @param updatable defines if the mesh must be flagged as updatable
  27038. * @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)
  27039. * @returns a new Mesh
  27040. */
  27041. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27042. /**
  27043. * Creates a polygon mesh.
  27044. * Please consider using the same method from the MeshBuilder class instead.
  27045. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27046. * 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.
  27047. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27048. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27049. * Remember you can only change the shape positions, not their number when updating a polygon.
  27050. */
  27051. /**
  27052. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27053. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27054. * @param name defines the name of the mesh to create
  27055. * @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
  27056. * @param scene defines the hosting scene
  27057. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27058. * @param updatable defines if the mesh must be flagged as updatable
  27059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27060. * @returns a new Mesh
  27061. */
  27062. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27063. /**
  27064. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27066. * @param name defines the name of the mesh to create
  27067. * @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
  27068. * @param depth defines the height of extrusion
  27069. * @param scene defines the hosting scene
  27070. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27071. * @param updatable defines if the mesh must be flagged as updatable
  27072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27073. * @returns a new Mesh
  27074. */
  27075. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27076. /**
  27077. * Creates an extruded shape mesh.
  27078. * 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
  27079. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27080. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27081. * @param name defines the name of the mesh to create
  27082. * @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
  27083. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27084. * @param scale is the value to scale the shape
  27085. * @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
  27086. * @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
  27087. * @param scene defines the hosting scene
  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. * @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)
  27091. * @returns a new Mesh
  27092. */
  27093. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27094. /**
  27095. * Creates an custom extruded shape mesh.
  27096. * The custom extrusion is a parametric shape.
  27097. * It has no predefined shape. Its final shape will depend on the input parameters.
  27098. * Please consider using the same method from the MeshBuilder class instead
  27099. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27100. * @param name defines the name of the mesh to create
  27101. * @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
  27102. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27103. * @param scaleFunction is a custom Javascript function called on each path point
  27104. * @param rotationFunction is a custom Javascript function called on each path point
  27105. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27106. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27107. * @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
  27108. * @param scene defines the hosting scene
  27109. * @param updatable defines if the mesh must be flagged as updatable
  27110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27111. * @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)
  27112. * @returns a new Mesh
  27113. */
  27114. 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;
  27115. /**
  27116. * Creates lathe mesh.
  27117. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27118. * Please consider using the same method from the MeshBuilder class instead
  27119. * @param name defines the name of the mesh to create
  27120. * @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
  27121. * @param radius is the radius value of the lathe
  27122. * @param tessellation is the side number of the lathe.
  27123. * @param scene defines the hosting scene
  27124. * @param updatable defines if the mesh must be flagged as updatable
  27125. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27126. * @returns a new Mesh
  27127. */
  27128. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27129. /**
  27130. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27131. * @param name defines the name of the mesh to create
  27132. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27133. * @param scene defines the hosting scene
  27134. * @param updatable defines if the mesh must be flagged as updatable
  27135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27136. * @returns a new Mesh
  27137. */
  27138. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27139. /**
  27140. * Creates a ground mesh.
  27141. * Please consider using the same method from the MeshBuilder class instead
  27142. * @param name defines the name of the mesh to create
  27143. * @param width set the width of the ground
  27144. * @param height set the height of the ground
  27145. * @param subdivisions sets the number of subdivisions per side
  27146. * @param scene defines the hosting scene
  27147. * @param updatable defines if the mesh must be flagged as updatable
  27148. * @returns a new Mesh
  27149. */
  27150. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27151. /**
  27152. * Creates a tiled ground mesh.
  27153. * Please consider using the same method from the MeshBuilder class instead
  27154. * @param name defines the name of the mesh to create
  27155. * @param xmin set the ground minimum X coordinate
  27156. * @param zmin set the ground minimum Y coordinate
  27157. * @param xmax set the ground maximum X coordinate
  27158. * @param zmax set the ground maximum Z coordinate
  27159. * @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
  27160. * @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
  27161. * @param scene defines the hosting scene
  27162. * @param updatable defines if the mesh must be flagged as updatable
  27163. * @returns a new Mesh
  27164. */
  27165. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27166. w: number;
  27167. h: number;
  27168. }, precision: {
  27169. w: number;
  27170. h: number;
  27171. }, scene: Scene, updatable?: boolean): Mesh;
  27172. /**
  27173. * Creates a ground mesh from a height map.
  27174. * Please consider using the same method from the MeshBuilder class instead
  27175. * @see http://doc.babylonjs.com/babylon101/height_map
  27176. * @param name defines the name of the mesh to create
  27177. * @param url sets the URL of the height map image resource
  27178. * @param width set the ground width size
  27179. * @param height set the ground height size
  27180. * @param subdivisions sets the number of subdivision per side
  27181. * @param minHeight is the minimum altitude on the ground
  27182. * @param maxHeight is the maximum altitude on the ground
  27183. * @param scene defines the hosting scene
  27184. * @param updatable defines if the mesh must be flagged as updatable
  27185. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27186. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27187. * @returns a new Mesh
  27188. */
  27189. 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;
  27190. /**
  27191. * Creates a tube mesh.
  27192. * The tube is a parametric shape.
  27193. * It has no predefined shape. Its final shape will depend on the input parameters.
  27194. * Please consider using the same method from the MeshBuilder class instead
  27195. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27196. * @param name defines the name of the mesh to create
  27197. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27198. * @param radius sets the tube radius size
  27199. * @param tessellation is the number of sides on the tubular surface
  27200. * @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
  27201. * @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
  27202. * @param scene defines the hosting scene
  27203. * @param updatable defines if the mesh must be flagged as updatable
  27204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27205. * @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)
  27206. * @returns a new Mesh
  27207. */
  27208. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27209. (i: number, distance: number): number;
  27210. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27211. /**
  27212. * Creates a polyhedron mesh.
  27213. * Please consider using the same method from the MeshBuilder class instead.
  27214. * * 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
  27215. * * The parameter `size` (positive float, default 1) sets the polygon size
  27216. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27217. * * 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`
  27218. * * 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
  27219. * * 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)`)
  27220. * * 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
  27221. * * 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
  27222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27223. * * 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
  27224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27225. * @param name defines the name of the mesh to create
  27226. * @param options defines the options used to create the mesh
  27227. * @param scene defines the hosting scene
  27228. * @returns a new Mesh
  27229. */
  27230. static CreatePolyhedron(name: string, options: {
  27231. type?: number;
  27232. size?: number;
  27233. sizeX?: number;
  27234. sizeY?: number;
  27235. sizeZ?: number;
  27236. custom?: any;
  27237. faceUV?: Vector4[];
  27238. faceColors?: Color4[];
  27239. updatable?: boolean;
  27240. sideOrientation?: number;
  27241. }, scene: Scene): Mesh;
  27242. /**
  27243. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27244. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27245. * * 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`)
  27246. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27247. * * 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
  27248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27249. * * 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
  27250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27251. * @param name defines the name of the mesh
  27252. * @param options defines the options used to create the mesh
  27253. * @param scene defines the hosting scene
  27254. * @returns a new Mesh
  27255. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27256. */
  27257. static CreateIcoSphere(name: string, options: {
  27258. radius?: number;
  27259. flat?: boolean;
  27260. subdivisions?: number;
  27261. sideOrientation?: number;
  27262. updatable?: boolean;
  27263. }, scene: Scene): Mesh;
  27264. /**
  27265. * Creates a decal mesh.
  27266. * Please consider using the same method from the MeshBuilder class instead.
  27267. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27268. * @param name defines the name of the mesh
  27269. * @param sourceMesh defines the mesh receiving the decal
  27270. * @param position sets the position of the decal in world coordinates
  27271. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27272. * @param size sets the decal scaling
  27273. * @param angle sets the angle to rotate the decal
  27274. * @returns a new Mesh
  27275. */
  27276. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27277. /**
  27278. * Prepare internal position array for software CPU skinning
  27279. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27280. */
  27281. setPositionsForCPUSkinning(): Float32Array;
  27282. /**
  27283. * Prepare internal normal array for software CPU skinning
  27284. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27285. */
  27286. setNormalsForCPUSkinning(): Float32Array;
  27287. /**
  27288. * Updates the vertex buffer by applying transformation from the bones
  27289. * @param skeleton defines the skeleton to apply to current mesh
  27290. * @returns the current mesh
  27291. */
  27292. applySkeleton(skeleton: Skeleton): Mesh;
  27293. /**
  27294. * 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
  27295. * @param meshes defines the list of meshes to scan
  27296. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27297. */
  27298. static MinMax(meshes: AbstractMesh[]): {
  27299. min: Vector3;
  27300. max: Vector3;
  27301. };
  27302. /**
  27303. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27304. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27305. * @returns a vector3
  27306. */
  27307. static Center(meshesOrMinMaxVector: {
  27308. min: Vector3;
  27309. max: Vector3;
  27310. } | AbstractMesh[]): Vector3;
  27311. /**
  27312. * Merge the array of meshes into a single mesh for performance reasons.
  27313. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27314. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27315. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27316. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27317. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27318. * @returns a new mesh
  27319. */
  27320. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27321. /** @hidden */
  27322. addInstance(instance: InstancedMesh): void;
  27323. /** @hidden */
  27324. removeInstance(instance: InstancedMesh): void;
  27325. }
  27326. }
  27327. declare module BABYLON {
  27328. /**
  27329. * Define an interface for all classes that will get and set the data on vertices
  27330. */
  27331. interface IGetSetVerticesData {
  27332. /**
  27333. * Gets a boolean indicating if specific vertex data is present
  27334. * @param kind defines the vertex data kind to use
  27335. * @returns true is data kind is present
  27336. */
  27337. isVerticesDataPresent(kind: string): boolean;
  27338. /**
  27339. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27340. * @param kind defines the data kind (Position, normal, etc...)
  27341. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27342. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27343. * @returns a float array containing vertex data
  27344. */
  27345. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27346. /**
  27347. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27348. * @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.
  27349. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27350. * @returns the indices array or an empty array if the mesh has no geometry
  27351. */
  27352. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27353. /**
  27354. * Set specific vertex data
  27355. * @param kind defines the data kind (Position, normal, etc...)
  27356. * @param data defines the vertex data to use
  27357. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27358. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27359. */
  27360. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27361. /**
  27362. * Update a specific associated vertex buffer
  27363. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27364. * - BABYLON.VertexBuffer.PositionKind
  27365. * - BABYLON.VertexBuffer.UVKind
  27366. * - BABYLON.VertexBuffer.UV2Kind
  27367. * - BABYLON.VertexBuffer.UV3Kind
  27368. * - BABYLON.VertexBuffer.UV4Kind
  27369. * - BABYLON.VertexBuffer.UV5Kind
  27370. * - BABYLON.VertexBuffer.UV6Kind
  27371. * - BABYLON.VertexBuffer.ColorKind
  27372. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27373. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27374. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27375. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27376. * @param data defines the data source
  27377. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27378. * @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)
  27379. */
  27380. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27381. /**
  27382. * Creates a new index buffer
  27383. * @param indices defines the indices to store in the index buffer
  27384. * @param totalVertices defines the total number of vertices (could be null)
  27385. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27386. */
  27387. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27388. }
  27389. /**
  27390. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27391. */
  27392. class VertexData {
  27393. /**
  27394. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27395. */
  27396. positions: Nullable<FloatArray>;
  27397. /**
  27398. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27399. */
  27400. normals: Nullable<FloatArray>;
  27401. /**
  27402. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27403. */
  27404. tangents: Nullable<FloatArray>;
  27405. /**
  27406. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27407. */
  27408. uvs: Nullable<FloatArray>;
  27409. /**
  27410. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27411. */
  27412. uvs2: Nullable<FloatArray>;
  27413. /**
  27414. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27415. */
  27416. uvs3: Nullable<FloatArray>;
  27417. /**
  27418. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27419. */
  27420. uvs4: Nullable<FloatArray>;
  27421. /**
  27422. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27423. */
  27424. uvs5: Nullable<FloatArray>;
  27425. /**
  27426. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27427. */
  27428. uvs6: Nullable<FloatArray>;
  27429. /**
  27430. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27431. */
  27432. colors: Nullable<FloatArray>;
  27433. /**
  27434. * 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).
  27435. */
  27436. matricesIndices: Nullable<FloatArray>;
  27437. /**
  27438. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27439. */
  27440. matricesWeights: Nullable<FloatArray>;
  27441. /**
  27442. * An array extending the number of possible indices
  27443. */
  27444. matricesIndicesExtra: Nullable<FloatArray>;
  27445. /**
  27446. * An array extending the number of possible weights when the number of indices is extended
  27447. */
  27448. matricesWeightsExtra: Nullable<FloatArray>;
  27449. /**
  27450. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27451. */
  27452. indices: Nullable<IndicesArray>;
  27453. /**
  27454. * Uses the passed data array to set the set the values for the specified kind of data
  27455. * @param data a linear array of floating numbers
  27456. * @param kind the type of data that is being set, eg positions, colors etc
  27457. */
  27458. set(data: FloatArray, kind: string): void;
  27459. /**
  27460. * Associates the vertexData to the passed Mesh.
  27461. * Sets it as updatable or not (default `false`)
  27462. * @param mesh the mesh the vertexData is applied to
  27463. * @param updatable when used and having the value true allows new data to update the vertexData
  27464. * @returns the VertexData
  27465. */
  27466. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27467. /**
  27468. * Associates the vertexData to the passed Geometry.
  27469. * Sets it as updatable or not (default `false`)
  27470. * @param geometry the geometry the vertexData is applied to
  27471. * @param updatable when used and having the value true allows new data to update the vertexData
  27472. * @returns VertexData
  27473. */
  27474. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27475. /**
  27476. * Updates the associated mesh
  27477. * @param mesh the mesh to be updated
  27478. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27479. * @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
  27480. * @returns VertexData
  27481. */
  27482. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27483. /**
  27484. * Updates the associated geometry
  27485. * @param geometry the geometry to be updated
  27486. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27487. * @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
  27488. * @returns VertexData.
  27489. */
  27490. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27491. private _applyTo;
  27492. private _update;
  27493. /**
  27494. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27495. * @param matrix the transforming matrix
  27496. * @returns the VertexData
  27497. */
  27498. transform(matrix: Matrix): VertexData;
  27499. /**
  27500. * Merges the passed VertexData into the current one
  27501. * @param other the VertexData to be merged into the current one
  27502. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27503. * @returns the modified VertexData
  27504. */
  27505. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27506. private _mergeElement;
  27507. private _validate;
  27508. /**
  27509. * Serializes the VertexData
  27510. * @returns a serialized object
  27511. */
  27512. serialize(): any;
  27513. /**
  27514. * Extracts the vertexData from a mesh
  27515. * @param mesh the mesh from which to extract the VertexData
  27516. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27517. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27518. * @returns the object VertexData associated to the passed mesh
  27519. */
  27520. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27521. /**
  27522. * Extracts the vertexData from the geometry
  27523. * @param geometry the geometry from which to extract the VertexData
  27524. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27525. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27526. * @returns the object VertexData associated to the passed mesh
  27527. */
  27528. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27529. private static _ExtractFrom;
  27530. /**
  27531. * Creates the VertexData for a Ribbon
  27532. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27533. * * pathArray array of paths, each of which an array of successive Vector3
  27534. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27535. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27536. * * 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
  27537. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27538. * * 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)
  27539. * * 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)
  27540. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27541. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27542. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27543. * @returns the VertexData of the ribbon
  27544. */
  27545. static CreateRibbon(options: {
  27546. pathArray: Vector3[][];
  27547. closeArray?: boolean;
  27548. closePath?: boolean;
  27549. offset?: number;
  27550. sideOrientation?: number;
  27551. frontUVs?: Vector4;
  27552. backUVs?: Vector4;
  27553. invertUV?: boolean;
  27554. uvs?: Vector2[];
  27555. colors?: Color4[];
  27556. }): VertexData;
  27557. /**
  27558. * Creates the VertexData for a box
  27559. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27560. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27561. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27562. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27563. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27564. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27565. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27566. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27567. * * 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)
  27568. * * 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)
  27569. * @returns the VertexData of the box
  27570. */
  27571. static CreateBox(options: {
  27572. size?: number;
  27573. width?: number;
  27574. height?: number;
  27575. depth?: number;
  27576. faceUV?: Vector4[];
  27577. faceColors?: Color4[];
  27578. sideOrientation?: number;
  27579. frontUVs?: Vector4;
  27580. backUVs?: Vector4;
  27581. }): VertexData;
  27582. /**
  27583. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27584. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27585. * * segments sets the number of horizontal strips optional, default 32
  27586. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27587. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27588. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27589. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27590. * * 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
  27591. * * 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
  27592. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27593. * * 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)
  27594. * * 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)
  27595. * @returns the VertexData of the ellipsoid
  27596. */
  27597. static CreateSphere(options: {
  27598. segments?: number;
  27599. diameter?: number;
  27600. diameterX?: number;
  27601. diameterY?: number;
  27602. diameterZ?: number;
  27603. arc?: number;
  27604. slice?: number;
  27605. sideOrientation?: number;
  27606. frontUVs?: Vector4;
  27607. backUVs?: Vector4;
  27608. }): VertexData;
  27609. /**
  27610. * Creates the VertexData for a cylinder, cone or prism
  27611. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27612. * * height sets the height (y direction) of the cylinder, optional, default 2
  27613. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27614. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27615. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27616. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27617. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27618. * * 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
  27619. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27621. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27622. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27623. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27624. * * 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)
  27625. * * 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)
  27626. * @returns the VertexData of the cylinder, cone or prism
  27627. */
  27628. static CreateCylinder(options: {
  27629. height?: number;
  27630. diameterTop?: number;
  27631. diameterBottom?: number;
  27632. diameter?: number;
  27633. tessellation?: number;
  27634. subdivisions?: number;
  27635. arc?: number;
  27636. faceColors?: Color4[];
  27637. faceUV?: Vector4[];
  27638. hasRings?: boolean;
  27639. enclose?: boolean;
  27640. sideOrientation?: number;
  27641. frontUVs?: Vector4;
  27642. backUVs?: Vector4;
  27643. }): VertexData;
  27644. /**
  27645. * Creates the VertexData for a torus
  27646. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27647. * * diameter the diameter of the torus, optional default 1
  27648. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27649. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27650. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27651. * * 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)
  27652. * * 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)
  27653. * @returns the VertexData of the torus
  27654. */
  27655. static CreateTorus(options: {
  27656. diameter?: number;
  27657. thickness?: number;
  27658. tessellation?: number;
  27659. sideOrientation?: number;
  27660. frontUVs?: Vector4;
  27661. backUVs?: Vector4;
  27662. }): VertexData;
  27663. /**
  27664. * Creates the VertexData of the LineSystem
  27665. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27666. * - lines an array of lines, each line being an array of successive Vector3
  27667. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27668. * @returns the VertexData of the LineSystem
  27669. */
  27670. static CreateLineSystem(options: {
  27671. lines: Vector3[][];
  27672. colors?: Nullable<Color4[][]>;
  27673. }): VertexData;
  27674. /**
  27675. * Create the VertexData for a DashedLines
  27676. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27677. * - points an array successive Vector3
  27678. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27679. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27680. * - dashNb the intended total number of dashes, optional, default 200
  27681. * @returns the VertexData for the DashedLines
  27682. */
  27683. static CreateDashedLines(options: {
  27684. points: Vector3[];
  27685. dashSize?: number;
  27686. gapSize?: number;
  27687. dashNb?: number;
  27688. }): VertexData;
  27689. /**
  27690. * Creates the VertexData for a Ground
  27691. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27692. * - width the width (x direction) of the ground, optional, default 1
  27693. * - height the height (z direction) of the ground, optional, default 1
  27694. * - subdivisions the number of subdivisions per side, optional, default 1
  27695. * @returns the VertexData of the Ground
  27696. */
  27697. static CreateGround(options: {
  27698. width?: number;
  27699. height?: number;
  27700. subdivisions?: number;
  27701. subdivisionsX?: number;
  27702. subdivisionsY?: number;
  27703. }): VertexData;
  27704. /**
  27705. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27706. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27707. * * xmin the ground minimum X coordinate, optional, default -1
  27708. * * zmin the ground minimum Z coordinate, optional, default -1
  27709. * * xmax the ground maximum X coordinate, optional, default 1
  27710. * * zmax the ground maximum Z coordinate, optional, default 1
  27711. * * 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}
  27712. * * 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}
  27713. * @returns the VertexData of the TiledGround
  27714. */
  27715. static CreateTiledGround(options: {
  27716. xmin: number;
  27717. zmin: number;
  27718. xmax: number;
  27719. zmax: number;
  27720. subdivisions?: {
  27721. w: number;
  27722. h: number;
  27723. };
  27724. precision?: {
  27725. w: number;
  27726. h: number;
  27727. };
  27728. }): VertexData;
  27729. /**
  27730. * Creates the VertexData of the Ground designed from a heightmap
  27731. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27732. * * width the width (x direction) of the ground
  27733. * * height the height (z direction) of the ground
  27734. * * subdivisions the number of subdivisions per side
  27735. * * minHeight the minimum altitude on the ground, optional, default 0
  27736. * * maxHeight the maximum altitude on the ground, optional default 1
  27737. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27738. * * buffer the array holding the image color data
  27739. * * bufferWidth the width of image
  27740. * * bufferHeight the height of image
  27741. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27742. * @returns the VertexData of the Ground designed from a heightmap
  27743. */
  27744. static CreateGroundFromHeightMap(options: {
  27745. width: number;
  27746. height: number;
  27747. subdivisions: number;
  27748. minHeight: number;
  27749. maxHeight: number;
  27750. colorFilter: Color3;
  27751. buffer: Uint8Array;
  27752. bufferWidth: number;
  27753. bufferHeight: number;
  27754. alphaFilter: number;
  27755. }): VertexData;
  27756. /**
  27757. * Creates the VertexData for a Plane
  27758. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27759. * * size sets the width and height of the plane to the value of size, optional default 1
  27760. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27761. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27762. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27763. * * 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)
  27764. * * 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)
  27765. * @returns the VertexData of the box
  27766. */
  27767. static CreatePlane(options: {
  27768. size?: number;
  27769. width?: number;
  27770. height?: number;
  27771. sideOrientation?: number;
  27772. frontUVs?: Vector4;
  27773. backUVs?: Vector4;
  27774. }): VertexData;
  27775. /**
  27776. * Creates the VertexData of the Disc or regular Polygon
  27777. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27778. * * radius the radius of the disc, optional default 0.5
  27779. * * tessellation the number of polygon sides, optional, default 64
  27780. * * 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
  27781. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27782. * * 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)
  27783. * * 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)
  27784. * @returns the VertexData of the box
  27785. */
  27786. static CreateDisc(options: {
  27787. radius?: number;
  27788. tessellation?: number;
  27789. arc?: number;
  27790. sideOrientation?: number;
  27791. frontUVs?: Vector4;
  27792. backUVs?: Vector4;
  27793. }): VertexData;
  27794. /**
  27795. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27796. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27797. * @param polygon a mesh built from polygonTriangulation.build()
  27798. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27799. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27800. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27801. * @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)
  27802. * @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)
  27803. * @returns the VertexData of the Polygon
  27804. */
  27805. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27806. /**
  27807. * Creates the VertexData of the IcoSphere
  27808. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27809. * * radius the radius of the IcoSphere, optional default 1
  27810. * * radiusX allows stretching in the x direction, optional, default radius
  27811. * * radiusY allows stretching in the y direction, optional, default radius
  27812. * * radiusZ allows stretching in the z direction, optional, default radius
  27813. * * flat when true creates a flat shaded mesh, optional, default true
  27814. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27815. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27816. * * 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)
  27817. * * 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)
  27818. * @returns the VertexData of the IcoSphere
  27819. */
  27820. static CreateIcoSphere(options: {
  27821. radius?: number;
  27822. radiusX?: number;
  27823. radiusY?: number;
  27824. radiusZ?: number;
  27825. flat?: boolean;
  27826. subdivisions?: number;
  27827. sideOrientation?: number;
  27828. frontUVs?: Vector4;
  27829. backUVs?: Vector4;
  27830. }): VertexData;
  27831. /**
  27832. * Creates the VertexData for a Polyhedron
  27833. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27834. * * type provided types are:
  27835. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27836. * * 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)
  27837. * * size the size of the IcoSphere, optional default 1
  27838. * * sizeX allows stretching in the x direction, optional, default size
  27839. * * sizeY allows stretching in the y direction, optional, default size
  27840. * * sizeZ allows stretching in the z direction, optional, default size
  27841. * * 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
  27842. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27843. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27844. * * flat when true creates a flat shaded mesh, optional, default true
  27845. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27846. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27847. * * 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)
  27848. * * 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)
  27849. * @returns the VertexData of the Polyhedron
  27850. */
  27851. static CreatePolyhedron(options: {
  27852. type?: number;
  27853. size?: number;
  27854. sizeX?: number;
  27855. sizeY?: number;
  27856. sizeZ?: number;
  27857. custom?: any;
  27858. faceUV?: Vector4[];
  27859. faceColors?: Color4[];
  27860. flat?: boolean;
  27861. sideOrientation?: number;
  27862. frontUVs?: Vector4;
  27863. backUVs?: Vector4;
  27864. }): VertexData;
  27865. /**
  27866. * Creates the VertexData for a TorusKnot
  27867. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27868. * * radius the radius of the torus knot, optional, default 2
  27869. * * tube the thickness of the tube, optional, default 0.5
  27870. * * radialSegments the number of sides on each tube segments, optional, default 32
  27871. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27872. * * p the number of windings around the z axis, optional, default 2
  27873. * * q the number of windings around the x axis, optional, default 3
  27874. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27875. * * 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)
  27876. * * 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)
  27877. * @returns the VertexData of the Torus Knot
  27878. */
  27879. static CreateTorusKnot(options: {
  27880. radius?: number;
  27881. tube?: number;
  27882. radialSegments?: number;
  27883. tubularSegments?: number;
  27884. p?: number;
  27885. q?: number;
  27886. sideOrientation?: number;
  27887. frontUVs?: Vector4;
  27888. backUVs?: Vector4;
  27889. }): VertexData;
  27890. /**
  27891. * Compute normals for given positions and indices
  27892. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27893. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27894. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27895. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27896. * * facetNormals : optional array of facet normals (vector3)
  27897. * * facetPositions : optional array of facet positions (vector3)
  27898. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27899. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27900. * * bInfo : optional bounding info, required for facetPartitioning computation
  27901. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27902. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27903. * * useRightHandedSystem: optional boolean to for right handed system computation
  27904. * * depthSort : optional boolean to enable the facet depth sort computation
  27905. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27906. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27907. */
  27908. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27909. facetNormals?: any;
  27910. facetPositions?: any;
  27911. facetPartitioning?: any;
  27912. ratio?: number;
  27913. bInfo?: any;
  27914. bbSize?: Vector3;
  27915. subDiv?: any;
  27916. useRightHandedSystem?: boolean;
  27917. depthSort?: boolean;
  27918. distanceTo?: Vector3;
  27919. depthSortedFacets?: any;
  27920. }): void;
  27921. private static _ComputeSides;
  27922. /**
  27923. * Applies VertexData created from the imported parameters to the geometry
  27924. * @param parsedVertexData the parsed data from an imported file
  27925. * @param geometry the geometry to apply the VertexData to
  27926. */
  27927. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27928. }
  27929. }
  27930. declare module BABYLON {
  27931. /**
  27932. * Class containing static functions to help procedurally build meshes
  27933. */
  27934. class MeshBuilder {
  27935. private static updateSideOrientation;
  27936. /**
  27937. * Creates a box mesh
  27938. * * The parameter `size` sets the size (float) of each box side (default 1)
  27939. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27940. * * 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)
  27941. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27943. * * 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
  27944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27945. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27946. * @param name defines the name of the mesh
  27947. * @param options defines the options used to create the mesh
  27948. * @param scene defines the hosting scene
  27949. * @returns the box mesh
  27950. */
  27951. static CreateBox(name: string, options: {
  27952. size?: number;
  27953. width?: number;
  27954. height?: number;
  27955. depth?: number;
  27956. faceUV?: Vector4[];
  27957. faceColors?: Color4[];
  27958. sideOrientation?: number;
  27959. frontUVs?: Vector4;
  27960. backUVs?: Vector4;
  27961. updatable?: boolean;
  27962. }, scene?: Nullable<Scene>): Mesh;
  27963. /**
  27964. * Creates a sphere mesh
  27965. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27966. * * 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`)
  27967. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27968. * * 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
  27969. * * 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)
  27970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27971. * * 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
  27972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27973. * @param name defines the name of the mesh
  27974. * @param options defines the options used to create the mesh
  27975. * @param scene defines the hosting scene
  27976. * @returns the sphere mesh
  27977. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27978. */
  27979. static CreateSphere(name: string, options: {
  27980. segments?: number;
  27981. diameter?: number;
  27982. diameterX?: number;
  27983. diameterY?: number;
  27984. diameterZ?: number;
  27985. arc?: number;
  27986. slice?: number;
  27987. sideOrientation?: number;
  27988. frontUVs?: Vector4;
  27989. backUVs?: Vector4;
  27990. updatable?: boolean;
  27991. }, scene: any): Mesh;
  27992. /**
  27993. * Creates a plane polygonal mesh. By default, this is a disc
  27994. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27995. * * 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
  27996. * * 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
  27997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27998. * * 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
  27999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28000. * @param name defines the name of the mesh
  28001. * @param options defines the options used to create the mesh
  28002. * @param scene defines the hosting scene
  28003. * @returns the plane polygonal mesh
  28004. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28005. */
  28006. static CreateDisc(name: string, options: {
  28007. radius?: number;
  28008. tessellation?: number;
  28009. arc?: number;
  28010. updatable?: boolean;
  28011. sideOrientation?: number;
  28012. frontUVs?: Vector4;
  28013. backUVs?: Vector4;
  28014. }, scene?: Nullable<Scene>): Mesh;
  28015. /**
  28016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28018. * * 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`)
  28019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28020. * * 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
  28021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28022. * * 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
  28023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28024. * @param name defines the name of the mesh
  28025. * @param options defines the options used to create the mesh
  28026. * @param scene defines the hosting scene
  28027. * @returns the icosahedron mesh
  28028. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28029. */
  28030. static CreateIcoSphere(name: string, options: {
  28031. radius?: number;
  28032. radiusX?: number;
  28033. radiusY?: number;
  28034. radiusZ?: number;
  28035. flat?: boolean;
  28036. subdivisions?: number;
  28037. sideOrientation?: number;
  28038. frontUVs?: Vector4;
  28039. backUVs?: Vector4;
  28040. updatable?: boolean;
  28041. }, scene: Scene): Mesh;
  28042. /**
  28043. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28044. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28045. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28046. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28047. * * 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
  28048. * * 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
  28049. * * 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
  28050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28051. * * 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
  28052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28053. * * 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
  28054. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28055. * * 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
  28056. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28058. * @param name defines the name of the mesh
  28059. * @param options defines the options used to create the mesh
  28060. * @param scene defines the hosting scene
  28061. * @returns the ribbon mesh
  28062. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28063. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28064. */
  28065. static CreateRibbon(name: string, options: {
  28066. pathArray: Vector3[][];
  28067. closeArray?: boolean;
  28068. closePath?: boolean;
  28069. offset?: number;
  28070. updatable?: boolean;
  28071. sideOrientation?: number;
  28072. frontUVs?: Vector4;
  28073. backUVs?: Vector4;
  28074. instance?: Mesh;
  28075. invertUV?: boolean;
  28076. uvs?: Vector2[];
  28077. colors?: Color4[];
  28078. }, scene?: Nullable<Scene>): Mesh;
  28079. /**
  28080. * Creates a cylinder or a cone mesh
  28081. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28082. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28083. * * 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.
  28084. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28085. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28086. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28087. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28088. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28089. * * 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).
  28090. * * 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
  28091. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28092. * * 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
  28093. * * 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.
  28094. * * If `enclose` is false, a ring surface is one element.
  28095. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28096. * * 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
  28097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28098. * * 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
  28099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28100. * @param name defines the name of the mesh
  28101. * @param options defines the options used to create the mesh
  28102. * @param scene defines the hosting scene
  28103. * @returns the cylinder mesh
  28104. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28105. */
  28106. static CreateCylinder(name: string, options: {
  28107. height?: number;
  28108. diameterTop?: number;
  28109. diameterBottom?: number;
  28110. diameter?: number;
  28111. tessellation?: number;
  28112. subdivisions?: number;
  28113. arc?: number;
  28114. faceColors?: Color4[];
  28115. faceUV?: Vector4[];
  28116. updatable?: boolean;
  28117. hasRings?: boolean;
  28118. enclose?: boolean;
  28119. sideOrientation?: number;
  28120. frontUVs?: Vector4;
  28121. backUVs?: Vector4;
  28122. }, scene: any): Mesh;
  28123. /**
  28124. * Creates a torus mesh
  28125. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28126. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28127. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28129. * * 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
  28130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28131. * @param name defines the name of the mesh
  28132. * @param options defines the options used to create the mesh
  28133. * @param scene defines the hosting scene
  28134. * @returns the torus mesh
  28135. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28136. */
  28137. static CreateTorus(name: string, options: {
  28138. diameter?: number;
  28139. thickness?: number;
  28140. tessellation?: number;
  28141. updatable?: boolean;
  28142. sideOrientation?: number;
  28143. frontUVs?: Vector4;
  28144. backUVs?: Vector4;
  28145. }, scene: any): Mesh;
  28146. /**
  28147. * Creates a torus knot mesh
  28148. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28149. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28150. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28151. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28153. * * 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
  28154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28155. * @param name defines the name of the mesh
  28156. * @param options defines the options used to create the mesh
  28157. * @param scene defines the hosting scene
  28158. * @returns the torus knot mesh
  28159. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28160. */
  28161. static CreateTorusKnot(name: string, options: {
  28162. radius?: number;
  28163. tube?: number;
  28164. radialSegments?: number;
  28165. tubularSegments?: number;
  28166. p?: number;
  28167. q?: number;
  28168. updatable?: boolean;
  28169. sideOrientation?: number;
  28170. frontUVs?: Vector4;
  28171. backUVs?: Vector4;
  28172. }, scene: any): Mesh;
  28173. /**
  28174. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28175. * * 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
  28176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28177. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28178. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28179. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28180. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28181. * * 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
  28182. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28185. * @param name defines the name of the new line system
  28186. * @param options defines the options used to create the line system
  28187. * @param scene defines the hosting scene
  28188. * @returns a new line system mesh
  28189. */
  28190. static CreateLineSystem(name: string, options: {
  28191. lines: Vector3[][];
  28192. updatable?: boolean;
  28193. instance?: Nullable<LinesMesh>;
  28194. colors?: Nullable<Color4[][]>;
  28195. useVertexAlpha?: boolean;
  28196. }, scene: Nullable<Scene>): LinesMesh;
  28197. /**
  28198. * Creates a line mesh
  28199. * 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
  28200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28201. * * The parameter `points` is an array successive Vector3
  28202. * * 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
  28203. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28205. * * When updating an instance, remember that only point positions can change, not the number of points
  28206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28207. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28208. * @param name defines the name of the new line system
  28209. * @param options defines the options used to create the line system
  28210. * @param scene defines the hosting scene
  28211. * @returns a new line mesh
  28212. */
  28213. static CreateLines(name: string, options: {
  28214. points: Vector3[];
  28215. updatable?: boolean;
  28216. instance?: Nullable<LinesMesh>;
  28217. colors?: Color4[];
  28218. useVertexAlpha?: boolean;
  28219. }, scene?: Nullable<Scene>): LinesMesh;
  28220. /**
  28221. * Creates a dashed line mesh
  28222. * * 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
  28223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28224. * * The parameter `points` is an array successive Vector3
  28225. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28226. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28227. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28228. * * 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
  28229. * * When updating an instance, remember that only point positions can change, not the number of points
  28230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28231. * @param name defines the name of the mesh
  28232. * @param options defines the options used to create the mesh
  28233. * @param scene defines the hosting scene
  28234. * @returns the dashed line mesh
  28235. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28236. */
  28237. static CreateDashedLines(name: string, options: {
  28238. points: Vector3[];
  28239. dashSize?: number;
  28240. gapSize?: number;
  28241. dashNb?: number;
  28242. updatable?: boolean;
  28243. instance?: LinesMesh;
  28244. }, scene?: Nullable<Scene>): LinesMesh;
  28245. /**
  28246. * 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.
  28247. * * 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.
  28248. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28249. * * 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.
  28250. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28251. * * 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
  28252. * * 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
  28253. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28255. * * 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
  28256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28258. * @param name defines the name of the mesh
  28259. * @param options defines the options used to create the mesh
  28260. * @param scene defines the hosting scene
  28261. * @returns the extruded shape mesh
  28262. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28263. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28264. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28265. */
  28266. static ExtrudeShape(name: string, options: {
  28267. shape: Vector3[];
  28268. path: Vector3[];
  28269. scale?: number;
  28270. rotation?: number;
  28271. cap?: number;
  28272. updatable?: boolean;
  28273. sideOrientation?: number;
  28274. frontUVs?: Vector4;
  28275. backUVs?: Vector4;
  28276. instance?: Mesh;
  28277. invertUV?: boolean;
  28278. }, scene?: Nullable<Scene>): Mesh;
  28279. /**
  28280. * Creates an custom extruded shape mesh.
  28281. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28282. * * 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.
  28283. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28284. * * 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
  28285. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28286. * * 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
  28287. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28288. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28289. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28290. * * 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
  28291. * * 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
  28292. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28294. * * 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
  28295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28297. * @param name defines the name of the mesh
  28298. * @param options defines the options used to create the mesh
  28299. * @param scene defines the hosting scene
  28300. * @returns the custom extruded shape mesh
  28301. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28302. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28303. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28304. */
  28305. static ExtrudeShapeCustom(name: string, options: {
  28306. shape: Vector3[];
  28307. path: Vector3[];
  28308. scaleFunction?: any;
  28309. rotationFunction?: any;
  28310. ribbonCloseArray?: boolean;
  28311. ribbonClosePath?: boolean;
  28312. cap?: number;
  28313. updatable?: boolean;
  28314. sideOrientation?: number;
  28315. frontUVs?: Vector4;
  28316. backUVs?: Vector4;
  28317. instance?: Mesh;
  28318. invertUV?: boolean;
  28319. }, scene: Scene): Mesh;
  28320. /**
  28321. * Creates lathe mesh.
  28322. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28323. * * 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
  28324. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28325. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28326. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28327. * * 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
  28328. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28329. * * 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
  28330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28331. * * 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
  28332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28334. * @param name defines the name of the mesh
  28335. * @param options defines the options used to create the mesh
  28336. * @param scene defines the hosting scene
  28337. * @returns the lathe mesh
  28338. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28339. */
  28340. static CreateLathe(name: string, options: {
  28341. shape: Vector3[];
  28342. radius?: number;
  28343. tessellation?: number;
  28344. clip?: number;
  28345. arc?: number;
  28346. closed?: boolean;
  28347. updatable?: boolean;
  28348. sideOrientation?: number;
  28349. frontUVs?: Vector4;
  28350. backUVs?: Vector4;
  28351. cap?: number;
  28352. invertUV?: boolean;
  28353. }, scene: Scene): Mesh;
  28354. /**
  28355. * Creates a plane mesh
  28356. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28357. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28358. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28360. * * 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
  28361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28362. * @param name defines the name of the mesh
  28363. * @param options defines the options used to create the mesh
  28364. * @param scene defines the hosting scene
  28365. * @returns the plane mesh
  28366. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28367. */
  28368. static CreatePlane(name: string, options: {
  28369. size?: number;
  28370. width?: number;
  28371. height?: number;
  28372. sideOrientation?: number;
  28373. frontUVs?: Vector4;
  28374. backUVs?: Vector4;
  28375. updatable?: boolean;
  28376. sourcePlane?: Plane;
  28377. }, scene: Scene): Mesh;
  28378. /**
  28379. * Creates a ground mesh
  28380. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28381. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28383. * @param name defines the name of the mesh
  28384. * @param options defines the options used to create the mesh
  28385. * @param scene defines the hosting scene
  28386. * @returns the ground mesh
  28387. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28388. */
  28389. static CreateGround(name: string, options: {
  28390. width?: number;
  28391. height?: number;
  28392. subdivisions?: number;
  28393. subdivisionsX?: number;
  28394. subdivisionsY?: number;
  28395. updatable?: boolean;
  28396. }, scene: any): Mesh;
  28397. /**
  28398. * Creates a tiled ground mesh
  28399. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28400. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28401. * * 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
  28402. * * 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
  28403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28404. * @param name defines the name of the mesh
  28405. * @param options defines the options used to create the mesh
  28406. * @param scene defines the hosting scene
  28407. * @returns the tiled ground mesh
  28408. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28409. */
  28410. static CreateTiledGround(name: string, options: {
  28411. xmin: number;
  28412. zmin: number;
  28413. xmax: number;
  28414. zmax: number;
  28415. subdivisions?: {
  28416. w: number;
  28417. h: number;
  28418. };
  28419. precision?: {
  28420. w: number;
  28421. h: number;
  28422. };
  28423. updatable?: boolean;
  28424. }, scene: Scene): Mesh;
  28425. /**
  28426. * Creates a ground mesh from a height map
  28427. * * The parameter `url` sets the URL of the height map image resource.
  28428. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28429. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28430. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28431. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28432. * * 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.
  28433. * * 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).
  28434. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28436. * @param name defines the name of the mesh
  28437. * @param url defines the url to the height map
  28438. * @param options defines the options used to create the mesh
  28439. * @param scene defines the hosting scene
  28440. * @returns the ground mesh
  28441. * @see http://doc.babylonjs.com/babylon101/height_map
  28442. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28443. */
  28444. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28445. width?: number;
  28446. height?: number;
  28447. subdivisions?: number;
  28448. minHeight?: number;
  28449. maxHeight?: number;
  28450. colorFilter?: Color3;
  28451. alphaFilter?: number;
  28452. updatable?: boolean;
  28453. onReady?: (mesh: GroundMesh) => void;
  28454. }, scene: Scene): GroundMesh;
  28455. /**
  28456. * Creates a polygon mesh
  28457. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28458. * * 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
  28459. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28461. * * 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)
  28462. * * Remember you can only change the shape positions, not their number when updating a polygon
  28463. * @param name defines the name of the mesh
  28464. * @param options defines the options used to create the mesh
  28465. * @param scene defines the hosting scene
  28466. * @returns the polygon mesh
  28467. */
  28468. static CreatePolygon(name: string, options: {
  28469. shape: Vector3[];
  28470. holes?: Vector3[][];
  28471. depth?: number;
  28472. faceUV?: Vector4[];
  28473. faceColors?: Color4[];
  28474. updatable?: boolean;
  28475. sideOrientation?: number;
  28476. frontUVs?: Vector4;
  28477. backUVs?: Vector4;
  28478. }, scene: Scene): Mesh;
  28479. /**
  28480. * Creates an extruded polygon mesh, with depth in the Y direction.
  28481. * * 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)
  28482. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28483. * @param name defines the name of the mesh
  28484. * @param options defines the options used to create the mesh
  28485. * @param scene defines the hosting scene
  28486. * @returns the polygon mesh
  28487. */
  28488. static ExtrudePolygon(name: string, options: {
  28489. shape: Vector3[];
  28490. holes?: Vector3[][];
  28491. depth?: number;
  28492. faceUV?: Vector4[];
  28493. faceColors?: Color4[];
  28494. updatable?: boolean;
  28495. sideOrientation?: number;
  28496. frontUVs?: Vector4;
  28497. backUVs?: Vector4;
  28498. }, scene: Scene): Mesh;
  28499. /**
  28500. * Creates a tube mesh.
  28501. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28502. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28503. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28504. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28505. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28506. * * 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)
  28507. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28508. * * 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
  28509. * * 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
  28510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28511. * * 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
  28512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28514. * @param name defines the name of the mesh
  28515. * @param options defines the options used to create the mesh
  28516. * @param scene defines the hosting scene
  28517. * @returns the tube mesh
  28518. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28519. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28520. */
  28521. static CreateTube(name: string, options: {
  28522. path: Vector3[];
  28523. radius?: number;
  28524. tessellation?: number;
  28525. radiusFunction?: {
  28526. (i: number, distance: number): number;
  28527. };
  28528. cap?: number;
  28529. arc?: number;
  28530. updatable?: boolean;
  28531. sideOrientation?: number;
  28532. frontUVs?: Vector4;
  28533. backUVs?: Vector4;
  28534. instance?: Mesh;
  28535. invertUV?: boolean;
  28536. }, scene: Scene): Mesh;
  28537. /**
  28538. * Creates a polyhedron mesh
  28539. * * 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
  28540. * * The parameter `size` (positive float, default 1) sets the polygon size
  28541. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28542. * * 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`
  28543. * * 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
  28544. * * 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)`)
  28545. * * 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
  28546. * * 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
  28547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28548. * * 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
  28549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28550. * @param name defines the name of the mesh
  28551. * @param options defines the options used to create the mesh
  28552. * @param scene defines the hosting scene
  28553. * @returns the polyhedron mesh
  28554. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28555. */
  28556. static CreatePolyhedron(name: string, options: {
  28557. type?: number;
  28558. size?: number;
  28559. sizeX?: number;
  28560. sizeY?: number;
  28561. sizeZ?: number;
  28562. custom?: any;
  28563. faceUV?: Vector4[];
  28564. faceColors?: Color4[];
  28565. flat?: boolean;
  28566. updatable?: boolean;
  28567. sideOrientation?: number;
  28568. frontUVs?: Vector4;
  28569. backUVs?: Vector4;
  28570. }, scene: Scene): Mesh;
  28571. /**
  28572. * Creates a decal mesh.
  28573. * 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
  28574. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28575. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28576. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28577. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28578. * @param name defines the name of the mesh
  28579. * @param sourceMesh defines the mesh where the decal must be applied
  28580. * @param options defines the options used to create the mesh
  28581. * @param scene defines the hosting scene
  28582. * @returns the decal mesh
  28583. * @see http://doc.babylonjs.com/how_to/decals
  28584. */
  28585. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28586. position?: Vector3;
  28587. normal?: Vector3;
  28588. size?: Vector3;
  28589. angle?: number;
  28590. }): Mesh;
  28591. private static _ExtrudeShapeGeneric;
  28592. }
  28593. }
  28594. declare module BABYLON {
  28595. /**
  28596. * Class used to represent a specific level of detail of a mesh
  28597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28598. */
  28599. class MeshLODLevel {
  28600. /** Defines the distance where this level should star being displayed */
  28601. distance: number;
  28602. /** Defines the mesh to use to render this level */
  28603. mesh: Nullable<Mesh>;
  28604. /**
  28605. * Creates a new LOD level
  28606. * @param distance defines the distance where this level should star being displayed
  28607. * @param mesh defines the mesh to use to render this level
  28608. */
  28609. constructor(
  28610. /** Defines the distance where this level should star being displayed */
  28611. distance: number,
  28612. /** Defines the mesh to use to render this level */
  28613. mesh: Nullable<Mesh>);
  28614. }
  28615. }
  28616. declare module BABYLON {
  28617. /**
  28618. * A simplifier interface for future simplification implementations
  28619. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28620. */
  28621. interface ISimplifier {
  28622. /**
  28623. * Simplification of a given mesh according to the given settings.
  28624. * Since this requires computation, it is assumed that the function runs async.
  28625. * @param settings The settings of the simplification, including quality and distance
  28626. * @param successCallback A callback that will be called after the mesh was simplified.
  28627. * @param errorCallback in case of an error, this callback will be called. optional.
  28628. */
  28629. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28630. }
  28631. /**
  28632. * Expected simplification settings.
  28633. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28634. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28635. */
  28636. interface ISimplificationSettings {
  28637. /**
  28638. * Gets or sets the expected quality
  28639. */
  28640. quality: number;
  28641. /**
  28642. * Gets or sets the distance when this optimized version should be used
  28643. */
  28644. distance: number;
  28645. /**
  28646. * Gets an already optimized mesh
  28647. */
  28648. optimizeMesh?: boolean;
  28649. }
  28650. /**
  28651. * Class used to specify simplification options
  28652. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28653. */
  28654. class SimplificationSettings implements ISimplificationSettings {
  28655. /** expected quality */
  28656. quality: number;
  28657. /** distance when this optimized version should be used */
  28658. distance: number;
  28659. /** already optimized mesh */
  28660. optimizeMesh?: boolean | undefined;
  28661. /**
  28662. * Creates a SimplificationSettings
  28663. * @param quality expected quality
  28664. * @param distance distance when this optimized version should be used
  28665. * @param optimizeMesh already optimized mesh
  28666. */
  28667. constructor(
  28668. /** expected quality */
  28669. quality: number,
  28670. /** distance when this optimized version should be used */
  28671. distance: number,
  28672. /** already optimized mesh */
  28673. optimizeMesh?: boolean | undefined);
  28674. }
  28675. /**
  28676. * Interface used to define a simplification task
  28677. */
  28678. interface ISimplificationTask {
  28679. /**
  28680. * Array of settings
  28681. */
  28682. settings: Array<ISimplificationSettings>;
  28683. /**
  28684. * Simplification type
  28685. */
  28686. simplificationType: SimplificationType;
  28687. /**
  28688. * Mesh to simplify
  28689. */
  28690. mesh: Mesh;
  28691. /**
  28692. * Callback called on success
  28693. */
  28694. successCallback?: () => void;
  28695. /**
  28696. * Defines if parallel processing can be used
  28697. */
  28698. parallelProcessing: boolean;
  28699. }
  28700. /**
  28701. * Queue used to order the simplification tasks
  28702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28703. */
  28704. class SimplificationQueue {
  28705. private _simplificationArray;
  28706. /**
  28707. * Gets a boolean indicating that the process is still running
  28708. */
  28709. running: boolean;
  28710. /**
  28711. * Creates a new queue
  28712. */
  28713. constructor();
  28714. /**
  28715. * Adds a new simplification task
  28716. * @param task defines a task to add
  28717. */
  28718. addTask(task: ISimplificationTask): void;
  28719. /**
  28720. * Execute next task
  28721. */
  28722. executeNext(): void;
  28723. /**
  28724. * Execute a simplification task
  28725. * @param task defines the task to run
  28726. */
  28727. runSimplification(task: ISimplificationTask): void;
  28728. private getSimplifier;
  28729. }
  28730. /**
  28731. * The implemented types of simplification
  28732. * At the moment only Quadratic Error Decimation is implemented
  28733. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28734. */
  28735. enum SimplificationType {
  28736. /** Quadratic error decimation */
  28737. QUADRATIC = 0
  28738. }
  28739. }
  28740. declare module BABYLON {
  28741. interface Scene {
  28742. /** @hidden (Backing field) */
  28743. _simplificationQueue: SimplificationQueue;
  28744. /**
  28745. * Gets or sets the simplification queue attached to the scene
  28746. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28747. */
  28748. simplificationQueue: SimplificationQueue;
  28749. }
  28750. interface Mesh {
  28751. /**
  28752. * Simplify the mesh according to the given array of settings.
  28753. * Function will return immediately and will simplify async
  28754. * @param settings a collection of simplification settings
  28755. * @param parallelProcessing should all levels calculate parallel or one after the other
  28756. * @param simplificationType the type of simplification to run
  28757. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28758. * @returns the current mesh
  28759. */
  28760. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28761. }
  28762. /**
  28763. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28764. * created in a scene
  28765. */
  28766. class SimplicationQueueSceneComponent implements ISceneComponent {
  28767. /**
  28768. * The component name helpfull to identify the component in the list of scene components.
  28769. */
  28770. readonly name: string;
  28771. /**
  28772. * The scene the component belongs to.
  28773. */
  28774. scene: Scene;
  28775. /**
  28776. * Creates a new instance of the component for the given scene
  28777. * @param scene Defines the scene to register the component in
  28778. */
  28779. constructor(scene: Scene);
  28780. /**
  28781. * Registers the component in a given scene
  28782. */
  28783. register(): void;
  28784. /**
  28785. * Rebuilds the elements related to this component in case of
  28786. * context lost for instance.
  28787. */
  28788. rebuild(): void;
  28789. /**
  28790. * Disposes the component and the associated ressources
  28791. */
  28792. dispose(): void;
  28793. private _beforeCameraUpdate;
  28794. }
  28795. }
  28796. declare module BABYLON {
  28797. /**
  28798. * Polygon
  28799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28800. */
  28801. class Polygon {
  28802. /**
  28803. * Creates a rectangle
  28804. * @param xmin bottom X coord
  28805. * @param ymin bottom Y coord
  28806. * @param xmax top X coord
  28807. * @param ymax top Y coord
  28808. * @returns points that make the resulting rectation
  28809. */
  28810. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28811. /**
  28812. * Creates a circle
  28813. * @param radius radius of circle
  28814. * @param cx scale in x
  28815. * @param cy scale in y
  28816. * @param numberOfSides number of sides that make up the circle
  28817. * @returns points that make the resulting circle
  28818. */
  28819. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28820. /**
  28821. * Creates a polygon from input string
  28822. * @param input Input polygon data
  28823. * @returns the parsed points
  28824. */
  28825. static Parse(input: string): Vector2[];
  28826. /**
  28827. * Starts building a polygon from x and y coordinates
  28828. * @param x x coordinate
  28829. * @param y y coordinate
  28830. * @returns the started path2
  28831. */
  28832. static StartingAt(x: number, y: number): Path2;
  28833. }
  28834. /**
  28835. * Builds a polygon
  28836. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28837. */
  28838. class PolygonMeshBuilder {
  28839. private _points;
  28840. private _outlinepoints;
  28841. private _holes;
  28842. private _name;
  28843. private _scene;
  28844. private _epoints;
  28845. private _eholes;
  28846. private _addToepoint;
  28847. /**
  28848. * Creates a PolygonMeshBuilder
  28849. * @param name name of the builder
  28850. * @param contours Path of the polygon
  28851. * @param scene scene to add to
  28852. */
  28853. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28854. /**
  28855. * Adds a whole within the polygon
  28856. * @param hole Array of points defining the hole
  28857. * @returns this
  28858. */
  28859. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28860. /**
  28861. * Creates the polygon
  28862. * @param updatable If the mesh should be updatable
  28863. * @param depth The depth of the mesh created
  28864. * @returns the created mesh
  28865. */
  28866. build(updatable?: boolean, depth?: number): Mesh;
  28867. /**
  28868. * Adds a side to the polygon
  28869. * @param positions points that make the polygon
  28870. * @param normals normals of the polygon
  28871. * @param uvs uvs of the polygon
  28872. * @param indices indices of the polygon
  28873. * @param bounds bounds of the polygon
  28874. * @param points points of the polygon
  28875. * @param depth depth of the polygon
  28876. * @param flip flip of the polygon
  28877. */
  28878. private addSide;
  28879. }
  28880. }
  28881. declare module BABYLON {
  28882. /**
  28883. * Base class for submeshes
  28884. */
  28885. class BaseSubMesh {
  28886. /** @hidden */
  28887. _materialDefines: Nullable<MaterialDefines>;
  28888. /** @hidden */
  28889. _materialEffect: Nullable<Effect>;
  28890. /**
  28891. * Gets associated effect
  28892. */
  28893. readonly effect: Nullable<Effect>;
  28894. /**
  28895. * Sets associated effect (effect used to render this submesh)
  28896. * @param effect defines the effect to associate with
  28897. * @param defines defines the set of defines used to compile this effect
  28898. */
  28899. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28900. }
  28901. /**
  28902. * Defines a subdivision inside a mesh
  28903. */
  28904. class SubMesh extends BaseSubMesh implements ICullable {
  28905. /** the material index to use */
  28906. materialIndex: number;
  28907. /** vertex index start */
  28908. verticesStart: number;
  28909. /** vertices count */
  28910. verticesCount: number;
  28911. /** index start */
  28912. indexStart: number;
  28913. /** indices count */
  28914. indexCount: number;
  28915. /** @hidden */
  28916. _linesIndexCount: number;
  28917. private _mesh;
  28918. private _renderingMesh;
  28919. private _boundingInfo;
  28920. private _linesIndexBuffer;
  28921. /** @hidden */
  28922. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28923. /** @hidden */
  28924. _trianglePlanes: Plane[];
  28925. /** @hidden */
  28926. _lastColliderTransformMatrix: Matrix;
  28927. /** @hidden */
  28928. _renderId: number;
  28929. /** @hidden */
  28930. _alphaIndex: number;
  28931. /** @hidden */
  28932. _distanceToCamera: number;
  28933. /** @hidden */
  28934. _id: number;
  28935. private _currentMaterial;
  28936. /**
  28937. * Add a new submesh to a mesh
  28938. * @param materialIndex defines the material index to use
  28939. * @param verticesStart defines vertex index start
  28940. * @param verticesCount defines vertices count
  28941. * @param indexStart defines index start
  28942. * @param indexCount defines indices count
  28943. * @param mesh defines the parent mesh
  28944. * @param renderingMesh defines an optional rendering mesh
  28945. * @param createBoundingBox defines if bounding box should be created for this submesh
  28946. * @returns the new submesh
  28947. */
  28948. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28949. /**
  28950. * Creates a new submesh
  28951. * @param materialIndex defines the material index to use
  28952. * @param verticesStart defines vertex index start
  28953. * @param verticesCount defines vertices count
  28954. * @param indexStart defines index start
  28955. * @param indexCount defines indices count
  28956. * @param mesh defines the parent mesh
  28957. * @param renderingMesh defines an optional rendering mesh
  28958. * @param createBoundingBox defines if bounding box should be created for this submesh
  28959. */
  28960. constructor(
  28961. /** the material index to use */
  28962. materialIndex: number,
  28963. /** vertex index start */
  28964. verticesStart: number,
  28965. /** vertices count */
  28966. verticesCount: number,
  28967. /** index start */
  28968. indexStart: number,
  28969. /** indices count */
  28970. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28971. /**
  28972. * Returns true if this submesh covers the entire parent mesh
  28973. * @ignorenaming
  28974. */
  28975. readonly IsGlobal: boolean;
  28976. /**
  28977. * Returns the submesh BoudingInfo object
  28978. * @returns current bounding info (or mesh's one if the submesh is global)
  28979. */
  28980. getBoundingInfo(): BoundingInfo;
  28981. /**
  28982. * Sets the submesh BoundingInfo
  28983. * @param boundingInfo defines the new bounding info to use
  28984. * @returns the SubMesh
  28985. */
  28986. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28987. /**
  28988. * Returns the mesh of the current submesh
  28989. * @return the parent mesh
  28990. */
  28991. getMesh(): AbstractMesh;
  28992. /**
  28993. * Returns the rendering mesh of the submesh
  28994. * @returns the rendering mesh (could be different from parent mesh)
  28995. */
  28996. getRenderingMesh(): Mesh;
  28997. /**
  28998. * Returns the submesh material
  28999. * @returns null or the current material
  29000. */
  29001. getMaterial(): Nullable<Material>;
  29002. /**
  29003. * Sets a new updated BoundingInfo object to the submesh
  29004. * @returns the SubMesh
  29005. */
  29006. refreshBoundingInfo(): SubMesh;
  29007. /** @hidden */
  29008. _checkCollision(collider: Collider): boolean;
  29009. /**
  29010. * Updates the submesh BoundingInfo
  29011. * @param world defines the world matrix to use to update the bounding info
  29012. * @returns the submesh
  29013. */
  29014. updateBoundingInfo(world: Matrix): SubMesh;
  29015. /**
  29016. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29017. * @param frustumPlanes defines the frustum planes
  29018. * @returns true if the submesh is intersecting with the frustum
  29019. */
  29020. isInFrustum(frustumPlanes: Plane[]): boolean;
  29021. /**
  29022. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29023. * @param frustumPlanes defines the frustum planes
  29024. * @returns true if the submesh is inside the frustum
  29025. */
  29026. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29027. /**
  29028. * Renders the submesh
  29029. * @param enableAlphaMode defines if alpha needs to be used
  29030. * @returns the submesh
  29031. */
  29032. render(enableAlphaMode: boolean): SubMesh;
  29033. /**
  29034. * @hidden
  29035. */
  29036. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29037. /**
  29038. * Checks if the submesh intersects with a ray
  29039. * @param ray defines the ray to test
  29040. * @returns true is the passed ray intersects the submesh bounding box
  29041. */
  29042. canIntersects(ray: Ray): boolean;
  29043. /**
  29044. * Intersects current submesh with a ray
  29045. * @param ray defines the ray to test
  29046. * @param positions defines mesh's positions array
  29047. * @param indices defines mesh's indices array
  29048. * @param fastCheck defines if only bounding info should be used
  29049. * @returns intersection info or null if no intersection
  29050. */
  29051. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29052. /** @hidden */
  29053. private _intersectLines;
  29054. /** @hidden */
  29055. private _intersectTriangles;
  29056. /** @hidden */
  29057. _rebuild(): void;
  29058. /**
  29059. * Creates a new submesh from the passed mesh
  29060. * @param newMesh defines the new hosting mesh
  29061. * @param newRenderingMesh defines an optional rendering mesh
  29062. * @returns the new submesh
  29063. */
  29064. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29065. /**
  29066. * Release associated resources
  29067. */
  29068. dispose(): void;
  29069. /**
  29070. * Creates a new submesh from indices data
  29071. * @param materialIndex the index of the main mesh material
  29072. * @param startIndex the index where to start the copy in the mesh indices array
  29073. * @param indexCount the number of indices to copy then from the startIndex
  29074. * @param mesh the main mesh to create the submesh from
  29075. * @param renderingMesh the optional rendering mesh
  29076. * @returns a new submesh
  29077. */
  29078. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29079. }
  29080. }
  29081. declare module BABYLON {
  29082. /**
  29083. * 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.
  29084. * @see https://doc.babylonjs.com/how_to/transformnode
  29085. */
  29086. class TransformNode extends Node {
  29087. /**
  29088. * Object will not rotate to face the camera
  29089. */
  29090. static BILLBOARDMODE_NONE: number;
  29091. /**
  29092. * Object will rotate to face the camera but only on the x axis
  29093. */
  29094. static BILLBOARDMODE_X: number;
  29095. /**
  29096. * Object will rotate to face the camera but only on the y axis
  29097. */
  29098. static BILLBOARDMODE_Y: number;
  29099. /**
  29100. * Object will rotate to face the camera but only on the z axis
  29101. */
  29102. static BILLBOARDMODE_Z: number;
  29103. /**
  29104. * Object will rotate to face the camera
  29105. */
  29106. static BILLBOARDMODE_ALL: number;
  29107. private _forward;
  29108. private _forwardInverted;
  29109. private _up;
  29110. private _right;
  29111. private _rightInverted;
  29112. private _position;
  29113. private _rotation;
  29114. private _rotationQuaternion;
  29115. protected _scaling: Vector3;
  29116. protected _isDirty: boolean;
  29117. private _transformToBoneReferal;
  29118. /**
  29119. * Set the billboard mode. Default is 0.
  29120. *
  29121. * | Value | Type | Description |
  29122. * | --- | --- | --- |
  29123. * | 0 | BILLBOARDMODE_NONE | |
  29124. * | 1 | BILLBOARDMODE_X | |
  29125. * | 2 | BILLBOARDMODE_Y | |
  29126. * | 4 | BILLBOARDMODE_Z | |
  29127. * | 7 | BILLBOARDMODE_ALL | |
  29128. *
  29129. */
  29130. billboardMode: number;
  29131. /**
  29132. * 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
  29133. */
  29134. scalingDeterminant: number;
  29135. /**
  29136. * Sets the distance of the object to max, often used by skybox
  29137. */
  29138. infiniteDistance: boolean;
  29139. /**
  29140. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29141. * By default the system will update normals to compensate
  29142. */
  29143. ignoreNonUniformScaling: boolean;
  29144. /** @hidden */
  29145. _poseMatrix: Matrix;
  29146. private _localWorld;
  29147. private _absolutePosition;
  29148. private _pivotMatrix;
  29149. private _pivotMatrixInverse;
  29150. private _postMultiplyPivotMatrix;
  29151. protected _isWorldMatrixFrozen: boolean;
  29152. /** @hidden */
  29153. _indexInSceneTransformNodesArray: number;
  29154. /**
  29155. * An event triggered after the world matrix is updated
  29156. */
  29157. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29158. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29159. /**
  29160. * Gets a string identifying the name of the class
  29161. * @returns "TransformNode" string
  29162. */
  29163. getClassName(): string;
  29164. /**
  29165. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29166. */
  29167. position: Vector3;
  29168. /**
  29169. * 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)).
  29170. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29171. */
  29172. rotation: Vector3;
  29173. /**
  29174. * 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)).
  29175. */
  29176. scaling: Vector3;
  29177. /**
  29178. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29179. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29180. */
  29181. rotationQuaternion: Nullable<Quaternion>;
  29182. /**
  29183. * The forward direction of that transform in world space.
  29184. */
  29185. readonly forward: Vector3;
  29186. /**
  29187. * The up direction of that transform in world space.
  29188. */
  29189. readonly up: Vector3;
  29190. /**
  29191. * The right direction of that transform in world space.
  29192. */
  29193. readonly right: Vector3;
  29194. /**
  29195. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29196. * @param matrix the matrix to copy the pose from
  29197. * @returns this TransformNode.
  29198. */
  29199. updatePoseMatrix(matrix: Matrix): TransformNode;
  29200. /**
  29201. * Returns the mesh Pose matrix.
  29202. * @returns the pose matrix
  29203. */
  29204. getPoseMatrix(): Matrix;
  29205. /** @hidden */
  29206. _isSynchronized(): boolean;
  29207. /** @hidden */
  29208. _initCache(): void;
  29209. /**
  29210. * Flag the transform node as dirty (Forcing it to update everything)
  29211. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29212. * @returns this transform node
  29213. */
  29214. markAsDirty(property: string): TransformNode;
  29215. /**
  29216. * Returns the current mesh absolute position.
  29217. * Returns a Vector3.
  29218. */
  29219. readonly absolutePosition: Vector3;
  29220. /**
  29221. * Sets a new matrix to apply before all other transformation
  29222. * @param matrix defines the transform matrix
  29223. * @returns the current TransformNode
  29224. */
  29225. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29226. /**
  29227. * Sets a new pivot matrix to the current node
  29228. * @param matrix defines the new pivot matrix to use
  29229. * @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
  29230. * @returns the current TransformNode
  29231. */
  29232. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  29233. /**
  29234. * Returns the mesh pivot matrix.
  29235. * Default : Identity.
  29236. * @returns the matrix
  29237. */
  29238. getPivotMatrix(): Matrix;
  29239. /**
  29240. * Prevents the World matrix to be computed any longer.
  29241. * @returns the TransformNode.
  29242. */
  29243. freezeWorldMatrix(): TransformNode;
  29244. /**
  29245. * Allows back the World matrix computation.
  29246. * @returns the TransformNode.
  29247. */
  29248. unfreezeWorldMatrix(): this;
  29249. /**
  29250. * True if the World matrix has been frozen.
  29251. */
  29252. readonly isWorldMatrixFrozen: boolean;
  29253. /**
  29254. * Retuns the mesh absolute position in the World.
  29255. * @returns a Vector3.
  29256. */
  29257. getAbsolutePosition(): Vector3;
  29258. /**
  29259. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29260. * @param absolutePosition the absolute position to set
  29261. * @returns the TransformNode.
  29262. */
  29263. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29264. /**
  29265. * Sets the mesh position in its local space.
  29266. * @param vector3 the position to set in localspace
  29267. * @returns the TransformNode.
  29268. */
  29269. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29270. /**
  29271. * Returns the mesh position in the local space from the current World matrix values.
  29272. * @returns a new Vector3.
  29273. */
  29274. getPositionExpressedInLocalSpace(): Vector3;
  29275. /**
  29276. * Translates the mesh along the passed Vector3 in its local space.
  29277. * @param vector3 the distance to translate in localspace
  29278. * @returns the TransformNode.
  29279. */
  29280. locallyTranslate(vector3: Vector3): TransformNode;
  29281. private static _lookAtVectorCache;
  29282. /**
  29283. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29284. * @param targetPoint the position (must be in same space as current mesh) to look at
  29285. * @param yawCor optional yaw (y-axis) correction in radians
  29286. * @param pitchCor optional pitch (x-axis) correction in radians
  29287. * @param rollCor optional roll (z-axis) correction in radians
  29288. * @param space the choosen space of the target
  29289. * @returns the TransformNode.
  29290. */
  29291. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29292. /**
  29293. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29294. * This Vector3 is expressed in the World space.
  29295. * @param localAxis axis to rotate
  29296. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29297. */
  29298. getDirection(localAxis: Vector3): Vector3;
  29299. /**
  29300. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29301. * localAxis is expressed in the mesh local space.
  29302. * result is computed in the Wordl space from the mesh World matrix.
  29303. * @param localAxis axis to rotate
  29304. * @param result the resulting transformnode
  29305. * @returns this TransformNode.
  29306. */
  29307. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29308. /**
  29309. * Sets a new pivot point to the current node
  29310. * @param point defines the new pivot point to use
  29311. * @param space defines if the point is in world or local space (local by default)
  29312. * @returns the current TransformNode
  29313. */
  29314. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29315. /**
  29316. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29317. * @returns the pivot point
  29318. */
  29319. getPivotPoint(): Vector3;
  29320. /**
  29321. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29322. * @param result the vector3 to store the result
  29323. * @returns this TransformNode.
  29324. */
  29325. getPivotPointToRef(result: Vector3): TransformNode;
  29326. /**
  29327. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29328. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29329. */
  29330. getAbsolutePivotPoint(): Vector3;
  29331. /**
  29332. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29333. * @param result vector3 to store the result
  29334. * @returns this TransformNode.
  29335. */
  29336. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29337. /**
  29338. * Defines the passed node as the parent of the current node.
  29339. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29340. * @param node the node ot set as the parent
  29341. * @returns this TransformNode.
  29342. */
  29343. setParent(node: Nullable<Node>): TransformNode;
  29344. private _nonUniformScaling;
  29345. /**
  29346. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29347. */
  29348. readonly nonUniformScaling: boolean;
  29349. /** @hidden */
  29350. _updateNonUniformScalingState(value: boolean): boolean;
  29351. /**
  29352. * Attach the current TransformNode to another TransformNode associated with a bone
  29353. * @param bone Bone affecting the TransformNode
  29354. * @param affectedTransformNode TransformNode associated with the bone
  29355. * @returns this object
  29356. */
  29357. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29358. /**
  29359. * Detach the transform node if its associated with a bone
  29360. * @returns this object
  29361. */
  29362. detachFromBone(): TransformNode;
  29363. private static _rotationAxisCache;
  29364. /**
  29365. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29366. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29367. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29368. * The passed axis is also normalized.
  29369. * @param axis the axis to rotate around
  29370. * @param amount the amount to rotate in radians
  29371. * @param space Space to rotate in (Default: local)
  29372. * @returns the TransformNode.
  29373. */
  29374. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29375. /**
  29376. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29377. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29378. * The passed axis is also normalized. .
  29379. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29380. * @param point the point to rotate around
  29381. * @param axis the axis to rotate around
  29382. * @param amount the amount to rotate in radians
  29383. * @returns the TransformNode
  29384. */
  29385. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29386. /**
  29387. * Translates the mesh along the axis vector for the passed distance in the given space.
  29388. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29389. * @param axis the axis to translate in
  29390. * @param distance the distance to translate
  29391. * @param space Space to rotate in (Default: local)
  29392. * @returns the TransformNode.
  29393. */
  29394. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29395. /**
  29396. * Adds a rotation step to the mesh current rotation.
  29397. * x, y, z are Euler angles expressed in radians.
  29398. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29399. * This means this rotation is made in the mesh local space only.
  29400. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29401. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29402. * ```javascript
  29403. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29404. * ```
  29405. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29406. * 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.
  29407. * @param x Rotation to add
  29408. * @param y Rotation to add
  29409. * @param z Rotation to add
  29410. * @returns the TransformNode.
  29411. */
  29412. addRotation(x: number, y: number, z: number): TransformNode;
  29413. /**
  29414. * Computes the world matrix of the node
  29415. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29416. * @returns the world matrix
  29417. */
  29418. computeWorldMatrix(force?: boolean): Matrix;
  29419. protected _afterComputeWorldMatrix(): void;
  29420. /**
  29421. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29422. * @param func callback function to add
  29423. *
  29424. * @returns the TransformNode.
  29425. */
  29426. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29427. /**
  29428. * Removes a registered callback function.
  29429. * @param func callback function to remove
  29430. * @returns the TransformNode.
  29431. */
  29432. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29433. /**
  29434. * Clone the current transform node
  29435. * @param name Name of the new clone
  29436. * @param newParent New parent for the clone
  29437. * @param doNotCloneChildren Do not clone children hierarchy
  29438. * @returns the new transform node
  29439. */
  29440. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29441. /**
  29442. * Serializes the objects information.
  29443. * @param currentSerializationObject defines the object to serialize in
  29444. * @returns the serialized object
  29445. */
  29446. serialize(currentSerializationObject?: any): any;
  29447. /**
  29448. * Returns a new TransformNode object parsed from the source provided.
  29449. * @param parsedTransformNode is the source.
  29450. * @param scene the scne the object belongs to
  29451. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29452. * @returns a new TransformNode object parsed from the source provided.
  29453. */
  29454. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29455. /**
  29456. * Releases resources associated with this transform node.
  29457. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29458. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29459. */
  29460. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29461. }
  29462. }
  29463. declare module BABYLON {
  29464. /**
  29465. * Specialized buffer used to store vertex data
  29466. */
  29467. class VertexBuffer {
  29468. /** @hidden */
  29469. _buffer: Buffer;
  29470. private _kind;
  29471. private _size;
  29472. private _ownsBuffer;
  29473. private _instanced;
  29474. private _instanceDivisor;
  29475. /**
  29476. * The byte type.
  29477. */
  29478. static readonly BYTE: number;
  29479. /**
  29480. * The unsigned byte type.
  29481. */
  29482. static readonly UNSIGNED_BYTE: number;
  29483. /**
  29484. * The short type.
  29485. */
  29486. static readonly SHORT: number;
  29487. /**
  29488. * The unsigned short type.
  29489. */
  29490. static readonly UNSIGNED_SHORT: number;
  29491. /**
  29492. * The integer type.
  29493. */
  29494. static readonly INT: number;
  29495. /**
  29496. * The unsigned integer type.
  29497. */
  29498. static readonly UNSIGNED_INT: number;
  29499. /**
  29500. * The float type.
  29501. */
  29502. static readonly FLOAT: number;
  29503. /**
  29504. * Gets or sets the instance divisor when in instanced mode
  29505. */
  29506. instanceDivisor: number;
  29507. /**
  29508. * Gets the byte stride.
  29509. */
  29510. readonly byteStride: number;
  29511. /**
  29512. * Gets the byte offset.
  29513. */
  29514. readonly byteOffset: number;
  29515. /**
  29516. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29517. */
  29518. readonly normalized: boolean;
  29519. /**
  29520. * Gets the data type of each component in the array.
  29521. */
  29522. readonly type: number;
  29523. /**
  29524. * Constructor
  29525. * @param engine the engine
  29526. * @param data the data to use for this vertex buffer
  29527. * @param kind the vertex buffer kind
  29528. * @param updatable whether the data is updatable
  29529. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29530. * @param stride the stride (optional)
  29531. * @param instanced whether the buffer is instanced (optional)
  29532. * @param offset the offset of the data (optional)
  29533. * @param size the number of components (optional)
  29534. * @param type the type of the component (optional)
  29535. * @param normalized whether the data contains normalized data (optional)
  29536. * @param useBytes set to true if stride and offset are in bytes (optional)
  29537. */
  29538. 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);
  29539. /** @hidden */
  29540. _rebuild(): void;
  29541. /**
  29542. * Returns the kind of the VertexBuffer (string)
  29543. * @returns a string
  29544. */
  29545. getKind(): string;
  29546. /**
  29547. * Gets a boolean indicating if the VertexBuffer is updatable?
  29548. * @returns true if the buffer is updatable
  29549. */
  29550. isUpdatable(): boolean;
  29551. /**
  29552. * Gets current buffer's data
  29553. * @returns a DataArray or null
  29554. */
  29555. getData(): Nullable<DataArray>;
  29556. /**
  29557. * Gets underlying native buffer
  29558. * @returns underlying native buffer
  29559. */
  29560. getBuffer(): Nullable<WebGLBuffer>;
  29561. /**
  29562. * Gets the stride in float32 units (i.e. byte stride / 4).
  29563. * May not be an integer if the byte stride is not divisible by 4.
  29564. * DEPRECATED. Use byteStride instead.
  29565. * @returns the stride in float32 units
  29566. */
  29567. getStrideSize(): number;
  29568. /**
  29569. * Returns the offset as a multiple of the type byte length.
  29570. * DEPRECATED. Use byteOffset instead.
  29571. * @returns the offset in bytes
  29572. */
  29573. getOffset(): number;
  29574. /**
  29575. * Returns the number of components per vertex attribute (integer)
  29576. * @returns the size in float
  29577. */
  29578. getSize(): number;
  29579. /**
  29580. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29581. * @returns true if this buffer is instanced
  29582. */
  29583. getIsInstanced(): boolean;
  29584. /**
  29585. * Returns the instancing divisor, zero for non-instanced (integer).
  29586. * @returns a number
  29587. */
  29588. getInstanceDivisor(): number;
  29589. /**
  29590. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29591. * @param data defines the data to store
  29592. */
  29593. create(data?: DataArray): void;
  29594. /**
  29595. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29596. * This function will create a new buffer if the current one is not updatable
  29597. * @param data defines the data to store
  29598. */
  29599. update(data: DataArray): void;
  29600. /**
  29601. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29602. * Returns the directly updated WebGLBuffer.
  29603. * @param data the new data
  29604. * @param offset the new offset
  29605. * @param useBytes set to true if the offset is in bytes
  29606. */
  29607. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29608. /**
  29609. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29610. */
  29611. dispose(): void;
  29612. /**
  29613. * Enumerates each value of this vertex buffer as numbers.
  29614. * @param count the number of values to enumerate
  29615. * @param callback the callback function called for each value
  29616. */
  29617. forEach(count: number, callback: (value: number, index: number) => void): void;
  29618. /**
  29619. * Positions
  29620. */
  29621. static readonly PositionKind: string;
  29622. /**
  29623. * Normals
  29624. */
  29625. static readonly NormalKind: string;
  29626. /**
  29627. * Tangents
  29628. */
  29629. static readonly TangentKind: string;
  29630. /**
  29631. * Texture coordinates
  29632. */
  29633. static readonly UVKind: string;
  29634. /**
  29635. * Texture coordinates 2
  29636. */
  29637. static readonly UV2Kind: string;
  29638. /**
  29639. * Texture coordinates 3
  29640. */
  29641. static readonly UV3Kind: string;
  29642. /**
  29643. * Texture coordinates 4
  29644. */
  29645. static readonly UV4Kind: string;
  29646. /**
  29647. * Texture coordinates 5
  29648. */
  29649. static readonly UV5Kind: string;
  29650. /**
  29651. * Texture coordinates 6
  29652. */
  29653. static readonly UV6Kind: string;
  29654. /**
  29655. * Colors
  29656. */
  29657. static readonly ColorKind: string;
  29658. /**
  29659. * Matrix indices (for bones)
  29660. */
  29661. static readonly MatricesIndicesKind: string;
  29662. /**
  29663. * Matrix weights (for bones)
  29664. */
  29665. static readonly MatricesWeightsKind: string;
  29666. /**
  29667. * Additional matrix indices (for bones)
  29668. */
  29669. static readonly MatricesIndicesExtraKind: string;
  29670. /**
  29671. * Additional matrix weights (for bones)
  29672. */
  29673. static readonly MatricesWeightsExtraKind: string;
  29674. /**
  29675. * Deduces the stride given a kind.
  29676. * @param kind The kind string to deduce
  29677. * @returns The deduced stride
  29678. */
  29679. static DeduceStride(kind: string): number;
  29680. /**
  29681. * Gets the byte length of the given type.
  29682. * @param type the type
  29683. * @returns the number of bytes
  29684. */
  29685. static GetTypeByteLength(type: number): number;
  29686. /**
  29687. * Enumerates each value of the given parameters as numbers.
  29688. * @param data the data to enumerate
  29689. * @param byteOffset the byte offset of the data
  29690. * @param byteStride the byte stride of the data
  29691. * @param componentCount the number of components per element
  29692. * @param componentType the type of the component
  29693. * @param count the total number of components
  29694. * @param normalized whether the data is normalized
  29695. * @param callback the callback function called for each value
  29696. */
  29697. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29698. private static _GetFloatValue;
  29699. }
  29700. }
  29701. declare module BABYLON {
  29702. /**
  29703. * Class used to enable access to IndexedDB
  29704. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29705. */
  29706. class Database implements IOfflineProvider {
  29707. private _callbackManifestChecked;
  29708. private _currentSceneUrl;
  29709. private _db;
  29710. private _enableSceneOffline;
  29711. private _enableTexturesOffline;
  29712. private _manifestVersionFound;
  29713. private _mustUpdateRessources;
  29714. private _hasReachedQuota;
  29715. private _isSupported;
  29716. private _idbFactory;
  29717. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29718. private static IsUASupportingBlobStorage;
  29719. /**
  29720. * Gets a boolean indicating if Database storate is enabled (off by default)
  29721. */
  29722. static IDBStorageEnabled: boolean;
  29723. /**
  29724. * Gets a boolean indicating if scene must be saved in the database
  29725. */
  29726. readonly enableSceneOffline: boolean;
  29727. /**
  29728. * Gets a boolean indicating if textures must be saved in the database
  29729. */
  29730. readonly enableTexturesOffline: boolean;
  29731. /**
  29732. * Creates a new Database
  29733. * @param urlToScene defines the url to load the scene
  29734. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29735. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29736. */
  29737. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29738. private static _ParseURL;
  29739. private static _ReturnFullUrlLocation;
  29740. private _checkManifestFile;
  29741. /**
  29742. * Open the database and make it available
  29743. * @param successCallback defines the callback to call on success
  29744. * @param errorCallback defines the callback to call on error
  29745. */
  29746. open(successCallback: () => void, errorCallback: () => void): void;
  29747. /**
  29748. * Loads an image from the database
  29749. * @param url defines the url to load from
  29750. * @param image defines the target DOM image
  29751. */
  29752. loadImage(url: string, image: HTMLImageElement): void;
  29753. private _loadImageFromDBAsync;
  29754. private _saveImageIntoDBAsync;
  29755. private _checkVersionFromDB;
  29756. private _loadVersionFromDBAsync;
  29757. private _saveVersionIntoDBAsync;
  29758. /**
  29759. * Loads a file from database
  29760. * @param url defines the URL to load from
  29761. * @param sceneLoaded defines a callback to call on success
  29762. * @param progressCallBack defines a callback to call when progress changed
  29763. * @param errorCallback defines a callback to call on error
  29764. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29765. */
  29766. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29767. private _loadFileAsync;
  29768. private _saveFileAsync;
  29769. }
  29770. }
  29771. declare module BABYLON {
  29772. /**
  29773. * Class used to enable access to offline support
  29774. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29775. */
  29776. interface IOfflineProvider {
  29777. /**
  29778. * Gets a boolean indicating if scene must be saved in the database
  29779. */
  29780. enableSceneOffline: boolean;
  29781. /**
  29782. * Gets a boolean indicating if textures must be saved in the database
  29783. */
  29784. enableTexturesOffline: boolean;
  29785. /**
  29786. * Open the offline support and make it available
  29787. * @param successCallback defines the callback to call on success
  29788. * @param errorCallback defines the callback to call on error
  29789. */
  29790. open(successCallback: () => void, errorCallback: () => void): void;
  29791. /**
  29792. * Loads an image from the offline support
  29793. * @param url defines the url to load from
  29794. * @param image defines the target DOM image
  29795. */
  29796. loadImage(url: string, image: HTMLImageElement): void;
  29797. /**
  29798. * Loads a file from offline support
  29799. * @param url defines the URL to load from
  29800. * @param sceneLoaded defines a callback to call on success
  29801. * @param progressCallBack defines a callback to call when progress changed
  29802. * @param errorCallback defines a callback to call on error
  29803. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29804. */
  29805. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29806. }
  29807. }
  29808. declare module BABYLON {
  29809. /**
  29810. * Interface used to describe a physics joint
  29811. */
  29812. interface PhysicsImpostorJoint {
  29813. /** Defines the main impostor to which the joint is linked */
  29814. mainImpostor: PhysicsImpostor;
  29815. /** Defines the impostor that is connected to the main impostor using this joint */
  29816. connectedImpostor: PhysicsImpostor;
  29817. /** Defines the joint itself */
  29818. joint: PhysicsJoint;
  29819. }
  29820. /** @hidden */
  29821. interface IPhysicsEnginePlugin {
  29822. world: any;
  29823. name: string;
  29824. setGravity(gravity: Vector3): void;
  29825. setTimeStep(timeStep: number): void;
  29826. getTimeStep(): number;
  29827. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  29828. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29829. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  29830. generatePhysicsBody(impostor: PhysicsImpostor): void;
  29831. removePhysicsBody(impostor: PhysicsImpostor): void;
  29832. generateJoint(joint: PhysicsImpostorJoint): void;
  29833. removeJoint(joint: PhysicsImpostorJoint): void;
  29834. isSupported(): boolean;
  29835. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  29836. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  29837. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29838. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  29839. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29840. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  29841. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  29842. getBodyMass(impostor: PhysicsImpostor): number;
  29843. getBodyFriction(impostor: PhysicsImpostor): number;
  29844. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  29845. getBodyRestitution(impostor: PhysicsImpostor): number;
  29846. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  29847. sleepBody(impostor: PhysicsImpostor): void;
  29848. wakeUpBody(impostor: PhysicsImpostor): void;
  29849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  29850. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  29851. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  29852. getRadius(impostor: PhysicsImpostor): number;
  29853. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  29854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  29855. dispose(): void;
  29856. }
  29857. /**
  29858. * Interface used to define a physics engine
  29859. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29860. */
  29861. interface IPhysicsEngine {
  29862. /**
  29863. * Gets the gravity vector used by the simulation
  29864. */
  29865. gravity: Vector3;
  29866. /**
  29867. * Sets the gravity vector used by the simulation
  29868. * @param gravity defines the gravity vector to use
  29869. */
  29870. setGravity(gravity: Vector3): void;
  29871. /**
  29872. * Set the time step of the physics engine.
  29873. * Default is 1/60.
  29874. * To slow it down, enter 1/600 for example.
  29875. * To speed it up, 1/30
  29876. * @param newTimeStep the new timestep to apply to this world.
  29877. */
  29878. setTimeStep(newTimeStep: number): void;
  29879. /**
  29880. * Get the time step of the physics engine.
  29881. * @returns the current time step
  29882. */
  29883. getTimeStep(): number;
  29884. /**
  29885. * Release all resources
  29886. */
  29887. dispose(): void;
  29888. /**
  29889. * Gets the name of the current physics plugin
  29890. * @returns the name of the plugin
  29891. */
  29892. getPhysicsPluginName(): string;
  29893. /**
  29894. * Adding a new impostor for the impostor tracking.
  29895. * This will be done by the impostor itself.
  29896. * @param impostor the impostor to add
  29897. */
  29898. addImpostor(impostor: PhysicsImpostor): void;
  29899. /**
  29900. * Remove an impostor from the engine.
  29901. * This impostor and its mesh will not longer be updated by the physics engine.
  29902. * @param impostor the impostor to remove
  29903. */
  29904. removeImpostor(impostor: PhysicsImpostor): void;
  29905. /**
  29906. * Add a joint to the physics engine
  29907. * @param mainImpostor defines the main impostor to which the joint is added.
  29908. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  29909. * @param joint defines the joint that will connect both impostors.
  29910. */
  29911. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29912. /**
  29913. * Removes a joint from the simulation
  29914. * @param mainImpostor defines the impostor used with the joint
  29915. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  29916. * @param joint defines the joint to remove
  29917. */
  29918. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  29919. /**
  29920. * Gets the current plugin used to run the simulation
  29921. * @returns current plugin
  29922. */
  29923. getPhysicsPlugin(): IPhysicsEnginePlugin;
  29924. /**
  29925. * Gets the list of physic impostors
  29926. * @returns an array of PhysicsImpostor
  29927. */
  29928. getImpostors(): Array<PhysicsImpostor>;
  29929. /**
  29930. * Gets the impostor for a physics enabled object
  29931. * @param object defines the object impersonated by the impostor
  29932. * @returns the PhysicsImpostor or null if not found
  29933. */
  29934. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29935. /**
  29936. * Gets the impostor for a physics body object
  29937. * @param body defines physics body used by the impostor
  29938. * @returns the PhysicsImpostor or null if not found
  29939. */
  29940. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  29941. /**
  29942. * Called by the scene. No need to call it.
  29943. * @param delta defines the timespam between frames
  29944. */
  29945. _step(delta: number): void;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. /**
  29950. * Class used to control physics engine
  29951. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  29952. */
  29953. class PhysicsEngine implements IPhysicsEngine {
  29954. private _physicsPlugin;
  29955. /**
  29956. * Global value used to control the smallest number supported by the simulation
  29957. */
  29958. static Epsilon: number;
  29959. private _impostors;
  29960. private _joints;
  29961. /**
  29962. * Gets the gravity vector used by the simulation
  29963. */
  29964. gravity: Vector3;
  29965. /**
  29966. * Creates a new Physics Engine
  29967. * @param gravity defines the gravity vector used by the simulation
  29968. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  29969. */
  29970. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  29971. /**
  29972. * Sets the gravity vector used by the simulation
  29973. * @param gravity defines the gravity vector to use
  29974. */
  29975. setGravity(gravity: Vector3): void;
  29976. /**
  29977. * Set the time step of the physics engine.
  29978. * Default is 1/60.
  29979. * To slow it down, enter 1/600 for example.
  29980. * To speed it up, 1/30
  29981. * @param newTimeStep defines the new timestep to apply to this world.
  29982. */
  29983. setTimeStep(newTimeStep?: number): void;
  29984. /**
  29985. * Get the time step of the physics engine.
  29986. * @returns the current time step
  29987. */
  29988. getTimeStep(): number;
  29989. /**
  29990. * Release all resources
  29991. */
  29992. dispose(): void;
  29993. /**
  29994. * Gets the name of the current physics plugin
  29995. * @returns the name of the plugin
  29996. */
  29997. getPhysicsPluginName(): string;
  29998. /**
  29999. * Adding a new impostor for the impostor tracking.
  30000. * This will be done by the impostor itself.
  30001. * @param impostor the impostor to add
  30002. */
  30003. addImpostor(impostor: PhysicsImpostor): void;
  30004. /**
  30005. * Remove an impostor from the engine.
  30006. * This impostor and its mesh will not longer be updated by the physics engine.
  30007. * @param impostor the impostor to remove
  30008. */
  30009. removeImpostor(impostor: PhysicsImpostor): void;
  30010. /**
  30011. * Add a joint to the physics engine
  30012. * @param mainImpostor defines the main impostor to which the joint is added.
  30013. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  30014. * @param joint defines the joint that will connect both impostors.
  30015. */
  30016. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30017. /**
  30018. * Removes a joint from the simulation
  30019. * @param mainImpostor defines the impostor used with the joint
  30020. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  30021. * @param joint defines the joint to remove
  30022. */
  30023. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  30024. /**
  30025. * Called by the scene. No need to call it.
  30026. * @param delta defines the timespam between frames
  30027. */
  30028. _step(delta: number): void;
  30029. /**
  30030. * Gets the current plugin used to run the simulation
  30031. * @returns current plugin
  30032. */
  30033. getPhysicsPlugin(): IPhysicsEnginePlugin;
  30034. /**
  30035. * Gets the list of physic impostors
  30036. * @returns an array of PhysicsImpostor
  30037. */
  30038. getImpostors(): Array<PhysicsImpostor>;
  30039. /**
  30040. * Gets the impostor for a physics enabled object
  30041. * @param object defines the object impersonated by the impostor
  30042. * @returns the PhysicsImpostor or null if not found
  30043. */
  30044. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30045. /**
  30046. * Gets the impostor for a physics body object
  30047. * @param body defines physics body used by the impostor
  30048. * @returns the PhysicsImpostor or null if not found
  30049. */
  30050. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  30051. }
  30052. }
  30053. declare module BABYLON {
  30054. interface Scene {
  30055. /** @hidden (Backing field) */
  30056. _physicsEngine: Nullable<IPhysicsEngine>;
  30057. /**
  30058. * Gets the current physics engine
  30059. * @returns a IPhysicsEngine or null if none attached
  30060. */
  30061. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  30062. /**
  30063. * Enables physics to the current scene
  30064. * @param gravity defines the scene's gravity for the physics engine
  30065. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  30066. * @return a boolean indicating if the physics engine was initialized
  30067. */
  30068. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  30069. /**
  30070. * Disables and disposes the physics engine associated with the scene
  30071. */
  30072. disablePhysicsEngine(): void;
  30073. /**
  30074. * Gets a boolean indicating if there is an active physics engine
  30075. * @returns a boolean indicating if there is an active physics engine
  30076. */
  30077. isPhysicsEnabled(): boolean;
  30078. /**
  30079. * Deletes a physics compound impostor
  30080. * @param compound defines the compound to delete
  30081. */
  30082. deleteCompoundImpostor(compound: any): void;
  30083. /**
  30084. * An event triggered when physic simulation is about to be run
  30085. */
  30086. onBeforePhysicsObservable: Observable<Scene>;
  30087. /**
  30088. * An event triggered when physic simulation has been done
  30089. */
  30090. onAfterPhysicsObservable: Observable<Scene>;
  30091. }
  30092. interface AbstractMesh {
  30093. /** @hidden */
  30094. _physicsImpostor: Nullable<PhysicsImpostor>;
  30095. /**
  30096. * Gets or sets impostor used for physic simulation
  30097. * @see http://doc.babylonjs.com/features/physics_engine
  30098. */
  30099. physicsImpostor: Nullable<PhysicsImpostor>;
  30100. /**
  30101. * Gets the current physics impostor
  30102. * @see http://doc.babylonjs.com/features/physics_engine
  30103. * @returns a physics impostor or null
  30104. */
  30105. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  30106. /** Apply a physic impulse to the mesh
  30107. * @param force defines the force to apply
  30108. * @param contactPoint defines where to apply the force
  30109. * @returns the current mesh
  30110. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  30111. */
  30112. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  30113. /**
  30114. * Creates a physic joint between two meshes
  30115. * @param otherMesh defines the other mesh to use
  30116. * @param pivot1 defines the pivot to use on this mesh
  30117. * @param pivot2 defines the pivot to use on the other mesh
  30118. * @param options defines additional options (can be plugin dependent)
  30119. * @returns the current mesh
  30120. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  30121. */
  30122. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  30123. /** @hidden */
  30124. _disposePhysicsObserver: Nullable<Observer<Node>>;
  30125. }
  30126. /**
  30127. * Defines the physics engine scene component responsible to manage a physics engine
  30128. */
  30129. class PhysicsEngineSceneComponent implements ISceneComponent {
  30130. /**
  30131. * The component name helpful to identify the component in the list of scene components.
  30132. */
  30133. readonly name: string;
  30134. /**
  30135. * The scene the component belongs to.
  30136. */
  30137. scene: Scene;
  30138. /**
  30139. * Creates a new instance of the component for the given scene
  30140. * @param scene Defines the scene to register the component in
  30141. */
  30142. constructor(scene: Scene);
  30143. /**
  30144. * Registers the component in a given scene
  30145. */
  30146. register(): void;
  30147. /**
  30148. * Rebuilds the elements related to this component in case of
  30149. * context lost for instance.
  30150. */
  30151. rebuild(): void;
  30152. /**
  30153. * Disposes the component and the associated ressources
  30154. */
  30155. dispose(): void;
  30156. }
  30157. }
  30158. declare module BABYLON {
  30159. /**
  30160. * A helper for physics simulations
  30161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30162. */
  30163. class PhysicsHelper {
  30164. private _scene;
  30165. private _physicsEngine;
  30166. /**
  30167. * Initializes the Physics helper
  30168. * @param scene Babylon.js scene
  30169. */
  30170. constructor(scene: Scene);
  30171. /**
  30172. * Applies a radial explosion impulse
  30173. * @param origin the origin of the explosion
  30174. * @param radius the explosion radius
  30175. * @param strength the explosion strength
  30176. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30177. * @returns A physics radial explosion event, or null
  30178. */
  30179. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30180. /**
  30181. * Applies a radial explosion force
  30182. * @param origin the origin of the explosion
  30183. * @param radius the explosion radius
  30184. * @param strength the explosion strength
  30185. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30186. * @returns A physics radial explosion event, or null
  30187. */
  30188. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  30189. /**
  30190. * Creates a gravitational field
  30191. * @param origin the origin of the explosion
  30192. * @param radius the explosion radius
  30193. * @param strength the explosion strength
  30194. * @param falloff possible options: Constant & Linear. Defaults to Constant
  30195. * @returns A physics gravitational field event, or null
  30196. */
  30197. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  30198. /**
  30199. * Creates a physics updraft event
  30200. * @param origin the origin of the updraft
  30201. * @param radius the radius of the updraft
  30202. * @param strength the strength of the updraft
  30203. * @param height the height of the updraft
  30204. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  30205. * @returns A physics updraft event, or null
  30206. */
  30207. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  30208. /**
  30209. * Creates a physics vortex event
  30210. * @param origin the of the vortex
  30211. * @param radius the radius of the vortex
  30212. * @param strength the strength of the vortex
  30213. * @param height the height of the vortex
  30214. * @returns a Physics vortex event, or null
  30215. * A physics vortex event or null
  30216. */
  30217. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  30218. }
  30219. /**
  30220. * Represents a physics radial explosion event
  30221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30222. */
  30223. class PhysicsRadialExplosionEvent {
  30224. private _scene;
  30225. private _sphere;
  30226. private _sphereOptions;
  30227. private _rays;
  30228. private _dataFetched;
  30229. /**
  30230. * Initializes a radial explosioin event
  30231. * @param scene BabylonJS scene
  30232. */
  30233. constructor(scene: Scene);
  30234. /**
  30235. * Returns the data related to the radial explosion event (sphere & rays).
  30236. * @returns The radial explosion event data
  30237. */
  30238. getData(): PhysicsRadialExplosionEventData;
  30239. /**
  30240. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  30241. * @param impostor A physics imposter
  30242. * @param origin the origin of the explosion
  30243. * @param radius the explosion radius
  30244. * @param strength the explosion strength
  30245. * @param falloff possible options: Constant & Linear
  30246. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  30247. */
  30248. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  30249. /**
  30250. * Disposes the sphere.
  30251. * @param force Specifies if the sphere should be disposed by force
  30252. */
  30253. dispose(force?: boolean): void;
  30254. /*** Helpers ***/
  30255. private _prepareSphere;
  30256. private _intersectsWithSphere;
  30257. }
  30258. /**
  30259. * Represents a gravitational field event
  30260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30261. */
  30262. class PhysicsGravitationalFieldEvent {
  30263. private _physicsHelper;
  30264. private _scene;
  30265. private _origin;
  30266. private _radius;
  30267. private _strength;
  30268. private _falloff;
  30269. private _tickCallback;
  30270. private _sphere;
  30271. private _dataFetched;
  30272. /**
  30273. * Initializes the physics gravitational field event
  30274. * @param physicsHelper A physics helper
  30275. * @param scene BabylonJS scene
  30276. * @param origin The origin position of the gravitational field event
  30277. * @param radius The radius of the gravitational field event
  30278. * @param strength The strength of the gravitational field event
  30279. * @param falloff The falloff for the gravitational field event
  30280. */
  30281. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  30282. /**
  30283. * Returns the data related to the gravitational field event (sphere).
  30284. * @returns A gravitational field event
  30285. */
  30286. getData(): PhysicsGravitationalFieldEventData;
  30287. /**
  30288. * Enables the gravitational field.
  30289. */
  30290. enable(): void;
  30291. /**
  30292. * Disables the gravitational field.
  30293. */
  30294. disable(): void;
  30295. /**
  30296. * Disposes the sphere.
  30297. * @param force The force to dispose from the gravitational field event
  30298. */
  30299. dispose(force?: boolean): void;
  30300. private _tick;
  30301. }
  30302. /**
  30303. * Represents a physics updraft event
  30304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30305. */
  30306. class PhysicsUpdraftEvent {
  30307. private _scene;
  30308. private _origin;
  30309. private _radius;
  30310. private _strength;
  30311. private _height;
  30312. private _updraftMode;
  30313. private _physicsEngine;
  30314. private _originTop;
  30315. private _originDirection;
  30316. private _tickCallback;
  30317. private _cylinder;
  30318. private _cylinderPosition;
  30319. private _dataFetched;
  30320. /**
  30321. * Initializes the physics updraft event
  30322. * @param _scene BabylonJS scene
  30323. * @param _origin The origin position of the updraft
  30324. * @param _radius The radius of the updraft
  30325. * @param _strength The strength of the updraft
  30326. * @param _height The height of the updraft
  30327. * @param _updraftMode The mode of the updraft
  30328. */
  30329. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  30330. /**
  30331. * Returns the data related to the updraft event (cylinder).
  30332. * @returns A physics updraft event
  30333. */
  30334. getData(): PhysicsUpdraftEventData;
  30335. /**
  30336. * Enables the updraft.
  30337. */
  30338. enable(): void;
  30339. /**
  30340. * Disables the cortex.
  30341. */
  30342. disable(): void;
  30343. /**
  30344. * Disposes the sphere.
  30345. * @param force Specifies if the updraft should be disposed by force
  30346. */
  30347. dispose(force?: boolean): void;
  30348. private getImpostorForceAndContactPoint;
  30349. private _tick;
  30350. /*** Helpers ***/
  30351. private _prepareCylinder;
  30352. private _intersectsWithCylinder;
  30353. }
  30354. /**
  30355. * Represents a physics vortex event
  30356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30357. */
  30358. class PhysicsVortexEvent {
  30359. private _scene;
  30360. private _origin;
  30361. private _radius;
  30362. private _strength;
  30363. private _height;
  30364. private _physicsEngine;
  30365. private _originTop;
  30366. private _centripetalForceThreshold;
  30367. private _updraftMultiplier;
  30368. private _tickCallback;
  30369. private _cylinder;
  30370. private _cylinderPosition;
  30371. private _dataFetched;
  30372. /**
  30373. * Initializes the physics vortex event
  30374. * @param _scene The BabylonJS scene
  30375. * @param _origin The origin position of the vortex
  30376. * @param _radius The radius of the vortex
  30377. * @param _strength The strength of the vortex
  30378. * @param _height The height of the vortex
  30379. */
  30380. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  30381. /**
  30382. * Returns the data related to the vortex event (cylinder).
  30383. * @returns The physics vortex event data
  30384. */
  30385. getData(): PhysicsVortexEventData;
  30386. /**
  30387. * Enables the vortex.
  30388. */
  30389. enable(): void;
  30390. /**
  30391. * Disables the cortex.
  30392. */
  30393. disable(): void;
  30394. /**
  30395. * Disposes the sphere.
  30396. * @param force
  30397. */
  30398. dispose(force?: boolean): void;
  30399. private getImpostorForceAndContactPoint;
  30400. private _tick;
  30401. /*** Helpers ***/
  30402. private _prepareCylinder;
  30403. private _intersectsWithCylinder;
  30404. }
  30405. /**
  30406. * The strenght of the force in correspondence to the distance of the affected object
  30407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30408. */
  30409. enum PhysicsRadialImpulseFalloff {
  30410. /** Defines that impulse is constant in strength across it's whole radius */
  30411. Constant = 0,
  30412. /** DEfines that impulse gets weaker if it's further from the origin */
  30413. Linear = 1
  30414. }
  30415. /**
  30416. * The strength of the force in correspondence to the distance of the affected object
  30417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30418. */
  30419. enum PhysicsUpdraftMode {
  30420. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  30421. Center = 0,
  30422. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  30423. Perpendicular = 1
  30424. }
  30425. /**
  30426. * Interface for a physics force and contact point
  30427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30428. */
  30429. interface PhysicsForceAndContactPoint {
  30430. /**
  30431. * The force applied at the contact point
  30432. */
  30433. force: Vector3;
  30434. /**
  30435. * The contact point
  30436. */
  30437. contactPoint: Vector3;
  30438. }
  30439. /**
  30440. * Interface for radial explosion event data
  30441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30442. */
  30443. interface PhysicsRadialExplosionEventData {
  30444. /**
  30445. * A sphere used for the radial explosion event
  30446. */
  30447. sphere: Mesh;
  30448. /**
  30449. * An array of rays for the radial explosion event
  30450. */
  30451. rays: Array<Ray>;
  30452. }
  30453. /**
  30454. * Interface for gravitational field event data
  30455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30456. */
  30457. interface PhysicsGravitationalFieldEventData {
  30458. /**
  30459. * A sphere mesh used for the gravitational field event
  30460. */
  30461. sphere: Mesh;
  30462. }
  30463. /**
  30464. * Interface for updraft event data
  30465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30466. */
  30467. interface PhysicsUpdraftEventData {
  30468. /**
  30469. * A cylinder used for the updraft event
  30470. */
  30471. cylinder: Mesh;
  30472. }
  30473. /**
  30474. * Interface for vortex event data
  30475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30476. */
  30477. interface PhysicsVortexEventData {
  30478. /**
  30479. * A cylinder used for the vortex event
  30480. */
  30481. cylinder: Mesh;
  30482. }
  30483. }
  30484. declare module BABYLON {
  30485. /**
  30486. * The interface for the physics imposter parameters
  30487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30488. */
  30489. interface PhysicsImpostorParameters {
  30490. /**
  30491. * The mass of the physics imposter
  30492. */
  30493. mass: number;
  30494. /**
  30495. * The friction of the physics imposter
  30496. */
  30497. friction?: number;
  30498. /**
  30499. * The coefficient of restitution of the physics imposter
  30500. */
  30501. restitution?: number;
  30502. /**
  30503. * The native options of the physics imposter
  30504. */
  30505. nativeOptions?: any;
  30506. /**
  30507. * Specifies if the parent should be ignored
  30508. */
  30509. ignoreParent?: boolean;
  30510. /**
  30511. * Specifies if bi-directional transformations should be disabled
  30512. */
  30513. disableBidirectionalTransformation?: boolean;
  30514. }
  30515. /**
  30516. * Interface for a physics-enabled object
  30517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30518. */
  30519. interface IPhysicsEnabledObject {
  30520. /**
  30521. * The position of the physics-enabled object
  30522. */
  30523. position: Vector3;
  30524. /**
  30525. * The rotation of the physics-enabled object
  30526. */
  30527. rotationQuaternion: Nullable<Quaternion>;
  30528. /**
  30529. * The scale of the physics-enabled object
  30530. */
  30531. scaling: Vector3;
  30532. /**
  30533. * The rotation of the physics-enabled object
  30534. */
  30535. rotation?: Vector3;
  30536. /**
  30537. * The parent of the physics-enabled object
  30538. */
  30539. parent?: any;
  30540. /**
  30541. * The bounding info of the physics-enabled object
  30542. * @returns The bounding info of the physics-enabled object
  30543. */
  30544. getBoundingInfo(): BoundingInfo;
  30545. /**
  30546. * Computes the world matrix
  30547. * @param force Specifies if the world matrix should be computed by force
  30548. * @returns A world matrix
  30549. */
  30550. computeWorldMatrix(force: boolean): Matrix;
  30551. /**
  30552. * Gets the world matrix
  30553. * @returns A world matrix
  30554. */
  30555. getWorldMatrix?(): Matrix;
  30556. /**
  30557. * Gets the child meshes
  30558. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  30559. * @returns An array of abstract meshes
  30560. */
  30561. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  30562. /**
  30563. * Gets the vertex data
  30564. * @param kind The type of vertex data
  30565. * @returns A nullable array of numbers, or a float32 array
  30566. */
  30567. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  30568. /**
  30569. * Gets the indices from the mesh
  30570. * @returns A nullable array of index arrays
  30571. */
  30572. getIndices?(): Nullable<IndicesArray>;
  30573. /**
  30574. * Gets the scene from the mesh
  30575. * @returns the indices array or null
  30576. */
  30577. getScene?(): Scene;
  30578. /**
  30579. * Gets the absolute position from the mesh
  30580. * @returns the absolute position
  30581. */
  30582. getAbsolutePosition(): Vector3;
  30583. /**
  30584. * Gets the absolute pivot point from the mesh
  30585. * @returns the absolute pivot point
  30586. */
  30587. getAbsolutePivotPoint(): Vector3;
  30588. /**
  30589. * Rotates the mesh
  30590. * @param axis The axis of rotation
  30591. * @param amount The amount of rotation
  30592. * @param space The space of the rotation
  30593. * @returns The rotation transform node
  30594. */
  30595. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  30596. /**
  30597. * Translates the mesh
  30598. * @param axis The axis of translation
  30599. * @param distance The distance of translation
  30600. * @param space The space of the translation
  30601. * @returns The transform node
  30602. */
  30603. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  30604. /**
  30605. * Sets the absolute position of the mesh
  30606. * @param absolutePosition The absolute position of the mesh
  30607. * @returns The transform node
  30608. */
  30609. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  30610. /**
  30611. * Gets the class name of the mesh
  30612. * @returns The class name
  30613. */
  30614. getClassName(): string;
  30615. }
  30616. /**
  30617. * Represents a physics imposter
  30618. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30619. */
  30620. class PhysicsImpostor {
  30621. /**
  30622. * The physics-enabled object used as the physics imposter
  30623. */
  30624. object: IPhysicsEnabledObject;
  30625. /**
  30626. * The type of the physics imposter
  30627. */
  30628. type: number;
  30629. private _options;
  30630. private _scene?;
  30631. /**
  30632. * The default object size of the imposter
  30633. */
  30634. static DEFAULT_OBJECT_SIZE: Vector3;
  30635. /**
  30636. * The identity quaternion of the imposter
  30637. */
  30638. static IDENTITY_QUATERNION: Quaternion;
  30639. private _physicsEngine;
  30640. private _physicsBody;
  30641. private _bodyUpdateRequired;
  30642. private _onBeforePhysicsStepCallbacks;
  30643. private _onAfterPhysicsStepCallbacks;
  30644. private _onPhysicsCollideCallbacks;
  30645. private _deltaPosition;
  30646. private _deltaRotation;
  30647. private _deltaRotationConjugated;
  30648. private _parent;
  30649. private _isDisposed;
  30650. private static _tmpVecs;
  30651. private static _tmpQuat;
  30652. /**
  30653. * Specifies if the physics imposter is disposed
  30654. */
  30655. readonly isDisposed: boolean;
  30656. /**
  30657. * Gets the mass of the physics imposter
  30658. */
  30659. mass: number;
  30660. /**
  30661. * Gets the coefficient of friction
  30662. */
  30663. /**
  30664. * Sets the coefficient of friction
  30665. */
  30666. friction: number;
  30667. /**
  30668. * Gets the coefficient of restitution
  30669. */
  30670. /**
  30671. * Sets the coefficient of restitution
  30672. */
  30673. restitution: number;
  30674. /**
  30675. * The unique id of the physics imposter
  30676. * set by the physics engine when adding this impostor to the array
  30677. */
  30678. uniqueId: number;
  30679. private _joints;
  30680. /**
  30681. * Initializes the physics imposter
  30682. * @param object The physics-enabled object used as the physics imposter
  30683. * @param type The type of the physics imposter
  30684. * @param _options The options for the physics imposter
  30685. * @param _scene The Babylon scene
  30686. */
  30687. constructor(
  30688. /**
  30689. * The physics-enabled object used as the physics imposter
  30690. */
  30691. object: IPhysicsEnabledObject,
  30692. /**
  30693. * The type of the physics imposter
  30694. */
  30695. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  30696. /**
  30697. * This function will completly initialize this impostor.
  30698. * It will create a new body - but only if this mesh has no parent.
  30699. * If it has, this impostor will not be used other than to define the impostor
  30700. * of the child mesh.
  30701. * @hidden
  30702. */
  30703. _init(): void;
  30704. private _getPhysicsParent;
  30705. /**
  30706. * Should a new body be generated.
  30707. * @returns boolean specifying if body initialization is required
  30708. */
  30709. isBodyInitRequired(): boolean;
  30710. /**
  30711. * Sets the updated scaling
  30712. * @param updated Specifies if the scaling is updated
  30713. */
  30714. setScalingUpdated(updated: boolean): void;
  30715. /**
  30716. * Force a regeneration of this or the parent's impostor's body.
  30717. * Use under cautious - This will remove all joints already implemented.
  30718. */
  30719. forceUpdate(): void;
  30720. /**
  30721. * Gets the body that holds this impostor. Either its own, or its parent.
  30722. */
  30723. /**
  30724. * Set the physics body. Used mainly by the physics engine/plugin
  30725. */
  30726. physicsBody: any;
  30727. /**
  30728. * Get the parent of the physics imposter
  30729. * @returns Physics imposter or null
  30730. */
  30731. /**
  30732. * Sets the parent of the physics imposter
  30733. */
  30734. parent: Nullable<PhysicsImpostor>;
  30735. /**
  30736. * Resets the update flags
  30737. */
  30738. resetUpdateFlags(): void;
  30739. /**
  30740. * Gets the object extend size
  30741. * @returns the object extend size
  30742. */
  30743. getObjectExtendSize(): Vector3;
  30744. /**
  30745. * Gets the object center
  30746. * @returns The object center
  30747. */
  30748. getObjectCenter(): Vector3;
  30749. /**
  30750. * Get a specific parametes from the options parameter
  30751. * @param paramName The object parameter name
  30752. * @returns The object parameter
  30753. */
  30754. getParam(paramName: string): any;
  30755. /**
  30756. * Sets a specific parameter in the options given to the physics plugin
  30757. * @param paramName The parameter name
  30758. * @param value The value of the parameter
  30759. */
  30760. setParam(paramName: string, value: number): void;
  30761. /**
  30762. * Specifically change the body's mass option. Won't recreate the physics body object
  30763. * @param mass The mass of the physics imposter
  30764. */
  30765. setMass(mass: number): void;
  30766. /**
  30767. * Gets the linear velocity
  30768. * @returns linear velocity or null
  30769. */
  30770. getLinearVelocity(): Nullable<Vector3>;
  30771. /**
  30772. * Sets the linear velocity
  30773. * @param velocity linear velocity or null
  30774. */
  30775. setLinearVelocity(velocity: Nullable<Vector3>): void;
  30776. /**
  30777. * Gets the angular velocity
  30778. * @returns angular velocity or null
  30779. */
  30780. getAngularVelocity(): Nullable<Vector3>;
  30781. /**
  30782. * Sets the angular velocity
  30783. * @param velocity The velocity or null
  30784. */
  30785. setAngularVelocity(velocity: Nullable<Vector3>): void;
  30786. /**
  30787. * Execute a function with the physics plugin native code
  30788. * Provide a function the will have two variables - the world object and the physics body object
  30789. * @param func The function to execute with the physics plugin native code
  30790. */
  30791. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  30792. /**
  30793. * Register a function that will be executed before the physics world is stepping forward
  30794. * @param func The function to execute before the physics world is stepped forward
  30795. */
  30796. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30797. /**
  30798. * Unregister a function that will be executed before the physics world is stepping forward
  30799. * @param func The function to execute before the physics world is stepped forward
  30800. */
  30801. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30802. /**
  30803. * Register a function that will be executed after the physics step
  30804. * @param func The function to execute after physics step
  30805. */
  30806. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30807. /**
  30808. * Unregisters a function that will be executed after the physics step
  30809. * @param func The function to execute after physics step
  30810. */
  30811. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  30812. /**
  30813. * register a function that will be executed when this impostor collides against a different body
  30814. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  30815. * @param func Callback that is executed on collision
  30816. */
  30817. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  30818. /**
  30819. * Unregisters the physics imposter on contact
  30820. * @param collideAgainst The physics object to collide against
  30821. * @param func Callback to execute on collision
  30822. */
  30823. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  30824. private _tmpQuat;
  30825. private _tmpQuat2;
  30826. /**
  30827. * Get the parent rotation
  30828. * @returns The parent rotation
  30829. */
  30830. getParentsRotation(): Quaternion;
  30831. /**
  30832. * this function is executed by the physics engine.
  30833. */
  30834. beforeStep: () => void;
  30835. /**
  30836. * this function is executed by the physics engine
  30837. */
  30838. afterStep: () => void;
  30839. /**
  30840. * Legacy collision detection event support
  30841. */
  30842. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  30843. /**
  30844. * event and body object due to cannon's event-based architecture.
  30845. */
  30846. onCollide: (e: {
  30847. body: any;
  30848. }) => void;
  30849. /**
  30850. * Apply a force
  30851. * @param force The force to apply
  30852. * @param contactPoint The contact point for the force
  30853. * @returns The physics imposter
  30854. */
  30855. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30856. /**
  30857. * Apply an impulse
  30858. * @param force The impulse force
  30859. * @param contactPoint The contact point for the impulse force
  30860. * @returns The physics imposter
  30861. */
  30862. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  30863. /**
  30864. * A help function to create a joint
  30865. * @param otherImpostor A physics imposter used to create a joint
  30866. * @param jointType The type of joint
  30867. * @param jointData The data for the joint
  30868. * @returns The physics imposter
  30869. */
  30870. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  30871. /**
  30872. * Add a joint to this impostor with a different impostor
  30873. * @param otherImpostor A physics imposter used to add a joint
  30874. * @param joint The joint to add
  30875. * @returns The physics imposter
  30876. */
  30877. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  30878. /**
  30879. * Will keep this body still, in a sleep mode.
  30880. * @returns the physics imposter
  30881. */
  30882. sleep(): PhysicsImpostor;
  30883. /**
  30884. * Wake the body up.
  30885. * @returns The physics imposter
  30886. */
  30887. wakeUp(): PhysicsImpostor;
  30888. /**
  30889. * Clones the physics imposter
  30890. * @param newObject The physics imposter clones to this physics-enabled object
  30891. * @returns A nullable physics imposter
  30892. */
  30893. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  30894. /**
  30895. * Disposes the physics imposter
  30896. */
  30897. dispose(): void;
  30898. /**
  30899. * Sets the delta position
  30900. * @param position The delta position amount
  30901. */
  30902. setDeltaPosition(position: Vector3): void;
  30903. /**
  30904. * Sets the delta rotation
  30905. * @param rotation The delta rotation amount
  30906. */
  30907. setDeltaRotation(rotation: Quaternion): void;
  30908. /**
  30909. * Gets the box size of the physics imposter and stores the result in the input parameter
  30910. * @param result Stores the box size
  30911. * @returns The physics imposter
  30912. */
  30913. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  30914. /**
  30915. * Gets the radius of the physics imposter
  30916. * @returns Radius of the physics imposter
  30917. */
  30918. getRadius(): number;
  30919. /**
  30920. * Sync a bone with this impostor
  30921. * @param bone The bone to sync to the impostor.
  30922. * @param boneMesh The mesh that the bone is influencing.
  30923. * @param jointPivot The pivot of the joint / bone in local space.
  30924. * @param distToJoint Optional distance from the impostor to the joint.
  30925. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30926. */
  30927. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  30928. /**
  30929. * Sync impostor to a bone
  30930. * @param bone The bone that the impostor will be synced to.
  30931. * @param boneMesh The mesh that the bone is influencing.
  30932. * @param jointPivot The pivot of the joint / bone in local space.
  30933. * @param distToJoint Optional distance from the impostor to the joint.
  30934. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  30935. * @param boneAxis Optional vector3 axis the bone is aligned with
  30936. */
  30937. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  30938. /**
  30939. * No-Imposter type
  30940. */
  30941. static NoImpostor: number;
  30942. /**
  30943. * Sphere-Imposter type
  30944. */
  30945. static SphereImpostor: number;
  30946. /**
  30947. * Box-Imposter type
  30948. */
  30949. static BoxImpostor: number;
  30950. /**
  30951. * Plane-Imposter type
  30952. */
  30953. static PlaneImpostor: number;
  30954. /**
  30955. * Mesh-imposter type
  30956. */
  30957. static MeshImpostor: number;
  30958. /**
  30959. * Cylinder-Imposter type
  30960. */
  30961. static CylinderImpostor: number;
  30962. /**
  30963. * Particle-Imposter type
  30964. */
  30965. static ParticleImpostor: number;
  30966. /**
  30967. * Heightmap-Imposter type
  30968. */
  30969. static HeightmapImpostor: number;
  30970. }
  30971. }
  30972. declare module BABYLON {
  30973. /**
  30974. * Interface for Physics-Joint data
  30975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30976. */
  30977. interface PhysicsJointData {
  30978. /**
  30979. * The main pivot of the joint
  30980. */
  30981. mainPivot?: Vector3;
  30982. /**
  30983. * The connected pivot of the joint
  30984. */
  30985. connectedPivot?: Vector3;
  30986. /**
  30987. * The main axis of the joint
  30988. */
  30989. mainAxis?: Vector3;
  30990. /**
  30991. * The connected axis of the joint
  30992. */
  30993. connectedAxis?: Vector3;
  30994. /**
  30995. * The collision of the joint
  30996. */
  30997. collision?: boolean;
  30998. /**
  30999. * Native Oimo/Cannon/Energy data
  31000. */
  31001. nativeParams?: any;
  31002. }
  31003. /**
  31004. * This is a holder class for the physics joint created by the physics plugin
  31005. * It holds a set of functions to control the underlying joint
  31006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31007. */
  31008. class PhysicsJoint {
  31009. /**
  31010. * The type of the physics joint
  31011. */
  31012. type: number;
  31013. /**
  31014. * The data for the physics joint
  31015. */
  31016. jointData: PhysicsJointData;
  31017. private _physicsJoint;
  31018. protected _physicsPlugin: IPhysicsEnginePlugin;
  31019. /**
  31020. * Initializes the physics joint
  31021. * @param type The type of the physics joint
  31022. * @param jointData The data for the physics joint
  31023. */
  31024. constructor(
  31025. /**
  31026. * The type of the physics joint
  31027. */
  31028. type: number,
  31029. /**
  31030. * The data for the physics joint
  31031. */
  31032. jointData: PhysicsJointData);
  31033. /**
  31034. * Gets the physics joint
  31035. */
  31036. /**
  31037. * Sets the physics joint
  31038. */
  31039. physicsJoint: any;
  31040. /**
  31041. * Sets the physics plugin
  31042. */
  31043. physicsPlugin: IPhysicsEnginePlugin;
  31044. /**
  31045. * Execute a function that is physics-plugin specific.
  31046. * @param {Function} func the function that will be executed.
  31047. * It accepts two parameters: the physics world and the physics joint
  31048. */
  31049. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31050. /**
  31051. * Distance-Joint type
  31052. */
  31053. static DistanceJoint: number;
  31054. /**
  31055. * Hinge-Joint type
  31056. */
  31057. static HingeJoint: number;
  31058. /**
  31059. * Ball-and-Socket joint type
  31060. */
  31061. static BallAndSocketJoint: number;
  31062. /**
  31063. * Wheel-Joint type
  31064. */
  31065. static WheelJoint: number;
  31066. /**
  31067. * Slider-Joint type
  31068. */
  31069. static SliderJoint: number;
  31070. /**
  31071. * Prismatic-Joint type
  31072. */
  31073. static PrismaticJoint: number;
  31074. /**
  31075. * Universal-Joint type
  31076. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31077. */
  31078. static UniversalJoint: number;
  31079. /**
  31080. * Hinge-Joint 2 type
  31081. */
  31082. static Hinge2Joint: number;
  31083. /**
  31084. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31085. */
  31086. static PointToPointJoint: number;
  31087. /**
  31088. * Spring-Joint type
  31089. */
  31090. static SpringJoint: number;
  31091. /**
  31092. * Lock-Joint type
  31093. */
  31094. static LockJoint: number;
  31095. }
  31096. /**
  31097. * A class representing a physics distance joint
  31098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31099. */
  31100. class DistanceJoint extends PhysicsJoint {
  31101. /**
  31102. *
  31103. * @param jointData The data for the Distance-Joint
  31104. */
  31105. constructor(jointData: DistanceJointData);
  31106. /**
  31107. * Update the predefined distance.
  31108. * @param maxDistance The maximum preferred distance
  31109. * @param minDistance The minimum preferred distance
  31110. */
  31111. updateDistance(maxDistance: number, minDistance?: number): void;
  31112. }
  31113. /**
  31114. * Represents a Motor-Enabled Joint
  31115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31116. */
  31117. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31118. /**
  31119. * Initializes the Motor-Enabled Joint
  31120. * @param type The type of the joint
  31121. * @param jointData The physica joint data for the joint
  31122. */
  31123. constructor(type: number, jointData: PhysicsJointData);
  31124. /**
  31125. * Set the motor values.
  31126. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31127. * @param force the force to apply
  31128. * @param maxForce max force for this motor.
  31129. */
  31130. setMotor(force?: number, maxForce?: number): void;
  31131. /**
  31132. * Set the motor's limits.
  31133. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31134. * @param upperLimit The upper limit of the motor
  31135. * @param lowerLimit The lower limit of the motor
  31136. */
  31137. setLimit(upperLimit: number, lowerLimit?: number): void;
  31138. }
  31139. /**
  31140. * This class represents a single physics Hinge-Joint
  31141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31142. */
  31143. class HingeJoint extends MotorEnabledJoint {
  31144. /**
  31145. * Initializes the Hinge-Joint
  31146. * @param jointData The joint data for the Hinge-Joint
  31147. */
  31148. constructor(jointData: PhysicsJointData);
  31149. /**
  31150. * Set the motor values.
  31151. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31152. * @param {number} force the force to apply
  31153. * @param {number} maxForce max force for this motor.
  31154. */
  31155. setMotor(force?: number, maxForce?: number): void;
  31156. /**
  31157. * Set the motor's limits.
  31158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31159. * @param upperLimit The upper limit of the motor
  31160. * @param lowerLimit The lower limit of the motor
  31161. */
  31162. setLimit(upperLimit: number, lowerLimit?: number): void;
  31163. }
  31164. /**
  31165. * This class represents a dual hinge physics joint (same as wheel joint)
  31166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31167. */
  31168. class Hinge2Joint extends MotorEnabledJoint {
  31169. /**
  31170. * Initializes the Hinge2-Joint
  31171. * @param jointData The joint data for the Hinge2-Joint
  31172. */
  31173. constructor(jointData: PhysicsJointData);
  31174. /**
  31175. * Set the motor values.
  31176. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31177. * @param {number} force the force to apply
  31178. * @param {number} maxForce max force for this motor.
  31179. * @param {motorIndex} the motor's index, 0 or 1.
  31180. */
  31181. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31182. /**
  31183. * Set the motor limits.
  31184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31185. * @param {number} upperLimit the upper limit
  31186. * @param {number} lowerLimit lower limit
  31187. * @param {motorIndex} the motor's index, 0 or 1.
  31188. */
  31189. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31190. }
  31191. /**
  31192. * Interface for a motor enabled joint
  31193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31194. */
  31195. interface IMotorEnabledJoint {
  31196. /**
  31197. * Physics joint
  31198. */
  31199. physicsJoint: any;
  31200. /**
  31201. * Sets the motor of the motor-enabled joint
  31202. * @param force The force of the motor
  31203. * @param maxForce The maximum force of the motor
  31204. * @param motorIndex The index of the motor
  31205. */
  31206. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31207. /**
  31208. * Sets the limit of the motor
  31209. * @param upperLimit The upper limit of the motor
  31210. * @param lowerLimit The lower limit of the motor
  31211. * @param motorIndex The index of the motor
  31212. */
  31213. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31214. }
  31215. /**
  31216. * Joint data for a Distance-Joint
  31217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31218. */
  31219. interface DistanceJointData extends PhysicsJointData {
  31220. /**
  31221. * Max distance the 2 joint objects can be apart
  31222. */
  31223. maxDistance: number;
  31224. }
  31225. /**
  31226. * Joint data from a spring joint
  31227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31228. */
  31229. interface SpringJointData extends PhysicsJointData {
  31230. /**
  31231. * Length of the spring
  31232. */
  31233. length: number;
  31234. /**
  31235. * Stiffness of the spring
  31236. */
  31237. stiffness: number;
  31238. /**
  31239. * Damping of the spring
  31240. */
  31241. damping: number;
  31242. /** this callback will be called when applying the force to the impostors. */
  31243. forceApplicationCallback: () => void;
  31244. }
  31245. }
  31246. declare module BABYLON {
  31247. /**
  31248. * This represents the base class for particle system in Babylon.
  31249. * 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.
  31250. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31251. * @example https://doc.babylonjs.com/babylon101/particles
  31252. */
  31253. class BaseParticleSystem {
  31254. /**
  31255. * Source color is added to the destination color without alpha affecting the result
  31256. */
  31257. static BLENDMODE_ONEONE: number;
  31258. /**
  31259. * Blend current color and particle color using particle’s alpha
  31260. */
  31261. static BLENDMODE_STANDARD: number;
  31262. /**
  31263. * Add current color and particle color multiplied by particle’s alpha
  31264. */
  31265. static BLENDMODE_ADD: number;
  31266. /**
  31267. * Multiply current color with particle color
  31268. */
  31269. static BLENDMODE_MULTIPLY: number;
  31270. /**
  31271. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  31272. */
  31273. static BLENDMODE_MULTIPLYADD: number;
  31274. /**
  31275. * List of animations used by the particle system.
  31276. */
  31277. animations: Animation[];
  31278. /**
  31279. * The id of the Particle system.
  31280. */
  31281. id: string;
  31282. /**
  31283. * The friendly name of the Particle system.
  31284. */
  31285. name: string;
  31286. /**
  31287. * The rendering group used by the Particle system to chose when to render.
  31288. */
  31289. renderingGroupId: number;
  31290. /**
  31291. * The emitter represents the Mesh or position we are attaching the particle system to.
  31292. */
  31293. emitter: Nullable<AbstractMesh | Vector3>;
  31294. /**
  31295. * The maximum number of particles to emit per frame
  31296. */
  31297. emitRate: number;
  31298. /**
  31299. * If you want to launch only a few particles at once, that can be done, as well.
  31300. */
  31301. manualEmitCount: number;
  31302. /**
  31303. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31304. */
  31305. updateSpeed: number;
  31306. /**
  31307. * The amount of time the particle system is running (depends of the overall update speed).
  31308. */
  31309. targetStopDuration: number;
  31310. /**
  31311. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31312. */
  31313. disposeOnStop: boolean;
  31314. /**
  31315. * Minimum power of emitting particles.
  31316. */
  31317. minEmitPower: number;
  31318. /**
  31319. * Maximum power of emitting particles.
  31320. */
  31321. maxEmitPower: number;
  31322. /**
  31323. * Minimum life time of emitting particles.
  31324. */
  31325. minLifeTime: number;
  31326. /**
  31327. * Maximum life time of emitting particles.
  31328. */
  31329. maxLifeTime: number;
  31330. /**
  31331. * Minimum Size of emitting particles.
  31332. */
  31333. minSize: number;
  31334. /**
  31335. * Maximum Size of emitting particles.
  31336. */
  31337. maxSize: number;
  31338. /**
  31339. * Minimum scale of emitting particles on X axis.
  31340. */
  31341. minScaleX: number;
  31342. /**
  31343. * Maximum scale of emitting particles on X axis.
  31344. */
  31345. maxScaleX: number;
  31346. /**
  31347. * Minimum scale of emitting particles on Y axis.
  31348. */
  31349. minScaleY: number;
  31350. /**
  31351. * Maximum scale of emitting particles on Y axis.
  31352. */
  31353. maxScaleY: number;
  31354. /**
  31355. * Gets or sets the minimal initial rotation in radians.
  31356. */
  31357. minInitialRotation: number;
  31358. /**
  31359. * Gets or sets the maximal initial rotation in radians.
  31360. */
  31361. maxInitialRotation: number;
  31362. /**
  31363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31364. */
  31365. minAngularSpeed: number;
  31366. /**
  31367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31368. */
  31369. maxAngularSpeed: number;
  31370. /**
  31371. * The texture used to render each particle. (this can be a spritesheet)
  31372. */
  31373. particleTexture: Nullable<Texture>;
  31374. /**
  31375. * The layer mask we are rendering the particles through.
  31376. */
  31377. layerMask: number;
  31378. /**
  31379. * This can help using your own shader to render the particle system.
  31380. * The according effect will be created
  31381. */
  31382. customShader: any;
  31383. /**
  31384. * By default particle system starts as soon as they are created. This prevents the
  31385. * automatic start to happen and let you decide when to start emitting particles.
  31386. */
  31387. preventAutoStart: boolean;
  31388. /**
  31389. * Gets or sets a texture used to add random noise to particle positions
  31390. */
  31391. noiseTexture: Nullable<ProceduralTexture>;
  31392. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31393. noiseStrength: Vector3;
  31394. /**
  31395. * Callback triggered when the particle animation is ending.
  31396. */
  31397. onAnimationEnd: Nullable<() => void>;
  31398. /**
  31399. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  31400. */
  31401. blendMode: number;
  31402. /**
  31403. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31404. * to override the particles.
  31405. */
  31406. forceDepthWrite: boolean;
  31407. /** 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 */
  31408. preWarmCycles: number;
  31409. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  31410. preWarmStepOffset: number;
  31411. /**
  31412. * 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)
  31413. */
  31414. spriteCellChangeSpeed: number;
  31415. /**
  31416. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31417. */
  31418. startSpriteCellID: number;
  31419. /**
  31420. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31421. */
  31422. endSpriteCellID: number;
  31423. /**
  31424. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31425. */
  31426. spriteCellWidth: number;
  31427. /**
  31428. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31429. */
  31430. spriteCellHeight: number;
  31431. /**
  31432. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31433. */
  31434. spriteRandomStartCell: boolean;
  31435. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31436. translationPivot: Vector2;
  31437. /** @hidden */
  31438. protected _isAnimationSheetEnabled: boolean;
  31439. /**
  31440. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31441. */
  31442. beginAnimationOnStart: boolean;
  31443. /**
  31444. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31445. */
  31446. beginAnimationFrom: number;
  31447. /**
  31448. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31449. */
  31450. beginAnimationTo: number;
  31451. /**
  31452. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31453. */
  31454. beginAnimationLoop: boolean;
  31455. /**
  31456. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  31457. */
  31458. isAnimationSheetEnabled: boolean;
  31459. /**
  31460. * Get hosting scene
  31461. * @returns the scene
  31462. */
  31463. getScene(): Scene;
  31464. /**
  31465. * You can use gravity if you want to give an orientation to your particles.
  31466. */
  31467. gravity: Vector3;
  31468. protected _colorGradients: Nullable<Array<ColorGradient>>;
  31469. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  31470. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  31471. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  31472. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  31473. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  31474. protected _dragGradients: Nullable<Array<FactorGradient>>;
  31475. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  31476. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  31477. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  31478. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  31479. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  31480. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  31481. /**
  31482. * Defines the delay in milliseconds before starting the system (0 by default)
  31483. */
  31484. startDelay: number;
  31485. /**
  31486. * Gets the current list of drag gradients.
  31487. * You must use addDragGradient and removeDragGradient to udpate this list
  31488. * @returns the list of drag gradients
  31489. */
  31490. getDragGradients(): Nullable<Array<FactorGradient>>;
  31491. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31492. limitVelocityDamping: number;
  31493. /**
  31494. * Gets the current list of limit velocity gradients.
  31495. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31496. * @returns the list of limit velocity gradients
  31497. */
  31498. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31499. /**
  31500. * Gets the current list of color gradients.
  31501. * You must use addColorGradient and removeColorGradient to udpate this list
  31502. * @returns the list of color gradients
  31503. */
  31504. getColorGradients(): Nullable<Array<ColorGradient>>;
  31505. /**
  31506. * Gets the current list of size gradients.
  31507. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31508. * @returns the list of size gradients
  31509. */
  31510. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31511. /**
  31512. * Gets the current list of color remap gradients.
  31513. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31514. * @returns the list of color remap gradients
  31515. */
  31516. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31517. /**
  31518. * Gets the current list of alpha remap gradients.
  31519. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31520. * @returns the list of alpha remap gradients
  31521. */
  31522. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31523. /**
  31524. * Gets the current list of life time gradients.
  31525. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31526. * @returns the list of life time gradients
  31527. */
  31528. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31529. /**
  31530. * Gets the current list of angular speed gradients.
  31531. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31532. * @returns the list of angular speed gradients
  31533. */
  31534. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31535. /**
  31536. * Gets the current list of velocity gradients.
  31537. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31538. * @returns the list of velocity gradients
  31539. */
  31540. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31541. /**
  31542. * Gets the current list of start size gradients.
  31543. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31544. * @returns the list of start size gradients
  31545. */
  31546. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31547. /**
  31548. * Gets the current list of emit rate gradients.
  31549. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31550. * @returns the list of emit rate gradients
  31551. */
  31552. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31553. /**
  31554. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31555. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31556. */
  31557. direction1: Vector3;
  31558. /**
  31559. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  31560. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31561. */
  31562. direction2: Vector3;
  31563. /**
  31564. * 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.
  31565. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31566. */
  31567. minEmitBox: Vector3;
  31568. /**
  31569. * 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.
  31570. * This only works when particleEmitterTyps is a BoxParticleEmitter
  31571. */
  31572. maxEmitBox: Vector3;
  31573. /**
  31574. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31575. */
  31576. color1: Color4;
  31577. /**
  31578. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  31579. */
  31580. color2: Color4;
  31581. /**
  31582. * Color the particle will have at the end of its lifetime
  31583. */
  31584. colorDead: Color4;
  31585. /**
  31586. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  31587. */
  31588. textureMask: Color4;
  31589. /**
  31590. * The particle emitter type defines the emitter used by the particle system.
  31591. * It can be for example box, sphere, or cone...
  31592. */
  31593. particleEmitterType: IParticleEmitterType;
  31594. /** @hidden */
  31595. _isSubEmitter: boolean;
  31596. /**
  31597. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31598. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31599. */
  31600. billboardMode: number;
  31601. protected _isBillboardBased: boolean;
  31602. /**
  31603. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31604. */
  31605. isBillboardBased: boolean;
  31606. /**
  31607. * The scene the particle system belongs to.
  31608. */
  31609. protected _scene: Scene;
  31610. /**
  31611. * Local cache of defines for image processing.
  31612. */
  31613. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  31614. /**
  31615. * Default configuration related to image processing available in the standard Material.
  31616. */
  31617. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31618. /**
  31619. * Gets the image processing configuration used either in this material.
  31620. */
  31621. /**
  31622. * Sets the Default image processing configuration used either in the this material.
  31623. *
  31624. * If sets to null, the scene one is in use.
  31625. */
  31626. imageProcessingConfiguration: ImageProcessingConfiguration;
  31627. /**
  31628. * Attaches a new image processing configuration to the Standard Material.
  31629. * @param configuration
  31630. */
  31631. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31632. /** @hidden */
  31633. protected _reset(): void;
  31634. /** @hidden */
  31635. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  31636. /**
  31637. * Instantiates a particle system.
  31638. * 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.
  31639. * @param name The name of the particle system
  31640. */
  31641. constructor(name: string);
  31642. /**
  31643. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31646. * @returns the emitter
  31647. */
  31648. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31649. /**
  31650. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31651. * @param radius The radius of the hemisphere to emit from
  31652. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31653. * @returns the emitter
  31654. */
  31655. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  31656. /**
  31657. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31658. * @param radius The radius of the sphere to emit from
  31659. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31660. * @returns the emitter
  31661. */
  31662. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  31663. /**
  31664. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31665. * @param radius The radius of the sphere to emit from
  31666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31668. * @returns the emitter
  31669. */
  31670. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  31671. /**
  31672. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31673. * @param radius The radius of the emission cylinder
  31674. * @param height The height of the emission cylinder
  31675. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31676. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31677. * @returns the emitter
  31678. */
  31679. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  31680. /**
  31681. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31682. * @param radius The radius of the cylinder to emit from
  31683. * @param height The height of the emission cylinder
  31684. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31687. * @returns the emitter
  31688. */
  31689. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  31690. /**
  31691. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31692. * @param radius The radius of the cone to emit from
  31693. * @param angle The base angle of the cone
  31694. * @returns the emitter
  31695. */
  31696. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  31697. /**
  31698. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31699. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31700. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31701. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31702. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31703. * @returns the emitter
  31704. */
  31705. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. /**
  31710. * This represents a GPU particle system in Babylon
  31711. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  31712. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  31713. */
  31714. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  31715. /**
  31716. * The layer mask we are rendering the particles through.
  31717. */
  31718. layerMask: number;
  31719. private _capacity;
  31720. private _activeCount;
  31721. private _currentActiveCount;
  31722. private _accumulatedCount;
  31723. private _renderEffect;
  31724. private _updateEffect;
  31725. private _buffer0;
  31726. private _buffer1;
  31727. private _spriteBuffer;
  31728. private _updateVAO;
  31729. private _renderVAO;
  31730. private _targetIndex;
  31731. private _sourceBuffer;
  31732. private _targetBuffer;
  31733. private _engine;
  31734. private _currentRenderId;
  31735. private _started;
  31736. private _stopped;
  31737. private _timeDelta;
  31738. private _randomTexture;
  31739. private _randomTexture2;
  31740. private _attributesStrideSize;
  31741. private _updateEffectOptions;
  31742. private _randomTextureSize;
  31743. private _actualFrame;
  31744. private readonly _rawTextureWidth;
  31745. /**
  31746. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  31747. */
  31748. static readonly IsSupported: boolean;
  31749. /**
  31750. * An event triggered when the system is disposed.
  31751. */
  31752. onDisposeObservable: Observable<GPUParticleSystem>;
  31753. /**
  31754. * Gets the maximum number of particles active at the same time.
  31755. * @returns The max number of active particles.
  31756. */
  31757. getCapacity(): number;
  31758. /**
  31759. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  31760. * to override the particles.
  31761. */
  31762. forceDepthWrite: boolean;
  31763. /**
  31764. * Gets or set the number of active particles
  31765. */
  31766. activeParticleCount: number;
  31767. private _preWarmDone;
  31768. /**
  31769. * Is this system ready to be used/rendered
  31770. * @return true if the system is ready
  31771. */
  31772. isReady(): boolean;
  31773. /**
  31774. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31775. * @returns True if it has been started, otherwise false.
  31776. */
  31777. isStarted(): boolean;
  31778. /**
  31779. * Starts the particle system and begins to emit
  31780. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31781. */
  31782. start(delay?: number): void;
  31783. /**
  31784. * Stops the particle system.
  31785. */
  31786. stop(): void;
  31787. /**
  31788. * Remove all active particles
  31789. */
  31790. reset(): void;
  31791. /**
  31792. * Returns the string "GPUParticleSystem"
  31793. * @returns a string containing the class name
  31794. */
  31795. getClassName(): string;
  31796. private _colorGradientsTexture;
  31797. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  31798. /**
  31799. * Adds a new color gradient
  31800. * @param gradient defines the gradient to use (between 0 and 1)
  31801. * @param color1 defines the color to affect to the specified gradient
  31802. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31803. * @returns the current particle system
  31804. */
  31805. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  31806. /**
  31807. * Remove a specific color gradient
  31808. * @param gradient defines the gradient to remove
  31809. * @returns the current particle system
  31810. */
  31811. removeColorGradient(gradient: number): GPUParticleSystem;
  31812. private _angularSpeedGradientsTexture;
  31813. private _sizeGradientsTexture;
  31814. private _velocityGradientsTexture;
  31815. private _limitVelocityGradientsTexture;
  31816. private _dragGradientsTexture;
  31817. private _addFactorGradient;
  31818. /**
  31819. * Adds a new size gradient
  31820. * @param gradient defines the gradient to use (between 0 and 1)
  31821. * @param factor defines the size factor to affect to the specified gradient
  31822. * @returns the current particle system
  31823. */
  31824. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  31825. /**
  31826. * Remove a specific size gradient
  31827. * @param gradient defines the gradient to remove
  31828. * @returns the current particle system
  31829. */
  31830. removeSizeGradient(gradient: number): GPUParticleSystem;
  31831. /**
  31832. * Adds a new angular speed gradient
  31833. * @param gradient defines the gradient to use (between 0 and 1)
  31834. * @param factor defines the angular speed to affect to the specified gradient
  31835. * @returns the current particle system
  31836. */
  31837. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  31838. /**
  31839. * Remove a specific angular speed gradient
  31840. * @param gradient defines the gradient to remove
  31841. * @returns the current particle system
  31842. */
  31843. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  31844. /**
  31845. * Adds a new velocity gradient
  31846. * @param gradient defines the gradient to use (between 0 and 1)
  31847. * @param factor defines the velocity to affect to the specified gradient
  31848. * @returns the current particle system
  31849. */
  31850. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31851. /**
  31852. * Remove a specific velocity gradient
  31853. * @param gradient defines the gradient to remove
  31854. * @returns the current particle system
  31855. */
  31856. removeVelocityGradient(gradient: number): GPUParticleSystem;
  31857. /**
  31858. * Adds a new limit velocity gradient
  31859. * @param gradient defines the gradient to use (between 0 and 1)
  31860. * @param factor defines the limit velocity value to affect to the specified gradient
  31861. * @returns the current particle system
  31862. */
  31863. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  31864. /**
  31865. * Remove a specific limit velocity gradient
  31866. * @param gradient defines the gradient to remove
  31867. * @returns the current particle system
  31868. */
  31869. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  31870. /**
  31871. * Adds a new drag gradient
  31872. * @param gradient defines the gradient to use (between 0 and 1)
  31873. * @param factor defines the drag value to affect to the specified gradient
  31874. * @returns the current particle system
  31875. */
  31876. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  31877. /**
  31878. * Remove a specific drag gradient
  31879. * @param gradient defines the gradient to remove
  31880. * @returns the current particle system
  31881. */
  31882. removeDragGradient(gradient: number): GPUParticleSystem;
  31883. /**
  31884. * Not supported by GPUParticleSystem
  31885. * @param gradient defines the gradient to use (between 0 and 1)
  31886. * @param factor defines the emit rate value to affect to the specified gradient
  31887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31888. * @returns the current particle system
  31889. */
  31890. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31891. /**
  31892. * Not supported by GPUParticleSystem
  31893. * @param gradient defines the gradient to remove
  31894. * @returns the current particle system
  31895. */
  31896. removeEmitRateGradient(gradient: number): IParticleSystem;
  31897. /**
  31898. * Not supported by GPUParticleSystem
  31899. * @param gradient defines the gradient to use (between 0 and 1)
  31900. * @param factor defines the start size value to affect to the specified gradient
  31901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31902. * @returns the current particle system
  31903. */
  31904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31905. /**
  31906. * Not supported by GPUParticleSystem
  31907. * @param gradient defines the gradient to remove
  31908. * @returns the current particle system
  31909. */
  31910. removeStartSizeGradient(gradient: number): IParticleSystem;
  31911. /**
  31912. * Not supported by GPUParticleSystem
  31913. * @param gradient defines the gradient to use (between 0 and 1)
  31914. * @param min defines the color remap minimal range
  31915. * @param max defines the color remap maximal range
  31916. * @returns the current particle system
  31917. */
  31918. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31919. /**
  31920. * Not supported by GPUParticleSystem
  31921. * @param gradient defines the gradient to remove
  31922. * @returns the current particle system
  31923. */
  31924. removeColorRemapGradient(gradient: number): IParticleSystem;
  31925. /**
  31926. * Not supported by GPUParticleSystem
  31927. * @param gradient defines the gradient to use (between 0 and 1)
  31928. * @param min defines the alpha remap minimal range
  31929. * @param max defines the alpha remap maximal range
  31930. * @returns the current particle system
  31931. */
  31932. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31933. /**
  31934. * Not supported by GPUParticleSystem
  31935. * @param gradient defines the gradient to remove
  31936. * @returns the current particle system
  31937. */
  31938. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31939. /**
  31940. * Not supported by GPUParticleSystem
  31941. * @param gradient defines the gradient to use (between 0 and 1)
  31942. * @param color defines the color to affect to the specified gradient
  31943. * @returns the current particle system
  31944. */
  31945. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31946. /**
  31947. * Not supported by GPUParticleSystem
  31948. * @param gradient defines the gradient to remove
  31949. * @returns the current particle system
  31950. */
  31951. removeRampGradient(gradient: number): IParticleSystem;
  31952. /**
  31953. * Not supported by GPUParticleSystem
  31954. * @returns the list of ramp gradients
  31955. */
  31956. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31957. /**
  31958. * Not supported by GPUParticleSystem
  31959. * Gets or sets a boolean indicating that ramp gradients must be used
  31960. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31961. */
  31962. useRampGradients: boolean;
  31963. /**
  31964. * Not supported by GPUParticleSystem
  31965. * @param gradient defines the gradient to use (between 0 and 1)
  31966. * @param factor defines the life time factor to affect to the specified gradient
  31967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31968. * @returns the current particle system
  31969. */
  31970. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31971. /**
  31972. * Not supported by GPUParticleSystem
  31973. * @param gradient defines the gradient to remove
  31974. * @returns the current particle system
  31975. */
  31976. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31977. /**
  31978. * Instantiates a GPU particle system.
  31979. * 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.
  31980. * @param name The name of the particle system
  31981. * @param options The options used to create the system
  31982. * @param scene The scene the particle system belongs to
  31983. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31984. */
  31985. constructor(name: string, options: Partial<{
  31986. capacity: number;
  31987. randomTextureSize: number;
  31988. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31989. protected _reset(): void;
  31990. private _createUpdateVAO;
  31991. private _createRenderVAO;
  31992. private _initialize;
  31993. /** @hidden */
  31994. _recreateUpdateEffect(): void;
  31995. /** @hidden */
  31996. _recreateRenderEffect(): void;
  31997. /**
  31998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31999. * @param preWarm defines if we are in the pre-warmimg phase
  32000. */
  32001. animate(preWarm?: boolean): void;
  32002. private _createFactorGradientTexture;
  32003. private _createSizeGradientTexture;
  32004. private _createAngularSpeedGradientTexture;
  32005. private _createVelocityGradientTexture;
  32006. private _createLimitVelocityGradientTexture;
  32007. private _createDragGradientTexture;
  32008. private _createColorGradientTexture;
  32009. /**
  32010. * Renders the particle system in its current state
  32011. * @param preWarm defines if the system should only update the particles but not render them
  32012. * @returns the current number of particles
  32013. */
  32014. render(preWarm?: boolean): number;
  32015. /**
  32016. * Rebuilds the particle system
  32017. */
  32018. rebuild(): void;
  32019. private _releaseBuffers;
  32020. private _releaseVAOs;
  32021. /**
  32022. * Disposes the particle system and free the associated resources
  32023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32024. */
  32025. dispose(disposeTexture?: boolean): void;
  32026. /**
  32027. * Clones the particle system.
  32028. * @param name The name of the cloned object
  32029. * @param newEmitter The new emitter to use
  32030. * @returns the cloned particle system
  32031. */
  32032. clone(name: string, newEmitter: any): GPUParticleSystem;
  32033. /**
  32034. * Serializes the particle system to a JSON object.
  32035. * @returns the JSON object
  32036. */
  32037. serialize(): any;
  32038. /**
  32039. * Parses a JSON object to create a GPU particle system.
  32040. * @param parsedParticleSystem The JSON object to parse
  32041. * @param scene The scene to create the particle system in
  32042. * @param rootUrl The root url to use to load external dependencies like texture
  32043. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32044. * @returns the parsed GPU particle system
  32045. */
  32046. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  32047. }
  32048. }
  32049. declare module BABYLON {
  32050. /**
  32051. * Interface representing a particle system in Babylon.js.
  32052. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  32053. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  32054. */
  32055. interface IParticleSystem {
  32056. /**
  32057. * List of animations used by the particle system.
  32058. */
  32059. animations: Animation[];
  32060. /**
  32061. * The id of the Particle system.
  32062. */
  32063. id: string;
  32064. /**
  32065. * The name of the Particle system.
  32066. */
  32067. name: string;
  32068. /**
  32069. * The emitter represents the Mesh or position we are attaching the particle system to.
  32070. */
  32071. emitter: Nullable<AbstractMesh | Vector3>;
  32072. /**
  32073. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  32074. */
  32075. isBillboardBased: boolean;
  32076. /**
  32077. * The rendering group used by the Particle system to chose when to render.
  32078. */
  32079. renderingGroupId: number;
  32080. /**
  32081. * The layer mask we are rendering the particles through.
  32082. */
  32083. layerMask: number;
  32084. /**
  32085. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  32086. */
  32087. updateSpeed: number;
  32088. /**
  32089. * The amount of time the particle system is running (depends of the overall update speed).
  32090. */
  32091. targetStopDuration: number;
  32092. /**
  32093. * The texture used to render each particle. (this can be a spritesheet)
  32094. */
  32095. particleTexture: Nullable<Texture>;
  32096. /**
  32097. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  32098. */
  32099. blendMode: number;
  32100. /**
  32101. * Minimum life time of emitting particles.
  32102. */
  32103. minLifeTime: number;
  32104. /**
  32105. * Maximum life time of emitting particles.
  32106. */
  32107. maxLifeTime: number;
  32108. /**
  32109. * Minimum Size of emitting particles.
  32110. */
  32111. minSize: number;
  32112. /**
  32113. * Maximum Size of emitting particles.
  32114. */
  32115. maxSize: number;
  32116. /**
  32117. * Minimum scale of emitting particles on X axis.
  32118. */
  32119. minScaleX: number;
  32120. /**
  32121. * Maximum scale of emitting particles on X axis.
  32122. */
  32123. maxScaleX: number;
  32124. /**
  32125. * Minimum scale of emitting particles on Y axis.
  32126. */
  32127. minScaleY: number;
  32128. /**
  32129. * Maximum scale of emitting particles on Y axis.
  32130. */
  32131. maxScaleY: number;
  32132. /**
  32133. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32134. */
  32135. color1: Color4;
  32136. /**
  32137. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  32138. */
  32139. color2: Color4;
  32140. /**
  32141. * Color the particle will have at the end of its lifetime.
  32142. */
  32143. colorDead: Color4;
  32144. /**
  32145. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  32146. */
  32147. emitRate: number;
  32148. /**
  32149. * You can use gravity if you want to give an orientation to your particles.
  32150. */
  32151. gravity: Vector3;
  32152. /**
  32153. * Minimum power of emitting particles.
  32154. */
  32155. minEmitPower: number;
  32156. /**
  32157. * Maximum power of emitting particles.
  32158. */
  32159. maxEmitPower: number;
  32160. /**
  32161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  32162. */
  32163. minAngularSpeed: number;
  32164. /**
  32165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  32166. */
  32167. maxAngularSpeed: number;
  32168. /**
  32169. * Gets or sets the minimal initial rotation in radians.
  32170. */
  32171. minInitialRotation: number;
  32172. /**
  32173. * Gets or sets the maximal initial rotation in radians.
  32174. */
  32175. maxInitialRotation: number;
  32176. /**
  32177. * The particle emitter type defines the emitter used by the particle system.
  32178. * It can be for example box, sphere, or cone...
  32179. */
  32180. particleEmitterType: Nullable<IParticleEmitterType>;
  32181. /**
  32182. * Defines the delay in milliseconds before starting the system (0 by default)
  32183. */
  32184. startDelay: number;
  32185. /**
  32186. * 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
  32187. */
  32188. preWarmCycles: number;
  32189. /**
  32190. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  32191. */
  32192. preWarmStepOffset: number;
  32193. /**
  32194. * 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)
  32195. */
  32196. spriteCellChangeSpeed: number;
  32197. /**
  32198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  32199. */
  32200. startSpriteCellID: number;
  32201. /**
  32202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  32203. */
  32204. endSpriteCellID: number;
  32205. /**
  32206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  32207. */
  32208. spriteCellWidth: number;
  32209. /**
  32210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  32211. */
  32212. spriteCellHeight: number;
  32213. /**
  32214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  32215. */
  32216. spriteRandomStartCell: boolean;
  32217. /**
  32218. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  32219. */
  32220. isAnimationSheetEnabled: boolean;
  32221. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  32222. translationPivot: Vector2;
  32223. /**
  32224. * Gets or sets a texture used to add random noise to particle positions
  32225. */
  32226. noiseTexture: Nullable<BaseTexture>;
  32227. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  32228. noiseStrength: Vector3;
  32229. /**
  32230. * Gets or sets the billboard mode to use when isBillboardBased = true.
  32231. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  32232. */
  32233. billboardMode: number;
  32234. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  32235. limitVelocityDamping: number;
  32236. /**
  32237. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  32238. */
  32239. beginAnimationOnStart: boolean;
  32240. /**
  32241. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  32242. */
  32243. beginAnimationFrom: number;
  32244. /**
  32245. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  32246. */
  32247. beginAnimationTo: number;
  32248. /**
  32249. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  32250. */
  32251. beginAnimationLoop: boolean;
  32252. /**
  32253. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  32254. */
  32255. disposeOnStop: boolean;
  32256. /**
  32257. * Gets the maximum number of particles active at the same time.
  32258. * @returns The max number of active particles.
  32259. */
  32260. getCapacity(): number;
  32261. /**
  32262. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32263. * @returns True if it has been started, otherwise false.
  32264. */
  32265. isStarted(): boolean;
  32266. /**
  32267. * Animates the particle system for this frame.
  32268. */
  32269. animate(): void;
  32270. /**
  32271. * Renders the particle system in its current state.
  32272. * @returns the current number of particles
  32273. */
  32274. render(): number;
  32275. /**
  32276. * Dispose the particle system and frees its associated resources.
  32277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32278. */
  32279. dispose(disposeTexture?: boolean): void;
  32280. /**
  32281. * Clones the particle system.
  32282. * @param name The name of the cloned object
  32283. * @param newEmitter The new emitter to use
  32284. * @returns the cloned particle system
  32285. */
  32286. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  32287. /**
  32288. * Serializes the particle system to a JSON object.
  32289. * @returns the JSON object
  32290. */
  32291. serialize(): any;
  32292. /**
  32293. * Rebuild the particle system
  32294. */
  32295. rebuild(): void;
  32296. /**
  32297. * Starts the particle system and begins to emit
  32298. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  32299. */
  32300. start(delay?: number): void;
  32301. /**
  32302. * Stops the particle system.
  32303. */
  32304. stop(): void;
  32305. /**
  32306. * Remove all active particles
  32307. */
  32308. reset(): void;
  32309. /**
  32310. * Is this system ready to be used/rendered
  32311. * @return true if the system is ready
  32312. */
  32313. isReady(): boolean;
  32314. /**
  32315. * Adds a new color gradient
  32316. * @param gradient defines the gradient to use (between 0 and 1)
  32317. * @param color1 defines the color to affect to the specified gradient
  32318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32319. * @returns the current particle system
  32320. */
  32321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32322. /**
  32323. * Remove a specific color gradient
  32324. * @param gradient defines the gradient to remove
  32325. * @returns the current particle system
  32326. */
  32327. removeColorGradient(gradient: number): IParticleSystem;
  32328. /**
  32329. * Adds a new size gradient
  32330. * @param gradient defines the gradient to use (between 0 and 1)
  32331. * @param factor defines the size factor to affect to the specified gradient
  32332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32333. * @returns the current particle system
  32334. */
  32335. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32336. /**
  32337. * Remove a specific size gradient
  32338. * @param gradient defines the gradient to remove
  32339. * @returns the current particle system
  32340. */
  32341. removeSizeGradient(gradient: number): IParticleSystem;
  32342. /**
  32343. * Gets the current list of color gradients.
  32344. * You must use addColorGradient and removeColorGradient to udpate this list
  32345. * @returns the list of color gradients
  32346. */
  32347. getColorGradients(): Nullable<Array<ColorGradient>>;
  32348. /**
  32349. * Gets the current list of size gradients.
  32350. * You must use addSizeGradient and removeSizeGradient to udpate this list
  32351. * @returns the list of size gradients
  32352. */
  32353. getSizeGradients(): Nullable<Array<FactorGradient>>;
  32354. /**
  32355. * Gets the current list of angular speed gradients.
  32356. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  32357. * @returns the list of angular speed gradients
  32358. */
  32359. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  32360. /**
  32361. * Adds a new angular speed gradient
  32362. * @param gradient defines the gradient to use (between 0 and 1)
  32363. * @param factor defines the angular speed to affect to the specified gradient
  32364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32365. * @returns the current particle system
  32366. */
  32367. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32368. /**
  32369. * Remove a specific angular speed gradient
  32370. * @param gradient defines the gradient to remove
  32371. * @returns the current particle system
  32372. */
  32373. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32374. /**
  32375. * Gets the current list of velocity gradients.
  32376. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  32377. * @returns the list of velocity gradients
  32378. */
  32379. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  32380. /**
  32381. * Adds a new velocity gradient
  32382. * @param gradient defines the gradient to use (between 0 and 1)
  32383. * @param factor defines the velocity to affect to the specified gradient
  32384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32385. * @returns the current particle system
  32386. */
  32387. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32388. /**
  32389. * Remove a specific velocity gradient
  32390. * @param gradient defines the gradient to remove
  32391. * @returns the current particle system
  32392. */
  32393. removeVelocityGradient(gradient: number): IParticleSystem;
  32394. /**
  32395. * Gets the current list of limit velocity gradients.
  32396. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  32397. * @returns the list of limit velocity gradients
  32398. */
  32399. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  32400. /**
  32401. * Adds a new limit velocity gradient
  32402. * @param gradient defines the gradient to use (between 0 and 1)
  32403. * @param factor defines the limit velocity to affect to the specified gradient
  32404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32405. * @returns the current particle system
  32406. */
  32407. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32408. /**
  32409. * Remove a specific limit velocity gradient
  32410. * @param gradient defines the gradient to remove
  32411. * @returns the current particle system
  32412. */
  32413. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32414. /**
  32415. * Adds a new drag gradient
  32416. * @param gradient defines the gradient to use (between 0 and 1)
  32417. * @param factor defines the drag to affect to the specified gradient
  32418. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32419. * @returns the current particle system
  32420. */
  32421. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32422. /**
  32423. * Remove a specific drag gradient
  32424. * @param gradient defines the gradient to remove
  32425. * @returns the current particle system
  32426. */
  32427. removeDragGradient(gradient: number): IParticleSystem;
  32428. /**
  32429. * Gets the current list of drag gradients.
  32430. * You must use addDragGradient and removeDragGradient to udpate this list
  32431. * @returns the list of drag gradients
  32432. */
  32433. getDragGradients(): Nullable<Array<FactorGradient>>;
  32434. /**
  32435. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32436. * @param gradient defines the gradient to use (between 0 and 1)
  32437. * @param factor defines the emit rate to affect to the specified gradient
  32438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32439. * @returns the current particle system
  32440. */
  32441. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32442. /**
  32443. * Remove a specific emit rate gradient
  32444. * @param gradient defines the gradient to remove
  32445. * @returns the current particle system
  32446. */
  32447. removeEmitRateGradient(gradient: number): IParticleSystem;
  32448. /**
  32449. * Gets the current list of emit rate gradients.
  32450. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  32451. * @returns the list of emit rate gradients
  32452. */
  32453. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  32454. /**
  32455. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32456. * @param gradient defines the gradient to use (between 0 and 1)
  32457. * @param factor defines the start size to affect to the specified gradient
  32458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32459. * @returns the current particle system
  32460. */
  32461. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32462. /**
  32463. * Remove a specific start size gradient
  32464. * @param gradient defines the gradient to remove
  32465. * @returns the current particle system
  32466. */
  32467. removeStartSizeGradient(gradient: number): IParticleSystem;
  32468. /**
  32469. * Gets the current list of start size gradients.
  32470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  32471. * @returns the list of start size gradients
  32472. */
  32473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  32474. /**
  32475. * Adds a new life time gradient
  32476. * @param gradient defines the gradient to use (between 0 and 1)
  32477. * @param factor defines the life time factor to affect to the specified gradient
  32478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32479. * @returns the current particle system
  32480. */
  32481. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32482. /**
  32483. * Remove a specific life time gradient
  32484. * @param gradient defines the gradient to remove
  32485. * @returns the current particle system
  32486. */
  32487. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32488. /**
  32489. * Gets the current list of life time gradients.
  32490. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  32491. * @returns the list of life time gradients
  32492. */
  32493. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  32494. /**
  32495. * Gets the current list of color gradients.
  32496. * You must use addColorGradient and removeColorGradient to udpate this list
  32497. * @returns the list of color gradients
  32498. */
  32499. getColorGradients(): Nullable<Array<ColorGradient>>;
  32500. /**
  32501. * Adds a new ramp gradient used to remap particle colors
  32502. * @param gradient defines the gradient to use (between 0 and 1)
  32503. * @param color defines the color to affect to the specified gradient
  32504. * @returns the current particle system
  32505. */
  32506. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  32507. /**
  32508. * Gets the current list of ramp gradients.
  32509. * You must use addRampGradient and removeRampGradient to udpate this list
  32510. * @returns the list of ramp gradients
  32511. */
  32512. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32513. /** Gets or sets a boolean indicating that ramp gradients must be used
  32514. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32515. */
  32516. useRampGradients: boolean;
  32517. /**
  32518. * Adds a new color remap gradient
  32519. * @param gradient defines the gradient to use (between 0 and 1)
  32520. * @param min defines the color remap minimal range
  32521. * @param max defines the color remap maximal range
  32522. * @returns the current particle system
  32523. */
  32524. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32525. /**
  32526. * Gets the current list of color remap gradients.
  32527. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  32528. * @returns the list of color remap gradients
  32529. */
  32530. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  32531. /**
  32532. * Adds a new alpha remap gradient
  32533. * @param gradient defines the gradient to use (between 0 and 1)
  32534. * @param min defines the alpha remap minimal range
  32535. * @param max defines the alpha remap maximal range
  32536. * @returns the current particle system
  32537. */
  32538. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32539. /**
  32540. * Gets the current list of alpha remap gradients.
  32541. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  32542. * @returns the list of alpha remap gradients
  32543. */
  32544. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  32545. /**
  32546. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  32547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32549. * @returns the emitter
  32550. */
  32551. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  32552. /**
  32553. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  32554. * @param radius The radius of the hemisphere to emit from
  32555. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32556. * @returns the emitter
  32557. */
  32558. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  32559. /**
  32560. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  32561. * @param radius The radius of the sphere to emit from
  32562. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  32563. * @returns the emitter
  32564. */
  32565. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  32566. /**
  32567. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  32568. * @param radius The radius of the sphere to emit from
  32569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  32570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  32571. * @returns the emitter
  32572. */
  32573. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32574. /**
  32575. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  32576. * @param radius The radius of the emission cylinder
  32577. * @param height The height of the emission cylinder
  32578. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  32579. * @param directionRandomizer How much to randomize the particle direction [0-1]
  32580. * @returns the emitter
  32581. */
  32582. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  32583. /**
  32584. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  32585. * @param radius The radius of the cylinder to emit from
  32586. * @param height The height of the emission cylinder
  32587. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  32588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  32589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  32590. * @returns the emitter
  32591. */
  32592. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  32593. /**
  32594. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  32595. * @param radius The radius of the cone to emit from
  32596. * @param angle The base angle of the cone
  32597. * @returns the emitter
  32598. */
  32599. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  32600. /**
  32601. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  32602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  32603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  32604. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32605. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  32606. * @returns the emitter
  32607. */
  32608. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  32609. /**
  32610. * Get hosting scene
  32611. * @returns the scene
  32612. */
  32613. getScene(): Scene;
  32614. }
  32615. }
  32616. declare module BABYLON {
  32617. /**
  32618. * A particle represents one of the element emitted by a particle system.
  32619. * This is mainly define by its coordinates, direction, velocity and age.
  32620. */
  32621. class Particle {
  32622. /**
  32623. * The particle system the particle belongs to.
  32624. */
  32625. particleSystem: ParticleSystem;
  32626. private static _Count;
  32627. /**
  32628. * Unique ID of the particle
  32629. */
  32630. id: number;
  32631. /**
  32632. * The world position of the particle in the scene.
  32633. */
  32634. position: Vector3;
  32635. /**
  32636. * The world direction of the particle in the scene.
  32637. */
  32638. direction: Vector3;
  32639. /**
  32640. * The color of the particle.
  32641. */
  32642. color: Color4;
  32643. /**
  32644. * The color change of the particle per step.
  32645. */
  32646. colorStep: Color4;
  32647. /**
  32648. * Defines how long will the life of the particle be.
  32649. */
  32650. lifeTime: number;
  32651. /**
  32652. * The current age of the particle.
  32653. */
  32654. age: number;
  32655. /**
  32656. * The current size of the particle.
  32657. */
  32658. size: number;
  32659. /**
  32660. * The current scale of the particle.
  32661. */
  32662. scale: Vector2;
  32663. /**
  32664. * The current angle of the particle.
  32665. */
  32666. angle: number;
  32667. /**
  32668. * Defines how fast is the angle changing.
  32669. */
  32670. angularSpeed: number;
  32671. /**
  32672. * Defines the cell index used by the particle to be rendered from a sprite.
  32673. */
  32674. cellIndex: number;
  32675. /**
  32676. * The information required to support color remapping
  32677. */
  32678. remapData: Vector4;
  32679. /** @hidden */
  32680. _randomCellOffset?: number;
  32681. /** @hidden */
  32682. _initialDirection: Nullable<Vector3>;
  32683. /** @hidden */
  32684. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  32685. /** @hidden */
  32686. _initialStartSpriteCellID: number;
  32687. /** @hidden */
  32688. _initialEndSpriteCellID: number;
  32689. /** @hidden */
  32690. _currentColorGradient: Nullable<ColorGradient>;
  32691. /** @hidden */
  32692. _currentColor1: Color4;
  32693. /** @hidden */
  32694. _currentColor2: Color4;
  32695. /** @hidden */
  32696. _currentSizeGradient: Nullable<FactorGradient>;
  32697. /** @hidden */
  32698. _currentSize1: number;
  32699. /** @hidden */
  32700. _currentSize2: number;
  32701. /** @hidden */
  32702. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  32703. /** @hidden */
  32704. _currentAngularSpeed1: number;
  32705. /** @hidden */
  32706. _currentAngularSpeed2: number;
  32707. /** @hidden */
  32708. _currentVelocityGradient: Nullable<FactorGradient>;
  32709. /** @hidden */
  32710. _currentVelocity1: number;
  32711. /** @hidden */
  32712. _currentVelocity2: number;
  32713. /** @hidden */
  32714. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  32715. /** @hidden */
  32716. _currentLimitVelocity1: number;
  32717. /** @hidden */
  32718. _currentLimitVelocity2: number;
  32719. /** @hidden */
  32720. _currentDragGradient: Nullable<FactorGradient>;
  32721. /** @hidden */
  32722. _currentDrag1: number;
  32723. /** @hidden */
  32724. _currentDrag2: number;
  32725. /** @hidden */
  32726. _randomNoiseCoordinates1: Vector3;
  32727. /** @hidden */
  32728. _randomNoiseCoordinates2: Vector3;
  32729. /**
  32730. * Creates a new instance Particle
  32731. * @param particleSystem the particle system the particle belongs to
  32732. */
  32733. constructor(
  32734. /**
  32735. * The particle system the particle belongs to.
  32736. */
  32737. particleSystem: ParticleSystem);
  32738. private updateCellInfoFromSystem;
  32739. /**
  32740. * Defines how the sprite cell index is updated for the particle
  32741. */
  32742. updateCellIndex(): void;
  32743. /** @hidden */
  32744. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  32745. /** @hidden */
  32746. _inheritParticleInfoToSubEmitters(): void;
  32747. /** @hidden */
  32748. _reset(): void;
  32749. /**
  32750. * Copy the properties of particle to another one.
  32751. * @param other the particle to copy the information to.
  32752. */
  32753. copyTo(other: Particle): void;
  32754. }
  32755. }
  32756. declare module BABYLON {
  32757. /**
  32758. * This class is made for on one-liner static method to help creating particle system set.
  32759. */
  32760. class ParticleHelper {
  32761. /**
  32762. * Gets or sets base Assets URL
  32763. */
  32764. static BaseAssetsUrl: string;
  32765. /**
  32766. * Create a default particle system that you can tweak
  32767. * @param emitter defines the emitter to use
  32768. * @param capacity defines the system capacity (default is 500 particles)
  32769. * @param scene defines the hosting scene
  32770. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  32771. * @returns the new Particle system
  32772. */
  32773. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  32774. /**
  32775. * This is the main static method (one-liner) of this helper to create different particle systems
  32776. * @param type This string represents the type to the particle system to create
  32777. * @param scene The scene where the particle system should live
  32778. * @param gpu If the system will use gpu
  32779. * @returns the ParticleSystemSet created
  32780. */
  32781. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  32782. /**
  32783. * Static function used to export a particle system to a ParticleSystemSet variable.
  32784. * Please note that the emitter shape is not exported
  32785. * @param systems defines the particle systems to export
  32786. * @returns the created particle system set
  32787. */
  32788. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  32789. }
  32790. }
  32791. declare module BABYLON {
  32792. /**
  32793. * This represents a particle system in Babylon.
  32794. * 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.
  32795. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  32796. * @example https://doc.babylonjs.com/babylon101/particles
  32797. */
  32798. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  32799. /**
  32800. * Billboard mode will only apply to Y axis
  32801. */
  32802. static readonly BILLBOARDMODE_Y: number;
  32803. /**
  32804. * Billboard mode will apply to all axes
  32805. */
  32806. static readonly BILLBOARDMODE_ALL: number;
  32807. /**
  32808. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  32809. */
  32810. static readonly BILLBOARDMODE_STRETCHED: number;
  32811. /**
  32812. * This function can be defined to provide custom update for active particles.
  32813. * This function will be called instead of regular update (age, position, color, etc.).
  32814. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  32815. */
  32816. updateFunction: (particles: Particle[]) => void;
  32817. private _emitterWorldMatrix;
  32818. /**
  32819. * This function can be defined to specify initial direction for every new particle.
  32820. * It by default use the emitterType defined function
  32821. */
  32822. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  32823. /**
  32824. * This function can be defined to specify initial position for every new particle.
  32825. * It by default use the emitterType defined function
  32826. */
  32827. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  32828. /**
  32829. * @hidden
  32830. */
  32831. _inheritedVelocityOffset: Vector3;
  32832. /**
  32833. * An event triggered when the system is disposed
  32834. */
  32835. onDisposeObservable: Observable<ParticleSystem>;
  32836. private _onDisposeObserver;
  32837. /**
  32838. * Sets a callback that will be triggered when the system is disposed
  32839. */
  32840. onDispose: () => void;
  32841. private _particles;
  32842. private _epsilon;
  32843. private _capacity;
  32844. private _stockParticles;
  32845. private _newPartsExcess;
  32846. private _vertexData;
  32847. private _vertexBuffer;
  32848. private _vertexBuffers;
  32849. private _spriteBuffer;
  32850. private _indexBuffer;
  32851. private _effect;
  32852. private _customEffect;
  32853. private _cachedDefines;
  32854. private _scaledColorStep;
  32855. private _colorDiff;
  32856. private _scaledDirection;
  32857. private _scaledGravity;
  32858. private _currentRenderId;
  32859. private _alive;
  32860. private _useInstancing;
  32861. private _started;
  32862. private _stopped;
  32863. private _actualFrame;
  32864. private _scaledUpdateSpeed;
  32865. private _vertexBufferSize;
  32866. /** @hidden */
  32867. _currentEmitRateGradient: Nullable<FactorGradient>;
  32868. /** @hidden */
  32869. _currentEmitRate1: number;
  32870. /** @hidden */
  32871. _currentEmitRate2: number;
  32872. /** @hidden */
  32873. _currentStartSizeGradient: Nullable<FactorGradient>;
  32874. /** @hidden */
  32875. _currentStartSize1: number;
  32876. /** @hidden */
  32877. _currentStartSize2: number;
  32878. private readonly _rawTextureWidth;
  32879. private _rampGradientsTexture;
  32880. private _useRampGradients;
  32881. /** Gets or sets a boolean indicating that ramp gradients must be used
  32882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  32883. */
  32884. useRampGradients: boolean;
  32885. /**
  32886. * 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.
  32887. * 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: [])
  32888. */
  32889. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  32890. private _subEmitters;
  32891. /**
  32892. * @hidden
  32893. * If the particle systems emitter should be disposed when the particle system is disposed
  32894. */
  32895. _disposeEmitterOnDispose: boolean;
  32896. /**
  32897. * The current active Sub-systems, this property is used by the root particle system only.
  32898. */
  32899. activeSubSystems: Array<ParticleSystem>;
  32900. private _rootParticleSystem;
  32901. /**
  32902. * Gets the current list of active particles
  32903. */
  32904. readonly particles: Particle[];
  32905. /**
  32906. * Returns the string "ParticleSystem"
  32907. * @returns a string containing the class name
  32908. */
  32909. getClassName(): string;
  32910. /**
  32911. * Instantiates a particle system.
  32912. * 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.
  32913. * @param name The name of the particle system
  32914. * @param capacity The max number of particles alive at the same time
  32915. * @param scene The scene the particle system belongs to
  32916. * @param customEffect a custom effect used to change the way particles are rendered by default
  32917. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32918. * @param epsilon Offset used to render the particles
  32919. */
  32920. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32921. private _addFactorGradient;
  32922. private _removeFactorGradient;
  32923. /**
  32924. * Adds a new life time gradient
  32925. * @param gradient defines the gradient to use (between 0 and 1)
  32926. * @param factor defines the life time factor to affect to the specified gradient
  32927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32928. * @returns the current particle system
  32929. */
  32930. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32931. /**
  32932. * Remove a specific life time gradient
  32933. * @param gradient defines the gradient to remove
  32934. * @returns the current particle system
  32935. */
  32936. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32937. /**
  32938. * Adds a new size gradient
  32939. * @param gradient defines the gradient to use (between 0 and 1)
  32940. * @param factor defines the size factor to affect to the specified gradient
  32941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32942. * @returns the current particle system
  32943. */
  32944. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32945. /**
  32946. * Remove a specific size gradient
  32947. * @param gradient defines the gradient to remove
  32948. * @returns the current particle system
  32949. */
  32950. removeSizeGradient(gradient: number): IParticleSystem;
  32951. /**
  32952. * Adds a new color remap gradient
  32953. * @param gradient defines the gradient to use (between 0 and 1)
  32954. * @param min defines the color remap minimal range
  32955. * @param max defines the color remap maximal range
  32956. * @returns the current particle system
  32957. */
  32958. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32959. /**
  32960. * Remove a specific color remap gradient
  32961. * @param gradient defines the gradient to remove
  32962. * @returns the current particle system
  32963. */
  32964. removeColorRemapGradient(gradient: number): IParticleSystem;
  32965. /**
  32966. * Adds a new alpha remap gradient
  32967. * @param gradient defines the gradient to use (between 0 and 1)
  32968. * @param min defines the alpha remap minimal range
  32969. * @param max defines the alpha remap maximal range
  32970. * @returns the current particle system
  32971. */
  32972. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32973. /**
  32974. * Remove a specific alpha remap gradient
  32975. * @param gradient defines the gradient to remove
  32976. * @returns the current particle system
  32977. */
  32978. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32979. /**
  32980. * Adds a new angular speed gradient
  32981. * @param gradient defines the gradient to use (between 0 and 1)
  32982. * @param factor defines the angular speed to affect to the specified gradient
  32983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32984. * @returns the current particle system
  32985. */
  32986. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32987. /**
  32988. * Remove a specific angular speed gradient
  32989. * @param gradient defines the gradient to remove
  32990. * @returns the current particle system
  32991. */
  32992. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32993. /**
  32994. * Adds a new velocity gradient
  32995. * @param gradient defines the gradient to use (between 0 and 1)
  32996. * @param factor defines the velocity to affect to the specified gradient
  32997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32998. * @returns the current particle system
  32999. */
  33000. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33001. /**
  33002. * Remove a specific velocity gradient
  33003. * @param gradient defines the gradient to remove
  33004. * @returns the current particle system
  33005. */
  33006. removeVelocityGradient(gradient: number): IParticleSystem;
  33007. /**
  33008. * Adds a new limit velocity gradient
  33009. * @param gradient defines the gradient to use (between 0 and 1)
  33010. * @param factor defines the limit velocity value to affect to the specified gradient
  33011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33012. * @returns the current particle system
  33013. */
  33014. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33015. /**
  33016. * Remove a specific limit velocity gradient
  33017. * @param gradient defines the gradient to remove
  33018. * @returns the current particle system
  33019. */
  33020. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  33021. /**
  33022. * Adds a new drag gradient
  33023. * @param gradient defines the gradient to use (between 0 and 1)
  33024. * @param factor defines the drag value to affect to the specified gradient
  33025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33026. * @returns the current particle system
  33027. */
  33028. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33029. /**
  33030. * Remove a specific drag gradient
  33031. * @param gradient defines the gradient to remove
  33032. * @returns the current particle system
  33033. */
  33034. removeDragGradient(gradient: number): IParticleSystem;
  33035. /**
  33036. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  33037. * @param gradient defines the gradient to use (between 0 and 1)
  33038. * @param factor defines the emit rate value to affect to the specified gradient
  33039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33040. * @returns the current particle system
  33041. */
  33042. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33043. /**
  33044. * Remove a specific emit rate gradient
  33045. * @param gradient defines the gradient to remove
  33046. * @returns the current particle system
  33047. */
  33048. removeEmitRateGradient(gradient: number): IParticleSystem;
  33049. /**
  33050. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  33051. * @param gradient defines the gradient to use (between 0 and 1)
  33052. * @param factor defines the start size value to affect to the specified gradient
  33053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  33054. * @returns the current particle system
  33055. */
  33056. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  33057. /**
  33058. * Remove a specific start size gradient
  33059. * @param gradient defines the gradient to remove
  33060. * @returns the current particle system
  33061. */
  33062. removeStartSizeGradient(gradient: number): IParticleSystem;
  33063. private _createRampGradientTexture;
  33064. /**
  33065. * Gets the current list of ramp gradients.
  33066. * You must use addRampGradient and removeRampGradient to udpate this list
  33067. * @returns the list of ramp gradients
  33068. */
  33069. getRampGradients(): Nullable<Array<Color3Gradient>>;
  33070. /**
  33071. * Adds a new ramp gradient used to remap particle colors
  33072. * @param gradient defines the gradient to use (between 0 and 1)
  33073. * @param color defines the color to affect to the specified gradient
  33074. * @returns the current particle system
  33075. */
  33076. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  33077. /**
  33078. * Remove a specific ramp gradient
  33079. * @param gradient defines the gradient to remove
  33080. * @returns the current particle system
  33081. */
  33082. removeRampGradient(gradient: number): ParticleSystem;
  33083. /**
  33084. * Adds a new color gradient
  33085. * @param gradient defines the gradient to use (between 0 and 1)
  33086. * @param color1 defines the color to affect to the specified gradient
  33087. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  33088. * @returns this particle system
  33089. */
  33090. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  33091. /**
  33092. * Remove a specific color gradient
  33093. * @param gradient defines the gradient to remove
  33094. * @returns this particle system
  33095. */
  33096. removeColorGradient(gradient: number): IParticleSystem;
  33097. private _fetchR;
  33098. protected _reset(): void;
  33099. private _resetEffect;
  33100. private _createVertexBuffers;
  33101. private _createIndexBuffer;
  33102. /**
  33103. * Gets the maximum number of particles active at the same time.
  33104. * @returns The max number of active particles.
  33105. */
  33106. getCapacity(): number;
  33107. /**
  33108. * Gets whether there are still active particles in the system.
  33109. * @returns True if it is alive, otherwise false.
  33110. */
  33111. isAlive(): boolean;
  33112. /**
  33113. * Gets if the system has been started. (Note: this will still be true after stop is called)
  33114. * @returns True if it has been started, otherwise false.
  33115. */
  33116. isStarted(): boolean;
  33117. private _prepareSubEmitterInternalArray;
  33118. /**
  33119. * Starts the particle system and begins to emit
  33120. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  33121. */
  33122. start(delay?: number): void;
  33123. /**
  33124. * Stops the particle system.
  33125. * @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.
  33126. */
  33127. stop(stopSubEmitters?: boolean): void;
  33128. /**
  33129. * Remove all active particles
  33130. */
  33131. reset(): void;
  33132. /**
  33133. * @hidden (for internal use only)
  33134. */
  33135. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  33136. /**
  33137. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  33138. * Its lifetime will start back at 0.
  33139. */
  33140. recycleParticle: (particle: Particle) => void;
  33141. private _stopSubEmitters;
  33142. private _createParticle;
  33143. private _removeFromRoot;
  33144. private _emitFromParticle;
  33145. private _update;
  33146. /** @hidden */
  33147. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  33148. /** @hidden */
  33149. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  33150. /** @hidden */
  33151. private _getEffect;
  33152. /**
  33153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  33154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  33155. */
  33156. animate(preWarmOnly?: boolean): void;
  33157. private _appendParticleVertices;
  33158. /**
  33159. * Rebuilds the particle system.
  33160. */
  33161. rebuild(): void;
  33162. /**
  33163. * Is this system ready to be used/rendered
  33164. * @return true if the system is ready
  33165. */
  33166. isReady(): boolean;
  33167. private _render;
  33168. /**
  33169. * Renders the particle system in its current state.
  33170. * @returns the current number of particles
  33171. */
  33172. render(): number;
  33173. /**
  33174. * Disposes the particle system and free the associated resources
  33175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  33176. */
  33177. dispose(disposeTexture?: boolean): void;
  33178. /**
  33179. * Clones the particle system.
  33180. * @param name The name of the cloned object
  33181. * @param newEmitter The new emitter to use
  33182. * @returns the cloned particle system
  33183. */
  33184. clone(name: string, newEmitter: any): ParticleSystem;
  33185. /**
  33186. * Serializes the particle system to a JSON object.
  33187. * @returns the JSON object
  33188. */
  33189. serialize(): any;
  33190. /** @hidden */
  33191. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  33192. /** @hidden */
  33193. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  33194. /**
  33195. * Parses a JSON object to create a particle system.
  33196. * @param parsedParticleSystem The JSON object to parse
  33197. * @param scene The scene to create the particle system in
  33198. * @param rootUrl The root url to use to load external dependencies like texture
  33199. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  33200. * @returns the Parsed particle system
  33201. */
  33202. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  33203. }
  33204. }
  33205. declare module BABYLON {
  33206. interface Engine {
  33207. /**
  33208. * Create an effect to use with particle systems.
  33209. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  33210. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  33211. * @param uniformsNames defines a list of attribute names
  33212. * @param samplers defines an array of string used to represent textures
  33213. * @param defines defines the string containing the defines to use to compile the shaders
  33214. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  33215. * @param onCompiled defines a function to call when the effect creation is successful
  33216. * @param onError defines a function to call when the effect creation has failed
  33217. * @returns the new Effect
  33218. */
  33219. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  33220. }
  33221. interface Mesh {
  33222. /**
  33223. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  33224. * @returns an array of IParticleSystem
  33225. */
  33226. getEmittedParticleSystems(): IParticleSystem[];
  33227. /**
  33228. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  33229. * @returns an array of IParticleSystem
  33230. */
  33231. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  33232. }
  33233. }
  33234. declare module BABYLON {
  33235. /**
  33236. * Represents a set of particle systems working together to create a specific effect
  33237. */
  33238. class ParticleSystemSet implements IDisposable {
  33239. private _emitterCreationOptions;
  33240. private _emitterNode;
  33241. /**
  33242. * Gets the particle system list
  33243. */
  33244. systems: IParticleSystem[];
  33245. /**
  33246. * Gets the emitter node used with this set
  33247. */
  33248. readonly emitterNode: Nullable<TransformNode>;
  33249. /**
  33250. * Creates a new emitter mesh as a sphere
  33251. * @param options defines the options used to create the sphere
  33252. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  33253. * @param scene defines the hosting scene
  33254. */
  33255. setEmitterAsSphere(options: {
  33256. diameter: number;
  33257. segments: number;
  33258. color: Color3;
  33259. }, renderingGroupId: number, scene: Scene): void;
  33260. /**
  33261. * Starts all particle systems of the set
  33262. * @param emitter defines an optional mesh to use as emitter for the particle systems
  33263. */
  33264. start(emitter?: AbstractMesh): void;
  33265. /**
  33266. * Release all associated resources
  33267. */
  33268. dispose(): void;
  33269. /**
  33270. * Serialize the set into a JSON compatible object
  33271. * @returns a JSON compatible representation of the set
  33272. */
  33273. serialize(): any;
  33274. /**
  33275. * Parse a new ParticleSystemSet from a serialized source
  33276. * @param data defines a JSON compatible representation of the set
  33277. * @param scene defines the hosting scene
  33278. * @param gpu defines if we want GPU particles or CPU particles
  33279. * @returns a new ParticleSystemSet
  33280. */
  33281. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  33282. }
  33283. }
  33284. declare module BABYLON {
  33285. /**
  33286. * Represents one particle of a solid particle system.
  33287. */
  33288. class SolidParticle {
  33289. /**
  33290. * particle global index
  33291. */
  33292. idx: number;
  33293. /**
  33294. * The color of the particle
  33295. */
  33296. color: Nullable<Color4>;
  33297. /**
  33298. * The world space position of the particle.
  33299. */
  33300. position: Vector3;
  33301. /**
  33302. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  33303. */
  33304. rotation: Vector3;
  33305. /**
  33306. * The world space rotation quaternion of the particle.
  33307. */
  33308. rotationQuaternion: Nullable<Quaternion>;
  33309. /**
  33310. * The scaling of the particle.
  33311. */
  33312. scaling: Vector3;
  33313. /**
  33314. * The uvs of the particle.
  33315. */
  33316. uvs: Vector4;
  33317. /**
  33318. * The current speed of the particle.
  33319. */
  33320. velocity: Vector3;
  33321. /**
  33322. * The pivot point in the particle local space.
  33323. */
  33324. pivot: Vector3;
  33325. /**
  33326. * Must the particle be translated from its pivot point in its local space ?
  33327. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  33328. * Default : false
  33329. */
  33330. translateFromPivot: boolean;
  33331. /**
  33332. * Is the particle active or not ?
  33333. */
  33334. alive: boolean;
  33335. /**
  33336. * Is the particle visible or not ?
  33337. */
  33338. isVisible: boolean;
  33339. /**
  33340. * Index of this particle in the global "positions" array (Internal use)
  33341. * @hidden
  33342. */
  33343. _pos: number;
  33344. /**
  33345. * @hidden Index of this particle in the global "indices" array (Internal use)
  33346. */
  33347. _ind: number;
  33348. /**
  33349. * @hidden ModelShape of this particle (Internal use)
  33350. */
  33351. _model: ModelShape;
  33352. /**
  33353. * ModelShape id of this particle
  33354. */
  33355. shapeId: number;
  33356. /**
  33357. * Index of the particle in its shape id (Internal use)
  33358. */
  33359. idxInShape: number;
  33360. /**
  33361. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  33362. */
  33363. _modelBoundingInfo: BoundingInfo;
  33364. /**
  33365. * @hidden Particle BoundingInfo object (Internal use)
  33366. */
  33367. _boundingInfo: BoundingInfo;
  33368. /**
  33369. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  33370. */
  33371. _sps: SolidParticleSystem;
  33372. /**
  33373. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33374. */
  33375. _stillInvisible: boolean;
  33376. /**
  33377. * @hidden Last computed particle rotation matrix
  33378. */
  33379. _rotationMatrix: number[];
  33380. /**
  33381. * Parent particle Id, if any.
  33382. * Default null.
  33383. */
  33384. parentId: Nullable<number>;
  33385. /**
  33386. * @hidden Internal global position in the SPS.
  33387. */
  33388. _globalPosition: Vector3;
  33389. /**
  33390. * Creates a Solid Particle object.
  33391. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33392. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  33393. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33394. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33395. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33396. * @param shapeId (integer) is the model shape identifier in the SPS.
  33397. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33398. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33399. */
  33400. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  33401. /**
  33402. * Legacy support, changed scale to scaling
  33403. */
  33404. /**
  33405. * Legacy support, changed scale to scaling
  33406. */
  33407. scale: Vector3;
  33408. /**
  33409. * Legacy support, changed quaternion to rotationQuaternion
  33410. */
  33411. /**
  33412. * Legacy support, changed quaternion to rotationQuaternion
  33413. */
  33414. quaternion: Nullable<Quaternion>;
  33415. /**
  33416. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33417. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33418. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33419. * @returns true if it intersects
  33420. */
  33421. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33422. /**
  33423. * get the rotation matrix of the particle
  33424. * @hidden
  33425. */
  33426. getRotationMatrix(m: Matrix): void;
  33427. }
  33428. /**
  33429. * Represents the shape of the model used by one particle of a solid particle system.
  33430. * SPS internal tool, don't use it manually.
  33431. */
  33432. class ModelShape {
  33433. /**
  33434. * The shape id
  33435. * @hidden
  33436. */
  33437. shapeID: number;
  33438. /**
  33439. * flat array of model positions (internal use)
  33440. * @hidden
  33441. */
  33442. _shape: Vector3[];
  33443. /**
  33444. * flat array of model UVs (internal use)
  33445. * @hidden
  33446. */
  33447. _shapeUV: number[];
  33448. /**
  33449. * length of the shape in the model indices array (internal use)
  33450. * @hidden
  33451. */
  33452. _indicesLength: number;
  33453. /**
  33454. * Custom position function (internal use)
  33455. * @hidden
  33456. */
  33457. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33458. /**
  33459. * Custom vertex function (internal use)
  33460. * @hidden
  33461. */
  33462. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33463. /**
  33464. * 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.
  33465. * SPS internal tool, don't use it manually.
  33466. * @hidden
  33467. */
  33468. 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>);
  33469. }
  33470. /**
  33471. * Represents a Depth Sorted Particle in the solid particle system.
  33472. */
  33473. class DepthSortedParticle {
  33474. /**
  33475. * Index of the particle in the "indices" array
  33476. */
  33477. ind: number;
  33478. /**
  33479. * Length of the particle shape in the "indices" array
  33480. */
  33481. indicesLength: number;
  33482. /**
  33483. * Squared distance from the particle to the camera
  33484. */
  33485. sqDistance: number;
  33486. }
  33487. }
  33488. declare module BABYLON {
  33489. /**
  33490. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  33491. *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.
  33492. * The SPS is also a particle system. It provides some methods to manage the particles.
  33493. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  33494. *
  33495. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  33496. */
  33497. class SolidParticleSystem implements IDisposable {
  33498. /**
  33499. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  33500. * Example : var p = SPS.particles[i];
  33501. */
  33502. particles: SolidParticle[];
  33503. /**
  33504. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  33505. */
  33506. nbParticles: number;
  33507. /**
  33508. * If the particles must ever face the camera (default false). Useful for planar particles.
  33509. */
  33510. billboard: boolean;
  33511. /**
  33512. * Recompute normals when adding a shape
  33513. */
  33514. recomputeNormals: boolean;
  33515. /**
  33516. * This a counter ofr your own usage. It's not set by any SPS functions.
  33517. */
  33518. counter: number;
  33519. /**
  33520. * The SPS name. This name is also given to the underlying mesh.
  33521. */
  33522. name: string;
  33523. /**
  33524. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  33525. */
  33526. mesh: Mesh;
  33527. /**
  33528. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  33529. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  33530. */
  33531. vars: any;
  33532. /**
  33533. * This array is populated when the SPS is set as 'pickable'.
  33534. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  33535. * Each element of this array is an object `{idx: int, faceId: int}`.
  33536. * `idx` is the picked particle index in the `SPS.particles` array
  33537. * `faceId` is the picked face index counted within this particle.
  33538. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  33539. */
  33540. pickedParticles: {
  33541. idx: number;
  33542. faceId: number;
  33543. }[];
  33544. /**
  33545. * This array is populated when `enableDepthSort` is set to true.
  33546. * Each element of this array is an instance of the class DepthSortedParticle.
  33547. */
  33548. depthSortedParticles: DepthSortedParticle[];
  33549. /**
  33550. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  33551. * @hidden
  33552. */
  33553. _bSphereOnly: boolean;
  33554. /**
  33555. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  33556. * @hidden
  33557. */
  33558. _bSphereRadiusFactor: number;
  33559. private _scene;
  33560. private _positions;
  33561. private _indices;
  33562. private _normals;
  33563. private _colors;
  33564. private _uvs;
  33565. private _indices32;
  33566. private _positions32;
  33567. private _normals32;
  33568. private _fixedNormal32;
  33569. private _colors32;
  33570. private _uvs32;
  33571. private _index;
  33572. private _updatable;
  33573. private _pickable;
  33574. private _isVisibilityBoxLocked;
  33575. private _alwaysVisible;
  33576. private _depthSort;
  33577. private _shapeCounter;
  33578. private _copy;
  33579. private _color;
  33580. private _computeParticleColor;
  33581. private _computeParticleTexture;
  33582. private _computeParticleRotation;
  33583. private _computeParticleVertex;
  33584. private _computeBoundingBox;
  33585. private _depthSortParticles;
  33586. private _camera;
  33587. private _mustUnrotateFixedNormals;
  33588. private _particlesIntersect;
  33589. private _needs32Bits;
  33590. /**
  33591. * Creates a SPS (Solid Particle System) object.
  33592. * @param name (String) is the SPS name, this will be the underlying mesh name.
  33593. * @param scene (Scene) is the scene in which the SPS is added.
  33594. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  33595. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  33596. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  33597. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  33598. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  33599. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  33600. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  33601. */
  33602. constructor(name: string, scene: Scene, options?: {
  33603. updatable?: boolean;
  33604. isPickable?: boolean;
  33605. enableDepthSort?: boolean;
  33606. particleIntersection?: boolean;
  33607. boundingSphereOnly?: boolean;
  33608. bSphereRadiusFactor?: number;
  33609. });
  33610. /**
  33611. * Builds the SPS underlying mesh. Returns a standard Mesh.
  33612. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  33613. * @returns the created mesh
  33614. */
  33615. buildMesh(): Mesh;
  33616. /**
  33617. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  33618. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  33619. * Thus the particles generated from `digest()` have their property `position` set yet.
  33620. * @param mesh ( Mesh ) is the mesh to be digested
  33621. * @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
  33622. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  33623. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  33624. * @returns the current SPS
  33625. */
  33626. digest(mesh: Mesh, options?: {
  33627. facetNb?: number;
  33628. number?: number;
  33629. delta?: number;
  33630. }): SolidParticleSystem;
  33631. private _unrotateFixedNormals;
  33632. private _resetCopy;
  33633. private _meshBuilder;
  33634. private _posToShape;
  33635. private _uvsToShapeUV;
  33636. private _addParticle;
  33637. /**
  33638. * Adds some particles to the SPS from the model shape. Returns the shape id.
  33639. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  33640. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  33641. * @param nb (positive integer) the number of particles to be created from this model
  33642. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  33643. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  33644. * @returns the number of shapes in the system
  33645. */
  33646. addShape(mesh: Mesh, nb: number, options?: {
  33647. positionFunction?: any;
  33648. vertexFunction?: any;
  33649. }): number;
  33650. private _rebuildParticle;
  33651. /**
  33652. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  33653. * @returns the SPS.
  33654. */
  33655. rebuildMesh(): SolidParticleSystem;
  33656. /**
  33657. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  33658. * This method calls `updateParticle()` for each particle of the SPS.
  33659. * For an animated SPS, it is usually called within the render loop.
  33660. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  33661. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  33662. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  33663. * @returns the SPS.
  33664. */
  33665. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  33666. /**
  33667. * Disposes the SPS.
  33668. */
  33669. dispose(): void;
  33670. /**
  33671. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  33672. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33673. * @returns the SPS.
  33674. */
  33675. refreshVisibleSize(): SolidParticleSystem;
  33676. /**
  33677. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  33678. * @param size the size (float) of the visibility box
  33679. * note : this doesn't lock the SPS mesh bounding box.
  33680. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33681. */
  33682. setVisibilityBox(size: number): void;
  33683. /**
  33684. * Gets whether the SPS as always visible or not
  33685. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33686. */
  33687. /**
  33688. * Sets the SPS as always visible or not
  33689. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33690. */
  33691. isAlwaysVisible: boolean;
  33692. /**
  33693. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33695. */
  33696. /**
  33697. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  33698. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  33699. */
  33700. isVisibilityBoxLocked: boolean;
  33701. /**
  33702. * Tells to `setParticles()` to compute the particle rotations or not.
  33703. * Default value : true. The SPS is faster when it's set to false.
  33704. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33705. */
  33706. /**
  33707. * Gets if `setParticles()` computes the particle rotations or not.
  33708. * Default value : true. The SPS is faster when it's set to false.
  33709. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  33710. */
  33711. computeParticleRotation: boolean;
  33712. /**
  33713. * Tells to `setParticles()` to compute the particle colors or not.
  33714. * Default value : true. The SPS is faster when it's set to false.
  33715. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33716. */
  33717. /**
  33718. * Gets if `setParticles()` computes the particle colors or not.
  33719. * Default value : true. The SPS is faster when it's set to false.
  33720. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  33721. */
  33722. computeParticleColor: boolean;
  33723. /**
  33724. * Gets if `setParticles()` computes the particle textures or not.
  33725. * Default value : true. The SPS is faster when it's set to false.
  33726. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  33727. */
  33728. computeParticleTexture: boolean;
  33729. /**
  33730. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  33731. * Default value : false. The SPS is faster when it's set to false.
  33732. * Note : the particle custom vertex positions aren't stored values.
  33733. */
  33734. /**
  33735. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  33736. * Default value : false. The SPS is faster when it's set to false.
  33737. * Note : the particle custom vertex positions aren't stored values.
  33738. */
  33739. computeParticleVertex: boolean;
  33740. /**
  33741. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  33742. */
  33743. /**
  33744. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  33745. */
  33746. computeBoundingBox: boolean;
  33747. /**
  33748. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  33749. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33750. * Default : `true`
  33751. */
  33752. /**
  33753. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  33754. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  33755. * Default : `true`
  33756. */
  33757. depthSortParticles: boolean;
  33758. /**
  33759. * This function does nothing. It may be overwritten to set all the particle first values.
  33760. * The SPS doesn't call this function, you may have to call it by your own.
  33761. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33762. */
  33763. initParticles(): void;
  33764. /**
  33765. * This function does nothing. It may be overwritten to recycle a particle.
  33766. * The SPS doesn't call this function, you may have to call it by your own.
  33767. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33768. * @param particle The particle to recycle
  33769. * @returns the recycled particle
  33770. */
  33771. recycleParticle(particle: SolidParticle): SolidParticle;
  33772. /**
  33773. * Updates a particle : this function should be overwritten by the user.
  33774. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  33775. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  33776. * @example : just set a particle position or velocity and recycle conditions
  33777. * @param particle The particle to update
  33778. * @returns the updated particle
  33779. */
  33780. updateParticle(particle: SolidParticle): SolidParticle;
  33781. /**
  33782. * Updates a vertex of a particle : it can be overwritten by the user.
  33783. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  33784. * @param particle the current particle
  33785. * @param vertex the current index of the current particle
  33786. * @param pt the index of the current vertex in the particle shape
  33787. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  33788. * @example : just set a vertex particle position
  33789. * @returns the updated vertex
  33790. */
  33791. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  33792. /**
  33793. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  33794. * This does nothing and may be overwritten by the user.
  33795. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33796. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33797. * @param update the boolean update value actually passed to setParticles()
  33798. */
  33799. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33800. /**
  33801. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  33802. * This will be passed three parameters.
  33803. * This does nothing and may be overwritten by the user.
  33804. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33805. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  33806. * @param update the boolean update value actually passed to setParticles()
  33807. */
  33808. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  33809. }
  33810. }
  33811. declare module BABYLON {
  33812. /**
  33813. * Type of sub emitter
  33814. */
  33815. enum SubEmitterType {
  33816. /**
  33817. * Attached to the particle over it's lifetime
  33818. */
  33819. ATTACHED = 0,
  33820. /**
  33821. * Created when the particle dies
  33822. */
  33823. END = 1
  33824. }
  33825. /**
  33826. * Sub emitter class used to emit particles from an existing particle
  33827. */
  33828. class SubEmitter {
  33829. /**
  33830. * the particle system to be used by the sub emitter
  33831. */
  33832. particleSystem: ParticleSystem;
  33833. /**
  33834. * Type of the submitter (Default: END)
  33835. */
  33836. type: SubEmitterType;
  33837. /**
  33838. * 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)
  33839. * Note: This only is supported when using an emitter of type Mesh
  33840. */
  33841. inheritDirection: boolean;
  33842. /**
  33843. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  33844. */
  33845. inheritedVelocityAmount: number;
  33846. /**
  33847. * Creates a sub emitter
  33848. * @param particleSystem the particle system to be used by the sub emitter
  33849. */
  33850. constructor(
  33851. /**
  33852. * the particle system to be used by the sub emitter
  33853. */
  33854. particleSystem: ParticleSystem);
  33855. /**
  33856. * Clones the sub emitter
  33857. * @returns the cloned sub emitter
  33858. */
  33859. clone(): SubEmitter;
  33860. /**
  33861. * Serialize current object to a JSON object
  33862. * @returns the serialized object
  33863. */
  33864. serialize(): any;
  33865. /**
  33866. * Creates a new SubEmitter from a serialized JSON version
  33867. * @param serializationObject defines the JSON object to read from
  33868. * @param scene defines the hosting scene
  33869. * @param rootUrl defines the rootUrl for data loading
  33870. * @returns a new SubEmitter
  33871. */
  33872. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  33873. /** Release associated resources */
  33874. dispose(): void;
  33875. }
  33876. }
  33877. declare module BABYLON {
  33878. interface Scene {
  33879. /**
  33880. * The list of reflection probes added to the scene
  33881. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33882. */
  33883. reflectionProbes: Array<ReflectionProbe>;
  33884. }
  33885. /**
  33886. * Class used to generate realtime reflection / refraction cube textures
  33887. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33888. */
  33889. class ReflectionProbe {
  33890. /** defines the name of the probe */
  33891. name: string;
  33892. private _scene;
  33893. private _renderTargetTexture;
  33894. private _projectionMatrix;
  33895. private _viewMatrix;
  33896. private _target;
  33897. private _add;
  33898. private _attachedMesh;
  33899. private _invertYAxis;
  33900. /** Gets or sets probe position (center of the cube map) */
  33901. position: Vector3;
  33902. /**
  33903. * Creates a new reflection probe
  33904. * @param name defines the name of the probe
  33905. * @param size defines the texture resolution (for each face)
  33906. * @param scene defines the hosting scene
  33907. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  33908. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  33909. */
  33910. constructor(
  33911. /** defines the name of the probe */
  33912. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  33913. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  33914. samples: number;
  33915. /** Gets or sets the refresh rate to use (on every frame by default) */
  33916. refreshRate: number;
  33917. /**
  33918. * Gets the hosting scene
  33919. * @returns a Scene
  33920. */
  33921. getScene(): Scene;
  33922. /** Gets the internal CubeTexture used to render to */
  33923. readonly cubeTexture: RenderTargetTexture;
  33924. /** Gets the list of meshes to render */
  33925. readonly renderList: Nullable<AbstractMesh[]>;
  33926. /**
  33927. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  33928. * @param mesh defines the mesh to attach to
  33929. */
  33930. attachToMesh(mesh: AbstractMesh): void;
  33931. /**
  33932. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  33933. * @param renderingGroupId The rendering group id corresponding to its index
  33934. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33935. */
  33936. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33937. /**
  33938. * Clean all associated resources
  33939. */
  33940. dispose(): void;
  33941. }
  33942. }
  33943. declare module BABYLON {
  33944. interface Scene {
  33945. /** @hidden (Backing field) */
  33946. _boundingBoxRenderer: BoundingBoxRenderer;
  33947. /** @hidden (Backing field) */
  33948. _forceShowBoundingBoxes: boolean;
  33949. /**
  33950. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  33951. */
  33952. forceShowBoundingBoxes: boolean;
  33953. /**
  33954. * Gets the bounding box renderer associated with the scene
  33955. * @returns a BoundingBoxRenderer
  33956. */
  33957. getBoundingBoxRenderer(): BoundingBoxRenderer;
  33958. }
  33959. interface AbstractMesh {
  33960. /** @hidden (Backing field) */
  33961. _showBoundingBox: boolean;
  33962. /**
  33963. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  33964. */
  33965. showBoundingBox: boolean;
  33966. }
  33967. /**
  33968. * Component responsible of rendering the bounding box of the meshes in a scene.
  33969. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  33970. */
  33971. class BoundingBoxRenderer implements ISceneComponent {
  33972. /**
  33973. * The component name helpfull to identify the component in the list of scene components.
  33974. */
  33975. readonly name: string;
  33976. /**
  33977. * The scene the component belongs to.
  33978. */
  33979. scene: Scene;
  33980. /**
  33981. * Color of the bounding box lines placed in front of an object
  33982. */
  33983. frontColor: Color3;
  33984. /**
  33985. * Color of the bounding box lines placed behind an object
  33986. */
  33987. backColor: Color3;
  33988. /**
  33989. * Defines if the renderer should show the back lines or not
  33990. */
  33991. showBackLines: boolean;
  33992. /**
  33993. * @hidden
  33994. */
  33995. renderList: SmartArray<BoundingBox>;
  33996. private _colorShader;
  33997. private _vertexBuffers;
  33998. private _indexBuffer;
  33999. /**
  34000. * Instantiates a new bounding box renderer in a scene.
  34001. * @param scene the scene the renderer renders in
  34002. */
  34003. constructor(scene: Scene);
  34004. /**
  34005. * Registers the component in a given scene
  34006. */
  34007. register(): void;
  34008. private _evaluateSubMesh;
  34009. private _activeMesh;
  34010. private _prepareRessources;
  34011. private _createIndexBuffer;
  34012. /**
  34013. * Rebuilds the elements related to this component in case of
  34014. * context lost for instance.
  34015. */
  34016. rebuild(): void;
  34017. /**
  34018. * @hidden
  34019. */
  34020. reset(): void;
  34021. /**
  34022. * Render the bounding boxes of a specific rendering group
  34023. * @param renderingGroupId defines the rendering group to render
  34024. */
  34025. render(renderingGroupId: number): void;
  34026. /**
  34027. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34028. * @param mesh Define the mesh to render the occlusion bounding box for
  34029. */
  34030. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34031. /**
  34032. * Dispose and release the resources attached to this renderer.
  34033. */
  34034. dispose(): void;
  34035. }
  34036. }
  34037. declare module BABYLON {
  34038. /**
  34039. * This represents a depth renderer in Babylon.
  34040. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34041. */
  34042. class DepthRenderer {
  34043. private _scene;
  34044. private _depthMap;
  34045. private _effect;
  34046. private _cachedDefines;
  34047. private _camera;
  34048. /**
  34049. * Specifiess that the depth renderer will only be used within
  34050. * the camera it is created for.
  34051. * This can help forcing its rendering during the camera processing.
  34052. */
  34053. useOnlyInActiveCamera: boolean;
  34054. /**
  34055. * Instantiates a depth renderer
  34056. * @param scene The scene the renderer belongs to
  34057. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34058. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34059. */
  34060. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34061. /**
  34062. * Creates the depth rendering effect and checks if the effect is ready.
  34063. * @param subMesh The submesh to be used to render the depth map of
  34064. * @param useInstances If multiple world instances should be used
  34065. * @returns if the depth renderer is ready to render the depth map
  34066. */
  34067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34068. /**
  34069. * Gets the texture which the depth map will be written to.
  34070. * @returns The depth map texture
  34071. */
  34072. getDepthMap(): RenderTargetTexture;
  34073. /**
  34074. * Disposes of the depth renderer.
  34075. */
  34076. dispose(): void;
  34077. }
  34078. }
  34079. declare module BABYLON {
  34080. interface Scene {
  34081. /** @hidden (Backing field) */
  34082. _depthRenderer: {
  34083. [id: string]: DepthRenderer;
  34084. };
  34085. /**
  34086. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34087. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34088. * @returns the created depth renderer
  34089. */
  34090. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34091. /**
  34092. * Disables a depth renderer for a given camera
  34093. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34094. */
  34095. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34096. }
  34097. /**
  34098. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  34099. * in several rendering techniques.
  34100. */
  34101. class DepthRendererSceneComponent implements ISceneComponent {
  34102. /**
  34103. * The component name helpfull to identify the component in the list of scene components.
  34104. */
  34105. readonly name: string;
  34106. /**
  34107. * The scene the component belongs to.
  34108. */
  34109. scene: Scene;
  34110. /**
  34111. * Creates a new instance of the component for the given scene
  34112. * @param scene Defines the scene to register the component in
  34113. */
  34114. constructor(scene: Scene);
  34115. /**
  34116. * Registers the component in a given scene
  34117. */
  34118. register(): void;
  34119. /**
  34120. * Rebuilds the elements related to this component in case of
  34121. * context lost for instance.
  34122. */
  34123. rebuild(): void;
  34124. /**
  34125. * Disposes the component and the associated ressources
  34126. */
  34127. dispose(): void;
  34128. private _gatherRenderTargets;
  34129. private _gatherActiveCameraRenderTargets;
  34130. }
  34131. }
  34132. declare module BABYLON {
  34133. interface AbstractMesh {
  34134. /**
  34135. * Disables the mesh edge rendering mode
  34136. * @returns the currentAbstractMesh
  34137. */
  34138. disableEdgesRendering(): AbstractMesh;
  34139. /**
  34140. * Enables the edge rendering mode on the mesh.
  34141. * This mode makes the mesh edges visible
  34142. * @param epsilon defines the maximal distance between two angles to detect a face
  34143. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34144. * @returns the currentAbstractMesh
  34145. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34146. */
  34147. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34148. /**
  34149. * Gets the edgesRenderer associated with the mesh
  34150. */
  34151. edgesRenderer: Nullable<EdgesRenderer>;
  34152. }
  34153. interface LinesMesh {
  34154. /**
  34155. * Enables the edge rendering mode on the mesh.
  34156. * This mode makes the mesh edges visible
  34157. * @param epsilon defines the maximal distance between two angles to detect a face
  34158. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34159. * @returns the currentAbstractMesh
  34160. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34161. */
  34162. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34163. }
  34164. /**
  34165. * Defines the minimum contract an Edges renderer should follow.
  34166. */
  34167. interface IEdgesRenderer extends IDisposable {
  34168. /**
  34169. * Gets or sets a boolean indicating if the edgesRenderer is active
  34170. */
  34171. isEnabled: boolean;
  34172. /**
  34173. * Renders the edges of the attached mesh,
  34174. */
  34175. render(): void;
  34176. /**
  34177. * Checks wether or not the edges renderer is ready to render.
  34178. * @return true if ready, otherwise false.
  34179. */
  34180. isReady(): boolean;
  34181. }
  34182. /**
  34183. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34184. */
  34185. class EdgesRenderer implements IEdgesRenderer {
  34186. /**
  34187. * Define the size of the edges with an orthographic camera
  34188. */
  34189. edgesWidthScalerForOrthographic: number;
  34190. /**
  34191. * Define the size of the edges with a perspective camera
  34192. */
  34193. edgesWidthScalerForPerspective: number;
  34194. protected _source: AbstractMesh;
  34195. protected _linesPositions: number[];
  34196. protected _linesNormals: number[];
  34197. protected _linesIndices: number[];
  34198. protected _epsilon: number;
  34199. protected _indicesCount: number;
  34200. protected _lineShader: ShaderMaterial;
  34201. protected _ib: WebGLBuffer;
  34202. protected _buffers: {
  34203. [key: string]: Nullable<VertexBuffer>;
  34204. };
  34205. protected _checkVerticesInsteadOfIndices: boolean;
  34206. private _meshRebuildObserver;
  34207. private _meshDisposeObserver;
  34208. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34209. isEnabled: boolean;
  34210. /**
  34211. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34212. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34213. * @param source Mesh used to create edges
  34214. * @param epsilon sum of angles in adjacency to check for edge
  34215. * @param checkVerticesInsteadOfIndices
  34216. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34217. */
  34218. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34219. protected _prepareRessources(): void;
  34220. /** @hidden */
  34221. _rebuild(): void;
  34222. /**
  34223. * Releases the required resources for the edges renderer
  34224. */
  34225. dispose(): void;
  34226. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34227. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34228. /**
  34229. * Checks if the pair of p0 and p1 is en edge
  34230. * @param faceIndex
  34231. * @param edge
  34232. * @param faceNormals
  34233. * @param p0
  34234. * @param p1
  34235. * @private
  34236. */
  34237. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34238. /**
  34239. * Generates lines edges from adjacencjes
  34240. * @private
  34241. */
  34242. _generateEdgesLines(): void;
  34243. /**
  34244. * Checks wether or not the edges renderer is ready to render.
  34245. * @return true if ready, otherwise false.
  34246. */
  34247. isReady(): boolean;
  34248. /**
  34249. * Renders the edges of the attached mesh,
  34250. */
  34251. render(): void;
  34252. }
  34253. }
  34254. declare module BABYLON {
  34255. /**
  34256. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34257. */
  34258. class GeometryBufferRenderer {
  34259. /**
  34260. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34261. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34262. */
  34263. static readonly POSITION_TEXTURE_TYPE: number;
  34264. /**
  34265. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34266. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34267. */
  34268. static readonly VELOCITY_TEXTURE_TYPE: number;
  34269. /**
  34270. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34271. * in order to compute objects velocities when enableVelocity is set to "true"
  34272. * @hidden
  34273. */
  34274. _previousTransformationMatrices: {
  34275. [index: number]: Matrix;
  34276. };
  34277. private _scene;
  34278. private _multiRenderTarget;
  34279. private _ratio;
  34280. private _enablePosition;
  34281. private _enableVelocity;
  34282. private _positionIndex;
  34283. private _velocityIndex;
  34284. protected _effect: Effect;
  34285. protected _cachedDefines: string;
  34286. /**
  34287. * Set the render list (meshes to be rendered) used in the G buffer.
  34288. */
  34289. renderList: Mesh[];
  34290. /**
  34291. * Gets wether or not G buffer are supported by the running hardware.
  34292. * This requires draw buffer supports
  34293. */
  34294. readonly isSupported: boolean;
  34295. /**
  34296. * Returns the index of the given texture type in the G-Buffer textures array
  34297. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34298. * @returns the index of the given texture type in the G-Buffer textures array
  34299. */
  34300. getTextureIndex(textureType: number): number;
  34301. /**
  34302. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34303. */
  34304. /**
  34305. * Sets whether or not objects positions are enabled for the G buffer.
  34306. */
  34307. enablePosition: boolean;
  34308. /**
  34309. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34310. */
  34311. /**
  34312. * Sets wether or not objects velocities are enabled for the G buffer.
  34313. */
  34314. enableVelocity: boolean;
  34315. /**
  34316. * Gets the scene associated with the buffer.
  34317. */
  34318. readonly scene: Scene;
  34319. /**
  34320. * Gets the ratio used by the buffer during its creation.
  34321. * How big is the buffer related to the main canvas.
  34322. */
  34323. readonly ratio: number;
  34324. /**
  34325. * Creates a new G Buffer for the scene
  34326. * @param scene The scene the buffer belongs to
  34327. * @param ratio How big is the buffer related to the main canvas.
  34328. */
  34329. constructor(scene: Scene, ratio?: number);
  34330. /**
  34331. * Checks wether everything is ready to render a submesh to the G buffer.
  34332. * @param subMesh the submesh to check readiness for
  34333. * @param useInstances is the mesh drawn using instance or not
  34334. * @returns true if ready otherwise false
  34335. */
  34336. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34337. /**
  34338. * Gets the current underlying G Buffer.
  34339. * @returns the buffer
  34340. */
  34341. getGBuffer(): MultiRenderTarget;
  34342. /**
  34343. * Gets the number of samples used to render the buffer (anti aliasing).
  34344. */
  34345. /**
  34346. * Sets the number of samples used to render the buffer (anti aliasing).
  34347. */
  34348. samples: number;
  34349. /**
  34350. * Disposes the renderer and frees up associated resources.
  34351. */
  34352. dispose(): void;
  34353. protected _createRenderTargets(): void;
  34354. }
  34355. }
  34356. declare module BABYLON {
  34357. interface Scene {
  34358. /** @hidden (Backing field) */
  34359. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34360. /**
  34361. * Gets or Sets the current geometry buffer associated to the scene.
  34362. */
  34363. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34364. /**
  34365. * Enables a GeometryBufferRender and associates it with the scene
  34366. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34367. * @returns the GeometryBufferRenderer
  34368. */
  34369. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34370. /**
  34371. * Disables the GeometryBufferRender associated with the scene
  34372. */
  34373. disableGeometryBufferRenderer(): void;
  34374. }
  34375. /**
  34376. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34377. * in several rendering techniques.
  34378. */
  34379. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34380. /**
  34381. * The component name helpful to identify the component in the list of scene components.
  34382. */
  34383. readonly name: string;
  34384. /**
  34385. * The scene the component belongs to.
  34386. */
  34387. scene: Scene;
  34388. /**
  34389. * Creates a new instance of the component for the given scene
  34390. * @param scene Defines the scene to register the component in
  34391. */
  34392. constructor(scene: Scene);
  34393. /**
  34394. * Registers the component in a given scene
  34395. */
  34396. register(): void;
  34397. /**
  34398. * Rebuilds the elements related to this component in case of
  34399. * context lost for instance.
  34400. */
  34401. rebuild(): void;
  34402. /**
  34403. * Disposes the component and the associated ressources
  34404. */
  34405. dispose(): void;
  34406. private _gatherRenderTargets;
  34407. }
  34408. }
  34409. declare module BABYLON {
  34410. /**
  34411. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34412. */
  34413. class LineEdgesRenderer extends EdgesRenderer {
  34414. /**
  34415. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34416. * @param source LineMesh used to generate edges
  34417. * @param epsilon not important (specified angle for edge detection)
  34418. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34419. */
  34420. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34421. /**
  34422. * Always create the edge since its a line so only important things are p0 and p1
  34423. * @param faceIndex not important for LineMesh
  34424. * @param edge not important for LineMesh
  34425. * @param faceNormals not important for LineMesh
  34426. * @param p0 beginnig of line
  34427. * @param p1 end of line
  34428. */
  34429. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34430. /**
  34431. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34432. */
  34433. _generateEdgesLines(): void;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. interface Scene {
  34438. /** @hidden */
  34439. _outlineRenderer: OutlineRenderer;
  34440. /**
  34441. * Gets the outline renderer associated with the scene
  34442. * @returns a OutlineRenderer
  34443. */
  34444. getOutlineRenderer(): OutlineRenderer;
  34445. }
  34446. interface AbstractMesh {
  34447. /** @hidden (Backing field) */
  34448. _renderOutline: boolean;
  34449. /**
  34450. * Gets or sets a boolean indicating if the outline must be rendered as well
  34451. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34452. */
  34453. renderOutline: boolean;
  34454. /** @hidden (Backing field) */
  34455. _renderOverlay: boolean;
  34456. /**
  34457. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34458. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34459. */
  34460. renderOverlay: boolean;
  34461. }
  34462. /**
  34463. * This class is responsible to draw bothe outline/overlay of meshes.
  34464. * It should not be used directly but through the available method on mesh.
  34465. */
  34466. class OutlineRenderer implements ISceneComponent {
  34467. /**
  34468. * The name of the component. Each component must have a unique name.
  34469. */
  34470. name: string;
  34471. /**
  34472. * The scene the component belongs to.
  34473. */
  34474. scene: Scene;
  34475. /**
  34476. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34477. */
  34478. zOffset: number;
  34479. private _engine;
  34480. private _effect;
  34481. private _cachedDefines;
  34482. private _savedDepthWrite;
  34483. /**
  34484. * Instantiates a new outline renderer. (There could be only one per scene).
  34485. * @param scene Defines the scene it belongs to
  34486. */
  34487. constructor(scene: Scene);
  34488. /**
  34489. * Register the component to one instance of a scene.
  34490. */
  34491. register(): void;
  34492. /**
  34493. * Rebuilds the elements related to this component in case of
  34494. * context lost for instance.
  34495. */
  34496. rebuild(): void;
  34497. /**
  34498. * Disposes the component and the associated ressources.
  34499. */
  34500. dispose(): void;
  34501. /**
  34502. * Renders the outline in the canvas.
  34503. * @param subMesh Defines the sumesh to render
  34504. * @param batch Defines the batch of meshes in case of instances
  34505. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34506. */
  34507. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34508. /**
  34509. * Returns whether or not the outline renderer is ready for a given submesh.
  34510. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34511. * @param subMesh Defines the submesh to check readyness for
  34512. * @param useInstances Defines wheter wee are trying to render instances or not
  34513. * @returns true if ready otherwise false
  34514. */
  34515. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34516. private _beforeRenderingMesh;
  34517. private _afterRenderingMesh;
  34518. }
  34519. }
  34520. declare module BABYLON {
  34521. /**
  34522. * This represents the object necessary to create a rendering group.
  34523. * This is exclusively used and created by the rendering manager.
  34524. * To modify the behavior, you use the available helpers in your scene or meshes.
  34525. * @hidden
  34526. */
  34527. class RenderingGroup {
  34528. index: number;
  34529. private _scene;
  34530. private _opaqueSubMeshes;
  34531. private _transparentSubMeshes;
  34532. private _alphaTestSubMeshes;
  34533. private _depthOnlySubMeshes;
  34534. private _particleSystems;
  34535. private _spriteManagers;
  34536. private _opaqueSortCompareFn;
  34537. private _alphaTestSortCompareFn;
  34538. private _transparentSortCompareFn;
  34539. private _renderOpaque;
  34540. private _renderAlphaTest;
  34541. private _renderTransparent;
  34542. private _edgesRenderers;
  34543. onBeforeTransparentRendering: () => void;
  34544. /**
  34545. * Set the opaque sort comparison function.
  34546. * If null the sub meshes will be render in the order they were created
  34547. */
  34548. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34549. /**
  34550. * Set the alpha test sort comparison function.
  34551. * If null the sub meshes will be render in the order they were created
  34552. */
  34553. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34554. /**
  34555. * Set the transparent sort comparison function.
  34556. * If null the sub meshes will be render in the order they were created
  34557. */
  34558. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34559. /**
  34560. * Creates a new rendering group.
  34561. * @param index The rendering group index
  34562. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  34563. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  34564. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  34565. */
  34566. 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>);
  34567. /**
  34568. * Render all the sub meshes contained in the group.
  34569. * @param customRenderFunction Used to override the default render behaviour of the group.
  34570. * @returns true if rendered some submeshes.
  34571. */
  34572. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  34573. /**
  34574. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  34575. * @param subMeshes The submeshes to render
  34576. */
  34577. private renderOpaqueSorted;
  34578. /**
  34579. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  34580. * @param subMeshes The submeshes to render
  34581. */
  34582. private renderAlphaTestSorted;
  34583. /**
  34584. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  34585. * @param subMeshes The submeshes to render
  34586. */
  34587. private renderTransparentSorted;
  34588. /**
  34589. * Renders the submeshes in a specified order.
  34590. * @param subMeshes The submeshes to sort before render
  34591. * @param sortCompareFn The comparison function use to sort
  34592. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  34593. * @param transparent Specifies to activate blending if true
  34594. */
  34595. private static renderSorted;
  34596. /**
  34597. * Renders the submeshes in the order they were dispatched (no sort applied).
  34598. * @param subMeshes The submeshes to render
  34599. */
  34600. private static renderUnsorted;
  34601. /**
  34602. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34603. * are rendered back to front if in the same alpha index.
  34604. *
  34605. * @param a The first submesh
  34606. * @param b The second submesh
  34607. * @returns The result of the comparison
  34608. */
  34609. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  34610. /**
  34611. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34612. * are rendered back to front.
  34613. *
  34614. * @param a The first submesh
  34615. * @param b The second submesh
  34616. * @returns The result of the comparison
  34617. */
  34618. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  34619. /**
  34620. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34621. * are rendered front to back (prevent overdraw).
  34622. *
  34623. * @param a The first submesh
  34624. * @param b The second submesh
  34625. * @returns The result of the comparison
  34626. */
  34627. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  34628. /**
  34629. * Resets the different lists of submeshes to prepare a new frame.
  34630. */
  34631. prepare(): void;
  34632. dispose(): void;
  34633. /**
  34634. * Inserts the submesh in its correct queue depending on its material.
  34635. * @param subMesh The submesh to dispatch
  34636. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34637. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34638. */
  34639. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34640. dispatchSprites(spriteManager: ISpriteManager): void;
  34641. dispatchParticles(particleSystem: IParticleSystem): void;
  34642. private _renderParticles;
  34643. private _renderSprites;
  34644. }
  34645. }
  34646. declare module BABYLON {
  34647. /**
  34648. * Interface describing the different options available in the rendering manager
  34649. * regarding Auto Clear between groups.
  34650. */
  34651. interface IRenderingManagerAutoClearSetup {
  34652. /**
  34653. * Defines whether or not autoclear is enable.
  34654. */
  34655. autoClear: boolean;
  34656. /**
  34657. * Defines whether or not to autoclear the depth buffer.
  34658. */
  34659. depth: boolean;
  34660. /**
  34661. * Defines whether or not to autoclear the stencil buffer.
  34662. */
  34663. stencil: boolean;
  34664. }
  34665. /**
  34666. * This is the manager responsible of all the rendering for meshes sprites and particles.
  34667. * It is enable to manage the different groups as well as the different necessary sort functions.
  34668. * This should not be used directly aside of the few static configurations
  34669. */
  34670. class RenderingManager {
  34671. /**
  34672. * The max id used for rendering groups (not included)
  34673. */
  34674. static MAX_RENDERINGGROUPS: number;
  34675. /**
  34676. * The min id used for rendering groups (included)
  34677. */
  34678. static MIN_RENDERINGGROUPS: number;
  34679. /**
  34680. * Used to globally prevent autoclearing scenes.
  34681. */
  34682. static AUTOCLEAR: boolean;
  34683. /**
  34684. * @hidden
  34685. */
  34686. _useSceneAutoClearSetup: boolean;
  34687. private _scene;
  34688. private _renderingGroups;
  34689. private _depthStencilBufferAlreadyCleaned;
  34690. private _autoClearDepthStencil;
  34691. private _customOpaqueSortCompareFn;
  34692. private _customAlphaTestSortCompareFn;
  34693. private _customTransparentSortCompareFn;
  34694. private _renderingGroupInfo;
  34695. /**
  34696. * Instantiates a new rendering group for a particular scene
  34697. * @param scene Defines the scene the groups belongs to
  34698. */
  34699. constructor(scene: Scene);
  34700. private _clearDepthStencilBuffer;
  34701. /**
  34702. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  34703. * @hidden
  34704. */
  34705. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  34706. /**
  34707. * Resets the different information of the group to prepare a new frame
  34708. * @hidden
  34709. */
  34710. reset(): void;
  34711. /**
  34712. * Dispose and release the group and its associated resources.
  34713. * @hidden
  34714. */
  34715. dispose(): void;
  34716. /**
  34717. * Clear the info related to rendering groups preventing retention points during dispose.
  34718. */
  34719. freeRenderingGroups(): void;
  34720. private _prepareRenderingGroup;
  34721. /**
  34722. * Add a sprite manager to the rendering manager in order to render it this frame.
  34723. * @param spriteManager Define the sprite manager to render
  34724. */
  34725. dispatchSprites(spriteManager: ISpriteManager): void;
  34726. /**
  34727. * Add a particle system to the rendering manager in order to render it this frame.
  34728. * @param particleSystem Define the particle system to render
  34729. */
  34730. dispatchParticles(particleSystem: IParticleSystem): void;
  34731. /**
  34732. * Add a submesh to the manager in order to render it this frame
  34733. * @param subMesh The submesh to dispatch
  34734. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  34735. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  34736. */
  34737. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  34738. /**
  34739. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34740. * This allowed control for front to back rendering or reversly depending of the special needs.
  34741. *
  34742. * @param renderingGroupId The rendering group id corresponding to its index
  34743. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34744. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34745. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34746. */
  34747. 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;
  34748. /**
  34749. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34750. *
  34751. * @param renderingGroupId The rendering group id corresponding to its index
  34752. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34753. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34754. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34755. */
  34756. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34757. /**
  34758. * Gets the current auto clear configuration for one rendering group of the rendering
  34759. * manager.
  34760. * @param index the rendering group index to get the information for
  34761. * @returns The auto clear setup for the requested rendering group
  34762. */
  34763. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34764. }
  34765. }
  34766. declare module BABYLON {
  34767. /**
  34768. * Renders a layer on top of an existing scene
  34769. */
  34770. class UtilityLayerRenderer implements IDisposable {
  34771. /** the original scene that will be rendered on top of */
  34772. originalScene: Scene;
  34773. private _pointerCaptures;
  34774. private _lastPointerEvents;
  34775. private static _DefaultUtilityLayer;
  34776. private static _DefaultKeepDepthUtilityLayer;
  34777. /**
  34778. * 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)
  34779. */
  34780. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  34781. /**
  34782. * 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)
  34783. */
  34784. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  34785. /**
  34786. * The scene that is rendered on top of the original scene
  34787. */
  34788. utilityLayerScene: Scene;
  34789. /**
  34790. * If the utility layer should automatically be rendered on top of existing scene
  34791. */
  34792. shouldRender: boolean;
  34793. /**
  34794. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  34795. */
  34796. onlyCheckPointerDownEvents: boolean;
  34797. /**
  34798. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  34799. */
  34800. processAllEvents: boolean;
  34801. /**
  34802. * Observable raised when the pointer move from the utility layer scene to the main scene
  34803. */
  34804. onPointerOutObservable: Observable<number>;
  34805. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  34806. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  34807. private _afterRenderObserver;
  34808. private _sceneDisposeObserver;
  34809. private _originalPointerObserver;
  34810. /**
  34811. * Instantiates a UtilityLayerRenderer
  34812. * @param originalScene the original scene that will be rendered on top of
  34813. */
  34814. constructor(
  34815. /** the original scene that will be rendered on top of */
  34816. originalScene: Scene);
  34817. private _notifyObservers;
  34818. /**
  34819. * Renders the utility layers scene on top of the original scene
  34820. */
  34821. render(): void;
  34822. /**
  34823. * Disposes of the renderer
  34824. */
  34825. dispose(): void;
  34826. private _updateCamera;
  34827. }
  34828. }
  34829. declare module BABYLON {
  34830. /**
  34831. * Class used to represent a sprite
  34832. * @see http://doc.babylonjs.com/babylon101/sprites
  34833. */
  34834. class Sprite {
  34835. /** defines the name */
  34836. name: string;
  34837. /** Gets or sets the current world position */
  34838. position: Vector3;
  34839. /** Gets or sets the main color */
  34840. color: Color4;
  34841. /** Gets or sets the width */
  34842. width: number;
  34843. /** Gets or sets the height */
  34844. height: number;
  34845. /** Gets or sets rotation angle */
  34846. angle: number;
  34847. /** Gets or sets the cell index in the sprite sheet */
  34848. cellIndex: number;
  34849. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  34850. invertU: number;
  34851. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  34852. invertV: number;
  34853. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  34854. disposeWhenFinishedAnimating: boolean;
  34855. /** Gets the list of attached animations */
  34856. animations: Animation[];
  34857. /** Gets or sets a boolean indicating if the sprite can be picked */
  34858. isPickable: boolean;
  34859. /**
  34860. * Gets or sets the associated action manager
  34861. */
  34862. actionManager: Nullable<ActionManager>;
  34863. private _animationStarted;
  34864. private _loopAnimation;
  34865. private _fromIndex;
  34866. private _toIndex;
  34867. private _delay;
  34868. private _direction;
  34869. private _manager;
  34870. private _time;
  34871. private _onAnimationEnd;
  34872. /**
  34873. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  34874. */
  34875. isVisible: boolean;
  34876. /**
  34877. * Gets or sets the sprite size
  34878. */
  34879. size: number;
  34880. /**
  34881. * Creates a new Sprite
  34882. * @param name defines the name
  34883. * @param manager defines the manager
  34884. */
  34885. constructor(
  34886. /** defines the name */
  34887. name: string, manager: ISpriteManager);
  34888. /**
  34889. * Starts an animation
  34890. * @param from defines the initial key
  34891. * @param to defines the end key
  34892. * @param loop defines if the animation must loop
  34893. * @param delay defines the start delay (in ms)
  34894. * @param onAnimationEnd defines a callback to call when animation ends
  34895. */
  34896. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  34897. /** Stops current animation (if any) */
  34898. stopAnimation(): void;
  34899. /** @hidden */
  34900. _animate(deltaTime: number): void;
  34901. /** Release associated resources */
  34902. dispose(): void;
  34903. }
  34904. }
  34905. declare module BABYLON {
  34906. /**
  34907. * Defines the minimum interface to fullfil in order to be a sprite manager.
  34908. */
  34909. interface ISpriteManager extends IDisposable {
  34910. /**
  34911. * Restricts the camera to viewing objects with the same layerMask.
  34912. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  34913. */
  34914. layerMask: number;
  34915. /**
  34916. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  34917. */
  34918. isPickable: boolean;
  34919. /**
  34920. * Specifies the rendering group id for this mesh (0 by default)
  34921. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  34922. */
  34923. renderingGroupId: number;
  34924. /**
  34925. * Defines the list of sprites managed by the manager.
  34926. */
  34927. sprites: Array<Sprite>;
  34928. /**
  34929. * Tests the intersection of a sprite with a specific ray.
  34930. * @param ray The ray we are sending to test the collision
  34931. * @param camera The camera space we are sending rays in
  34932. * @param predicate A predicate allowing excluding sprites from the list of object to test
  34933. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  34934. * @returns picking info or null.
  34935. */
  34936. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  34937. /**
  34938. * Renders the list of sprites on screen.
  34939. */
  34940. render(): void;
  34941. }
  34942. /**
  34943. * Class used to manage multiple sprites on the same spritesheet
  34944. * @see http://doc.babylonjs.com/babylon101/sprites
  34945. */
  34946. class SpriteManager implements ISpriteManager {
  34947. /** defines the manager's name */
  34948. name: string;
  34949. /** Gets the list of sprites */
  34950. sprites: Sprite[];
  34951. /** Gets or sets the rendering group id (0 by default) */
  34952. renderingGroupId: number;
  34953. /** Gets or sets camera layer mask */
  34954. layerMask: number;
  34955. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  34956. fogEnabled: boolean;
  34957. /** Gets or sets a boolean indicating if the sprites are pickable */
  34958. isPickable: boolean;
  34959. /** Defines the default width of a cell in the spritesheet */
  34960. cellWidth: number;
  34961. /** Defines the default height of a cell in the spritesheet */
  34962. cellHeight: number;
  34963. /**
  34964. * An event triggered when the manager is disposed.
  34965. */
  34966. onDisposeObservable: Observable<SpriteManager>;
  34967. private _onDisposeObserver;
  34968. /**
  34969. * Callback called when the manager is disposed
  34970. */
  34971. onDispose: () => void;
  34972. private _capacity;
  34973. private _spriteTexture;
  34974. private _epsilon;
  34975. private _scene;
  34976. private _vertexData;
  34977. private _buffer;
  34978. private _vertexBuffers;
  34979. private _indexBuffer;
  34980. private _effectBase;
  34981. private _effectFog;
  34982. /**
  34983. * Gets or sets the spritesheet texture
  34984. */
  34985. texture: Texture;
  34986. /**
  34987. * Creates a new sprite manager
  34988. * @param name defines the manager's name
  34989. * @param imgUrl defines the sprite sheet url
  34990. * @param capacity defines the maximum allowed number of sprites
  34991. * @param cellSize defines the size of a sprite cell
  34992. * @param scene defines the hosting scene
  34993. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  34994. * @param samplingMode defines the smapling mode to use with spritesheet
  34995. */
  34996. constructor(
  34997. /** defines the manager's name */
  34998. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  34999. private _appendSpriteVertex;
  35000. /**
  35001. * Intersects the sprites with a ray
  35002. * @param ray defines the ray to intersect with
  35003. * @param camera defines the current active camera
  35004. * @param predicate defines a predicate used to select candidate sprites
  35005. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  35006. * @returns null if no hit or a PickingInfo
  35007. */
  35008. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  35009. /**
  35010. * Render all child sprites
  35011. */
  35012. render(): void;
  35013. /**
  35014. * Release associated resources
  35015. */
  35016. dispose(): void;
  35017. }
  35018. }
  35019. declare module BABYLON {
  35020. interface Scene {
  35021. /** @hidden */
  35022. _pointerOverSprite: Nullable<Sprite>;
  35023. /** @hidden */
  35024. _pickedDownSprite: Nullable<Sprite>;
  35025. /** @hidden */
  35026. _tempSpritePickingRay: Nullable<Ray>;
  35027. /**
  35028. * All of the sprite managers added to this scene
  35029. * @see http://doc.babylonjs.com/babylon101/sprites
  35030. */
  35031. spriteManagers: Array<ISpriteManager>;
  35032. /**
  35033. * An event triggered when sprites rendering is about to start
  35034. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35035. */
  35036. onBeforeSpritesRenderingObservable: Observable<Scene>;
  35037. /**
  35038. * An event triggered when sprites rendering is done
  35039. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  35040. */
  35041. onAfterSpritesRenderingObservable: Observable<Scene>;
  35042. /** @hidden */
  35043. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35044. /** Launch a ray to try to pick a sprite in the scene
  35045. * @param x position on screen
  35046. * @param y position on screen
  35047. * @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
  35048. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35049. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35050. * @returns a PickingInfo
  35051. */
  35052. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35053. /** Use the given ray to pick a sprite in the scene
  35054. * @param ray The ray (in world space) to use to pick meshes
  35055. * @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
  35056. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  35058. * @returns a PickingInfo
  35059. */
  35060. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  35061. /**
  35062. * Force the sprite under the pointer
  35063. * @param sprite defines the sprite to use
  35064. */
  35065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  35066. /**
  35067. * Gets the sprite under the pointer
  35068. * @returns a Sprite or null if no sprite is under the pointer
  35069. */
  35070. getPointerOverSprite(): Nullable<Sprite>;
  35071. }
  35072. /**
  35073. * Defines the sprite scene component responsible to manage sprites
  35074. * in a given scene.
  35075. */
  35076. class SpriteSceneComponent implements ISceneComponent {
  35077. /**
  35078. * The component name helpfull to identify the component in the list of scene components.
  35079. */
  35080. readonly name: string;
  35081. /**
  35082. * The scene the component belongs to.
  35083. */
  35084. scene: Scene;
  35085. /** @hidden */
  35086. private _spritePredicate;
  35087. /**
  35088. * Creates a new instance of the component for the given scene
  35089. * @param scene Defines the scene to register the component in
  35090. */
  35091. constructor(scene: Scene);
  35092. /**
  35093. * Registers the component in a given scene
  35094. */
  35095. register(): void;
  35096. /**
  35097. * Rebuilds the elements related to this component in case of
  35098. * context lost for instance.
  35099. */
  35100. rebuild(): void;
  35101. /**
  35102. * Disposes the component and the associated ressources.
  35103. */
  35104. dispose(): void;
  35105. private _pickSpriteButKeepRay;
  35106. private _pointerMove;
  35107. private _pointerDown;
  35108. private _pointerUp;
  35109. }
  35110. }
  35111. declare module BABYLON {
  35112. /**
  35113. * Postprocess used to generate anaglyphic rendering
  35114. */
  35115. class AnaglyphPostProcess extends PostProcess {
  35116. private _passedProcess;
  35117. /**
  35118. * Creates a new AnaglyphPostProcess
  35119. * @param name defines postprocess name
  35120. * @param options defines creation options or target ratio scale
  35121. * @param rigCameras defines cameras using this postprocess
  35122. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35123. * @param engine defines hosting engine
  35124. * @param reusable defines if the postprocess will be reused multiple times per frame
  35125. */
  35126. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35127. }
  35128. }
  35129. declare module BABYLON {
  35130. /**
  35131. * Post process used to render in black and white
  35132. */
  35133. class BlackAndWhitePostProcess extends PostProcess {
  35134. /**
  35135. * Linear about to convert he result to black and white (default: 1)
  35136. */
  35137. degree: number;
  35138. /**
  35139. * Creates a black and white post process
  35140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35141. * @param name The name of the effect.
  35142. * @param options The required width/height ratio to downsize to before computing the render pass.
  35143. * @param camera The camera to apply the render pass to.
  35144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35145. * @param engine The engine which the post process will be applied. (default: current engine)
  35146. * @param reusable If the post process can be reused on the same frame. (default: false)
  35147. */
  35148. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35149. }
  35150. }
  35151. declare module BABYLON {
  35152. /**
  35153. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35154. */
  35155. class BloomEffect extends PostProcessRenderEffect {
  35156. private bloomScale;
  35157. /**
  35158. * @hidden Internal
  35159. */
  35160. _effects: Array<PostProcess>;
  35161. /**
  35162. * @hidden Internal
  35163. */
  35164. _downscale: ExtractHighlightsPostProcess;
  35165. private _blurX;
  35166. private _blurY;
  35167. private _merge;
  35168. /**
  35169. * The luminance threshold to find bright areas of the image to bloom.
  35170. */
  35171. threshold: number;
  35172. /**
  35173. * The strength of the bloom.
  35174. */
  35175. weight: number;
  35176. /**
  35177. * Specifies the size of the bloom blur kernel, relative to the final output size
  35178. */
  35179. kernel: number;
  35180. /**
  35181. * Creates a new instance of @see BloomEffect
  35182. * @param scene The scene the effect belongs to.
  35183. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35184. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35185. * @param bloomWeight The the strength of bloom.
  35186. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35187. * @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)
  35188. */
  35189. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35190. /**
  35191. * Disposes each of the internal effects for a given camera.
  35192. * @param camera The camera to dispose the effect on.
  35193. */
  35194. disposeEffects(camera: Camera): void;
  35195. /**
  35196. * @hidden Internal
  35197. */
  35198. _updateEffects(): void;
  35199. /**
  35200. * Internal
  35201. * @returns if all the contained post processes are ready.
  35202. * @hidden
  35203. */
  35204. _isReady(): boolean;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35210. */
  35211. class BloomMergePostProcess extends PostProcess {
  35212. /** Weight of the bloom to be added to the original input. */
  35213. weight: number;
  35214. /**
  35215. * Creates a new instance of @see BloomMergePostProcess
  35216. * @param name The name of the effect.
  35217. * @param originalFromInput Post process which's input will be used for the merge.
  35218. * @param blurred Blurred highlights post process which's output will be used.
  35219. * @param weight Weight of the bloom to be added to the original input.
  35220. * @param options The required width/height ratio to downsize to before computing the render pass.
  35221. * @param camera The camera to apply the render pass to.
  35222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35223. * @param engine The engine which the post process will be applied. (default: current engine)
  35224. * @param reusable If the post process can be reused on the same frame. (default: false)
  35225. * @param textureType Type of textures used when performing the post process. (default: 0)
  35226. * @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)
  35227. */
  35228. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35229. /** Weight of the bloom to be added to the original input. */
  35230. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35231. }
  35232. }
  35233. declare module BABYLON {
  35234. /**
  35235. * The Blur Post Process which blurs an image based on a kernel and direction.
  35236. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35237. */
  35238. class BlurPostProcess extends PostProcess {
  35239. /** The direction in which to blur the image. */
  35240. direction: Vector2;
  35241. private blockCompilation;
  35242. protected _kernel: number;
  35243. protected _idealKernel: number;
  35244. protected _packedFloat: boolean;
  35245. private _staticDefines;
  35246. /**
  35247. * Sets the length in pixels of the blur sample region
  35248. */
  35249. /**
  35250. * Gets the length in pixels of the blur sample region
  35251. */
  35252. kernel: number;
  35253. /**
  35254. * Sets wether or not the blur needs to unpack/repack floats
  35255. */
  35256. /**
  35257. * Gets wether or not the blur is unpacking/repacking floats
  35258. */
  35259. packedFloat: boolean;
  35260. /**
  35261. * Creates a new instance BlurPostProcess
  35262. * @param name The name of the effect.
  35263. * @param direction The direction in which to blur the image.
  35264. * @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.
  35265. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35266. * @param camera The camera to apply the render pass to.
  35267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35268. * @param engine The engine which the post process will be applied. (default: current engine)
  35269. * @param reusable If the post process can be reused on the same frame. (default: false)
  35270. * @param textureType Type of textures used when performing the post process. (default: 0)
  35271. * @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)
  35272. */
  35273. constructor(name: string,
  35274. /** The direction in which to blur the image. */
  35275. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35276. /**
  35277. * Updates the effect with the current post process compile time values and recompiles the shader.
  35278. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35279. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35280. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35281. * @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
  35282. * @param onCompiled Called when the shader has been compiled.
  35283. * @param onError Called if there is an error when compiling a shader.
  35284. */
  35285. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35286. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35287. /**
  35288. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35289. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35290. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35291. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35292. * The gaps between physical kernels are compensated for in the weighting of the samples
  35293. * @param idealKernel Ideal blur kernel.
  35294. * @return Nearest best kernel.
  35295. */
  35296. protected _nearestBestKernel(idealKernel: number): number;
  35297. /**
  35298. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35299. * @param x The point on the Gaussian distribution to sample.
  35300. * @return the value of the Gaussian function at x.
  35301. */
  35302. protected _gaussianWeight(x: number): number;
  35303. /**
  35304. * Generates a string that can be used as a floating point number in GLSL.
  35305. * @param x Value to print.
  35306. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35307. * @return GLSL float string.
  35308. */
  35309. protected _glslFloat(x: number, decimalFigures?: number): string;
  35310. }
  35311. }
  35312. declare module BABYLON {
  35313. /**
  35314. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35315. */
  35316. class ChromaticAberrationPostProcess extends PostProcess {
  35317. /**
  35318. * The amount of seperation of rgb channels (default: 30)
  35319. */
  35320. aberrationAmount: number;
  35321. /**
  35322. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35323. */
  35324. radialIntensity: number;
  35325. /**
  35326. * 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))
  35327. */
  35328. direction: Vector2;
  35329. /**
  35330. * 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))
  35331. */
  35332. centerPosition: Vector2;
  35333. /**
  35334. * Creates a new instance ChromaticAberrationPostProcess
  35335. * @param name The name of the effect.
  35336. * @param screenWidth The width of the screen to apply the effect on.
  35337. * @param screenHeight The height of the screen to apply the effect on.
  35338. * @param options The required width/height ratio to downsize to before computing the render pass.
  35339. * @param camera The camera to apply the render pass to.
  35340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35341. * @param engine The engine which the post process will be applied. (default: current engine)
  35342. * @param reusable If the post process can be reused on the same frame. (default: false)
  35343. * @param textureType Type of textures used when performing the post process. (default: 0)
  35344. * @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)
  35345. */
  35346. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35347. }
  35348. }
  35349. declare module BABYLON {
  35350. /**
  35351. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35352. */
  35353. class CircleOfConfusionPostProcess extends PostProcess {
  35354. /**
  35355. * 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.
  35356. */
  35357. lensSize: number;
  35358. /**
  35359. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35360. */
  35361. fStop: number;
  35362. /**
  35363. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35364. */
  35365. focusDistance: number;
  35366. /**
  35367. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35368. */
  35369. focalLength: number;
  35370. private _depthTexture;
  35371. /**
  35372. * Creates a new instance CircleOfConfusionPostProcess
  35373. * @param name The name of the effect.
  35374. * @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.
  35375. * @param options The required width/height ratio to downsize to before computing the render pass.
  35376. * @param camera The camera to apply the render pass to.
  35377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35378. * @param engine The engine which the post process will be applied. (default: current engine)
  35379. * @param reusable If the post process can be reused on the same frame. (default: false)
  35380. * @param textureType Type of textures used when performing the post process. (default: 0)
  35381. * @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)
  35382. */
  35383. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35384. /**
  35385. * 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.
  35386. */
  35387. depthTexture: RenderTargetTexture;
  35388. }
  35389. }
  35390. declare module BABYLON {
  35391. /**
  35392. *
  35393. * This post-process allows the modification of rendered colors by using
  35394. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35395. *
  35396. * The object needs to be provided an url to a texture containing the color
  35397. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35398. * Use an image editing software to tweak the LUT to match your needs.
  35399. *
  35400. * For an example of a color LUT, see here:
  35401. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35402. * For explanations on color grading, see here:
  35403. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35404. *
  35405. */
  35406. class ColorCorrectionPostProcess extends PostProcess {
  35407. private _colorTableTexture;
  35408. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35409. }
  35410. }
  35411. declare module BABYLON {
  35412. /**
  35413. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35414. * input texture to perform effects such as edge detection or sharpening
  35415. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35416. */
  35417. class ConvolutionPostProcess extends PostProcess {
  35418. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35419. kernel: number[];
  35420. /**
  35421. * Creates a new instance ConvolutionPostProcess
  35422. * @param name The name of the effect.
  35423. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35424. * @param options The required width/height ratio to downsize to before computing the render pass.
  35425. * @param camera The camera to apply the render pass to.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  35430. */
  35431. constructor(name: string,
  35432. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35433. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35434. /**
  35435. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35436. */
  35437. static EdgeDetect0Kernel: number[];
  35438. /**
  35439. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35440. */
  35441. static EdgeDetect1Kernel: number[];
  35442. /**
  35443. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35444. */
  35445. static EdgeDetect2Kernel: number[];
  35446. /**
  35447. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35448. */
  35449. static SharpenKernel: number[];
  35450. /**
  35451. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35452. */
  35453. static EmbossKernel: number[];
  35454. /**
  35455. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35456. */
  35457. static GaussianKernel: number[];
  35458. }
  35459. }
  35460. declare module BABYLON {
  35461. /**
  35462. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35463. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35464. * based on samples that have a large difference in distance than the center pixel.
  35465. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35466. */
  35467. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35468. direction: Vector2;
  35469. /**
  35470. * Creates a new instance CircleOfConfusionPostProcess
  35471. * @param name The name of the effect.
  35472. * @param scene The scene the effect belongs to.
  35473. * @param direction The direction the blur should be applied.
  35474. * @param kernel The size of the kernel used to blur.
  35475. * @param options The required width/height ratio to downsize to before computing the render pass.
  35476. * @param camera The camera to apply the render pass to.
  35477. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35478. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35480. * @param engine The engine which the post process will be applied. (default: current engine)
  35481. * @param reusable If the post process can be reused on the same frame. (default: false)
  35482. * @param textureType Type of textures used when performing the post process. (default: 0)
  35483. * @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)
  35484. */
  35485. 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);
  35486. }
  35487. }
  35488. declare module BABYLON {
  35489. /**
  35490. * Specifies the level of max blur that should be applied when using the depth of field effect
  35491. */
  35492. enum DepthOfFieldEffectBlurLevel {
  35493. /**
  35494. * Subtle blur
  35495. */
  35496. Low = 0,
  35497. /**
  35498. * Medium blur
  35499. */
  35500. Medium = 1,
  35501. /**
  35502. * Large blur
  35503. */
  35504. High = 2
  35505. }
  35506. /**
  35507. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35508. */
  35509. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35510. private _circleOfConfusion;
  35511. /**
  35512. * @hidden Internal, blurs from high to low
  35513. */
  35514. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35515. private _depthOfFieldBlurY;
  35516. private _dofMerge;
  35517. /**
  35518. * @hidden Internal post processes in depth of field effect
  35519. */
  35520. _effects: Array<PostProcess>;
  35521. /**
  35522. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35523. */
  35524. focalLength: number;
  35525. /**
  35526. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35527. */
  35528. fStop: number;
  35529. /**
  35530. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35531. */
  35532. focusDistance: number;
  35533. /**
  35534. * 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.
  35535. */
  35536. lensSize: number;
  35537. /**
  35538. * Creates a new instance DepthOfFieldEffect
  35539. * @param scene The scene the effect belongs to.
  35540. * @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.
  35541. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35542. * @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)
  35543. */
  35544. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35545. /**
  35546. * 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.
  35547. */
  35548. depthTexture: RenderTargetTexture;
  35549. /**
  35550. * Disposes each of the internal effects for a given camera.
  35551. * @param camera The camera to dispose the effect on.
  35552. */
  35553. disposeEffects(camera: Camera): void;
  35554. /**
  35555. * @hidden Internal
  35556. */
  35557. _updateEffects(): void;
  35558. /**
  35559. * Internal
  35560. * @returns if all the contained post processes are ready.
  35561. * @hidden
  35562. */
  35563. _isReady(): boolean;
  35564. }
  35565. }
  35566. declare module BABYLON {
  35567. /**
  35568. * Options to be set when merging outputs from the default pipeline.
  35569. */
  35570. class DepthOfFieldMergePostProcessOptions {
  35571. /**
  35572. * The original image to merge on top of
  35573. */
  35574. originalFromInput: PostProcess;
  35575. /**
  35576. * Parameters to perform the merge of the depth of field effect
  35577. */
  35578. depthOfField?: {
  35579. circleOfConfusion: PostProcess;
  35580. blurSteps: Array<PostProcess>;
  35581. };
  35582. /**
  35583. * Parameters to perform the merge of bloom effect
  35584. */
  35585. bloom?: {
  35586. blurred: PostProcess;
  35587. weight: number;
  35588. };
  35589. }
  35590. /**
  35591. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35592. */
  35593. class DepthOfFieldMergePostProcess extends PostProcess {
  35594. private blurSteps;
  35595. /**
  35596. * Creates a new instance of DepthOfFieldMergePostProcess
  35597. * @param name The name of the effect.
  35598. * @param originalFromInput Post process which's input will be used for the merge.
  35599. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35600. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35601. * @param options The required width/height ratio to downsize to before computing the render pass.
  35602. * @param camera The camera to apply the render pass to.
  35603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35604. * @param engine The engine which the post process will be applied. (default: current engine)
  35605. * @param reusable If the post process can be reused on the same frame. (default: false)
  35606. * @param textureType Type of textures used when performing the post process. (default: 0)
  35607. * @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)
  35608. */
  35609. 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);
  35610. /**
  35611. * Updates the effect with the current post process compile time values and recompiles the shader.
  35612. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35613. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35614. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35615. * @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
  35616. * @param onCompiled Called when the shader has been compiled.
  35617. * @param onError Called if there is an error when compiling a shader.
  35618. */
  35619. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35620. }
  35621. }
  35622. declare module BABYLON {
  35623. /**
  35624. * DisplayPassPostProcess which produces an output the same as it's input
  35625. */
  35626. class DisplayPassPostProcess extends PostProcess {
  35627. /**
  35628. * Creates the DisplayPassPostProcess
  35629. * @param name The name of the effect.
  35630. * @param options The required width/height ratio to downsize to before computing the render pass.
  35631. * @param camera The camera to apply the render pass to.
  35632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35633. * @param engine The engine which the post process will be applied. (default: current engine)
  35634. * @param reusable If the post process can be reused on the same frame. (default: false)
  35635. */
  35636. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35637. }
  35638. }
  35639. declare module BABYLON {
  35640. /**
  35641. * 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.
  35642. */
  35643. class ExtractHighlightsPostProcess extends PostProcess {
  35644. /**
  35645. * The luminance threshold, pixels below this value will be set to black.
  35646. */
  35647. threshold: number;
  35648. /** @hidden */
  35649. _exposure: number;
  35650. /**
  35651. * Post process which has the input texture to be used when performing highlight extraction
  35652. * @hidden
  35653. */
  35654. _inputPostProcess: Nullable<PostProcess>;
  35655. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35656. }
  35657. }
  35658. declare module BABYLON {
  35659. /**
  35660. * Applies a kernel filter to the image
  35661. */
  35662. class FilterPostProcess extends PostProcess {
  35663. /** The matrix to be applied to the image */
  35664. kernelMatrix: Matrix;
  35665. /**
  35666. *
  35667. * @param name The name of the effect.
  35668. * @param kernelMatrix The matrix to be applied to the image
  35669. * @param options The required width/height ratio to downsize to before computing the render pass.
  35670. * @param camera The camera to apply the render pass to.
  35671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35672. * @param engine The engine which the post process will be applied. (default: current engine)
  35673. * @param reusable If the post process can be reused on the same frame. (default: false)
  35674. */
  35675. constructor(name: string,
  35676. /** The matrix to be applied to the image */
  35677. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35678. }
  35679. }
  35680. declare module BABYLON {
  35681. /**
  35682. * Fxaa post process
  35683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35684. */
  35685. class FxaaPostProcess extends PostProcess {
  35686. /** @hidden */
  35687. texelWidth: number;
  35688. /** @hidden */
  35689. texelHeight: number;
  35690. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35691. private _getDefines;
  35692. }
  35693. }
  35694. declare module BABYLON {
  35695. /**
  35696. * The GrainPostProcess adds noise to the image at mid luminance levels
  35697. */
  35698. class GrainPostProcess extends PostProcess {
  35699. /**
  35700. * The intensity of the grain added (default: 30)
  35701. */
  35702. intensity: number;
  35703. /**
  35704. * If the grain should be randomized on every frame
  35705. */
  35706. animated: boolean;
  35707. /**
  35708. * Creates a new instance of @see GrainPostProcess
  35709. * @param name The name of the effect.
  35710. * @param options The required width/height ratio to downsize to before computing the render pass.
  35711. * @param camera The camera to apply the render pass to.
  35712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35713. * @param engine The engine which the post process will be applied. (default: current engine)
  35714. * @param reusable If the post process can be reused on the same frame. (default: false)
  35715. * @param textureType Type of textures used when performing the post process. (default: 0)
  35716. * @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)
  35717. */
  35718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35719. }
  35720. }
  35721. declare module BABYLON {
  35722. /**
  35723. * Extracts highlights from the image
  35724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35725. */
  35726. class HighlightsPostProcess extends PostProcess {
  35727. /**
  35728. * Extracts highlights from the image
  35729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35730. * @param name The name of the effect.
  35731. * @param options The required width/height ratio to downsize to before computing the render pass.
  35732. * @param camera The camera to apply the render pass to.
  35733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35734. * @param engine The engine which the post process will be applied. (default: current engine)
  35735. * @param reusable If the post process can be reused on the same frame. (default: false)
  35736. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35737. */
  35738. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35739. }
  35740. }
  35741. declare module BABYLON {
  35742. /**
  35743. * ImageProcessingPostProcess
  35744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35745. */
  35746. class ImageProcessingPostProcess extends PostProcess {
  35747. /**
  35748. * Default configuration related to image processing available in the PBR Material.
  35749. */
  35750. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35751. /**
  35752. * Gets the image processing configuration used either in this material.
  35753. */
  35754. /**
  35755. * Sets the Default image processing configuration used either in the this material.
  35756. *
  35757. * If sets to null, the scene one is in use.
  35758. */
  35759. imageProcessingConfiguration: ImageProcessingConfiguration;
  35760. /**
  35761. * Keep track of the image processing observer to allow dispose and replace.
  35762. */
  35763. private _imageProcessingObserver;
  35764. /**
  35765. * Attaches a new image processing configuration to the PBR Material.
  35766. * @param configuration
  35767. */
  35768. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35769. /**
  35770. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35771. */
  35772. /**
  35773. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35774. */
  35775. colorCurves: Nullable<ColorCurves>;
  35776. /**
  35777. * Gets wether the color curves effect is enabled.
  35778. */
  35779. /**
  35780. * Sets wether the color curves effect is enabled.
  35781. */
  35782. colorCurvesEnabled: boolean;
  35783. /**
  35784. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35785. */
  35786. /**
  35787. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35788. */
  35789. colorGradingTexture: Nullable<BaseTexture>;
  35790. /**
  35791. * Gets wether the color grading effect is enabled.
  35792. */
  35793. /**
  35794. * Gets wether the color grading effect is enabled.
  35795. */
  35796. colorGradingEnabled: boolean;
  35797. /**
  35798. * Gets exposure used in the effect.
  35799. */
  35800. /**
  35801. * Sets exposure used in the effect.
  35802. */
  35803. exposure: number;
  35804. /**
  35805. * Gets wether tonemapping is enabled or not.
  35806. */
  35807. /**
  35808. * Sets wether tonemapping is enabled or not
  35809. */
  35810. toneMappingEnabled: boolean;
  35811. /**
  35812. * Gets contrast used in the effect.
  35813. */
  35814. /**
  35815. * Sets contrast used in the effect.
  35816. */
  35817. contrast: number;
  35818. /**
  35819. * Gets Vignette stretch size.
  35820. */
  35821. /**
  35822. * Sets Vignette stretch size.
  35823. */
  35824. vignetteStretch: number;
  35825. /**
  35826. * Gets Vignette centre X Offset.
  35827. */
  35828. /**
  35829. * Sets Vignette centre X Offset.
  35830. */
  35831. vignetteCentreX: number;
  35832. /**
  35833. * Gets Vignette centre Y Offset.
  35834. */
  35835. /**
  35836. * Sets Vignette centre Y Offset.
  35837. */
  35838. vignetteCentreY: number;
  35839. /**
  35840. * Gets Vignette weight or intensity of the vignette effect.
  35841. */
  35842. /**
  35843. * Sets Vignette weight or intensity of the vignette effect.
  35844. */
  35845. vignetteWeight: number;
  35846. /**
  35847. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35848. * if vignetteEnabled is set to true.
  35849. */
  35850. /**
  35851. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35852. * if vignetteEnabled is set to true.
  35853. */
  35854. vignetteColor: Color4;
  35855. /**
  35856. * Gets Camera field of view used by the Vignette effect.
  35857. */
  35858. /**
  35859. * Sets Camera field of view used by the Vignette effect.
  35860. */
  35861. vignetteCameraFov: number;
  35862. /**
  35863. * Gets the vignette blend mode allowing different kind of effect.
  35864. */
  35865. /**
  35866. * Sets the vignette blend mode allowing different kind of effect.
  35867. */
  35868. vignetteBlendMode: number;
  35869. /**
  35870. * Gets wether the vignette effect is enabled.
  35871. */
  35872. /**
  35873. * Sets wether the vignette effect is enabled.
  35874. */
  35875. vignetteEnabled: boolean;
  35876. private _fromLinearSpace;
  35877. /**
  35878. * Gets wether the input of the processing is in Gamma or Linear Space.
  35879. */
  35880. /**
  35881. * Sets wether the input of the processing is in Gamma or Linear Space.
  35882. */
  35883. fromLinearSpace: boolean;
  35884. /**
  35885. * Defines cache preventing GC.
  35886. */
  35887. private _defines;
  35888. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35889. /**
  35890. * "ImageProcessingPostProcess"
  35891. * @returns "ImageProcessingPostProcess"
  35892. */
  35893. getClassName(): string;
  35894. protected _updateParameters(): void;
  35895. dispose(camera?: Camera): void;
  35896. }
  35897. }
  35898. declare module BABYLON {
  35899. /**
  35900. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35901. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35902. * As an example, all you have to do is to create the post-process:
  35903. * var mb = new BABYLON.MotionBlurPostProcess(
  35904. * 'mb', // The name of the effect.
  35905. * scene, // The scene containing the objects to blur according to their velocity.
  35906. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35907. * camera // The camera to apply the render pass to.
  35908. * );
  35909. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35910. */
  35911. class MotionBlurPostProcess extends PostProcess {
  35912. /**
  35913. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35914. */
  35915. motionStrength: number;
  35916. /**
  35917. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35918. */
  35919. /**
  35920. * Sets the number of iterations to be used for motion blur quality
  35921. */
  35922. motionBlurSamples: number;
  35923. private _motionBlurSamples;
  35924. private _geometryBufferRenderer;
  35925. /**
  35926. * Creates a new instance MotionBlurPostProcess
  35927. * @param name The name of the effect.
  35928. * @param scene The scene containing the objects to blur according to their velocity.
  35929. * @param options The required width/height ratio to downsize to before computing the render pass.
  35930. * @param camera The camera to apply the render pass to.
  35931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35932. * @param engine The engine which the post process will be applied. (default: current engine)
  35933. * @param reusable If the post process can be reused on the same frame. (default: false)
  35934. * @param textureType Type of textures used when performing the post process. (default: 0)
  35935. * @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)
  35936. */
  35937. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35938. /**
  35939. * Disposes the post process.
  35940. * @param camera The camera to dispose the post process on.
  35941. */
  35942. dispose(camera?: Camera): void;
  35943. }
  35944. }
  35945. declare module BABYLON {
  35946. /**
  35947. * PassPostProcess which produces an output the same as it's input
  35948. */
  35949. class PassPostProcess extends PostProcess {
  35950. /**
  35951. * Creates the PassPostProcess
  35952. * @param name The name of the effect.
  35953. * @param options The required width/height ratio to downsize to before computing the render pass.
  35954. * @param camera The camera to apply the render pass to.
  35955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35956. * @param engine The engine which the post process will be applied. (default: current engine)
  35957. * @param reusable If the post process can be reused on the same frame. (default: false)
  35958. * @param textureType The type of texture to be used when performing the post processing.
  35959. * @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)
  35960. */
  35961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35962. }
  35963. }
  35964. declare module BABYLON {
  35965. /**
  35966. * Size options for a post process
  35967. */
  35968. type PostProcessOptions = {
  35969. width: number;
  35970. height: number;
  35971. };
  35972. /**
  35973. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35974. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35975. */
  35976. class PostProcess {
  35977. /** Name of the PostProcess. */
  35978. name: string;
  35979. /**
  35980. * Width of the texture to apply the post process on
  35981. */
  35982. width: number;
  35983. /**
  35984. * Height of the texture to apply the post process on
  35985. */
  35986. height: number;
  35987. /**
  35988. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35989. * @hidden
  35990. */
  35991. _outputTexture: Nullable<InternalTexture>;
  35992. /**
  35993. * Sampling mode used by the shader
  35994. * See https://doc.babylonjs.com/classes/3.1/texture
  35995. */
  35996. renderTargetSamplingMode: number;
  35997. /**
  35998. * Clear color to use when screen clearing
  35999. */
  36000. clearColor: Color4;
  36001. /**
  36002. * If the buffer needs to be cleared before applying the post process. (default: true)
  36003. * Should be set to false if shader will overwrite all previous pixels.
  36004. */
  36005. autoClear: boolean;
  36006. /**
  36007. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36008. */
  36009. alphaMode: number;
  36010. /**
  36011. * Sets the setAlphaBlendConstants of the babylon engine
  36012. */
  36013. alphaConstants: Color4;
  36014. /**
  36015. * Animations to be used for the post processing
  36016. */
  36017. animations: Animation[];
  36018. /**
  36019. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36020. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36021. */
  36022. enablePixelPerfectMode: boolean;
  36023. /**
  36024. * Force the postprocess to be applied without taking in account viewport
  36025. */
  36026. forceFullscreenViewport: boolean;
  36027. /**
  36028. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36029. *
  36030. * | Value | Type | Description |
  36031. * | ----- | ----------------------------------- | ----------- |
  36032. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36033. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36034. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36035. *
  36036. */
  36037. scaleMode: number;
  36038. /**
  36039. * Force textures to be a power of two (default: false)
  36040. */
  36041. alwaysForcePOT: boolean;
  36042. private _samples;
  36043. /**
  36044. * Number of sample textures (default: 1)
  36045. */
  36046. samples: number;
  36047. /**
  36048. * Modify the scale of the post process to be the same as the viewport (default: false)
  36049. */
  36050. adaptScaleToCurrentViewport: boolean;
  36051. private _camera;
  36052. private _scene;
  36053. private _engine;
  36054. private _options;
  36055. private _reusable;
  36056. private _textureType;
  36057. /**
  36058. * Smart array of input and output textures for the post process.
  36059. * @hidden
  36060. */
  36061. _textures: SmartArray<InternalTexture>;
  36062. /**
  36063. * The index in _textures that corresponds to the output texture.
  36064. * @hidden
  36065. */
  36066. _currentRenderTextureInd: number;
  36067. private _effect;
  36068. private _samplers;
  36069. private _fragmentUrl;
  36070. private _vertexUrl;
  36071. private _parameters;
  36072. private _scaleRatio;
  36073. protected _indexParameters: any;
  36074. private _shareOutputWithPostProcess;
  36075. private _texelSize;
  36076. private _forcedOutputTexture;
  36077. /**
  36078. * An event triggered when the postprocess is activated.
  36079. */
  36080. onActivateObservable: Observable<Camera>;
  36081. private _onActivateObserver;
  36082. /**
  36083. * A function that is added to the onActivateObservable
  36084. */
  36085. onActivate: Nullable<(camera: Camera) => void>;
  36086. /**
  36087. * An event triggered when the postprocess changes its size.
  36088. */
  36089. onSizeChangedObservable: Observable<PostProcess>;
  36090. private _onSizeChangedObserver;
  36091. /**
  36092. * A function that is added to the onSizeChangedObservable
  36093. */
  36094. onSizeChanged: (postProcess: PostProcess) => void;
  36095. /**
  36096. * An event triggered when the postprocess applies its effect.
  36097. */
  36098. onApplyObservable: Observable<Effect>;
  36099. private _onApplyObserver;
  36100. /**
  36101. * A function that is added to the onApplyObservable
  36102. */
  36103. onApply: (effect: Effect) => void;
  36104. /**
  36105. * An event triggered before rendering the postprocess
  36106. */
  36107. onBeforeRenderObservable: Observable<Effect>;
  36108. private _onBeforeRenderObserver;
  36109. /**
  36110. * A function that is added to the onBeforeRenderObservable
  36111. */
  36112. onBeforeRender: (effect: Effect) => void;
  36113. /**
  36114. * An event triggered after rendering the postprocess
  36115. */
  36116. onAfterRenderObservable: Observable<Effect>;
  36117. private _onAfterRenderObserver;
  36118. /**
  36119. * A function that is added to the onAfterRenderObservable
  36120. */
  36121. onAfterRender: (efect: Effect) => void;
  36122. /**
  36123. * 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
  36124. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36125. */
  36126. inputTexture: InternalTexture;
  36127. /**
  36128. * Gets the camera which post process is applied to.
  36129. * @returns The camera the post process is applied to.
  36130. */
  36131. getCamera(): Camera;
  36132. /**
  36133. * Gets the texel size of the postprocess.
  36134. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36135. */
  36136. readonly texelSize: Vector2;
  36137. /**
  36138. * Creates a new instance PostProcess
  36139. * @param name The name of the PostProcess.
  36140. * @param fragmentUrl The url of the fragment shader to be used.
  36141. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36142. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36143. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36144. * @param camera The camera to apply the render pass to.
  36145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36146. * @param engine The engine which the post process will be applied. (default: current engine)
  36147. * @param reusable If the post process can be reused on the same frame. (default: false)
  36148. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36149. * @param textureType Type of textures used when performing the post process. (default: 0)
  36150. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36151. * @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
  36152. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36153. */
  36154. constructor(
  36155. /** Name of the PostProcess. */
  36156. 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);
  36157. /**
  36158. * Gets the engine which this post process belongs to.
  36159. * @returns The engine the post process was enabled with.
  36160. */
  36161. getEngine(): Engine;
  36162. /**
  36163. * The effect that is created when initializing the post process.
  36164. * @returns The created effect corrisponding the the postprocess.
  36165. */
  36166. getEffect(): Effect;
  36167. /**
  36168. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36169. * @param postProcess The post process to share the output with.
  36170. * @returns This post process.
  36171. */
  36172. shareOutputWith(postProcess: PostProcess): PostProcess;
  36173. /**
  36174. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36175. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36176. */
  36177. useOwnOutput(): void;
  36178. /**
  36179. * Updates the effect with the current post process compile time values and recompiles the shader.
  36180. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36181. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36182. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36183. * @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
  36184. * @param onCompiled Called when the shader has been compiled.
  36185. * @param onError Called if there is an error when compiling a shader.
  36186. */
  36187. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36188. /**
  36189. * The post process is reusable if it can be used multiple times within one frame.
  36190. * @returns If the post process is reusable
  36191. */
  36192. isReusable(): boolean;
  36193. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36194. markTextureDirty(): void;
  36195. /**
  36196. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36197. * 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.
  36198. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36199. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36200. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36201. * @returns The target texture that was bound to be written to.
  36202. */
  36203. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36204. /**
  36205. * If the post process is supported.
  36206. */
  36207. readonly isSupported: boolean;
  36208. /**
  36209. * The aspect ratio of the output texture.
  36210. */
  36211. readonly aspectRatio: number;
  36212. /**
  36213. * Get a value indicating if the post-process is ready to be used
  36214. * @returns true if the post-process is ready (shader is compiled)
  36215. */
  36216. isReady(): boolean;
  36217. /**
  36218. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36219. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36220. */
  36221. apply(): Nullable<Effect>;
  36222. private _disposeTextures;
  36223. /**
  36224. * Disposes the post process.
  36225. * @param camera The camera to dispose the post process on.
  36226. */
  36227. dispose(camera?: Camera): void;
  36228. }
  36229. }
  36230. declare module BABYLON {
  36231. /**
  36232. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36233. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36234. */
  36235. class PostProcessManager {
  36236. private _scene;
  36237. private _indexBuffer;
  36238. private _vertexBuffers;
  36239. /**
  36240. * Creates a new instance PostProcess
  36241. * @param scene The scene that the post process is associated with.
  36242. */
  36243. constructor(scene: Scene);
  36244. private _prepareBuffers;
  36245. private _buildIndexBuffer;
  36246. /**
  36247. * Rebuilds the vertex buffers of the manager.
  36248. * @hidden
  36249. */
  36250. _rebuild(): void;
  36251. /**
  36252. * Prepares a frame to be run through a post process.
  36253. * @param sourceTexture The input texture to the post procesess. (default: null)
  36254. * @param postProcesses An array of post processes to be run. (default: null)
  36255. * @returns True if the post processes were able to be run.
  36256. * @hidden
  36257. */
  36258. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36259. /**
  36260. * Manually render a set of post processes to a texture.
  36261. * @param postProcesses An array of post processes to be run.
  36262. * @param targetTexture The target texture to render to.
  36263. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36264. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36265. * @param lodLevel defines which lod of the texture to render to
  36266. */
  36267. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36268. /**
  36269. * Finalize the result of the output of the postprocesses.
  36270. * @param doNotPresent If true the result will not be displayed to the screen.
  36271. * @param targetTexture The target texture to render to.
  36272. * @param faceIndex The index of the face to bind the target texture to.
  36273. * @param postProcesses The array of post processes to render.
  36274. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36275. * @hidden
  36276. */
  36277. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36278. /**
  36279. * Disposes of the post process manager.
  36280. */
  36281. dispose(): void;
  36282. }
  36283. }
  36284. declare module BABYLON {
  36285. /**
  36286. * Post process which applies a refractin texture
  36287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36288. */
  36289. class RefractionPostProcess extends PostProcess {
  36290. /** the base color of the refraction (used to taint the rendering) */
  36291. color: Color3;
  36292. /** simulated refraction depth */
  36293. depth: number;
  36294. /** the coefficient of the base color (0 to remove base color tainting) */
  36295. colorLevel: number;
  36296. private _refTexture;
  36297. private _ownRefractionTexture;
  36298. /**
  36299. * Gets or sets the refraction texture
  36300. * Please note that you are responsible for disposing the texture if you set it manually
  36301. */
  36302. refractionTexture: Texture;
  36303. /**
  36304. * Initializes the RefractionPostProcess
  36305. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36306. * @param name The name of the effect.
  36307. * @param refractionTextureUrl Url of the refraction texture to use
  36308. * @param color the base color of the refraction (used to taint the rendering)
  36309. * @param depth simulated refraction depth
  36310. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36311. * @param camera The camera to apply the render pass to.
  36312. * @param options The required width/height ratio to downsize to before computing the render pass.
  36313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36314. * @param engine The engine which the post process will be applied. (default: current engine)
  36315. * @param reusable If the post process can be reused on the same frame. (default: false)
  36316. */
  36317. constructor(name: string, refractionTextureUrl: string,
  36318. /** the base color of the refraction (used to taint the rendering) */
  36319. color: Color3,
  36320. /** simulated refraction depth */
  36321. depth: number,
  36322. /** the coefficient of the base color (0 to remove base color tainting) */
  36323. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36324. /**
  36325. * Disposes of the post process
  36326. * @param camera Camera to dispose post process on
  36327. */
  36328. dispose(camera: Camera): void;
  36329. }
  36330. }
  36331. declare module BABYLON {
  36332. /**
  36333. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36334. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36335. */
  36336. class SharpenPostProcess extends PostProcess {
  36337. /**
  36338. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36339. */
  36340. colorAmount: number;
  36341. /**
  36342. * How much sharpness should be applied (default: 0.3)
  36343. */
  36344. edgeAmount: number;
  36345. /**
  36346. * Creates a new instance ConvolutionPostProcess
  36347. * @param name The name of the effect.
  36348. * @param options The required width/height ratio to downsize to before computing the render pass.
  36349. * @param camera The camera to apply the render pass to.
  36350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36351. * @param engine The engine which the post process will be applied. (default: current engine)
  36352. * @param reusable If the post process can be reused on the same frame. (default: false)
  36353. * @param textureType Type of textures used when performing the post process. (default: 0)
  36354. * @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)
  36355. */
  36356. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36357. }
  36358. }
  36359. declare module BABYLON {
  36360. /**
  36361. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36362. */
  36363. class StereoscopicInterlacePostProcess extends PostProcess {
  36364. private _stepSize;
  36365. private _passedProcess;
  36366. /**
  36367. * Initializes a StereoscopicInterlacePostProcess
  36368. * @param name The name of the effect.
  36369. * @param rigCameras The rig cameras to be appled to the post process
  36370. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36372. * @param engine The engine which the post process will be applied. (default: current engine)
  36373. * @param reusable If the post process can be reused on the same frame. (default: false)
  36374. */
  36375. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36376. }
  36377. }
  36378. declare module BABYLON {
  36379. /** Defines operator used for tonemapping */
  36380. enum TonemappingOperator {
  36381. /** Hable */
  36382. Hable = 0,
  36383. /** Reinhard */
  36384. Reinhard = 1,
  36385. /** HejiDawson */
  36386. HejiDawson = 2,
  36387. /** Photographic */
  36388. Photographic = 3
  36389. }
  36390. /**
  36391. * Defines a post process to apply tone mapping
  36392. */
  36393. class TonemapPostProcess extends PostProcess {
  36394. private _operator;
  36395. /** Defines the required exposure adjustement */
  36396. exposureAdjustment: number;
  36397. /**
  36398. * Creates a new TonemapPostProcess
  36399. * @param name defines the name of the postprocess
  36400. * @param _operator defines the operator to use
  36401. * @param exposureAdjustment defines the required exposure adjustement
  36402. * @param camera defines the camera to use (can be null)
  36403. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36404. * @param engine defines the hosting engine (can be ignore if camera is set)
  36405. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36406. */
  36407. constructor(name: string, _operator: TonemappingOperator,
  36408. /** Defines the required exposure adjustement */
  36409. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36410. }
  36411. }
  36412. declare module BABYLON {
  36413. /**
  36414. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36415. */
  36416. class VolumetricLightScatteringPostProcess extends PostProcess {
  36417. private _volumetricLightScatteringPass;
  36418. private _volumetricLightScatteringRTT;
  36419. private _viewPort;
  36420. private _screenCoordinates;
  36421. private _cachedDefines;
  36422. /**
  36423. * If not undefined, the mesh position is computed from the attached node position
  36424. */
  36425. attachedNode: {
  36426. position: Vector3;
  36427. };
  36428. /**
  36429. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36430. */
  36431. customMeshPosition: Vector3;
  36432. /**
  36433. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36434. */
  36435. useCustomMeshPosition: boolean;
  36436. /**
  36437. * If the post-process should inverse the light scattering direction
  36438. */
  36439. invert: boolean;
  36440. /**
  36441. * The internal mesh used by the post-process
  36442. */
  36443. mesh: Mesh;
  36444. /**
  36445. * @hidden
  36446. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36447. */
  36448. useDiffuseColor: boolean;
  36449. /**
  36450. * Array containing the excluded meshes not rendered in the internal pass
  36451. */
  36452. excludedMeshes: AbstractMesh[];
  36453. /**
  36454. * Controls the overall intensity of the post-process
  36455. */
  36456. exposure: number;
  36457. /**
  36458. * Dissipates each sample's contribution in range [0, 1]
  36459. */
  36460. decay: number;
  36461. /**
  36462. * Controls the overall intensity of each sample
  36463. */
  36464. weight: number;
  36465. /**
  36466. * Controls the density of each sample
  36467. */
  36468. density: number;
  36469. /**
  36470. * @constructor
  36471. * @param name The post-process name
  36472. * @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)
  36473. * @param camera The camera that the post-process will be attached to
  36474. * @param mesh The mesh used to create the light scattering
  36475. * @param samples The post-process quality, default 100
  36476. * @param samplingModeThe post-process filtering mode
  36477. * @param engine The babylon engine
  36478. * @param reusable If the post-process is reusable
  36479. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36480. */
  36481. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36482. /**
  36483. * Returns the string "VolumetricLightScatteringPostProcess"
  36484. * @returns "VolumetricLightScatteringPostProcess"
  36485. */
  36486. getClassName(): string;
  36487. private _isReady;
  36488. /**
  36489. * Sets the new light position for light scattering effect
  36490. * @param position The new custom light position
  36491. */
  36492. setCustomMeshPosition(position: Vector3): void;
  36493. /**
  36494. * Returns the light position for light scattering effect
  36495. * @return Vector3 The custom light position
  36496. */
  36497. getCustomMeshPosition(): Vector3;
  36498. /**
  36499. * Disposes the internal assets and detaches the post-process from the camera
  36500. */
  36501. dispose(camera: Camera): void;
  36502. /**
  36503. * Returns the render target texture used by the post-process
  36504. * @return the render target texture used by the post-process
  36505. */
  36506. getPass(): RenderTargetTexture;
  36507. private _meshExcluded;
  36508. private _createPass;
  36509. private _updateMeshScreenCoordinates;
  36510. /**
  36511. * Creates a default mesh for the Volumeric Light Scattering post-process
  36512. * @param name The mesh name
  36513. * @param scene The scene where to create the mesh
  36514. * @return the default mesh
  36515. */
  36516. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36517. }
  36518. }
  36519. declare module BABYLON {
  36520. /**
  36521. * VRDistortionCorrectionPostProcess used for mobile VR
  36522. */
  36523. class VRDistortionCorrectionPostProcess extends PostProcess {
  36524. private _isRightEye;
  36525. private _distortionFactors;
  36526. private _postProcessScaleFactor;
  36527. private _lensCenterOffset;
  36528. private _scaleIn;
  36529. private _scaleFactor;
  36530. private _lensCenter;
  36531. /**
  36532. * Initializes the VRDistortionCorrectionPostProcess
  36533. * @param name The name of the effect.
  36534. * @param camera The camera to apply the render pass to.
  36535. * @param isRightEye If this is for the right eye distortion
  36536. * @param vrMetrics All the required metrics for the VR camera
  36537. */
  36538. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36539. }
  36540. }
  36541. declare module BABYLON {
  36542. /**
  36543. * @hidden
  36544. **/
  36545. class _AlphaState {
  36546. private _isAlphaBlendDirty;
  36547. private _isBlendFunctionParametersDirty;
  36548. private _isBlendEquationParametersDirty;
  36549. private _isBlendConstantsDirty;
  36550. private _alphaBlend;
  36551. private _blendFunctionParameters;
  36552. private _blendEquationParameters;
  36553. private _blendConstants;
  36554. /**
  36555. * Initializes the state.
  36556. */
  36557. constructor();
  36558. readonly isDirty: boolean;
  36559. alphaBlend: boolean;
  36560. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36561. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36562. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36563. reset(): void;
  36564. apply(gl: WebGLRenderingContext): void;
  36565. }
  36566. }
  36567. declare module BABYLON {
  36568. /**
  36569. * @hidden
  36570. **/
  36571. class _DepthCullingState {
  36572. private _isDepthTestDirty;
  36573. private _isDepthMaskDirty;
  36574. private _isDepthFuncDirty;
  36575. private _isCullFaceDirty;
  36576. private _isCullDirty;
  36577. private _isZOffsetDirty;
  36578. private _isFrontFaceDirty;
  36579. private _depthTest;
  36580. private _depthMask;
  36581. private _depthFunc;
  36582. private _cull;
  36583. private _cullFace;
  36584. private _zOffset;
  36585. private _frontFace;
  36586. /**
  36587. * Initializes the state.
  36588. */
  36589. constructor();
  36590. readonly isDirty: boolean;
  36591. zOffset: number;
  36592. cullFace: Nullable<number>;
  36593. cull: Nullable<boolean>;
  36594. depthFunc: Nullable<number>;
  36595. depthMask: boolean;
  36596. depthTest: boolean;
  36597. frontFace: Nullable<number>;
  36598. reset(): void;
  36599. apply(gl: WebGLRenderingContext): void;
  36600. }
  36601. }
  36602. declare module BABYLON {
  36603. /**
  36604. * @hidden
  36605. **/
  36606. class _StencilState {
  36607. private _isStencilTestDirty;
  36608. private _isStencilMaskDirty;
  36609. private _isStencilFuncDirty;
  36610. private _isStencilOpDirty;
  36611. private _stencilTest;
  36612. private _stencilMask;
  36613. private _stencilFunc;
  36614. private _stencilFuncRef;
  36615. private _stencilFuncMask;
  36616. private _stencilOpStencilFail;
  36617. private _stencilOpDepthFail;
  36618. private _stencilOpStencilDepthPass;
  36619. readonly isDirty: boolean;
  36620. stencilFunc: number;
  36621. stencilFuncRef: number;
  36622. stencilFuncMask: number;
  36623. stencilOpStencilFail: number;
  36624. stencilOpDepthFail: number;
  36625. stencilOpStencilDepthPass: number;
  36626. stencilMask: number;
  36627. stencilTest: boolean;
  36628. constructor();
  36629. reset(): void;
  36630. apply(gl: WebGLRenderingContext): void;
  36631. }
  36632. }
  36633. declare module BABYLON {
  36634. /**
  36635. * Class used to evalaute queries containing `and` and `or` operators
  36636. */
  36637. class AndOrNotEvaluator {
  36638. /**
  36639. * Evaluate a query
  36640. * @param query defines the query to evaluate
  36641. * @param evaluateCallback defines the callback used to filter result
  36642. * @returns true if the query matches
  36643. */
  36644. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36645. private static _HandleParenthesisContent;
  36646. private static _SimplifyNegation;
  36647. }
  36648. }
  36649. declare module BABYLON {
  36650. /**
  36651. * Defines the list of states available for a task inside a AssetsManager
  36652. */
  36653. enum AssetTaskState {
  36654. /**
  36655. * Initialization
  36656. */
  36657. INIT = 0,
  36658. /**
  36659. * Running
  36660. */
  36661. RUNNING = 1,
  36662. /**
  36663. * Done
  36664. */
  36665. DONE = 2,
  36666. /**
  36667. * Error
  36668. */
  36669. ERROR = 3
  36670. }
  36671. /**
  36672. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36673. */
  36674. abstract class AbstractAssetTask {
  36675. /**
  36676. * Task name
  36677. */ name: string;
  36678. /**
  36679. * Callback called when the task is successful
  36680. */
  36681. onSuccess: (task: any) => void;
  36682. /**
  36683. * Callback called when the task is not successful
  36684. */
  36685. onError: (task: any, message?: string, exception?: any) => void;
  36686. /**
  36687. * Creates a new AssetsManager
  36688. * @param name defines the name of the task
  36689. */
  36690. constructor(
  36691. /**
  36692. * Task name
  36693. */ name: string);
  36694. private _isCompleted;
  36695. private _taskState;
  36696. private _errorObject;
  36697. /**
  36698. * Get if the task is completed
  36699. */
  36700. readonly isCompleted: boolean;
  36701. /**
  36702. * Gets the current state of the task
  36703. */
  36704. readonly taskState: AssetTaskState;
  36705. /**
  36706. * Gets the current error object (if task is in error)
  36707. */
  36708. readonly errorObject: {
  36709. message?: string;
  36710. exception?: any;
  36711. };
  36712. /**
  36713. * Internal only
  36714. * @hidden
  36715. */
  36716. _setErrorObject(message?: string, exception?: any): void;
  36717. /**
  36718. * Execute the current task
  36719. * @param scene defines the scene where you want your assets to be loaded
  36720. * @param onSuccess is a callback called when the task is successfully executed
  36721. * @param onError is a callback called if an error occurs
  36722. */
  36723. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36724. /**
  36725. * Execute the current task
  36726. * @param scene defines the scene where you want your assets to be loaded
  36727. * @param onSuccess is a callback called when the task is successfully executed
  36728. * @param onError is a callback called if an error occurs
  36729. */
  36730. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36731. /**
  36732. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36733. * This can be used with failed tasks that have the reason for failure fixed.
  36734. */
  36735. reset(): void;
  36736. private onErrorCallback;
  36737. private onDoneCallback;
  36738. }
  36739. /**
  36740. * Define the interface used by progress events raised during assets loading
  36741. */
  36742. interface IAssetsProgressEvent {
  36743. /**
  36744. * Defines the number of remaining tasks to process
  36745. */
  36746. remainingCount: number;
  36747. /**
  36748. * Defines the total number of tasks
  36749. */
  36750. totalCount: number;
  36751. /**
  36752. * Defines the task that was just processed
  36753. */
  36754. task: AbstractAssetTask;
  36755. }
  36756. /**
  36757. * Class used to share progress information about assets loading
  36758. */
  36759. class AssetsProgressEvent implements IAssetsProgressEvent {
  36760. /**
  36761. * Defines the number of remaining tasks to process
  36762. */
  36763. remainingCount: number;
  36764. /**
  36765. * Defines the total number of tasks
  36766. */
  36767. totalCount: number;
  36768. /**
  36769. * Defines the task that was just processed
  36770. */
  36771. task: AbstractAssetTask;
  36772. /**
  36773. * Creates a AssetsProgressEvent
  36774. * @param remainingCount defines the number of remaining tasks to process
  36775. * @param totalCount defines the total number of tasks
  36776. * @param task defines the task that was just processed
  36777. */
  36778. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36779. }
  36780. /**
  36781. * Define a task used by AssetsManager to load meshes
  36782. */
  36783. class MeshAssetTask extends AbstractAssetTask {
  36784. /**
  36785. * Defines the name of the task
  36786. */
  36787. name: string;
  36788. /**
  36789. * Defines the list of mesh's names you want to load
  36790. */
  36791. meshesNames: any;
  36792. /**
  36793. * Defines the root url to use as a base to load your meshes and associated resources
  36794. */
  36795. rootUrl: string;
  36796. /**
  36797. * Defines the filename of the scene to load from
  36798. */
  36799. sceneFilename: string;
  36800. /**
  36801. * Gets the list of loaded meshes
  36802. */
  36803. loadedMeshes: Array<AbstractMesh>;
  36804. /**
  36805. * Gets the list of loaded particle systems
  36806. */
  36807. loadedParticleSystems: Array<IParticleSystem>;
  36808. /**
  36809. * Gets the list of loaded skeletons
  36810. */
  36811. loadedSkeletons: Array<Skeleton>;
  36812. /**
  36813. * Callback called when the task is successful
  36814. */
  36815. onSuccess: (task: MeshAssetTask) => void;
  36816. /**
  36817. * Callback called when the task is successful
  36818. */
  36819. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36820. /**
  36821. * Creates a new MeshAssetTask
  36822. * @param name defines the name of the task
  36823. * @param meshesNames defines the list of mesh's names you want to load
  36824. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36825. * @param sceneFilename defines the filename of the scene to load from
  36826. */
  36827. constructor(
  36828. /**
  36829. * Defines the name of the task
  36830. */
  36831. name: string,
  36832. /**
  36833. * Defines the list of mesh's names you want to load
  36834. */
  36835. meshesNames: any,
  36836. /**
  36837. * Defines the root url to use as a base to load your meshes and associated resources
  36838. */
  36839. rootUrl: string,
  36840. /**
  36841. * Defines the filename of the scene to load from
  36842. */
  36843. sceneFilename: string);
  36844. /**
  36845. * Execute the current task
  36846. * @param scene defines the scene where you want your assets to be loaded
  36847. * @param onSuccess is a callback called when the task is successfully executed
  36848. * @param onError is a callback called if an error occurs
  36849. */
  36850. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36851. }
  36852. /**
  36853. * Define a task used by AssetsManager to load text content
  36854. */
  36855. class TextFileAssetTask extends AbstractAssetTask {
  36856. /**
  36857. * Defines the name of the task
  36858. */
  36859. name: string;
  36860. /**
  36861. * Defines the location of the file to load
  36862. */
  36863. url: string;
  36864. /**
  36865. * Gets the loaded text string
  36866. */
  36867. text: string;
  36868. /**
  36869. * Callback called when the task is successful
  36870. */
  36871. onSuccess: (task: TextFileAssetTask) => void;
  36872. /**
  36873. * Callback called when the task is successful
  36874. */
  36875. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36876. /**
  36877. * Creates a new TextFileAssetTask object
  36878. * @param name defines the name of the task
  36879. * @param url defines the location of the file to load
  36880. */
  36881. constructor(
  36882. /**
  36883. * Defines the name of the task
  36884. */
  36885. name: string,
  36886. /**
  36887. * Defines the location of the file to load
  36888. */
  36889. url: string);
  36890. /**
  36891. * Execute the current task
  36892. * @param scene defines the scene where you want your assets to be loaded
  36893. * @param onSuccess is a callback called when the task is successfully executed
  36894. * @param onError is a callback called if an error occurs
  36895. */
  36896. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36897. }
  36898. /**
  36899. * Define a task used by AssetsManager to load binary data
  36900. */
  36901. class BinaryFileAssetTask extends AbstractAssetTask {
  36902. /**
  36903. * Defines the name of the task
  36904. */
  36905. name: string;
  36906. /**
  36907. * Defines the location of the file to load
  36908. */
  36909. url: string;
  36910. /**
  36911. * Gets the lodaded data (as an array buffer)
  36912. */
  36913. data: ArrayBuffer;
  36914. /**
  36915. * Callback called when the task is successful
  36916. */
  36917. onSuccess: (task: BinaryFileAssetTask) => void;
  36918. /**
  36919. * Callback called when the task is successful
  36920. */
  36921. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36922. /**
  36923. * Creates a new BinaryFileAssetTask object
  36924. * @param name defines the name of the new task
  36925. * @param url defines the location of the file to load
  36926. */
  36927. constructor(
  36928. /**
  36929. * Defines the name of the task
  36930. */
  36931. name: string,
  36932. /**
  36933. * Defines the location of the file to load
  36934. */
  36935. url: string);
  36936. /**
  36937. * Execute the current task
  36938. * @param scene defines the scene where you want your assets to be loaded
  36939. * @param onSuccess is a callback called when the task is successfully executed
  36940. * @param onError is a callback called if an error occurs
  36941. */
  36942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36943. }
  36944. /**
  36945. * Define a task used by AssetsManager to load images
  36946. */
  36947. class ImageAssetTask extends AbstractAssetTask {
  36948. /**
  36949. * Defines the name of the task
  36950. */
  36951. name: string;
  36952. /**
  36953. * Defines the location of the image to load
  36954. */
  36955. url: string;
  36956. /**
  36957. * Gets the loaded images
  36958. */
  36959. image: HTMLImageElement;
  36960. /**
  36961. * Callback called when the task is successful
  36962. */
  36963. onSuccess: (task: ImageAssetTask) => void;
  36964. /**
  36965. * Callback called when the task is successful
  36966. */
  36967. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36968. /**
  36969. * Creates a new ImageAssetTask
  36970. * @param name defines the name of the task
  36971. * @param url defines the location of the image to load
  36972. */
  36973. constructor(
  36974. /**
  36975. * Defines the name of the task
  36976. */
  36977. name: string,
  36978. /**
  36979. * Defines the location of the image to load
  36980. */
  36981. url: string);
  36982. /**
  36983. * Execute the current task
  36984. * @param scene defines the scene where you want your assets to be loaded
  36985. * @param onSuccess is a callback called when the task is successfully executed
  36986. * @param onError is a callback called if an error occurs
  36987. */
  36988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36989. }
  36990. /**
  36991. * Defines the interface used by texture loading tasks
  36992. */
  36993. interface ITextureAssetTask<TEX extends BaseTexture> {
  36994. /**
  36995. * Gets the loaded texture
  36996. */
  36997. texture: TEX;
  36998. }
  36999. /**
  37000. * Define a task used by AssetsManager to load 2D textures
  37001. */
  37002. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37003. /**
  37004. * Defines the name of the task
  37005. */
  37006. name: string;
  37007. /**
  37008. * Defines the location of the file to load
  37009. */
  37010. url: string;
  37011. /**
  37012. * Defines if mipmap should not be generated (default is false)
  37013. */
  37014. noMipmap?: boolean | undefined;
  37015. /**
  37016. * Defines if texture must be inverted on Y axis (default is false)
  37017. */
  37018. invertY?: boolean | undefined;
  37019. /**
  37020. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37021. */
  37022. samplingMode: number;
  37023. /**
  37024. * Gets the loaded texture
  37025. */
  37026. texture: Texture;
  37027. /**
  37028. * Callback called when the task is successful
  37029. */
  37030. onSuccess: (task: TextureAssetTask) => void;
  37031. /**
  37032. * Callback called when the task is successful
  37033. */
  37034. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37035. /**
  37036. * Creates a new TextureAssetTask object
  37037. * @param name defines the name of the task
  37038. * @param url defines the location of the file to load
  37039. * @param noMipmap defines if mipmap should not be generated (default is false)
  37040. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37041. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37042. */
  37043. constructor(
  37044. /**
  37045. * Defines the name of the task
  37046. */
  37047. name: string,
  37048. /**
  37049. * Defines the location of the file to load
  37050. */
  37051. url: string,
  37052. /**
  37053. * Defines if mipmap should not be generated (default is false)
  37054. */
  37055. noMipmap?: boolean | undefined,
  37056. /**
  37057. * Defines if texture must be inverted on Y axis (default is false)
  37058. */
  37059. invertY?: boolean | undefined,
  37060. /**
  37061. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37062. */
  37063. samplingMode?: number);
  37064. /**
  37065. * Execute the current task
  37066. * @param scene defines the scene where you want your assets to be loaded
  37067. * @param onSuccess is a callback called when the task is successfully executed
  37068. * @param onError is a callback called if an error occurs
  37069. */
  37070. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37071. }
  37072. /**
  37073. * Define a task used by AssetsManager to load cube textures
  37074. */
  37075. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37076. /**
  37077. * Defines the name of the task
  37078. */
  37079. name: string;
  37080. /**
  37081. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37082. */
  37083. url: string;
  37084. /**
  37085. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37086. */
  37087. extensions?: string[] | undefined;
  37088. /**
  37089. * Defines if mipmaps should not be generated (default is false)
  37090. */
  37091. noMipmap?: boolean | undefined;
  37092. /**
  37093. * Defines the explicit list of files (undefined by default)
  37094. */
  37095. files?: string[] | undefined;
  37096. /**
  37097. * Gets the loaded texture
  37098. */
  37099. texture: CubeTexture;
  37100. /**
  37101. * Callback called when the task is successful
  37102. */
  37103. onSuccess: (task: CubeTextureAssetTask) => void;
  37104. /**
  37105. * Callback called when the task is successful
  37106. */
  37107. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37108. /**
  37109. * Creates a new CubeTextureAssetTask
  37110. * @param name defines the name of the task
  37111. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37112. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37113. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37114. * @param files defines the explicit list of files (undefined by default)
  37115. */
  37116. constructor(
  37117. /**
  37118. * Defines the name of the task
  37119. */
  37120. name: string,
  37121. /**
  37122. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37123. */
  37124. url: string,
  37125. /**
  37126. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37127. */
  37128. extensions?: string[] | undefined,
  37129. /**
  37130. * Defines if mipmaps should not be generated (default is false)
  37131. */
  37132. noMipmap?: boolean | undefined,
  37133. /**
  37134. * Defines the explicit list of files (undefined by default)
  37135. */
  37136. files?: string[] | undefined);
  37137. /**
  37138. * Execute the current task
  37139. * @param scene defines the scene where you want your assets to be loaded
  37140. * @param onSuccess is a callback called when the task is successfully executed
  37141. * @param onError is a callback called if an error occurs
  37142. */
  37143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37144. }
  37145. /**
  37146. * Define a task used by AssetsManager to load HDR cube textures
  37147. */
  37148. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37149. /**
  37150. * Defines the name of the task
  37151. */
  37152. name: string;
  37153. /**
  37154. * Defines the location of the file to load
  37155. */
  37156. url: string;
  37157. /**
  37158. * Defines the desired size (the more it increases the longer the generation will be)
  37159. */
  37160. size: number;
  37161. /**
  37162. * Defines if mipmaps should not be generated (default is false)
  37163. */
  37164. noMipmap: boolean;
  37165. /**
  37166. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37167. */
  37168. generateHarmonics: boolean;
  37169. /**
  37170. * 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)
  37171. */
  37172. gammaSpace: boolean;
  37173. /**
  37174. * Internal Use Only
  37175. */
  37176. reserved: boolean;
  37177. /**
  37178. * Gets the loaded texture
  37179. */
  37180. texture: HDRCubeTexture;
  37181. /**
  37182. * Callback called when the task is successful
  37183. */
  37184. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37185. /**
  37186. * Callback called when the task is successful
  37187. */
  37188. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37189. /**
  37190. * Creates a new HDRCubeTextureAssetTask object
  37191. * @param name defines the name of the task
  37192. * @param url defines the location of the file to load
  37193. * @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.
  37194. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37195. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37196. * @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)
  37197. * @param reserved Internal use only
  37198. */
  37199. constructor(
  37200. /**
  37201. * Defines the name of the task
  37202. */
  37203. name: string,
  37204. /**
  37205. * Defines the location of the file to load
  37206. */
  37207. url: string,
  37208. /**
  37209. * Defines the desired size (the more it increases the longer the generation will be)
  37210. */
  37211. size: number,
  37212. /**
  37213. * Defines if mipmaps should not be generated (default is false)
  37214. */
  37215. noMipmap?: boolean,
  37216. /**
  37217. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37218. */
  37219. generateHarmonics?: boolean,
  37220. /**
  37221. * 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)
  37222. */
  37223. gammaSpace?: boolean,
  37224. /**
  37225. * Internal Use Only
  37226. */
  37227. reserved?: boolean);
  37228. /**
  37229. * Execute the current task
  37230. * @param scene defines the scene where you want your assets to be loaded
  37231. * @param onSuccess is a callback called when the task is successfully executed
  37232. * @param onError is a callback called if an error occurs
  37233. */
  37234. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37235. }
  37236. /**
  37237. * This class can be used to easily import assets into a scene
  37238. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37239. */
  37240. class AssetsManager {
  37241. private _scene;
  37242. private _isLoading;
  37243. protected _tasks: AbstractAssetTask[];
  37244. protected _waitingTasksCount: number;
  37245. protected _totalTasksCount: number;
  37246. /**
  37247. * Callback called when all tasks are processed
  37248. */
  37249. onFinish: (tasks: AbstractAssetTask[]) => void;
  37250. /**
  37251. * Callback called when a task is successful
  37252. */
  37253. onTaskSuccess: (task: AbstractAssetTask) => void;
  37254. /**
  37255. * Callback called when a task had an error
  37256. */
  37257. onTaskError: (task: AbstractAssetTask) => void;
  37258. /**
  37259. * Callback called when a task is done (whatever the result is)
  37260. */
  37261. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37262. /**
  37263. * Observable called when all tasks are processed
  37264. */
  37265. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37266. /**
  37267. * Observable called when a task had an error
  37268. */
  37269. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37270. /**
  37271. * Observable called when a task is successful
  37272. */
  37273. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37274. /**
  37275. * Observable called when a task is done (whatever the result is)
  37276. */
  37277. onProgressObservable: Observable<IAssetsProgressEvent>;
  37278. /**
  37279. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37281. */
  37282. useDefaultLoadingScreen: boolean;
  37283. /**
  37284. * Creates a new AssetsManager
  37285. * @param scene defines the scene to work on
  37286. */
  37287. constructor(scene: Scene);
  37288. /**
  37289. * Add a MeshAssetTask to the list of active tasks
  37290. * @param taskName defines the name of the new task
  37291. * @param meshesNames defines the name of meshes to load
  37292. * @param rootUrl defines the root url to use to locate files
  37293. * @param sceneFilename defines the filename of the scene file
  37294. * @returns a new MeshAssetTask object
  37295. */
  37296. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37297. /**
  37298. * Add a TextFileAssetTask to the list of active tasks
  37299. * @param taskName defines the name of the new task
  37300. * @param url defines the url of the file to load
  37301. * @returns a new TextFileAssetTask object
  37302. */
  37303. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37304. /**
  37305. * Add a BinaryFileAssetTask to the list of active tasks
  37306. * @param taskName defines the name of the new task
  37307. * @param url defines the url of the file to load
  37308. * @returns a new BinaryFileAssetTask object
  37309. */
  37310. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37311. /**
  37312. * Add a ImageAssetTask to the list of active tasks
  37313. * @param taskName defines the name of the new task
  37314. * @param url defines the url of the file to load
  37315. * @returns a new ImageAssetTask object
  37316. */
  37317. addImageTask(taskName: string, url: string): ImageAssetTask;
  37318. /**
  37319. * Add a TextureAssetTask to the list of active tasks
  37320. * @param taskName defines the name of the new task
  37321. * @param url defines the url of the file to load
  37322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37323. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37324. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37325. * @returns a new TextureAssetTask object
  37326. */
  37327. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37328. /**
  37329. * Add a CubeTextureAssetTask to the list of active tasks
  37330. * @param taskName defines the name of the new task
  37331. * @param url defines the url of the file to load
  37332. * @param extensions defines the extension to use to load the cube map (can be null)
  37333. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37334. * @param files defines the list of files to load (can be null)
  37335. * @returns a new CubeTextureAssetTask object
  37336. */
  37337. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37338. /**
  37339. *
  37340. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37341. * @param taskName defines the name of the new task
  37342. * @param url defines the url of the file to load
  37343. * @param size defines the size you want for the cubemap (can be null)
  37344. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37345. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37346. * @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)
  37347. * @param reserved Internal use only
  37348. * @returns a new HDRCubeTextureAssetTask object
  37349. */
  37350. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37351. /**
  37352. * Remove a task from the assets manager.
  37353. * @param task the task to remove
  37354. */
  37355. removeTask(task: AbstractAssetTask): void;
  37356. private _decreaseWaitingTasksCount;
  37357. private _runTask;
  37358. /**
  37359. * Reset the AssetsManager and remove all tasks
  37360. * @return the current instance of the AssetsManager
  37361. */
  37362. reset(): AssetsManager;
  37363. /**
  37364. * Start the loading process
  37365. * @return the current instance of the AssetsManager
  37366. */
  37367. load(): AssetsManager;
  37368. }
  37369. }
  37370. declare module BABYLON {
  37371. /**
  37372. * Direct draw surface info
  37373. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37374. */
  37375. interface DDSInfo {
  37376. /**
  37377. * Width of the texture
  37378. */
  37379. width: number;
  37380. /**
  37381. * Width of the texture
  37382. */
  37383. height: number;
  37384. /**
  37385. * Number of Mipmaps for the texture
  37386. * @see https://en.wikipedia.org/wiki/Mipmap
  37387. */
  37388. mipmapCount: number;
  37389. /**
  37390. * If the textures format is a known fourCC format
  37391. * @see https://www.fourcc.org/
  37392. */
  37393. isFourCC: boolean;
  37394. /**
  37395. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37396. */
  37397. isRGB: boolean;
  37398. /**
  37399. * If the texture is a lumincance format
  37400. */
  37401. isLuminance: boolean;
  37402. /**
  37403. * If this is a cube texture
  37404. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37405. */
  37406. isCube: boolean;
  37407. /**
  37408. * If the texture is a compressed format eg. FOURCC_DXT1
  37409. */
  37410. isCompressed: boolean;
  37411. /**
  37412. * The dxgiFormat of the texture
  37413. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37414. */
  37415. dxgiFormat: number;
  37416. /**
  37417. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37418. */
  37419. textureType: number;
  37420. /**
  37421. * Sphericle polynomial created for the dds texture
  37422. */
  37423. sphericalPolynomial?: SphericalPolynomial;
  37424. }
  37425. /**
  37426. * Class used to provide DDS decompression tools
  37427. */
  37428. class DDSTools {
  37429. /**
  37430. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37431. */
  37432. static StoreLODInAlphaChannel: boolean;
  37433. /**
  37434. * Gets DDS information from an array buffer
  37435. * @param arrayBuffer defines the array buffer to read data from
  37436. * @returns the DDS information
  37437. */
  37438. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37439. private static _FloatView;
  37440. private static _Int32View;
  37441. private static _ToHalfFloat;
  37442. private static _FromHalfFloat;
  37443. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37444. private static _GetHalfFloatRGBAArrayBuffer;
  37445. private static _GetFloatRGBAArrayBuffer;
  37446. private static _GetFloatAsUIntRGBAArrayBuffer;
  37447. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37448. private static _GetRGBAArrayBuffer;
  37449. private static _ExtractLongWordOrder;
  37450. private static _GetRGBArrayBuffer;
  37451. private static _GetLuminanceArrayBuffer;
  37452. /**
  37453. * Uploads DDS Levels to a Babylon Texture
  37454. * @hidden
  37455. */
  37456. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37457. }
  37458. }
  37459. declare module BABYLON {
  37460. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37461. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37462. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37463. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37464. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37465. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37466. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37467. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37468. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37469. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37470. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37471. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37472. /**
  37473. * Decorator used to define property that can be serialized as reference to a camera
  37474. * @param sourceName defines the name of the property to decorate
  37475. */
  37476. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37477. /**
  37478. * Class used to help serialization objects
  37479. */
  37480. class SerializationHelper {
  37481. /**
  37482. * Static function used to serialized a specific entity
  37483. * @param entity defines the entity to serialize
  37484. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37485. * @returns a JSON compatible object representing the serialization of the entity
  37486. */
  37487. static Serialize<T>(entity: T, serializationObject?: any): any;
  37488. /**
  37489. * Creates a new entity from a serialization data object
  37490. * @param creationFunction defines a function used to instanciated the new entity
  37491. * @param source defines the source serialization data
  37492. * @param scene defines the hosting scene
  37493. * @param rootUrl defines the root url for resources
  37494. * @returns a new entity
  37495. */
  37496. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37497. /**
  37498. * Clones an object
  37499. * @param creationFunction defines the function used to instanciate the new object
  37500. * @param source defines the source object
  37501. * @returns the cloned object
  37502. */
  37503. static Clone<T>(creationFunction: () => T, source: T): T;
  37504. /**
  37505. * Instanciates a new object based on a source one (some data will be shared between both object)
  37506. * @param creationFunction defines the function used to instanciate the new object
  37507. * @param source defines the source object
  37508. * @returns the new object
  37509. */
  37510. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. /**
  37515. * Wrapper class for promise with external resolve and reject.
  37516. */
  37517. class Deferred<T> {
  37518. /**
  37519. * The promise associated with this deferred object.
  37520. */
  37521. readonly promise: Promise<T>;
  37522. private _resolve;
  37523. private _reject;
  37524. /**
  37525. * The resolve method of the promise associated with this deferred object.
  37526. */
  37527. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37528. /**
  37529. * The reject method of the promise associated with this deferred object.
  37530. */
  37531. readonly reject: (reason?: any) => void;
  37532. /**
  37533. * Constructor for this deferred object.
  37534. */
  37535. constructor();
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. /**
  37540. * Raw texture data and descriptor sufficient for WebGL texture upload
  37541. */
  37542. interface EnvironmentTextureInfo {
  37543. /**
  37544. * Version of the environment map
  37545. */
  37546. version: number;
  37547. /**
  37548. * Width of image
  37549. */
  37550. width: number;
  37551. /**
  37552. * Irradiance information stored in the file.
  37553. */
  37554. irradiance: any;
  37555. /**
  37556. * Specular information stored in the file.
  37557. */
  37558. specular: any;
  37559. }
  37560. /**
  37561. * Sets of helpers addressing the serialization and deserialization of environment texture
  37562. * stored in a BabylonJS env file.
  37563. * Those files are usually stored as .env files.
  37564. */
  37565. class EnvironmentTextureTools {
  37566. /**
  37567. * Magic number identifying the env file.
  37568. */
  37569. private static _MagicBytes;
  37570. /**
  37571. * Gets the environment info from an env file.
  37572. * @param data The array buffer containing the .env bytes.
  37573. * @returns the environment file info (the json header) if successfully parsed.
  37574. */
  37575. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37576. /**
  37577. * Creates an environment texture from a loaded cube texture.
  37578. * @param texture defines the cube texture to convert in env file
  37579. * @return a promise containing the environment data if succesfull.
  37580. */
  37581. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37582. /**
  37583. * Creates a JSON representation of the spherical data.
  37584. * @param texture defines the texture containing the polynomials
  37585. * @return the JSON representation of the spherical info
  37586. */
  37587. private static _CreateEnvTextureIrradiance;
  37588. /**
  37589. * Uploads the texture info contained in the env file to the GPU.
  37590. * @param texture defines the internal texture to upload to
  37591. * @param arrayBuffer defines the buffer cotaining the data to load
  37592. * @param info defines the texture info retrieved through the GetEnvInfo method
  37593. * @returns a promise
  37594. */
  37595. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37596. /**
  37597. * Uploads the levels of image data to the GPU.
  37598. * @param texture defines the internal texture to upload to
  37599. * @param imageData defines the array buffer views of image data [mipmap][face]
  37600. * @returns a promise
  37601. */
  37602. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37603. /**
  37604. * Uploads spherical polynomials information to the texture.
  37605. * @param texture defines the texture we are trying to upload the information to
  37606. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37607. */
  37608. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37609. }
  37610. }
  37611. declare module BABYLON {
  37612. /**
  37613. * Class used to help managing file picking and drag'n'drop
  37614. */
  37615. class FilesInput {
  37616. /**
  37617. * List of files ready to be loaded
  37618. */
  37619. static FilesToLoad: {
  37620. [key: string]: File;
  37621. };
  37622. /**
  37623. * Callback called when a file is processed
  37624. */
  37625. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37626. private _engine;
  37627. private _currentScene;
  37628. private _sceneLoadedCallback;
  37629. private _progressCallback;
  37630. private _additionalRenderLoopLogicCallback;
  37631. private _textureLoadingCallback;
  37632. private _startingProcessingFilesCallback;
  37633. private _onReloadCallback;
  37634. private _errorCallback;
  37635. private _elementToMonitor;
  37636. private _sceneFileToLoad;
  37637. private _filesToLoad;
  37638. /**
  37639. * Creates a new FilesInput
  37640. * @param engine defines the rendering engine
  37641. * @param scene defines the hosting scene
  37642. * @param sceneLoadedCallback callback called when scene is loaded
  37643. * @param progressCallback callback called to track progress
  37644. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37645. * @param textureLoadingCallback callback called when a texture is loading
  37646. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37647. * @param onReloadCallback callback called when a reload is requested
  37648. * @param errorCallback callback call if an error occurs
  37649. */
  37650. 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);
  37651. private _dragEnterHandler;
  37652. private _dragOverHandler;
  37653. private _dropHandler;
  37654. /**
  37655. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37656. * @param elementToMonitor defines the DOM element to track
  37657. */
  37658. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37659. /**
  37660. * Release all associated resources
  37661. */
  37662. dispose(): void;
  37663. private renderFunction;
  37664. private drag;
  37665. private drop;
  37666. private _traverseFolder;
  37667. private _processFiles;
  37668. /**
  37669. * Load files from a drop event
  37670. * @param event defines the drop event to use as source
  37671. */
  37672. loadFiles(event: any): void;
  37673. private _processReload;
  37674. /**
  37675. * Reload the current scene from the loaded files
  37676. */
  37677. reload(): void;
  37678. }
  37679. }
  37680. declare module BABYLON {
  37681. /**
  37682. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37683. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37684. */
  37685. class KhronosTextureContainer {
  37686. /** contents of the KTX container file */
  37687. arrayBuffer: any;
  37688. private static HEADER_LEN;
  37689. private static COMPRESSED_2D;
  37690. private static COMPRESSED_3D;
  37691. private static TEX_2D;
  37692. private static TEX_3D;
  37693. /**
  37694. * Gets the openGL type
  37695. */
  37696. glType: number;
  37697. /**
  37698. * Gets the openGL type size
  37699. */
  37700. glTypeSize: number;
  37701. /**
  37702. * Gets the openGL format
  37703. */
  37704. glFormat: number;
  37705. /**
  37706. * Gets the openGL internal format
  37707. */
  37708. glInternalFormat: number;
  37709. /**
  37710. * Gets the base internal format
  37711. */
  37712. glBaseInternalFormat: number;
  37713. /**
  37714. * Gets image width in pixel
  37715. */
  37716. pixelWidth: number;
  37717. /**
  37718. * Gets image height in pixel
  37719. */
  37720. pixelHeight: number;
  37721. /**
  37722. * Gets image depth in pixels
  37723. */
  37724. pixelDepth: number;
  37725. /**
  37726. * Gets the number of array elements
  37727. */
  37728. numberOfArrayElements: number;
  37729. /**
  37730. * Gets the number of faces
  37731. */
  37732. numberOfFaces: number;
  37733. /**
  37734. * Gets the number of mipmap levels
  37735. */
  37736. numberOfMipmapLevels: number;
  37737. /**
  37738. * Gets the bytes of key value data
  37739. */
  37740. bytesOfKeyValueData: number;
  37741. /**
  37742. * Gets the load type
  37743. */
  37744. loadType: number;
  37745. /**
  37746. * Creates a new KhronosTextureContainer
  37747. * @param arrayBuffer contents of the KTX container file
  37748. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37749. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37750. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37751. */
  37752. constructor(
  37753. /** contents of the KTX container file */
  37754. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37755. /**
  37756. * Revert the endianness of a value.
  37757. * Not as fast hardware based, but will probably never need to use
  37758. * @param val defines the value to convert
  37759. * @returns the new value
  37760. */
  37761. switchEndianness(val: number): number;
  37762. /**
  37763. * Uploads KTX content to a Babylon Texture.
  37764. * It is assumed that the texture has already been created & is currently bound
  37765. * @hidden
  37766. */
  37767. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37768. private _upload2DCompressedLevels;
  37769. }
  37770. }
  37771. declare module BABYLON {
  37772. /**
  37773. * A class serves as a medium between the observable and its observers
  37774. */
  37775. class EventState {
  37776. /**
  37777. * Create a new EventState
  37778. * @param mask defines the mask associated with this state
  37779. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37780. * @param target defines the original target of the state
  37781. * @param currentTarget defines the current target of the state
  37782. */
  37783. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37784. /**
  37785. * Initialize the current event state
  37786. * @param mask defines the mask associated with this state
  37787. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37788. * @param target defines the original target of the state
  37789. * @param currentTarget defines the current target of the state
  37790. * @returns the current event state
  37791. */
  37792. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37793. /**
  37794. * An Observer can set this property to true to prevent subsequent observers of being notified
  37795. */
  37796. skipNextObservers: boolean;
  37797. /**
  37798. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37799. */
  37800. mask: number;
  37801. /**
  37802. * The object that originally notified the event
  37803. */
  37804. target?: any;
  37805. /**
  37806. * The current object in the bubbling phase
  37807. */
  37808. currentTarget?: any;
  37809. /**
  37810. * This will be populated with the return value of the last function that was executed.
  37811. * If it is the first function in the callback chain it will be the event data.
  37812. */
  37813. lastReturnValue?: any;
  37814. }
  37815. /**
  37816. * Represent an Observer registered to a given Observable object.
  37817. */
  37818. class Observer<T> {
  37819. /**
  37820. * Defines the callback to call when the observer is notified
  37821. */
  37822. callback: (eventData: T, eventState: EventState) => void;
  37823. /**
  37824. * Defines the mask of the observer (used to filter notifications)
  37825. */
  37826. mask: number;
  37827. /**
  37828. * Defines the current scope used to restore the JS context
  37829. */
  37830. scope: any;
  37831. /** @hidden */
  37832. _willBeUnregistered: boolean;
  37833. /**
  37834. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37835. */
  37836. unregisterOnNextCall: boolean;
  37837. /**
  37838. * Creates a new observer
  37839. * @param callback defines the callback to call when the observer is notified
  37840. * @param mask defines the mask of the observer (used to filter notifications)
  37841. * @param scope defines the current scope used to restore the JS context
  37842. */
  37843. constructor(
  37844. /**
  37845. * Defines the callback to call when the observer is notified
  37846. */
  37847. callback: (eventData: T, eventState: EventState) => void,
  37848. /**
  37849. * Defines the mask of the observer (used to filter notifications)
  37850. */
  37851. mask: number,
  37852. /**
  37853. * Defines the current scope used to restore the JS context
  37854. */
  37855. scope?: any);
  37856. }
  37857. /**
  37858. * Represent a list of observers registered to multiple Observables object.
  37859. */
  37860. class MultiObserver<T> {
  37861. private _observers;
  37862. private _observables;
  37863. /**
  37864. * Release associated resources
  37865. */
  37866. dispose(): void;
  37867. /**
  37868. * Raise a callback when one of the observable will notify
  37869. * @param observables defines a list of observables to watch
  37870. * @param callback defines the callback to call on notification
  37871. * @param mask defines the mask used to filter notifications
  37872. * @param scope defines the current scope used to restore the JS context
  37873. * @returns the new MultiObserver
  37874. */
  37875. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37876. }
  37877. /**
  37878. * The Observable class is a simple implementation of the Observable pattern.
  37879. *
  37880. * 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.
  37881. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37882. * 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).
  37883. * 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.
  37884. */
  37885. class Observable<T> {
  37886. private _observers;
  37887. private _eventState;
  37888. private _onObserverAdded;
  37889. /**
  37890. * Creates a new observable
  37891. * @param onObserverAdded defines a callback to call when a new observer is added
  37892. */
  37893. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37894. /**
  37895. * Create a new Observer with the specified callback
  37896. * @param callback the callback that will be executed for that Observer
  37897. * @param mask the mask used to filter observers
  37898. * @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.
  37899. * @param scope optional scope for the callback to be called from
  37900. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37901. * @returns the new observer created for the callback
  37902. */
  37903. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37904. /**
  37905. * Create a new Observer with the specified callback and unregisters after the next notification
  37906. * @param callback the callback that will be executed for that Observer
  37907. * @returns the new observer created for the callback
  37908. */
  37909. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37910. /**
  37911. * Remove an Observer from the Observable object
  37912. * @param observer the instance of the Observer to remove
  37913. * @returns false if it doesn't belong to this Observable
  37914. */
  37915. remove(observer: Nullable<Observer<T>>): boolean;
  37916. /**
  37917. * Remove a callback from the Observable object
  37918. * @param callback the callback to remove
  37919. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37920. * @returns false if it doesn't belong to this Observable
  37921. */
  37922. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37923. private _deferUnregister;
  37924. private _remove;
  37925. /**
  37926. * Notify all Observers by calling their respective callback with the given data
  37927. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37928. * @param eventData defines the data to send to all observers
  37929. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37930. * @param target defines the original target of the state
  37931. * @param currentTarget defines the current target of the state
  37932. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37933. */
  37934. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37935. /**
  37936. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37937. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37938. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37939. * and it is crucial that all callbacks will be executed.
  37940. * The order of the callbacks is kept, callbacks are not executed parallel.
  37941. *
  37942. * @param eventData The data to be sent to each callback
  37943. * @param mask is used to filter observers defaults to -1
  37944. * @param target defines the callback target (see EventState)
  37945. * @param currentTarget defines he current object in the bubbling phase
  37946. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37947. */
  37948. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37949. /**
  37950. * Notify a specific observer
  37951. * @param observer defines the observer to notify
  37952. * @param eventData defines the data to be sent to each callback
  37953. * @param mask is used to filter observers defaults to -1
  37954. */
  37955. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37956. /**
  37957. * Gets a boolean indicating if the observable has at least one observer
  37958. * @returns true is the Observable has at least one Observer registered
  37959. */
  37960. hasObservers(): boolean;
  37961. /**
  37962. * Clear the list of observers
  37963. */
  37964. clear(): void;
  37965. /**
  37966. * Clone the current observable
  37967. * @returns a new observable
  37968. */
  37969. clone(): Observable<T>;
  37970. /**
  37971. * Does this observable handles observer registered with a given mask
  37972. * @param mask defines the mask to be tested
  37973. * @return whether or not one observer registered with the given mask is handeled
  37974. **/
  37975. hasSpecificMask(mask?: number): boolean;
  37976. }
  37977. }
  37978. declare module BABYLON {
  37979. /**
  37980. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37981. */
  37982. class PerformanceMonitor {
  37983. private _enabled;
  37984. private _rollingFrameTime;
  37985. private _lastFrameTimeMs;
  37986. /**
  37987. * constructor
  37988. * @param frameSampleSize The number of samples required to saturate the sliding window
  37989. */
  37990. constructor(frameSampleSize?: number);
  37991. /**
  37992. * Samples current frame
  37993. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37994. */
  37995. sampleFrame(timeMs?: number): void;
  37996. /**
  37997. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37998. */
  37999. readonly averageFrameTime: number;
  38000. /**
  38001. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38002. */
  38003. readonly averageFrameTimeVariance: number;
  38004. /**
  38005. * Returns the frame time of the most recent frame
  38006. */
  38007. readonly instantaneousFrameTime: number;
  38008. /**
  38009. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38010. */
  38011. readonly averageFPS: number;
  38012. /**
  38013. * Returns the average framerate in frames per second using the most recent frame time
  38014. */
  38015. readonly instantaneousFPS: number;
  38016. /**
  38017. * Returns true if enough samples have been taken to completely fill the sliding window
  38018. */
  38019. readonly isSaturated: boolean;
  38020. /**
  38021. * Enables contributions to the sliding window sample set
  38022. */
  38023. enable(): void;
  38024. /**
  38025. * Disables contributions to the sliding window sample set
  38026. * Samples will not be interpolated over the disabled period
  38027. */
  38028. disable(): void;
  38029. /**
  38030. * Returns true if sampling is enabled
  38031. */
  38032. readonly isEnabled: boolean;
  38033. /**
  38034. * Resets performance monitor
  38035. */
  38036. reset(): void;
  38037. }
  38038. /**
  38039. * RollingAverage
  38040. *
  38041. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38042. */
  38043. class RollingAverage {
  38044. /**
  38045. * Current average
  38046. */
  38047. average: number;
  38048. /**
  38049. * Current variance
  38050. */
  38051. variance: number;
  38052. protected _samples: Array<number>;
  38053. protected _sampleCount: number;
  38054. protected _pos: number;
  38055. protected _m2: number;
  38056. /**
  38057. * constructor
  38058. * @param length The number of samples required to saturate the sliding window
  38059. */
  38060. constructor(length: number);
  38061. /**
  38062. * Adds a sample to the sample set
  38063. * @param v The sample value
  38064. */
  38065. add(v: number): void;
  38066. /**
  38067. * Returns previously added values or null if outside of history or outside the sliding window domain
  38068. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38069. * @return Value previously recorded with add() or null if outside of range
  38070. */
  38071. history(i: number): number;
  38072. /**
  38073. * Returns true if enough samples have been taken to completely fill the sliding window
  38074. * @return true if sample-set saturated
  38075. */
  38076. isSaturated(): boolean;
  38077. /**
  38078. * Resets the rolling average (equivalent to 0 samples taken so far)
  38079. */
  38080. reset(): void;
  38081. /**
  38082. * Wraps a value around the sample range boundaries
  38083. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38084. * @return Wrapped position in sample range
  38085. */
  38086. protected _wrapPosition(i: number): number;
  38087. }
  38088. }
  38089. declare module BABYLON {
  38090. /**
  38091. * Helper class that provides a small promise polyfill
  38092. */
  38093. class PromisePolyfill {
  38094. /**
  38095. * Static function used to check if the polyfill is required
  38096. * If this is the case then the function will inject the polyfill to window.Promise
  38097. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38098. */
  38099. static Apply(force?: boolean): void;
  38100. }
  38101. }
  38102. declare module BABYLON {
  38103. /**
  38104. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38106. */
  38107. class SceneOptimization {
  38108. /**
  38109. * Defines the priority of this optimization (0 by default which means first in the list)
  38110. */
  38111. priority: number;
  38112. /**
  38113. * Gets a string describing the action executed by the current optimization
  38114. * @returns description string
  38115. */
  38116. getDescription(): string;
  38117. /**
  38118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38119. * @param scene defines the current scene where to apply this optimization
  38120. * @param optimizer defines the current optimizer
  38121. * @returns true if everything that can be done was applied
  38122. */
  38123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38124. /**
  38125. * Creates the SceneOptimization object
  38126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38127. * @param desc defines the description associated with the optimization
  38128. */
  38129. constructor(
  38130. /**
  38131. * Defines the priority of this optimization (0 by default which means first in the list)
  38132. */
  38133. priority?: number);
  38134. }
  38135. /**
  38136. * Defines an optimization used to reduce the size of render target textures
  38137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38138. */
  38139. class TextureOptimization extends SceneOptimization {
  38140. /**
  38141. * Defines the priority of this optimization (0 by default which means first in the list)
  38142. */
  38143. priority: number;
  38144. /**
  38145. * 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
  38146. */
  38147. maximumSize: number;
  38148. /**
  38149. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38150. */
  38151. step: number;
  38152. /**
  38153. * Gets a string describing the action executed by the current optimization
  38154. * @returns description string
  38155. */
  38156. getDescription(): string;
  38157. /**
  38158. * Creates the TextureOptimization object
  38159. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38160. * @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
  38161. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38162. */
  38163. constructor(
  38164. /**
  38165. * Defines the priority of this optimization (0 by default which means first in the list)
  38166. */
  38167. priority?: number,
  38168. /**
  38169. * 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
  38170. */
  38171. maximumSize?: number,
  38172. /**
  38173. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38174. */
  38175. step?: number);
  38176. /**
  38177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38178. * @param scene defines the current scene where to apply this optimization
  38179. * @param optimizer defines the current optimizer
  38180. * @returns true if everything that can be done was applied
  38181. */
  38182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38183. }
  38184. /**
  38185. * Defines an optimization used to increase or decrease the rendering resolution
  38186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38187. */
  38188. class HardwareScalingOptimization extends SceneOptimization {
  38189. /**
  38190. * Defines the priority of this optimization (0 by default which means first in the list)
  38191. */
  38192. priority: number;
  38193. /**
  38194. * Defines the maximum scale to use (2 by default)
  38195. */
  38196. maximumScale: number;
  38197. /**
  38198. * Defines the step to use between two passes (0.5 by default)
  38199. */
  38200. step: number;
  38201. private _currentScale;
  38202. private _directionOffset;
  38203. /**
  38204. * Gets a string describing the action executed by the current optimization
  38205. * @return description string
  38206. */
  38207. getDescription(): string;
  38208. /**
  38209. * Creates the HardwareScalingOptimization object
  38210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38211. * @param maximumScale defines the maximum scale to use (2 by default)
  38212. * @param step defines the step to use between two passes (0.5 by default)
  38213. */
  38214. constructor(
  38215. /**
  38216. * Defines the priority of this optimization (0 by default which means first in the list)
  38217. */
  38218. priority?: number,
  38219. /**
  38220. * Defines the maximum scale to use (2 by default)
  38221. */
  38222. maximumScale?: number,
  38223. /**
  38224. * Defines the step to use between two passes (0.5 by default)
  38225. */
  38226. step?: number);
  38227. /**
  38228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38229. * @param scene defines the current scene where to apply this optimization
  38230. * @param optimizer defines the current optimizer
  38231. * @returns true if everything that can be done was applied
  38232. */
  38233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38234. }
  38235. /**
  38236. * Defines an optimization used to remove shadows
  38237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38238. */
  38239. class ShadowsOptimization extends SceneOptimization {
  38240. /**
  38241. * Gets a string describing the action executed by the current optimization
  38242. * @return description string
  38243. */
  38244. getDescription(): string;
  38245. /**
  38246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38247. * @param scene defines the current scene where to apply this optimization
  38248. * @param optimizer defines the current optimizer
  38249. * @returns true if everything that can be done was applied
  38250. */
  38251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38252. }
  38253. /**
  38254. * Defines an optimization used to turn post-processes off
  38255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38256. */
  38257. class PostProcessesOptimization extends SceneOptimization {
  38258. /**
  38259. * Gets a string describing the action executed by the current optimization
  38260. * @return description string
  38261. */
  38262. getDescription(): string;
  38263. /**
  38264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38265. * @param scene defines the current scene where to apply this optimization
  38266. * @param optimizer defines the current optimizer
  38267. * @returns true if everything that can be done was applied
  38268. */
  38269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38270. }
  38271. /**
  38272. * Defines an optimization used to turn lens flares off
  38273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38274. */
  38275. class LensFlaresOptimization extends SceneOptimization {
  38276. /**
  38277. * Gets a string describing the action executed by the current optimization
  38278. * @return description string
  38279. */
  38280. getDescription(): string;
  38281. /**
  38282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38283. * @param scene defines the current scene where to apply this optimization
  38284. * @param optimizer defines the current optimizer
  38285. * @returns true if everything that can be done was applied
  38286. */
  38287. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38288. }
  38289. /**
  38290. * Defines an optimization based on user defined callback.
  38291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38292. */
  38293. class CustomOptimization extends SceneOptimization {
  38294. /**
  38295. * Callback called to apply the custom optimization.
  38296. */
  38297. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38298. /**
  38299. * Callback called to get custom description
  38300. */
  38301. onGetDescription: () => string;
  38302. /**
  38303. * Gets a string describing the action executed by the current optimization
  38304. * @returns description string
  38305. */
  38306. getDescription(): string;
  38307. /**
  38308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38309. * @param scene defines the current scene where to apply this optimization
  38310. * @param optimizer defines the current optimizer
  38311. * @returns true if everything that can be done was applied
  38312. */
  38313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38314. }
  38315. /**
  38316. * Defines an optimization used to turn particles off
  38317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38318. */
  38319. class ParticlesOptimization extends SceneOptimization {
  38320. /**
  38321. * Gets a string describing the action executed by the current optimization
  38322. * @return description string
  38323. */
  38324. getDescription(): string;
  38325. /**
  38326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38327. * @param scene defines the current scene where to apply this optimization
  38328. * @param optimizer defines the current optimizer
  38329. * @returns true if everything that can be done was applied
  38330. */
  38331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38332. }
  38333. /**
  38334. * Defines an optimization used to turn render targets off
  38335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38336. */
  38337. class RenderTargetsOptimization extends SceneOptimization {
  38338. /**
  38339. * Gets a string describing the action executed by the current optimization
  38340. * @return description string
  38341. */
  38342. getDescription(): string;
  38343. /**
  38344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38345. * @param scene defines the current scene where to apply this optimization
  38346. * @param optimizer defines the current optimizer
  38347. * @returns true if everything that can be done was applied
  38348. */
  38349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38350. }
  38351. /**
  38352. * Defines an optimization used to merge meshes with compatible materials
  38353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38354. */
  38355. class MergeMeshesOptimization extends SceneOptimization {
  38356. private static _UpdateSelectionTree;
  38357. /**
  38358. * Gets or sets a boolean which defines if optimization octree has to be updated
  38359. */
  38360. /**
  38361. * Gets or sets a boolean which defines if optimization octree has to be updated
  38362. */
  38363. static UpdateSelectionTree: boolean;
  38364. /**
  38365. * Gets a string describing the action executed by the current optimization
  38366. * @return description string
  38367. */
  38368. getDescription(): string;
  38369. private _canBeMerged;
  38370. /**
  38371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38372. * @param scene defines the current scene where to apply this optimization
  38373. * @param optimizer defines the current optimizer
  38374. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38375. * @returns true if everything that can be done was applied
  38376. */
  38377. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38378. }
  38379. /**
  38380. * Defines a list of options used by SceneOptimizer
  38381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38382. */
  38383. class SceneOptimizerOptions {
  38384. /**
  38385. * Defines the target frame rate to reach (60 by default)
  38386. */
  38387. targetFrameRate: number;
  38388. /**
  38389. * Defines the interval between two checkes (2000ms by default)
  38390. */
  38391. trackerDuration: number;
  38392. /**
  38393. * Gets the list of optimizations to apply
  38394. */
  38395. optimizations: SceneOptimization[];
  38396. /**
  38397. * Creates a new list of options used by SceneOptimizer
  38398. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38399. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38400. */
  38401. constructor(
  38402. /**
  38403. * Defines the target frame rate to reach (60 by default)
  38404. */
  38405. targetFrameRate?: number,
  38406. /**
  38407. * Defines the interval between two checkes (2000ms by default)
  38408. */
  38409. trackerDuration?: number);
  38410. /**
  38411. * Add a new optimization
  38412. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38413. * @returns the current SceneOptimizerOptions
  38414. */
  38415. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38416. /**
  38417. * Add a new custom optimization
  38418. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38419. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38421. * @returns the current SceneOptimizerOptions
  38422. */
  38423. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38424. /**
  38425. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38426. * @param targetFrameRate defines the target frame rate (60 by default)
  38427. * @returns a SceneOptimizerOptions object
  38428. */
  38429. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38430. /**
  38431. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38432. * @param targetFrameRate defines the target frame rate (60 by default)
  38433. * @returns a SceneOptimizerOptions object
  38434. */
  38435. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38436. /**
  38437. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38438. * @param targetFrameRate defines the target frame rate (60 by default)
  38439. * @returns a SceneOptimizerOptions object
  38440. */
  38441. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38442. }
  38443. /**
  38444. * Class used to run optimizations in order to reach a target frame rate
  38445. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38446. */
  38447. class SceneOptimizer implements IDisposable {
  38448. private _isRunning;
  38449. private _options;
  38450. private _scene;
  38451. private _currentPriorityLevel;
  38452. private _targetFrameRate;
  38453. private _trackerDuration;
  38454. private _currentFrameRate;
  38455. private _sceneDisposeObserver;
  38456. private _improvementMode;
  38457. /**
  38458. * Defines an observable called when the optimizer reaches the target frame rate
  38459. */
  38460. onSuccessObservable: Observable<SceneOptimizer>;
  38461. /**
  38462. * Defines an observable called when the optimizer enables an optimization
  38463. */
  38464. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38465. /**
  38466. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38467. */
  38468. onFailureObservable: Observable<SceneOptimizer>;
  38469. /**
  38470. * Gets a boolean indicating if the optimizer is in improvement mode
  38471. */
  38472. readonly isInImprovementMode: boolean;
  38473. /**
  38474. * Gets the current priority level (0 at start)
  38475. */
  38476. readonly currentPriorityLevel: number;
  38477. /**
  38478. * Gets the current frame rate checked by the SceneOptimizer
  38479. */
  38480. readonly currentFrameRate: number;
  38481. /**
  38482. * Gets or sets the current target frame rate (60 by default)
  38483. */
  38484. /**
  38485. * Gets or sets the current target frame rate (60 by default)
  38486. */
  38487. targetFrameRate: number;
  38488. /**
  38489. * Gets or sets the current interval between two checks (every 2000ms by default)
  38490. */
  38491. /**
  38492. * Gets or sets the current interval between two checks (every 2000ms by default)
  38493. */
  38494. trackerDuration: number;
  38495. /**
  38496. * Gets the list of active optimizations
  38497. */
  38498. readonly optimizations: SceneOptimization[];
  38499. /**
  38500. * Creates a new SceneOptimizer
  38501. * @param scene defines the scene to work on
  38502. * @param options defines the options to use with the SceneOptimizer
  38503. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38504. * @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)
  38505. */
  38506. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38507. /**
  38508. * Stops the current optimizer
  38509. */
  38510. stop(): void;
  38511. /**
  38512. * Reset the optimizer to initial step (current priority level = 0)
  38513. */
  38514. reset(): void;
  38515. /**
  38516. * Start the optimizer. By default it will try to reach a specific framerate
  38517. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38518. */
  38519. start(): void;
  38520. private _checkCurrentState;
  38521. /**
  38522. * Release all resources
  38523. */
  38524. dispose(): void;
  38525. /**
  38526. * Helper function to create a SceneOptimizer with one single line of code
  38527. * @param scene defines the scene to work on
  38528. * @param options defines the options to use with the SceneOptimizer
  38529. * @param onSuccess defines a callback to call on success
  38530. * @param onFailure defines a callback to call on failure
  38531. * @returns the new SceneOptimizer object
  38532. */
  38533. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38534. }
  38535. }
  38536. declare module BABYLON {
  38537. /**
  38538. * Class used to serialize a scene into a string
  38539. */
  38540. class SceneSerializer {
  38541. /**
  38542. * Clear cache used by a previous serialization
  38543. */
  38544. static ClearCache(): void;
  38545. /**
  38546. * Serialize a scene into a JSON compatible object
  38547. * @param scene defines the scene to serialize
  38548. * @returns a JSON compatible object
  38549. */
  38550. static Serialize(scene: Scene): any;
  38551. /**
  38552. * Serialize a mesh into a JSON compatible object
  38553. * @param toSerialize defines the mesh to serialize
  38554. * @param withParents defines if parents must be serialized as well
  38555. * @param withChildren defines if children must be serialized as well
  38556. * @returns a JSON compatible object
  38557. */
  38558. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38559. }
  38560. }
  38561. declare module BABYLON {
  38562. /**
  38563. * Defines an array and its length.
  38564. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38565. */
  38566. interface ISmartArrayLike<T> {
  38567. /**
  38568. * The data of the array.
  38569. */
  38570. data: Array<T>;
  38571. /**
  38572. * The active length of the array.
  38573. */
  38574. length: number;
  38575. }
  38576. /**
  38577. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38578. */
  38579. class SmartArray<T> implements ISmartArrayLike<T> {
  38580. /**
  38581. * The full set of data from the array.
  38582. */
  38583. data: Array<T>;
  38584. /**
  38585. * The active length of the array.
  38586. */
  38587. length: number;
  38588. protected _id: number;
  38589. /**
  38590. * Instantiates a Smart Array.
  38591. * @param capacity defines the default capacity of the array.
  38592. */
  38593. constructor(capacity: number);
  38594. /**
  38595. * Pushes a value at the end of the active data.
  38596. * @param value defines the object to push in the array.
  38597. */
  38598. push(value: T): void;
  38599. /**
  38600. * Iterates over the active data and apply the lambda to them.
  38601. * @param func defines the action to apply on each value.
  38602. */
  38603. forEach(func: (content: T) => void): void;
  38604. /**
  38605. * Sorts the full sets of data.
  38606. * @param compareFn defines the comparison function to apply.
  38607. */
  38608. sort(compareFn: (a: T, b: T) => number): void;
  38609. /**
  38610. * Resets the active data to an empty array.
  38611. */
  38612. reset(): void;
  38613. /**
  38614. * Releases all the data from the array as well as the array.
  38615. */
  38616. dispose(): void;
  38617. /**
  38618. * Concats the active data with a given array.
  38619. * @param array defines the data to concatenate with.
  38620. */
  38621. concat(array: any): void;
  38622. /**
  38623. * Returns the position of a value in the active data.
  38624. * @param value defines the value to find the index for
  38625. * @returns the index if found in the active data otherwise -1
  38626. */
  38627. indexOf(value: T): number;
  38628. /**
  38629. * Returns whether an element is part of the active data.
  38630. * @param value defines the value to look for
  38631. * @returns true if found in the active data otherwise false
  38632. */
  38633. contains(value: T): boolean;
  38634. private static _GlobalId;
  38635. }
  38636. /**
  38637. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38638. * The data in this array can only be present once
  38639. */
  38640. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38641. private _duplicateId;
  38642. /**
  38643. * Pushes a value at the end of the active data.
  38644. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38645. * @param value defines the object to push in the array.
  38646. */
  38647. push(value: T): void;
  38648. /**
  38649. * Pushes a value at the end of the active data.
  38650. * If the data is already present, it won t be added again
  38651. * @param value defines the object to push in the array.
  38652. * @returns true if added false if it was already present
  38653. */
  38654. pushNoDuplicate(value: T): boolean;
  38655. /**
  38656. * Resets the active data to an empty array.
  38657. */
  38658. reset(): void;
  38659. /**
  38660. * Concats the active data with a given array.
  38661. * This ensures no dupplicate will be present in the result.
  38662. * @param array defines the data to concatenate with.
  38663. */
  38664. concatWithNoDuplicate(array: any): void;
  38665. }
  38666. }
  38667. declare module BABYLON {
  38668. /**
  38669. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38670. * The underlying implementation relies on an associative array to ensure the best performances.
  38671. * The value can be anything including 'null' but except 'undefined'
  38672. */
  38673. class StringDictionary<T> {
  38674. /**
  38675. * This will clear this dictionary and copy the content from the 'source' one.
  38676. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38677. * @param source the dictionary to take the content from and copy to this dictionary
  38678. */
  38679. copyFrom(source: StringDictionary<T>): void;
  38680. /**
  38681. * Get a value based from its key
  38682. * @param key the given key to get the matching value from
  38683. * @return the value if found, otherwise undefined is returned
  38684. */
  38685. get(key: string): T | undefined;
  38686. /**
  38687. * Get a value from its key or add it if it doesn't exist.
  38688. * This method will ensure you that a given key/data will be present in the dictionary.
  38689. * @param key the given key to get the matching value from
  38690. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38691. * The factory will only be invoked if there's no data for the given key.
  38692. * @return the value corresponding to the key.
  38693. */
  38694. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38695. /**
  38696. * Get a value from its key if present in the dictionary otherwise add it
  38697. * @param key the key to get the value from
  38698. * @param val if there's no such key/value pair in the dictionary add it with this value
  38699. * @return the value corresponding to the key
  38700. */
  38701. getOrAdd(key: string, val: T): T;
  38702. /**
  38703. * Check if there's a given key in the dictionary
  38704. * @param key the key to check for
  38705. * @return true if the key is present, false otherwise
  38706. */
  38707. contains(key: string): boolean;
  38708. /**
  38709. * Add a new key and its corresponding value
  38710. * @param key the key to add
  38711. * @param value the value corresponding to the key
  38712. * @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
  38713. */
  38714. add(key: string, value: T): boolean;
  38715. /**
  38716. * Update a specific value associated to a key
  38717. * @param key defines the key to use
  38718. * @param value defines the value to store
  38719. * @returns true if the value was updated (or false if the key was not found)
  38720. */
  38721. set(key: string, value: T): boolean;
  38722. /**
  38723. * Get the element of the given key and remove it from the dictionary
  38724. * @param key defines the key to search
  38725. * @returns the value associated with the key or null if not found
  38726. */
  38727. getAndRemove(key: string): Nullable<T>;
  38728. /**
  38729. * Remove a key/value from the dictionary.
  38730. * @param key the key to remove
  38731. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38732. */
  38733. remove(key: string): boolean;
  38734. /**
  38735. * Clear the whole content of the dictionary
  38736. */
  38737. clear(): void;
  38738. /**
  38739. * Gets the current count
  38740. */
  38741. readonly count: number;
  38742. /**
  38743. * Execute a callback on each key/val of the dictionary.
  38744. * Note that you can remove any element in this dictionary in the callback implementation
  38745. * @param callback the callback to execute on a given key/value pair
  38746. */
  38747. forEach(callback: (key: string, val: T) => void): void;
  38748. /**
  38749. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38750. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38751. * Note that you can remove any element in this dictionary in the callback implementation
  38752. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38753. * @returns the first item
  38754. */
  38755. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38756. private _count;
  38757. private _data;
  38758. }
  38759. }
  38760. declare module BABYLON {
  38761. /**
  38762. * Class used to store custom tags
  38763. */
  38764. class Tags {
  38765. /**
  38766. * Adds support for tags on the given object
  38767. * @param obj defines the object to use
  38768. */
  38769. static EnableFor(obj: any): void;
  38770. /**
  38771. * Removes tags support
  38772. * @param obj defines the object to use
  38773. */
  38774. static DisableFor(obj: any): void;
  38775. /**
  38776. * Gets a boolean indicating if the given object has tags
  38777. * @param obj defines the object to use
  38778. * @returns a boolean
  38779. */
  38780. static HasTags(obj: any): boolean;
  38781. /**
  38782. * Gets the tags available on a given object
  38783. * @param obj defines the object to use
  38784. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38785. * @returns the tags
  38786. */
  38787. static GetTags(obj: any, asString?: boolean): any;
  38788. /**
  38789. * Adds tags to an object
  38790. * @param obj defines the object to use
  38791. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38792. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38793. */
  38794. static AddTagsTo(obj: any, tagsString: string): void;
  38795. /**
  38796. * @hidden
  38797. */
  38798. static _AddTagTo(obj: any, tag: string): void;
  38799. /**
  38800. * Removes specific tags from a specific object
  38801. * @param obj defines the object to use
  38802. * @param tagsString defines the tags to remove
  38803. */
  38804. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38805. /**
  38806. * @hidden
  38807. */
  38808. static _RemoveTagFrom(obj: any, tag: string): void;
  38809. /**
  38810. * Defines if tags hosted on an object match a given query
  38811. * @param obj defines the object to use
  38812. * @param tagsQuery defines the tag query
  38813. * @returns a boolean
  38814. */
  38815. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38816. }
  38817. }
  38818. declare module BABYLON {
  38819. /**
  38820. * Class used to host texture specific utilities
  38821. */
  38822. class TextureTools {
  38823. /**
  38824. * Uses the GPU to create a copy texture rescaled at a given size
  38825. * @param texture Texture to copy from
  38826. * @param width defines the desired width
  38827. * @param height defines the desired height
  38828. * @param useBilinearMode defines if bilinear mode has to be used
  38829. * @return the generated texture
  38830. */
  38831. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38832. /**
  38833. * Gets an environment BRDF texture for a given scene
  38834. * @param scene defines the hosting scene
  38835. * @returns the environment BRDF texture
  38836. */
  38837. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38838. private static _environmentBRDFBase64Texture;
  38839. }
  38840. }
  38841. declare module BABYLON {
  38842. /**
  38843. * Based on jsTGALoader - Javascript loader for TGA file
  38844. * By Vincent Thibault
  38845. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38846. */
  38847. class TGATools {
  38848. private static _TYPE_INDEXED;
  38849. private static _TYPE_RGB;
  38850. private static _TYPE_GREY;
  38851. private static _TYPE_RLE_INDEXED;
  38852. private static _TYPE_RLE_RGB;
  38853. private static _TYPE_RLE_GREY;
  38854. private static _ORIGIN_MASK;
  38855. private static _ORIGIN_SHIFT;
  38856. private static _ORIGIN_BL;
  38857. private static _ORIGIN_BR;
  38858. private static _ORIGIN_UL;
  38859. private static _ORIGIN_UR;
  38860. /**
  38861. * Gets the header of a TGA file
  38862. * @param data defines the TGA data
  38863. * @returns the header
  38864. */
  38865. static GetTGAHeader(data: Uint8Array): any;
  38866. /**
  38867. * Uploads TGA content to a Babylon Texture
  38868. * @hidden
  38869. */
  38870. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38871. /** @hidden */
  38872. 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;
  38873. /** @hidden */
  38874. 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;
  38875. /** @hidden */
  38876. 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;
  38877. /** @hidden */
  38878. 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;
  38879. /** @hidden */
  38880. 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;
  38881. /** @hidden */
  38882. 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;
  38883. }
  38884. }
  38885. declare module BABYLON {
  38886. /**
  38887. * Interface for any object that can request an animation frame
  38888. */
  38889. interface ICustomAnimationFrameRequester {
  38890. /**
  38891. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38892. */
  38893. renderFunction?: Function;
  38894. /**
  38895. * Called to request the next frame to render to
  38896. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38897. */
  38898. requestAnimationFrame: Function;
  38899. /**
  38900. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38901. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38902. */
  38903. requestID?: number;
  38904. }
  38905. /**
  38906. * Interface containing an array of animations
  38907. */
  38908. interface IAnimatable {
  38909. /**
  38910. * Array of animations
  38911. */
  38912. animations: Array<Animation>;
  38913. }
  38914. /** Interface used by value gradients (color, factor, ...) */
  38915. interface IValueGradient {
  38916. /**
  38917. * Gets or sets the gradient value (between 0 and 1)
  38918. */
  38919. gradient: number;
  38920. }
  38921. /** Class used to store color4 gradient */
  38922. class ColorGradient implements IValueGradient {
  38923. /**
  38924. * Gets or sets the gradient value (between 0 and 1)
  38925. */
  38926. gradient: number;
  38927. /**
  38928. * Gets or sets first associated color
  38929. */
  38930. color1: Color4;
  38931. /**
  38932. * Gets or sets second associated color
  38933. */
  38934. color2?: Color4;
  38935. /**
  38936. * Will get a color picked randomly between color1 and color2.
  38937. * If color2 is undefined then color1 will be used
  38938. * @param result defines the target Color4 to store the result in
  38939. */
  38940. getColorToRef(result: Color4): void;
  38941. }
  38942. /** Class used to store color 3 gradient */
  38943. class Color3Gradient implements IValueGradient {
  38944. /**
  38945. * Gets or sets the gradient value (between 0 and 1)
  38946. */
  38947. gradient: number;
  38948. /**
  38949. * Gets or sets the associated color
  38950. */
  38951. color: Color3;
  38952. }
  38953. /** Class used to store factor gradient */
  38954. class FactorGradient implements IValueGradient {
  38955. /**
  38956. * Gets or sets the gradient value (between 0 and 1)
  38957. */
  38958. gradient: number;
  38959. /**
  38960. * Gets or sets first associated factor
  38961. */
  38962. factor1: number;
  38963. /**
  38964. * Gets or sets second associated factor
  38965. */
  38966. factor2?: number;
  38967. /**
  38968. * Will get a number picked randomly between factor1 and factor2.
  38969. * If factor2 is undefined then factor1 will be used
  38970. * @returns the picked number
  38971. */
  38972. getFactor(): number;
  38973. }
  38974. /**
  38975. * @ignore
  38976. * Application error to support additional information when loading a file
  38977. */
  38978. class LoadFileError extends Error {
  38979. /** defines the optional XHR request */
  38980. request?: XMLHttpRequest | undefined;
  38981. private static _setPrototypeOf;
  38982. /**
  38983. * Creates a new LoadFileError
  38984. * @param message defines the message of the error
  38985. * @param request defines the optional XHR request
  38986. */
  38987. constructor(message: string,
  38988. /** defines the optional XHR request */
  38989. request?: XMLHttpRequest | undefined);
  38990. }
  38991. /**
  38992. * Class used to define a retry strategy when error happens while loading assets
  38993. */
  38994. class RetryStrategy {
  38995. /**
  38996. * Function used to defines an exponential back off strategy
  38997. * @param maxRetries defines the maximum number of retries (3 by default)
  38998. * @param baseInterval defines the interval between retries
  38999. * @returns the strategy function to use
  39000. */
  39001. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39002. }
  39003. /**
  39004. * File request interface
  39005. */
  39006. interface IFileRequest {
  39007. /**
  39008. * Raised when the request is complete (success or error).
  39009. */
  39010. onCompleteObservable: Observable<IFileRequest>;
  39011. /**
  39012. * Aborts the request for a file.
  39013. */
  39014. abort: () => void;
  39015. }
  39016. /**
  39017. * Class containing a set of static utilities functions
  39018. */
  39019. class Tools {
  39020. /**
  39021. * Gets or sets the base URL to use to load assets
  39022. */
  39023. static BaseUrl: string;
  39024. /**
  39025. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39026. */
  39027. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39028. /**
  39029. * Default behaviour for cors in the application.
  39030. * It can be a string if the expected behavior is identical in the entire app.
  39031. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39032. */
  39033. static CorsBehavior: string | ((url: string | string[]) => string);
  39034. /**
  39035. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39036. * @ignorenaming
  39037. */
  39038. static UseFallbackTexture: boolean;
  39039. /**
  39040. * Use this object to register external classes like custom textures or material
  39041. * to allow the laoders to instantiate them
  39042. */
  39043. static RegisteredExternalClasses: {
  39044. [key: string]: Object;
  39045. };
  39046. /**
  39047. * Texture content used if a texture cannot loaded
  39048. * @ignorenaming
  39049. */
  39050. static fallbackTexture: string;
  39051. /**
  39052. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39053. * @param u defines the coordinate on X axis
  39054. * @param v defines the coordinate on Y axis
  39055. * @param width defines the width of the source data
  39056. * @param height defines the height of the source data
  39057. * @param pixels defines the source byte array
  39058. * @param color defines the output color
  39059. */
  39060. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39061. /**
  39062. * Interpolates between a and b via alpha
  39063. * @param a The lower value (returned when alpha = 0)
  39064. * @param b The upper value (returned when alpha = 1)
  39065. * @param alpha The interpolation-factor
  39066. * @return The mixed value
  39067. */
  39068. static Mix(a: number, b: number, alpha: number): number;
  39069. /**
  39070. * Tries to instantiate a new object from a given class name
  39071. * @param className defines the class name to instantiate
  39072. * @returns the new object or null if the system was not able to do the instantiation
  39073. */
  39074. static Instantiate(className: string): any;
  39075. /**
  39076. * Provides a slice function that will work even on IE
  39077. * @param data defines the array to slice
  39078. * @param start defines the start of the data (optional)
  39079. * @param end defines the end of the data (optional)
  39080. * @returns the new sliced array
  39081. */
  39082. static Slice<T>(data: T, start?: number, end?: number): T;
  39083. /**
  39084. * Polyfill for setImmediate
  39085. * @param action defines the action to execute after the current execution block
  39086. */
  39087. static SetImmediate(action: () => void): void;
  39088. /**
  39089. * Function indicating if a number is an exponent of 2
  39090. * @param value defines the value to test
  39091. * @returns true if the value is an exponent of 2
  39092. */
  39093. static IsExponentOfTwo(value: number): boolean;
  39094. private static _tmpFloatArray;
  39095. /**
  39096. * Returns the nearest 32-bit single precision float representation of a Number
  39097. * @param value A Number. If the parameter is of a different type, it will get converted
  39098. * to a number or to NaN if it cannot be converted
  39099. * @returns number
  39100. */
  39101. static FloatRound(value: number): number;
  39102. /**
  39103. * Find the next highest power of two.
  39104. * @param x Number to start search from.
  39105. * @return Next highest power of two.
  39106. */
  39107. static CeilingPOT(x: number): number;
  39108. /**
  39109. * Find the next lowest power of two.
  39110. * @param x Number to start search from.
  39111. * @return Next lowest power of two.
  39112. */
  39113. static FloorPOT(x: number): number;
  39114. /**
  39115. * Find the nearest power of two.
  39116. * @param x Number to start search from.
  39117. * @return Next nearest power of two.
  39118. */
  39119. static NearestPOT(x: number): number;
  39120. /**
  39121. * Get the closest exponent of two
  39122. * @param value defines the value to approximate
  39123. * @param max defines the maximum value to return
  39124. * @param mode defines how to define the closest value
  39125. * @returns closest exponent of two of the given value
  39126. */
  39127. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39128. /**
  39129. * Extracts the filename from a path
  39130. * @param path defines the path to use
  39131. * @returns the filename
  39132. */
  39133. static GetFilename(path: string): string;
  39134. /**
  39135. * Extracts the "folder" part of a path (everything before the filename).
  39136. * @param uri The URI to extract the info from
  39137. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39138. * @returns The "folder" part of the path
  39139. */
  39140. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39141. /**
  39142. * Extracts text content from a DOM element hierarchy
  39143. * @param element defines the root element
  39144. * @returns a string
  39145. */
  39146. static GetDOMTextContent(element: HTMLElement): string;
  39147. /**
  39148. * Convert an angle in radians to degrees
  39149. * @param angle defines the angle to convert
  39150. * @returns the angle in degrees
  39151. */
  39152. static ToDegrees(angle: number): number;
  39153. /**
  39154. * Convert an angle in degrees to radians
  39155. * @param angle defines the angle to convert
  39156. * @returns the angle in radians
  39157. */
  39158. static ToRadians(angle: number): number;
  39159. /**
  39160. * Encode a buffer to a base64 string
  39161. * @param buffer defines the buffer to encode
  39162. * @returns the encoded string
  39163. */
  39164. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39165. /**
  39166. * Extracts minimum and maximum values from a list of indexed positions
  39167. * @param positions defines the positions to use
  39168. * @param indices defines the indices to the positions
  39169. * @param indexStart defines the start index
  39170. * @param indexCount defines the end index
  39171. * @param bias defines bias value to add to the result
  39172. * @return minimum and maximum values
  39173. */
  39174. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39175. minimum: Vector3;
  39176. maximum: Vector3;
  39177. };
  39178. /**
  39179. * Extracts minimum and maximum values from a list of positions
  39180. * @param positions defines the positions to use
  39181. * @param start defines the start index in the positions array
  39182. * @param count defines the number of positions to handle
  39183. * @param bias defines bias value to add to the result
  39184. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39185. * @return minimum and maximum values
  39186. */
  39187. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39188. minimum: Vector3;
  39189. maximum: Vector3;
  39190. };
  39191. /**
  39192. * Returns an array if obj is not an array
  39193. * @param obj defines the object to evaluate as an array
  39194. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39195. * @returns either obj directly if obj is an array or a new array containing obj
  39196. */
  39197. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39198. /**
  39199. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39200. * @param size the number of element to construct and put in the array
  39201. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39202. * @returns a new array filled with new objects
  39203. */
  39204. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39205. /**
  39206. * Gets the pointer prefix to use
  39207. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39208. */
  39209. static GetPointerPrefix(): string;
  39210. /**
  39211. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39212. * @param func - the function to be called
  39213. * @param requester - the object that will request the next frame. Falls back to window.
  39214. * @returns frame number
  39215. */
  39216. static QueueNewFrame(func: () => void, requester?: any): number;
  39217. /**
  39218. * Ask the browser to promote the current element to fullscreen rendering mode
  39219. * @param element defines the DOM element to promote
  39220. */
  39221. static RequestFullscreen(element: HTMLElement): void;
  39222. /**
  39223. * Asks the browser to exit fullscreen mode
  39224. */
  39225. static ExitFullscreen(): void;
  39226. /**
  39227. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39228. * @param url define the url we are trying
  39229. * @param element define the dom element where to configure the cors policy
  39230. */
  39231. static SetCorsBehavior(url: string | string[], element: {
  39232. crossOrigin: string | null;
  39233. }): void;
  39234. /**
  39235. * Removes unwanted characters from an url
  39236. * @param url defines the url to clean
  39237. * @returns the cleaned url
  39238. */
  39239. static CleanUrl(url: string): string;
  39240. /**
  39241. * Gets or sets a function used to pre-process url before using them to load assets
  39242. */
  39243. static PreprocessUrl: (url: string) => string;
  39244. /**
  39245. * Loads an image as an HTMLImageElement.
  39246. * @param input url string, ArrayBuffer, or Blob to load
  39247. * @param onLoad callback called when the image successfully loads
  39248. * @param onError callback called when the image fails to load
  39249. * @param offlineProvider offline provider for caching
  39250. * @returns the HTMLImageElement of the loaded image
  39251. */
  39252. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39253. /**
  39254. * Loads a file
  39255. * @param url url string, ArrayBuffer, or Blob to load
  39256. * @param onSuccess callback called when the file successfully loads
  39257. * @param onProgress callback called while file is loading (if the server supports this mode)
  39258. * @param offlineProvider defines the offline provider for caching
  39259. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39260. * @param onError callback called when the file fails to load
  39261. * @returns a file request object
  39262. */
  39263. 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;
  39264. /**
  39265. * Load a script (identified by an url). When the url returns, the
  39266. * content of this file is added into a new script element, attached to the DOM (body element)
  39267. * @param scriptUrl defines the url of the script to laod
  39268. * @param onSuccess defines the callback called when the script is loaded
  39269. * @param onError defines the callback to call if an error occurs
  39270. */
  39271. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39272. /**
  39273. * Loads a file from a blob
  39274. * @param fileToLoad defines the blob to use
  39275. * @param callback defines the callback to call when data is loaded
  39276. * @param progressCallback defines the callback to call during loading process
  39277. * @returns a file request object
  39278. */
  39279. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39280. /**
  39281. * Loads a file
  39282. * @param fileToLoad defines the file to load
  39283. * @param callback defines the callback to call when data is loaded
  39284. * @param progressCallBack defines the callback to call during loading process
  39285. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39286. * @returns a file request object
  39287. */
  39288. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39289. /**
  39290. * Creates a data url from a given string content
  39291. * @param content defines the content to convert
  39292. * @returns the new data url link
  39293. */
  39294. static FileAsURL(content: string): string;
  39295. /**
  39296. * Format the given number to a specific decimal format
  39297. * @param value defines the number to format
  39298. * @param decimals defines the number of decimals to use
  39299. * @returns the formatted string
  39300. */
  39301. static Format(value: number, decimals?: number): string;
  39302. /**
  39303. * Checks if a given vector is inside a specific range
  39304. * @param v defines the vector to test
  39305. * @param min defines the minimum range
  39306. * @param max defines the maximum range
  39307. */
  39308. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39309. /**
  39310. * Tries to copy an object by duplicating every property
  39311. * @param source defines the source object
  39312. * @param destination defines the target object
  39313. * @param doNotCopyList defines a list of properties to avoid
  39314. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39315. */
  39316. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39317. /**
  39318. * Gets a boolean indicating if the given object has no own property
  39319. * @param obj defines the object to test
  39320. * @returns true if object has no own property
  39321. */
  39322. static IsEmpty(obj: any): boolean;
  39323. /**
  39324. * Function used to register events at window level
  39325. * @param events defines the events to register
  39326. */
  39327. static RegisterTopRootEvents(events: {
  39328. name: string;
  39329. handler: Nullable<(e: FocusEvent) => any>;
  39330. }[]): void;
  39331. /**
  39332. * Function used to unregister events from window level
  39333. * @param events defines the events to unregister
  39334. */
  39335. static UnregisterTopRootEvents(events: {
  39336. name: string;
  39337. handler: Nullable<(e: FocusEvent) => any>;
  39338. }[]): void;
  39339. /**
  39340. * Dumps the current bound framebuffer
  39341. * @param width defines the rendering width
  39342. * @param height defines the rendering height
  39343. * @param engine defines the hosting engine
  39344. * @param successCallback defines the callback triggered once the data are available
  39345. * @param mimeType defines the mime type of the result
  39346. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39347. */
  39348. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39349. /**
  39350. * Converts the canvas data to blob.
  39351. * This acts as a polyfill for browsers not supporting the to blob function.
  39352. * @param canvas Defines the canvas to extract the data from
  39353. * @param successCallback Defines the callback triggered once the data are available
  39354. * @param mimeType Defines the mime type of the result
  39355. */
  39356. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39357. /**
  39358. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39359. * @param successCallback defines the callback triggered once the data are available
  39360. * @param mimeType defines the mime type of the result
  39361. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39362. */
  39363. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39364. /**
  39365. * Downloads a blob in the browser
  39366. * @param blob defines the blob to download
  39367. * @param fileName defines the name of the downloaded file
  39368. */
  39369. static Download(blob: Blob, fileName: string): void;
  39370. /**
  39371. * Captures a screenshot of the current rendering
  39372. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39373. * @param engine defines the rendering engine
  39374. * @param camera defines the source camera
  39375. * @param size This parameter can be set to a single number or to an object with the
  39376. * following (optional) properties: precision, width, height. If a single number is passed,
  39377. * it will be used for both width and height. If an object is passed, the screenshot size
  39378. * will be derived from the parameters. The precision property is a multiplier allowing
  39379. * rendering at a higher or lower resolution
  39380. * @param successCallback defines the callback receives a single parameter which contains the
  39381. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39382. * src parameter of an <img> to display it
  39383. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39384. * Check your browser for supported MIME types
  39385. */
  39386. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39387. /**
  39388. * Generates an image screenshot from the specified camera.
  39389. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39390. * @param engine The engine to use for rendering
  39391. * @param camera The camera to use for rendering
  39392. * @param size This parameter can be set to a single number or to an object with the
  39393. * following (optional) properties: precision, width, height. If a single number is passed,
  39394. * it will be used for both width and height. If an object is passed, the screenshot size
  39395. * will be derived from the parameters. The precision property is a multiplier allowing
  39396. * rendering at a higher or lower resolution
  39397. * @param successCallback The callback receives a single parameter which contains the
  39398. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39399. * src parameter of an <img> to display it
  39400. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39401. * Check your browser for supported MIME types
  39402. * @param samples Texture samples (default: 1)
  39403. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39404. * @param fileName A name for for the downloaded file.
  39405. */
  39406. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39407. /**
  39408. * Validates if xhr data is correct
  39409. * @param xhr defines the request to validate
  39410. * @param dataType defines the expected data type
  39411. * @returns true if data is correct
  39412. */
  39413. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39414. /**
  39415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39416. * Be aware Math.random() could cause collisions, but:
  39417. * "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"
  39418. * @returns a pseudo random id
  39419. */
  39420. static RandomId(): string;
  39421. /**
  39422. * Test if the given uri is a base64 string
  39423. * @param uri The uri to test
  39424. * @return True if the uri is a base64 string or false otherwise
  39425. */
  39426. static IsBase64(uri: string): boolean;
  39427. /**
  39428. * Decode the given base64 uri.
  39429. * @param uri The uri to decode
  39430. * @return The decoded base64 data.
  39431. */
  39432. static DecodeBase64(uri: string): ArrayBuffer;
  39433. /**
  39434. * No log
  39435. */
  39436. static readonly NoneLogLevel: number;
  39437. /**
  39438. * Only message logs
  39439. */
  39440. static readonly MessageLogLevel: number;
  39441. /**
  39442. * Only warning logs
  39443. */
  39444. static readonly WarningLogLevel: number;
  39445. /**
  39446. * Only error logs
  39447. */
  39448. static readonly ErrorLogLevel: number;
  39449. /**
  39450. * All logs
  39451. */
  39452. static readonly AllLogLevel: number;
  39453. private static _LogCache;
  39454. /**
  39455. * Gets a value indicating the number of loading errors
  39456. * @ignorenaming
  39457. */
  39458. static errorsCount: number;
  39459. /**
  39460. * Callback called when a new log is added
  39461. */
  39462. static OnNewCacheEntry: (entry: string) => void;
  39463. private static _AddLogEntry;
  39464. private static _FormatMessage;
  39465. private static _LogDisabled;
  39466. private static _LogEnabled;
  39467. private static _WarnDisabled;
  39468. private static _WarnEnabled;
  39469. private static _ErrorDisabled;
  39470. private static _ErrorEnabled;
  39471. /**
  39472. * Log a message to the console
  39473. */
  39474. static Log: (message: string) => void;
  39475. /**
  39476. * Write a warning message to the console
  39477. */
  39478. static Warn: (message: string) => void;
  39479. /**
  39480. * Write an error message to the console
  39481. */
  39482. static Error: (message: string) => void;
  39483. /**
  39484. * Gets current log cache (list of logs)
  39485. */
  39486. static readonly LogCache: string;
  39487. /**
  39488. * Clears the log cache
  39489. */
  39490. static ClearLogCache(): void;
  39491. /**
  39492. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39493. */
  39494. static LogLevels: number;
  39495. /**
  39496. * Checks if the loaded document was accessed via `file:`-Protocol.
  39497. * @returns boolean
  39498. */
  39499. static IsFileURL(): boolean;
  39500. /**
  39501. * Checks if the window object exists
  39502. * @returns true if the window object exists
  39503. */
  39504. static IsWindowObjectExist(): boolean;
  39505. /**
  39506. * No performance log
  39507. */
  39508. static readonly PerformanceNoneLogLevel: number;
  39509. /**
  39510. * Use user marks to log performance
  39511. */
  39512. static readonly PerformanceUserMarkLogLevel: number;
  39513. /**
  39514. * Log performance to the console
  39515. */
  39516. static readonly PerformanceConsoleLogLevel: number;
  39517. private static _performance;
  39518. /**
  39519. * Sets the current performance log level
  39520. */
  39521. static PerformanceLogLevel: number;
  39522. private static _StartPerformanceCounterDisabled;
  39523. private static _EndPerformanceCounterDisabled;
  39524. private static _StartUserMark;
  39525. private static _EndUserMark;
  39526. private static _StartPerformanceConsole;
  39527. private static _EndPerformanceConsole;
  39528. /**
  39529. * Starts a performance counter
  39530. */
  39531. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39532. /**
  39533. * Ends a specific performance coutner
  39534. */
  39535. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39536. /**
  39537. * Gets either window.performance.now() if supported or Date.now() else
  39538. */
  39539. static readonly Now: number;
  39540. /**
  39541. * This method will return the name of the class used to create the instance of the given object.
  39542. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39543. * @param object the object to get the class name from
  39544. * @param isType defines if the object is actually a type
  39545. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39546. */
  39547. static GetClassName(object: any, isType?: boolean): string;
  39548. /**
  39549. * Gets the first element of an array satisfying a given predicate
  39550. * @param array defines the array to browse
  39551. * @param predicate defines the predicate to use
  39552. * @returns null if not found or the element
  39553. */
  39554. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39555. /**
  39556. * This method will return the name of the full name of the class, including its owning module (if any).
  39557. * 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).
  39558. * @param object the object to get the class name from
  39559. * @param isType defines if the object is actually a type
  39560. * @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.
  39561. * @ignorenaming
  39562. */
  39563. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39564. /**
  39565. * Returns a promise that resolves after the given amount of time.
  39566. * @param delay Number of milliseconds to delay
  39567. * @returns Promise that resolves after the given amount of time
  39568. */
  39569. static DelayAsync(delay: number): Promise<void>;
  39570. /**
  39571. * Gets the current gradient from an array of IValueGradient
  39572. * @param ratio defines the current ratio to get
  39573. * @param gradients defines the array of IValueGradient
  39574. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39575. */
  39576. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39577. }
  39578. /**
  39579. * This class is used to track a performance counter which is number based.
  39580. * The user has access to many properties which give statistics of different nature.
  39581. *
  39582. * The implementer can track two kinds of Performance Counter: time and count.
  39583. * 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.
  39584. * 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.
  39585. */
  39586. class PerfCounter {
  39587. /**
  39588. * Gets or sets a global boolean to turn on and off all the counters
  39589. */
  39590. static Enabled: boolean;
  39591. /**
  39592. * Returns the smallest value ever
  39593. */
  39594. readonly min: number;
  39595. /**
  39596. * Returns the biggest value ever
  39597. */
  39598. readonly max: number;
  39599. /**
  39600. * Returns the average value since the performance counter is running
  39601. */
  39602. readonly average: number;
  39603. /**
  39604. * Returns the average value of the last second the counter was monitored
  39605. */
  39606. readonly lastSecAverage: number;
  39607. /**
  39608. * Returns the current value
  39609. */
  39610. readonly current: number;
  39611. /**
  39612. * Gets the accumulated total
  39613. */
  39614. readonly total: number;
  39615. /**
  39616. * Gets the total value count
  39617. */
  39618. readonly count: number;
  39619. /**
  39620. * Creates a new counter
  39621. */
  39622. constructor();
  39623. /**
  39624. * Call this method to start monitoring a new frame.
  39625. * 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.
  39626. */
  39627. fetchNewFrame(): void;
  39628. /**
  39629. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39630. * @param newCount the count value to add to the monitored count
  39631. * @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.
  39632. */
  39633. addCount(newCount: number, fetchResult: boolean): void;
  39634. /**
  39635. * Start monitoring this performance counter
  39636. */
  39637. beginMonitoring(): void;
  39638. /**
  39639. * Compute the time lapsed since the previous beginMonitoring() call.
  39640. * @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
  39641. */
  39642. endMonitoring(newFrame?: boolean): void;
  39643. private _fetchResult;
  39644. private _startMonitoringTime;
  39645. private _min;
  39646. private _max;
  39647. private _average;
  39648. private _current;
  39649. private _totalValueCount;
  39650. private _totalAccumulated;
  39651. private _lastSecAverage;
  39652. private _lastSecAccumulated;
  39653. private _lastSecTime;
  39654. private _lastSecValueCount;
  39655. }
  39656. /**
  39657. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39658. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39659. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39660. * @param name The name of the class, case should be preserved
  39661. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39662. */
  39663. function className(name: string, module?: string): (target: Object) => void;
  39664. /**
  39665. * An implementation of a loop for asynchronous functions.
  39666. */
  39667. class AsyncLoop {
  39668. /**
  39669. * Defines the number of iterations for the loop
  39670. */
  39671. iterations: number;
  39672. /**
  39673. * Defines the current index of the loop.
  39674. */
  39675. index: number;
  39676. private _done;
  39677. private _fn;
  39678. private _successCallback;
  39679. /**
  39680. * Constructor.
  39681. * @param iterations the number of iterations.
  39682. * @param func the function to run each iteration
  39683. * @param successCallback the callback that will be called upon succesful execution
  39684. * @param offset starting offset.
  39685. */
  39686. constructor(
  39687. /**
  39688. * Defines the number of iterations for the loop
  39689. */
  39690. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39691. /**
  39692. * Execute the next iteration. Must be called after the last iteration was finished.
  39693. */
  39694. executeNext(): void;
  39695. /**
  39696. * Break the loop and run the success callback.
  39697. */
  39698. breakLoop(): void;
  39699. /**
  39700. * Create and run an async loop.
  39701. * @param iterations the number of iterations.
  39702. * @param fn the function to run each iteration
  39703. * @param successCallback the callback that will be called upon succesful execution
  39704. * @param offset starting offset.
  39705. * @returns the created async loop object
  39706. */
  39707. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39708. /**
  39709. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39710. * @param iterations total number of iterations
  39711. * @param syncedIterations number of synchronous iterations in each async iteration.
  39712. * @param fn the function to call each iteration.
  39713. * @param callback a success call back that will be called when iterating stops.
  39714. * @param breakFunction a break condition (optional)
  39715. * @param timeout timeout settings for the setTimeout function. default - 0.
  39716. * @returns the created async loop object
  39717. */
  39718. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39719. }
  39720. }
  39721. interface HTMLCanvasElement {
  39722. /** Track wether a record is in progress */
  39723. isRecording: boolean;
  39724. /** Capture Stream method defined by some browsers */
  39725. captureStream(fps?: number): MediaStream;
  39726. }
  39727. interface MediaRecorder {
  39728. /** Starts recording */
  39729. start(timeSlice: number): void;
  39730. /** Stops recording */
  39731. stop(): void;
  39732. /** Event raised when an error arised. */
  39733. onerror: (event: ErrorEvent) => void;
  39734. /** Event raised when the recording stops. */
  39735. onstop: (event: Event) => void;
  39736. /** Event raised when a new chunk of data is available and should be tracked. */
  39737. ondataavailable: (event: Event) => void;
  39738. }
  39739. interface MediaRecorderOptions {
  39740. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39741. mimeType?: string;
  39742. /** The chosen bitrate for the audio component of the media. */
  39743. audioBitsPerSecond?: number;
  39744. /** The chosen bitrate for the video component of the media. */
  39745. videoBitsPerSecond?: number;
  39746. /** 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. */
  39747. bitsPerSecond?: number;
  39748. }
  39749. interface MediaRecorderConstructor {
  39750. /**
  39751. * A reference to the prototype.
  39752. */
  39753. readonly prototype: MediaRecorder;
  39754. /**
  39755. * Creates a new MediaRecorder.
  39756. * @param stream Defines the stream to record.
  39757. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39758. */
  39759. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39760. }
  39761. /**
  39762. * MediaRecoreder object available in some browsers.
  39763. */
  39764. declare var MediaRecorder: MediaRecorderConstructor;
  39765. declare module BABYLON {
  39766. /**
  39767. * This represents the different options avilable for the video capture.
  39768. */
  39769. interface VideoRecorderOptions {
  39770. /** Defines the mime type of the video */
  39771. mimeType: string;
  39772. /** Defines the video the video should be recorded at */
  39773. fps: number;
  39774. /** Defines the chunk size for the recording data */
  39775. recordChunckSize: number;
  39776. }
  39777. /**
  39778. * This can helps recording videos from BabylonJS.
  39779. * This is based on the available WebRTC functionalities of the browser.
  39780. *
  39781. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39782. */
  39783. class VideoRecorder {
  39784. private static readonly _defaultOptions;
  39785. /**
  39786. * Returns wehther or not the VideoRecorder is available in your browser.
  39787. * @param engine Defines the Babylon Engine to check the support for
  39788. * @returns true if supported otherwise false
  39789. */
  39790. static IsSupported(engine: Engine): boolean;
  39791. private readonly _options;
  39792. private _canvas;
  39793. private _mediaRecorder;
  39794. private _recordedChunks;
  39795. private _fileName;
  39796. private _resolve;
  39797. private _reject;
  39798. /**
  39799. * True wether a recording is already in progress.
  39800. */
  39801. readonly isRecording: boolean;
  39802. /**
  39803. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39804. * a video file.
  39805. * @param engine Defines the BabylonJS Engine you wish to record
  39806. * @param options Defines options that can be used to customized the capture
  39807. */
  39808. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39809. /**
  39810. * Stops the current recording before the default capture timeout passed in the startRecording
  39811. * functions.
  39812. */
  39813. stopRecording(): void;
  39814. /**
  39815. * Starts recording the canvas for a max duration specified in parameters.
  39816. * @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.
  39817. * @param maxDuration Defines the maximum recording time in seconds.
  39818. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39819. * @return a promise callback at the end of the recording with the video data in Blob.
  39820. */
  39821. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39822. /**
  39823. * Releases internal resources used during the recording.
  39824. */
  39825. dispose(): void;
  39826. private _handleDataAvailable;
  39827. private _handleError;
  39828. private _handleStop;
  39829. }
  39830. }
  39831. declare module BABYLON {
  39832. /**
  39833. * Defines the potential axis of a Joystick
  39834. */
  39835. enum JoystickAxis {
  39836. /** X axis */
  39837. X = 0,
  39838. /** Y axis */
  39839. Y = 1,
  39840. /** Z axis */
  39841. Z = 2
  39842. }
  39843. /**
  39844. * Class used to define virtual joystick (used in touch mode)
  39845. */
  39846. class VirtualJoystick {
  39847. /**
  39848. * Gets or sets a boolean indicating that left and right values must be inverted
  39849. */
  39850. reverseLeftRight: boolean;
  39851. /**
  39852. * Gets or sets a boolean indicating that up and down values must be inverted
  39853. */
  39854. reverseUpDown: boolean;
  39855. /**
  39856. * Gets the offset value for the position (ie. the change of the position value)
  39857. */
  39858. deltaPosition: Vector3;
  39859. /**
  39860. * Gets a boolean indicating if the virtual joystick was pressed
  39861. */
  39862. pressed: boolean;
  39863. private static _globalJoystickIndex;
  39864. private static vjCanvas;
  39865. private static vjCanvasContext;
  39866. private static vjCanvasWidth;
  39867. private static vjCanvasHeight;
  39868. private static halfWidth;
  39869. private _action;
  39870. private _axisTargetedByLeftAndRight;
  39871. private _axisTargetedByUpAndDown;
  39872. private _joystickSensibility;
  39873. private _inversedSensibility;
  39874. private _joystickPointerID;
  39875. private _joystickColor;
  39876. private _joystickPointerPos;
  39877. private _joystickPreviousPointerPos;
  39878. private _joystickPointerStartPos;
  39879. private _deltaJoystickVector;
  39880. private _leftJoystick;
  39881. private _touches;
  39882. private _onPointerDownHandlerRef;
  39883. private _onPointerMoveHandlerRef;
  39884. private _onPointerUpHandlerRef;
  39885. private _onResize;
  39886. /**
  39887. * Creates a new virtual joystick
  39888. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39889. */
  39890. constructor(leftJoystick?: boolean);
  39891. /**
  39892. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39893. * @param newJoystickSensibility defines the new sensibility
  39894. */
  39895. setJoystickSensibility(newJoystickSensibility: number): void;
  39896. private _onPointerDown;
  39897. private _onPointerMove;
  39898. private _onPointerUp;
  39899. /**
  39900. * Change the color of the virtual joystick
  39901. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39902. */
  39903. setJoystickColor(newColor: string): void;
  39904. /**
  39905. * Defines a callback to call when the joystick is touched
  39906. * @param action defines the callback
  39907. */
  39908. setActionOnTouch(action: () => any): void;
  39909. /**
  39910. * Defines which axis you'd like to control for left & right
  39911. * @param axis defines the axis to use
  39912. */
  39913. setAxisForLeftRight(axis: JoystickAxis): void;
  39914. /**
  39915. * Defines which axis you'd like to control for up & down
  39916. * @param axis defines the axis to use
  39917. */
  39918. setAxisForUpDown(axis: JoystickAxis): void;
  39919. private _drawVirtualJoystick;
  39920. /**
  39921. * Release internal HTML canvas
  39922. */
  39923. releaseCanvas(): void;
  39924. }
  39925. }
  39926. declare module BABYLON {
  39927. /**
  39928. * Helper class to push actions to a pool of workers.
  39929. */
  39930. class WorkerPool implements IDisposable {
  39931. private _workerInfos;
  39932. private _pendingActions;
  39933. /**
  39934. * Constructor
  39935. * @param workers Array of workers to use for actions
  39936. */
  39937. constructor(workers: Array<Worker>);
  39938. /**
  39939. * Terminates all workers and clears any pending actions.
  39940. */
  39941. dispose(): void;
  39942. /**
  39943. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39944. * pended until a worker has completed its action.
  39945. * @param action The action to perform. Call onComplete when the action is complete.
  39946. */
  39947. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39948. private _execute;
  39949. }
  39950. }
  39951. declare module BABYLON {
  39952. /**
  39953. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39955. */
  39956. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39957. /**
  39958. * Gets the name of the behavior.
  39959. */
  39960. readonly name: string;
  39961. private _zoomStopsAnimation;
  39962. private _idleRotationSpeed;
  39963. private _idleRotationWaitTime;
  39964. private _idleRotationSpinupTime;
  39965. /**
  39966. * Sets the flag that indicates if user zooming should stop animation.
  39967. */
  39968. /**
  39969. * Gets the flag that indicates if user zooming should stop animation.
  39970. */
  39971. zoomStopsAnimation: boolean;
  39972. /**
  39973. * Sets the default speed at which the camera rotates around the model.
  39974. */
  39975. /**
  39976. * Gets the default speed at which the camera rotates around the model.
  39977. */
  39978. idleRotationSpeed: number;
  39979. /**
  39980. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39981. */
  39982. /**
  39983. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39984. */
  39985. idleRotationWaitTime: number;
  39986. /**
  39987. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39988. */
  39989. /**
  39990. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39991. */
  39992. idleRotationSpinupTime: number;
  39993. /**
  39994. * Gets a value indicating if the camera is currently rotating because of this behavior
  39995. */
  39996. readonly rotationInProgress: boolean;
  39997. private _onPrePointerObservableObserver;
  39998. private _onAfterCheckInputsObserver;
  39999. private _attachedCamera;
  40000. private _isPointerDown;
  40001. private _lastFrameTime;
  40002. private _lastInteractionTime;
  40003. private _cameraRotationSpeed;
  40004. /**
  40005. * Initializes the behavior.
  40006. */
  40007. init(): void;
  40008. /**
  40009. * Attaches the behavior to its arc rotate camera.
  40010. * @param camera Defines the camera to attach the behavior to
  40011. */
  40012. attach(camera: ArcRotateCamera): void;
  40013. /**
  40014. * Detaches the behavior from its current arc rotate camera.
  40015. */
  40016. detach(): void;
  40017. /**
  40018. * Returns true if user is scrolling.
  40019. * @return true if user is scrolling.
  40020. */
  40021. private _userIsZooming;
  40022. private _lastFrameRadius;
  40023. private _shouldAnimationStopForInteraction;
  40024. /**
  40025. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40026. */
  40027. private _applyUserInteraction;
  40028. private _userIsMoving;
  40029. }
  40030. }
  40031. declare module BABYLON {
  40032. /**
  40033. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40034. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40035. */
  40036. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40037. /**
  40038. * Gets the name of the behavior.
  40039. */
  40040. readonly name: string;
  40041. /**
  40042. * The easing function used by animations
  40043. */
  40044. static EasingFunction: BackEase;
  40045. /**
  40046. * The easing mode used by animations
  40047. */
  40048. static EasingMode: number;
  40049. /**
  40050. * The duration of the animation, in milliseconds
  40051. */
  40052. transitionDuration: number;
  40053. /**
  40054. * Length of the distance animated by the transition when lower radius is reached
  40055. */
  40056. lowerRadiusTransitionRange: number;
  40057. /**
  40058. * Length of the distance animated by the transition when upper radius is reached
  40059. */
  40060. upperRadiusTransitionRange: number;
  40061. private _autoTransitionRange;
  40062. /**
  40063. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40064. */
  40065. /**
  40066. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40067. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40068. */
  40069. autoTransitionRange: boolean;
  40070. private _attachedCamera;
  40071. private _onAfterCheckInputsObserver;
  40072. private _onMeshTargetChangedObserver;
  40073. /**
  40074. * Initializes the behavior.
  40075. */
  40076. init(): void;
  40077. /**
  40078. * Attaches the behavior to its arc rotate camera.
  40079. * @param camera Defines the camera to attach the behavior to
  40080. */
  40081. attach(camera: ArcRotateCamera): void;
  40082. /**
  40083. * Detaches the behavior from its current arc rotate camera.
  40084. */
  40085. detach(): void;
  40086. private _radiusIsAnimating;
  40087. private _radiusBounceTransition;
  40088. private _animatables;
  40089. private _cachedWheelPrecision;
  40090. /**
  40091. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40092. * @param radiusLimit The limit to check against.
  40093. * @return Bool to indicate if at limit.
  40094. */
  40095. private _isRadiusAtLimit;
  40096. /**
  40097. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40098. * @param radiusDelta The delta by which to animate to. Can be negative.
  40099. */
  40100. private _applyBoundRadiusAnimation;
  40101. /**
  40102. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40103. */
  40104. protected _clearAnimationLocks(): void;
  40105. /**
  40106. * Stops and removes all animations that have been applied to the camera
  40107. */
  40108. stopAllAnimations(): void;
  40109. }
  40110. }
  40111. declare module BABYLON {
  40112. /**
  40113. * 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.
  40114. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40115. */
  40116. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40117. /**
  40118. * Gets the name of the behavior.
  40119. */
  40120. readonly name: string;
  40121. private _mode;
  40122. private _radiusScale;
  40123. private _positionScale;
  40124. private _defaultElevation;
  40125. private _elevationReturnTime;
  40126. private _elevationReturnWaitTime;
  40127. private _zoomStopsAnimation;
  40128. private _framingTime;
  40129. /**
  40130. * The easing function used by animations
  40131. */
  40132. static EasingFunction: ExponentialEase;
  40133. /**
  40134. * The easing mode used by animations
  40135. */
  40136. static EasingMode: number;
  40137. /**
  40138. * Sets the current mode used by the behavior
  40139. */
  40140. /**
  40141. * Gets current mode used by the behavior.
  40142. */
  40143. mode: number;
  40144. /**
  40145. * Sets the scale applied to the radius (1 by default)
  40146. */
  40147. /**
  40148. * Gets the scale applied to the radius
  40149. */
  40150. radiusScale: number;
  40151. /**
  40152. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40153. */
  40154. /**
  40155. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40156. */
  40157. positionScale: number;
  40158. /**
  40159. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40160. * behaviour is triggered, in radians.
  40161. */
  40162. /**
  40163. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40164. * behaviour is triggered, in radians.
  40165. */
  40166. defaultElevation: number;
  40167. /**
  40168. * Sets the time (in milliseconds) taken to return to the default beta position.
  40169. * Negative value indicates camera should not return to default.
  40170. */
  40171. /**
  40172. * Gets the time (in milliseconds) taken to return to the default beta position.
  40173. * Negative value indicates camera should not return to default.
  40174. */
  40175. elevationReturnTime: number;
  40176. /**
  40177. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40178. */
  40179. /**
  40180. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40181. */
  40182. elevationReturnWaitTime: number;
  40183. /**
  40184. * Sets the flag that indicates if user zooming should stop animation.
  40185. */
  40186. /**
  40187. * Gets the flag that indicates if user zooming should stop animation.
  40188. */
  40189. zoomStopsAnimation: boolean;
  40190. /**
  40191. * Sets the transition time when framing the mesh, in milliseconds
  40192. */
  40193. /**
  40194. * Gets the transition time when framing the mesh, in milliseconds
  40195. */
  40196. framingTime: number;
  40197. /**
  40198. * Define if the behavior should automatically change the configured
  40199. * camera limits and sensibilities.
  40200. */
  40201. autoCorrectCameraLimitsAndSensibility: boolean;
  40202. private _onPrePointerObservableObserver;
  40203. private _onAfterCheckInputsObserver;
  40204. private _onMeshTargetChangedObserver;
  40205. private _attachedCamera;
  40206. private _isPointerDown;
  40207. private _lastInteractionTime;
  40208. /**
  40209. * Initializes the behavior.
  40210. */
  40211. init(): void;
  40212. /**
  40213. * Attaches the behavior to its arc rotate camera.
  40214. * @param camera Defines the camera to attach the behavior to
  40215. */
  40216. attach(camera: ArcRotateCamera): void;
  40217. /**
  40218. * Detaches the behavior from its current arc rotate camera.
  40219. */
  40220. detach(): void;
  40221. private _animatables;
  40222. private _betaIsAnimating;
  40223. private _betaTransition;
  40224. private _radiusTransition;
  40225. private _vectorTransition;
  40226. /**
  40227. * Targets the given mesh and updates zoom level accordingly.
  40228. * @param mesh The mesh to target.
  40229. * @param radius Optional. If a cached radius position already exists, overrides default.
  40230. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40231. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40232. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40233. */
  40234. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40235. /**
  40236. * Targets the given mesh with its children and updates zoom level accordingly.
  40237. * @param mesh The mesh to target.
  40238. * @param radius Optional. If a cached radius position already exists, overrides default.
  40239. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40240. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40241. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40242. */
  40243. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40244. /**
  40245. * Targets the given meshes with their children and updates zoom level accordingly.
  40246. * @param meshes The mesh to target.
  40247. * @param radius Optional. If a cached radius position already exists, overrides default.
  40248. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40249. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40250. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40251. */
  40252. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40253. /**
  40254. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40255. * @param minimumWorld Determines the smaller position of the bounding box extend
  40256. * @param maximumWorld Determines the bigger position of the bounding box extend
  40257. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40258. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40259. */
  40260. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40261. /**
  40262. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40263. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40264. * frustum width.
  40265. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40266. * to fully enclose the mesh in the viewing frustum.
  40267. */
  40268. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40269. /**
  40270. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40271. * is automatically returned to its default position (expected to be above ground plane).
  40272. */
  40273. private _maintainCameraAboveGround;
  40274. /**
  40275. * Returns the frustum slope based on the canvas ratio and camera FOV
  40276. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40277. */
  40278. private _getFrustumSlope;
  40279. /**
  40280. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40281. */
  40282. private _clearAnimationLocks;
  40283. /**
  40284. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40285. */
  40286. private _applyUserInteraction;
  40287. /**
  40288. * Stops and removes all animations that have been applied to the camera
  40289. */
  40290. stopAllAnimations(): void;
  40291. /**
  40292. * Gets a value indicating if the user is moving the camera
  40293. */
  40294. readonly isUserIsMoving: boolean;
  40295. /**
  40296. * The camera can move all the way towards the mesh.
  40297. */
  40298. static IgnoreBoundsSizeMode: number;
  40299. /**
  40300. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40301. */
  40302. static FitFrustumSidesMode: number;
  40303. }
  40304. }
  40305. declare module BABYLON {
  40306. /**
  40307. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40308. */
  40309. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40310. private ui;
  40311. /**
  40312. * The name of the behavior
  40313. */
  40314. name: string;
  40315. /**
  40316. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40317. */
  40318. distanceAwayFromFace: number;
  40319. /**
  40320. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40321. */
  40322. distanceAwayFromBottomOfFace: number;
  40323. private _faceVectors;
  40324. private _target;
  40325. private _scene;
  40326. private _onRenderObserver;
  40327. private _tmpMatrix;
  40328. private _tmpVector;
  40329. /**
  40330. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40331. * @param ui The transform node that should be attched to the mesh
  40332. */
  40333. constructor(ui: BABYLON.TransformNode);
  40334. /**
  40335. * Initializes the behavior
  40336. */
  40337. init(): void;
  40338. private _closestFace;
  40339. private _zeroVector;
  40340. private _lookAtTmpMatrix;
  40341. private _lookAtToRef;
  40342. /**
  40343. * Attaches the AttachToBoxBehavior to the passed in mesh
  40344. * @param target The mesh that the specified node will be attached to
  40345. */
  40346. attach(target: BABYLON.Mesh): void;
  40347. /**
  40348. * Detaches the behavior from the mesh
  40349. */
  40350. detach(): void;
  40351. }
  40352. }
  40353. declare module BABYLON {
  40354. /**
  40355. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40356. */
  40357. class FadeInOutBehavior implements Behavior<Mesh> {
  40358. /**
  40359. * Time in milliseconds to delay before fading in (Default: 0)
  40360. */
  40361. delay: number;
  40362. /**
  40363. * Time in milliseconds for the mesh to fade in (Default: 300)
  40364. */
  40365. fadeInTime: number;
  40366. private _millisecondsPerFrame;
  40367. private _hovered;
  40368. private _hoverValue;
  40369. private _ownerNode;
  40370. /**
  40371. * Instatiates the FadeInOutBehavior
  40372. */
  40373. constructor();
  40374. /**
  40375. * The name of the behavior
  40376. */
  40377. readonly name: string;
  40378. /**
  40379. * Initializes the behavior
  40380. */
  40381. init(): void;
  40382. /**
  40383. * Attaches the fade behavior on the passed in mesh
  40384. * @param ownerNode The mesh that will be faded in/out once attached
  40385. */
  40386. attach(ownerNode: Mesh): void;
  40387. /**
  40388. * Detaches the behavior from the mesh
  40389. */
  40390. detach(): void;
  40391. /**
  40392. * Triggers the mesh to begin fading in or out
  40393. * @param value if the object should fade in or out (true to fade in)
  40394. */
  40395. fadeIn(value: boolean): void;
  40396. private _update;
  40397. private _setAllVisibility;
  40398. }
  40399. }
  40400. declare module BABYLON {
  40401. /**
  40402. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40403. */
  40404. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40405. private _dragBehaviorA;
  40406. private _dragBehaviorB;
  40407. private _startDistance;
  40408. private _initialScale;
  40409. private _targetScale;
  40410. private _ownerNode;
  40411. private _sceneRenderObserver;
  40412. /**
  40413. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40414. */
  40415. constructor();
  40416. /**
  40417. * The name of the behavior
  40418. */
  40419. readonly name: string;
  40420. /**
  40421. * Initializes the behavior
  40422. */
  40423. init(): void;
  40424. private _getCurrentDistance;
  40425. /**
  40426. * Attaches the scale behavior the passed in mesh
  40427. * @param ownerNode The mesh that will be scaled around once attached
  40428. */
  40429. attach(ownerNode: Mesh): void;
  40430. /**
  40431. * Detaches the behavior from the mesh
  40432. */
  40433. detach(): void;
  40434. }
  40435. }
  40436. declare module BABYLON {
  40437. /**
  40438. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40439. */
  40440. class PointerDragBehavior implements Behavior<Mesh> {
  40441. private static _AnyMouseID;
  40442. private _attachedNode;
  40443. private _dragPlane;
  40444. private _scene;
  40445. private _pointerObserver;
  40446. private _beforeRenderObserver;
  40447. private static _planeScene;
  40448. /**
  40449. * 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)
  40450. */
  40451. maxDragAngle: number;
  40452. /**
  40453. * @hidden
  40454. */
  40455. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40456. /**
  40457. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40458. */
  40459. currentDraggingPointerID: number;
  40460. /**
  40461. * The last position where the pointer hit the drag plane in world space
  40462. */
  40463. lastDragPosition: Vector3;
  40464. /**
  40465. * If the behavior is currently in a dragging state
  40466. */
  40467. dragging: boolean;
  40468. /**
  40469. * 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)
  40470. */
  40471. dragDeltaRatio: number;
  40472. /**
  40473. * If the drag plane orientation should be updated during the dragging (Default: true)
  40474. */
  40475. updateDragPlane: boolean;
  40476. private _debugMode;
  40477. private _moving;
  40478. /**
  40479. * Fires each time the attached mesh is dragged with the pointer
  40480. * * delta between last drag position and current drag position in world space
  40481. * * dragDistance along the drag axis
  40482. * * dragPlaneNormal normal of the current drag plane used during the drag
  40483. * * dragPlanePoint in world space where the drag intersects the drag plane
  40484. */
  40485. onDragObservable: Observable<{
  40486. delta: Vector3;
  40487. dragPlanePoint: Vector3;
  40488. dragPlaneNormal: Vector3;
  40489. dragDistance: number;
  40490. pointerId: number;
  40491. }>;
  40492. /**
  40493. * Fires each time a drag begins (eg. mouse down on mesh)
  40494. */
  40495. onDragStartObservable: Observable<{
  40496. dragPlanePoint: Vector3;
  40497. pointerId: number;
  40498. }>;
  40499. /**
  40500. * Fires each time a drag ends (eg. mouse release after drag)
  40501. */
  40502. onDragEndObservable: Observable<{
  40503. dragPlanePoint: Vector3;
  40504. pointerId: number;
  40505. }>;
  40506. /**
  40507. * If the attached mesh should be moved when dragged
  40508. */
  40509. moveAttached: boolean;
  40510. /**
  40511. * If the drag behavior will react to drag events (Default: true)
  40512. */
  40513. enabled: boolean;
  40514. /**
  40515. * If camera controls should be detached during the drag
  40516. */
  40517. detachCameraControls: boolean;
  40518. /**
  40519. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40520. */
  40521. useObjectOrienationForDragging: boolean;
  40522. private _options;
  40523. /**
  40524. * Creates a pointer drag behavior that can be attached to a mesh
  40525. * @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)
  40526. */
  40527. constructor(options?: {
  40528. dragAxis?: Vector3;
  40529. dragPlaneNormal?: Vector3;
  40530. });
  40531. /**
  40532. * The name of the behavior
  40533. */
  40534. readonly name: string;
  40535. /**
  40536. * Initializes the behavior
  40537. */
  40538. init(): void;
  40539. private _tmpVector;
  40540. private _alternatePickedPoint;
  40541. private _worldDragAxis;
  40542. private _targetPosition;
  40543. private _attachedElement;
  40544. /**
  40545. * Attaches the drag behavior the passed in mesh
  40546. * @param ownerNode The mesh that will be dragged around once attached
  40547. */
  40548. attach(ownerNode: Mesh): void;
  40549. /**
  40550. * Force relase the drag action by code.
  40551. */
  40552. releaseDrag(): void;
  40553. private _startDragRay;
  40554. private _lastPointerRay;
  40555. /**
  40556. * Simulates the start of a pointer drag event on the behavior
  40557. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40558. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40559. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40560. */
  40561. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40562. private _startDrag;
  40563. private _dragDelta;
  40564. private _moveDrag;
  40565. private _pickWithRayOnDragPlane;
  40566. private _pointA;
  40567. private _pointB;
  40568. private _pointC;
  40569. private _lineA;
  40570. private _lineB;
  40571. private _localAxis;
  40572. private _lookAt;
  40573. private _updateDragPlanePosition;
  40574. /**
  40575. * Detaches the behavior from the mesh
  40576. */
  40577. detach(): void;
  40578. }
  40579. }
  40580. declare module BABYLON {
  40581. /**
  40582. * 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
  40583. */
  40584. class SixDofDragBehavior implements Behavior<Mesh> {
  40585. private static _virtualScene;
  40586. private _ownerNode;
  40587. private _sceneRenderObserver;
  40588. private _scene;
  40589. private _targetPosition;
  40590. private _virtualOriginMesh;
  40591. private _virtualDragMesh;
  40592. private _pointerObserver;
  40593. private _moving;
  40594. private _startingOrientation;
  40595. /**
  40596. * 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)
  40597. */
  40598. private zDragFactor;
  40599. /**
  40600. * If the behavior is currently in a dragging state
  40601. */
  40602. dragging: boolean;
  40603. /**
  40604. * 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)
  40605. */
  40606. dragDeltaRatio: number;
  40607. /**
  40608. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40609. */
  40610. currentDraggingPointerID: number;
  40611. /**
  40612. * If camera controls should be detached during the drag
  40613. */
  40614. detachCameraControls: boolean;
  40615. /**
  40616. * Fires each time a drag starts
  40617. */
  40618. onDragStartObservable: Observable<{}>;
  40619. /**
  40620. * Fires each time a drag ends (eg. mouse release after drag)
  40621. */
  40622. onDragEndObservable: Observable<{}>;
  40623. /**
  40624. * 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
  40625. */
  40626. constructor();
  40627. /**
  40628. * The name of the behavior
  40629. */
  40630. readonly name: string;
  40631. /**
  40632. * Initializes the behavior
  40633. */
  40634. init(): void;
  40635. /**
  40636. * Attaches the scale behavior the passed in mesh
  40637. * @param ownerNode The mesh that will be scaled around once attached
  40638. */
  40639. attach(ownerNode: Mesh): void;
  40640. /**
  40641. * Detaches the behavior from the mesh
  40642. */
  40643. detach(): void;
  40644. }
  40645. }
  40646. declare module BABYLON {
  40647. /**
  40648. * Contains an array of blocks representing the octree
  40649. */
  40650. interface IOctreeContainer<T> {
  40651. /**
  40652. * Blocks within the octree
  40653. */
  40654. blocks: Array<OctreeBlock<T>>;
  40655. }
  40656. /**
  40657. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40658. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40659. */
  40660. class Octree<T> {
  40661. /** 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.) */
  40662. maxDepth: number;
  40663. /**
  40664. * Blocks within the octree containing objects
  40665. */
  40666. blocks: Array<OctreeBlock<T>>;
  40667. /**
  40668. * Content stored in the octree
  40669. */
  40670. dynamicContent: T[];
  40671. private _maxBlockCapacity;
  40672. private _selectionContent;
  40673. private _creationFunc;
  40674. /**
  40675. * Creates a octree
  40676. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40677. * @param creationFunc function to be used to instatiate the octree
  40678. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40679. * @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.)
  40680. */
  40681. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40682. /** 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.) */
  40683. maxDepth?: number);
  40684. /**
  40685. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40686. * @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);
  40687. * @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);
  40688. * @param entries meshes to be added to the octree blocks
  40689. */
  40690. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40691. /**
  40692. * Adds a mesh to the octree
  40693. * @param entry Mesh to add to the octree
  40694. */
  40695. addMesh(entry: T): void;
  40696. /**
  40697. * Selects an array of meshes within the frustum
  40698. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40699. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40700. * @returns array of meshes within the frustum
  40701. */
  40702. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40703. /**
  40704. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40705. * @param sphereCenter defines the bounding sphere center
  40706. * @param sphereRadius defines the bounding sphere radius
  40707. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40708. * @returns an array of objects that intersect the sphere
  40709. */
  40710. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40711. /**
  40712. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40713. * @param ray defines the ray to test with
  40714. * @returns array of intersected objects
  40715. */
  40716. intersectsRay(ray: Ray): SmartArray<T>;
  40717. /**
  40718. * @hidden
  40719. */
  40720. 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;
  40721. /**
  40722. * Adds a mesh into the octree block if it intersects the block
  40723. */
  40724. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40725. /**
  40726. * Adds a submesh into the octree block if it intersects the block
  40727. */
  40728. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40729. }
  40730. }
  40731. declare module BABYLON {
  40732. /**
  40733. * Class used to store a cell in an octree
  40734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40735. */
  40736. class OctreeBlock<T> {
  40737. /**
  40738. * Gets the content of the current block
  40739. */
  40740. entries: T[];
  40741. /**
  40742. * Gets the list of block children
  40743. */
  40744. blocks: Array<OctreeBlock<T>>;
  40745. private _depth;
  40746. private _maxDepth;
  40747. private _capacity;
  40748. private _minPoint;
  40749. private _maxPoint;
  40750. private _boundingVectors;
  40751. private _creationFunc;
  40752. /**
  40753. * Creates a new block
  40754. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40755. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40756. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40757. * @param depth defines the current depth of this block in the octree
  40758. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40759. * @param creationFunc defines a callback to call when an element is added to the block
  40760. */
  40761. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40762. /**
  40763. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40764. */
  40765. readonly capacity: number;
  40766. /**
  40767. * Gets the minimum vector (in world space) of the block's bounding box
  40768. */
  40769. readonly minPoint: Vector3;
  40770. /**
  40771. * Gets the maximum vector (in world space) of the block's bounding box
  40772. */
  40773. readonly maxPoint: Vector3;
  40774. /**
  40775. * Add a new element to this block
  40776. * @param entry defines the element to add
  40777. */
  40778. addEntry(entry: T): void;
  40779. /**
  40780. * Add an array of elements to this block
  40781. * @param entries defines the array of elements to add
  40782. */
  40783. addEntries(entries: T[]): void;
  40784. /**
  40785. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40786. * @param frustumPlanes defines the frustum planes to test
  40787. * @param selection defines the array to store current content if selection is positive
  40788. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40789. */
  40790. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40791. /**
  40792. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40793. * @param sphereCenter defines the bounding sphere center
  40794. * @param sphereRadius defines the bounding sphere radius
  40795. * @param selection defines the array to store current content if selection is positive
  40796. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40797. */
  40798. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40799. /**
  40800. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40801. * @param ray defines the ray to test with
  40802. * @param selection defines the array to store current content if selection is positive
  40803. */
  40804. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40805. /**
  40806. * Subdivide the content into child blocks (this block will then be empty)
  40807. */
  40808. createInnerBlocks(): void;
  40809. }
  40810. }
  40811. declare module BABYLON {
  40812. interface Scene {
  40813. /**
  40814. * @hidden
  40815. * Backing Filed
  40816. */
  40817. _selectionOctree: Octree<AbstractMesh>;
  40818. /**
  40819. * Gets the octree used to boost mesh selection (picking)
  40820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40821. */
  40822. selectionOctree: Octree<AbstractMesh>;
  40823. /**
  40824. * Creates or updates the octree used to boost selection (picking)
  40825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40826. * @param maxCapacity defines the maximum capacity per leaf
  40827. * @param maxDepth defines the maximum depth of the octree
  40828. * @returns an octree of AbstractMesh
  40829. */
  40830. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40831. }
  40832. interface AbstractMesh {
  40833. /**
  40834. * @hidden
  40835. * Backing Field
  40836. */
  40837. _submeshesOctree: Octree<SubMesh>;
  40838. /**
  40839. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40840. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40841. * @param maxCapacity defines the maximum size of each block (64 by default)
  40842. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40843. * @returns the new octree
  40844. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40846. */
  40847. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40848. }
  40849. /**
  40850. * Defines the octree scene component responsible to manage any octrees
  40851. * in a given scene.
  40852. */
  40853. class OctreeSceneComponent {
  40854. /**
  40855. * The component name helpfull to identify the component in the list of scene components.
  40856. */
  40857. readonly name: string;
  40858. /**
  40859. * The scene the component belongs to.
  40860. */
  40861. scene: Scene;
  40862. /**
  40863. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40864. */
  40865. readonly checksIsEnabled: boolean;
  40866. /**
  40867. * Creates a new instance of the component for the given scene
  40868. * @param scene Defines the scene to register the component in
  40869. */
  40870. constructor(scene: Scene);
  40871. /**
  40872. * Registers the component in a given scene
  40873. */
  40874. register(): void;
  40875. /**
  40876. * Return the list of active meshes
  40877. * @returns the list of active meshes
  40878. */
  40879. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40880. /**
  40881. * Return the list of active sub meshes
  40882. * @param mesh The mesh to get the candidates sub meshes from
  40883. * @returns the list of active sub meshes
  40884. */
  40885. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40886. private _tempRay;
  40887. /**
  40888. * Return the list of sub meshes intersecting with a given local ray
  40889. * @param mesh defines the mesh to find the submesh for
  40890. * @param localRay defines the ray in local space
  40891. * @returns the list of intersecting sub meshes
  40892. */
  40893. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40894. /**
  40895. * Return the list of sub meshes colliding with a collider
  40896. * @param mesh defines the mesh to find the submesh for
  40897. * @param collider defines the collider to evaluate the collision against
  40898. * @returns the list of colliding sub meshes
  40899. */
  40900. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40901. /**
  40902. * Rebuilds the elements related to this component in case of
  40903. * context lost for instance.
  40904. */
  40905. rebuild(): void;
  40906. /**
  40907. * Disposes the component and the associated ressources.
  40908. */
  40909. dispose(): void;
  40910. }
  40911. }
  40912. declare module BABYLON {
  40913. /**
  40914. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40915. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40916. */
  40917. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40918. /**
  40919. * Creates a new AnaglyphArcRotateCamera
  40920. * @param name defines camera name
  40921. * @param alpha defines alpha angle (in radians)
  40922. * @param beta defines beta angle (in radians)
  40923. * @param radius defines radius
  40924. * @param target defines camera target
  40925. * @param interaxialDistance defines distance between each color axis
  40926. * @param scene defines the hosting scene
  40927. */
  40928. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40929. /**
  40930. * Gets camera class name
  40931. * @returns AnaglyphArcRotateCamera
  40932. */
  40933. getClassName(): string;
  40934. }
  40935. }
  40936. declare module BABYLON {
  40937. /**
  40938. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40939. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40940. */
  40941. class AnaglyphFreeCamera extends FreeCamera {
  40942. /**
  40943. * Creates a new AnaglyphFreeCamera
  40944. * @param name defines camera name
  40945. * @param position defines initial position
  40946. * @param interaxialDistance defines distance between each color axis
  40947. * @param scene defines the hosting scene
  40948. */
  40949. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40950. /**
  40951. * Gets camera class name
  40952. * @returns AnaglyphFreeCamera
  40953. */
  40954. getClassName(): string;
  40955. }
  40956. }
  40957. declare module BABYLON {
  40958. /**
  40959. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40960. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40961. */
  40962. class AnaglyphGamepadCamera extends GamepadCamera {
  40963. /**
  40964. * Creates a new AnaglyphGamepadCamera
  40965. * @param name defines camera name
  40966. * @param position defines initial position
  40967. * @param interaxialDistance defines distance between each color axis
  40968. * @param scene defines the hosting scene
  40969. */
  40970. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40971. /**
  40972. * Gets camera class name
  40973. * @returns AnaglyphGamepadCamera
  40974. */
  40975. getClassName(): string;
  40976. }
  40977. }
  40978. declare module BABYLON {
  40979. /**
  40980. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40981. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40982. */
  40983. class AnaglyphUniversalCamera extends UniversalCamera {
  40984. /**
  40985. * Creates a new AnaglyphUniversalCamera
  40986. * @param name defines camera name
  40987. * @param position defines initial position
  40988. * @param interaxialDistance defines distance between each color axis
  40989. * @param scene defines the hosting scene
  40990. */
  40991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40992. /**
  40993. * Gets camera class name
  40994. * @returns AnaglyphUniversalCamera
  40995. */
  40996. getClassName(): string;
  40997. }
  40998. }
  40999. declare module BABYLON {
  41000. /**
  41001. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41002. * @see http://doc.babylonjs.com/features/cameras
  41003. */
  41004. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41005. /**
  41006. * Creates a new StereoscopicArcRotateCamera
  41007. * @param name defines camera name
  41008. * @param alpha defines alpha angle (in radians)
  41009. * @param beta defines beta angle (in radians)
  41010. * @param radius defines radius
  41011. * @param target defines camera target
  41012. * @param interaxialDistance defines distance between each color axis
  41013. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41014. * @param scene defines the hosting scene
  41015. */
  41016. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41017. /**
  41018. * Gets camera class name
  41019. * @returns StereoscopicArcRotateCamera
  41020. */
  41021. getClassName(): string;
  41022. }
  41023. }
  41024. declare module BABYLON {
  41025. /**
  41026. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41027. * @see http://doc.babylonjs.com/features/cameras
  41028. */
  41029. class StereoscopicFreeCamera extends FreeCamera {
  41030. /**
  41031. * Creates a new StereoscopicFreeCamera
  41032. * @param name defines camera name
  41033. * @param position defines initial position
  41034. * @param interaxialDistance defines distance between each color axis
  41035. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41036. * @param scene defines the hosting scene
  41037. */
  41038. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41039. /**
  41040. * Gets camera class name
  41041. * @returns StereoscopicFreeCamera
  41042. */
  41043. getClassName(): string;
  41044. }
  41045. }
  41046. declare module BABYLON {
  41047. /**
  41048. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41049. * @see http://doc.babylonjs.com/features/cameras
  41050. */
  41051. class StereoscopicGamepadCamera extends GamepadCamera {
  41052. /**
  41053. * Creates a new StereoscopicGamepadCamera
  41054. * @param name defines camera name
  41055. * @param position defines initial position
  41056. * @param interaxialDistance defines distance between each color axis
  41057. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41058. * @param scene defines the hosting scene
  41059. */
  41060. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41061. /**
  41062. * Gets camera class name
  41063. * @returns StereoscopicGamepadCamera
  41064. */
  41065. getClassName(): string;
  41066. }
  41067. }
  41068. declare module BABYLON {
  41069. /**
  41070. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41071. * @see http://doc.babylonjs.com/features/cameras
  41072. */
  41073. class StereoscopicUniversalCamera extends UniversalCamera {
  41074. /**
  41075. * Creates a new StereoscopicUniversalCamera
  41076. * @param name defines camera name
  41077. * @param position defines initial position
  41078. * @param interaxialDistance defines distance between each color axis
  41079. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41080. * @param scene defines the hosting scene
  41081. */
  41082. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41083. /**
  41084. * Gets camera class name
  41085. * @returns StereoscopicUniversalCamera
  41086. */
  41087. getClassName(): string;
  41088. }
  41089. }
  41090. declare module BABYLON {
  41091. /**
  41092. * Manage the gamepad inputs to control an arc rotate camera.
  41093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41094. */
  41095. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41096. /**
  41097. * Defines the camera the input is attached to.
  41098. */
  41099. camera: ArcRotateCamera;
  41100. /**
  41101. * Defines the gamepad the input is gathering event from.
  41102. */
  41103. gamepad: Nullable<Gamepad>;
  41104. /**
  41105. * Defines the gamepad rotation sensiblity.
  41106. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41107. */
  41108. gamepadRotationSensibility: number;
  41109. /**
  41110. * Defines the gamepad move sensiblity.
  41111. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41112. */
  41113. gamepadMoveSensibility: number;
  41114. private _onGamepadConnectedObserver;
  41115. private _onGamepadDisconnectedObserver;
  41116. /**
  41117. * Attach the input controls to a specific dom element to get the input from.
  41118. * @param element Defines the element the controls should be listened from
  41119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41120. */
  41121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41122. /**
  41123. * Detach the current controls from the specified dom element.
  41124. * @param element Defines the element to stop listening the inputs from
  41125. */
  41126. detachControl(element: Nullable<HTMLElement>): void;
  41127. /**
  41128. * Update the current camera state depending on the inputs that have been used this frame.
  41129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41130. */
  41131. checkInputs(): void;
  41132. /**
  41133. * Gets the class name of the current intput.
  41134. * @returns the class name
  41135. */
  41136. getClassName(): string;
  41137. /**
  41138. * Get the friendly name associated with the input class.
  41139. * @returns the input friendly name
  41140. */
  41141. getSimpleName(): string;
  41142. }
  41143. }
  41144. declare module BABYLON {
  41145. /**
  41146. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41148. */
  41149. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41150. /**
  41151. * Defines the camera the input is attached to.
  41152. */
  41153. camera: ArcRotateCamera;
  41154. /**
  41155. * Defines the list of key codes associated with the up action (increase alpha)
  41156. */
  41157. keysUp: number[];
  41158. /**
  41159. * Defines the list of key codes associated with the down action (decrease alpha)
  41160. */
  41161. keysDown: number[];
  41162. /**
  41163. * Defines the list of key codes associated with the left action (increase beta)
  41164. */
  41165. keysLeft: number[];
  41166. /**
  41167. * Defines the list of key codes associated with the right action (decrease beta)
  41168. */
  41169. keysRight: number[];
  41170. /**
  41171. * Defines the list of key codes associated with the reset action.
  41172. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41173. */
  41174. keysReset: number[];
  41175. /**
  41176. * Defines the panning sensibility of the inputs.
  41177. * (How fast is the camera paning)
  41178. */
  41179. panningSensibility: number;
  41180. /**
  41181. * Defines the zooming sensibility of the inputs.
  41182. * (How fast is the camera zooming)
  41183. */
  41184. zoomingSensibility: number;
  41185. /**
  41186. * Defines wether maintaining the alt key down switch the movement mode from
  41187. * orientation to zoom.
  41188. */
  41189. useAltToZoom: boolean;
  41190. /**
  41191. * Rotation speed of the camera
  41192. */
  41193. angularSpeed: number;
  41194. private _keys;
  41195. private _ctrlPressed;
  41196. private _altPressed;
  41197. private _onCanvasBlurObserver;
  41198. private _onKeyboardObserver;
  41199. private _engine;
  41200. private _scene;
  41201. /**
  41202. * Attach the input controls to a specific dom element to get the input from.
  41203. * @param element Defines the element the controls should be listened from
  41204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41205. */
  41206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41207. /**
  41208. * Detach the current controls from the specified dom element.
  41209. * @param element Defines the element to stop listening the inputs from
  41210. */
  41211. detachControl(element: Nullable<HTMLElement>): void;
  41212. /**
  41213. * Update the current camera state depending on the inputs that have been used this frame.
  41214. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41215. */
  41216. checkInputs(): void;
  41217. /**
  41218. * Gets the class name of the current intput.
  41219. * @returns the class name
  41220. */
  41221. getClassName(): string;
  41222. /**
  41223. * Get the friendly name associated with the input class.
  41224. * @returns the input friendly name
  41225. */
  41226. getSimpleName(): string;
  41227. }
  41228. }
  41229. declare module BABYLON {
  41230. /**
  41231. * Manage the mouse wheel inputs to control an arc rotate camera.
  41232. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41233. */
  41234. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41235. /**
  41236. * Defines the camera the input is attached to.
  41237. */
  41238. camera: ArcRotateCamera;
  41239. /**
  41240. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41241. */
  41242. wheelPrecision: number;
  41243. /**
  41244. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41245. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41246. */
  41247. wheelDeltaPercentage: number;
  41248. private _wheel;
  41249. private _observer;
  41250. /**
  41251. * Attach the input controls to a specific dom element to get the input from.
  41252. * @param element Defines the element the controls should be listened from
  41253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41254. */
  41255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41256. /**
  41257. * Detach the current controls from the specified dom element.
  41258. * @param element Defines the element to stop listening the inputs from
  41259. */
  41260. detachControl(element: Nullable<HTMLElement>): void;
  41261. /**
  41262. * Gets the class name of the current intput.
  41263. * @returns the class name
  41264. */
  41265. getClassName(): string;
  41266. /**
  41267. * Get the friendly name associated with the input class.
  41268. * @returns the input friendly name
  41269. */
  41270. getSimpleName(): string;
  41271. }
  41272. }
  41273. declare module BABYLON {
  41274. /**
  41275. * Manage the pointers inputs to control an arc rotate camera.
  41276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41277. */
  41278. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41279. /**
  41280. * Defines the camera the input is attached to.
  41281. */
  41282. camera: ArcRotateCamera;
  41283. /**
  41284. * Defines the buttons associated with the input to handle camera move.
  41285. */
  41286. buttons: number[];
  41287. /**
  41288. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41289. */
  41290. angularSensibilityX: number;
  41291. /**
  41292. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41293. */
  41294. angularSensibilityY: number;
  41295. /**
  41296. * Defines the pointer pinch precision or how fast is the camera zooming.
  41297. */
  41298. pinchPrecision: number;
  41299. /**
  41300. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41301. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41302. */
  41303. pinchDeltaPercentage: number;
  41304. /**
  41305. * Defines the pointer panning sensibility or how fast is the camera moving.
  41306. */
  41307. panningSensibility: number;
  41308. /**
  41309. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41310. */
  41311. multiTouchPanning: boolean;
  41312. /**
  41313. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41314. */
  41315. multiTouchPanAndZoom: boolean;
  41316. /**
  41317. * Revers pinch action direction.
  41318. */
  41319. pinchInwards: boolean;
  41320. private _isPanClick;
  41321. private _pointerInput;
  41322. private _observer;
  41323. private _onMouseMove;
  41324. private _onGestureStart;
  41325. private _onGesture;
  41326. private _MSGestureHandler;
  41327. private _onLostFocus;
  41328. private _onContextMenu;
  41329. /**
  41330. * Attach the input controls to a specific dom element to get the input from.
  41331. * @param element Defines the element the controls should be listened from
  41332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41333. */
  41334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41335. /**
  41336. * Detach the current controls from the specified dom element.
  41337. * @param element Defines the element to stop listening the inputs from
  41338. */
  41339. detachControl(element: Nullable<HTMLElement>): void;
  41340. /**
  41341. * Gets the class name of the current intput.
  41342. * @returns the class name
  41343. */
  41344. getClassName(): string;
  41345. /**
  41346. * Get the friendly name associated with the input class.
  41347. * @returns the input friendly name
  41348. */
  41349. getSimpleName(): string;
  41350. }
  41351. }
  41352. declare module BABYLON {
  41353. /**
  41354. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41356. */
  41357. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41358. /**
  41359. * Defines the camera the input is attached to.
  41360. */
  41361. camera: ArcRotateCamera;
  41362. /**
  41363. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41364. */
  41365. alphaCorrection: number;
  41366. /**
  41367. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  41368. */
  41369. betaCorrection: number;
  41370. /**
  41371. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41372. */
  41373. gammaCorrection: number;
  41374. private _alpha;
  41375. private _gamma;
  41376. private _dirty;
  41377. private _deviceOrientationHandler;
  41378. /**
  41379. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41380. */
  41381. constructor();
  41382. /**
  41383. * Attach the input controls to a specific dom element to get the input from.
  41384. * @param element Defines the element the controls should be listened from
  41385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41386. */
  41387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41388. /** @hidden */
  41389. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41390. /**
  41391. * Update the current camera state depending on the inputs that have been used this frame.
  41392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41393. */
  41394. checkInputs(): void;
  41395. /**
  41396. * Detach the current controls from the specified dom element.
  41397. * @param element Defines the element to stop listening the inputs from
  41398. */
  41399. detachControl(element: Nullable<HTMLElement>): void;
  41400. /**
  41401. * Gets the class name of the current intput.
  41402. * @returns the class name
  41403. */
  41404. getClassName(): string;
  41405. /**
  41406. * Get the friendly name associated with the input class.
  41407. * @returns the input friendly name
  41408. */
  41409. getSimpleName(): string;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Listen to keyboard events to control the camera.
  41415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41416. */
  41417. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41418. /**
  41419. * Defines the camera the input is attached to.
  41420. */
  41421. camera: FlyCamera;
  41422. /**
  41423. * The list of keyboard keys used to control the forward move of the camera.
  41424. */
  41425. keysForward: number[];
  41426. /**
  41427. * The list of keyboard keys used to control the backward move of the camera.
  41428. */
  41429. keysBackward: number[];
  41430. /**
  41431. * The list of keyboard keys used to control the forward move of the camera.
  41432. */
  41433. keysUp: number[];
  41434. /**
  41435. * The list of keyboard keys used to control the backward move of the camera.
  41436. */
  41437. keysDown: number[];
  41438. /**
  41439. * The list of keyboard keys used to control the right strafe move of the camera.
  41440. */
  41441. keysRight: number[];
  41442. /**
  41443. * The list of keyboard keys used to control the left strafe move of the camera.
  41444. */
  41445. keysLeft: number[];
  41446. private _keys;
  41447. private _onCanvasBlurObserver;
  41448. private _onKeyboardObserver;
  41449. private _engine;
  41450. private _scene;
  41451. /**
  41452. * Attach the input controls to a specific dom element to get the input from.
  41453. * @param element Defines the element the controls should be listened from
  41454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41455. */
  41456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41457. /**
  41458. * Detach the current controls from the specified dom element.
  41459. * @param element Defines the element to stop listening the inputs from
  41460. */
  41461. detachControl(element: Nullable<HTMLElement>): void;
  41462. /**
  41463. * Gets the class name of the current intput.
  41464. * @returns the class name
  41465. */
  41466. getClassName(): string;
  41467. /** @hidden */
  41468. _onLostFocus(e: FocusEvent): void;
  41469. /**
  41470. * Get the friendly name associated with the input class.
  41471. * @returns the input friendly name
  41472. */
  41473. getSimpleName(): string;
  41474. /**
  41475. * Update the current camera state depending on the inputs that have been used this frame.
  41476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41477. */
  41478. checkInputs(): void;
  41479. }
  41480. }
  41481. declare module BABYLON {
  41482. /**
  41483. * Listen to mouse events to control the camera.
  41484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41485. */
  41486. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41487. /**
  41488. * Defines the camera the input is attached to.
  41489. */
  41490. camera: FlyCamera;
  41491. /**
  41492. * Defines if touch is enabled. (Default is true.)
  41493. */
  41494. touchEnabled: boolean;
  41495. /**
  41496. * Defines the buttons associated with the input to handle camera rotation.
  41497. */
  41498. buttons: number[];
  41499. /**
  41500. * Assign buttons for Yaw control.
  41501. */
  41502. buttonsYaw: number[];
  41503. /**
  41504. * Assign buttons for Pitch control.
  41505. */
  41506. buttonsPitch: number[];
  41507. /**
  41508. * Assign buttons for Roll control.
  41509. */
  41510. buttonsRoll: number[];
  41511. /**
  41512. * Detect if any button is being pressed while mouse is moved.
  41513. * -1 = Mouse locked.
  41514. * 0 = Left button.
  41515. * 1 = Middle Button.
  41516. * 2 = Right Button.
  41517. */
  41518. activeButton: number;
  41519. /**
  41520. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41521. * Higher values reduce its sensitivity.
  41522. */
  41523. angularSensibility: number;
  41524. private _mousemoveCallback;
  41525. private _observer;
  41526. private _rollObserver;
  41527. private previousPosition;
  41528. private noPreventDefault;
  41529. private element;
  41530. /**
  41531. * Listen to mouse events to control the camera.
  41532. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41534. */
  41535. constructor(touchEnabled?: boolean);
  41536. /**
  41537. * Attach the mouse control to the HTML DOM element.
  41538. * @param element Defines the element that listens to the input events.
  41539. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41540. */
  41541. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41542. /**
  41543. * Detach the current controls from the specified dom element.
  41544. * @param element Defines the element to stop listening the inputs from
  41545. */
  41546. detachControl(element: Nullable<HTMLElement>): void;
  41547. /**
  41548. * Gets the class name of the current input.
  41549. * @returns the class name.
  41550. */
  41551. getClassName(): string;
  41552. /**
  41553. * Get the friendly name associated with the input class.
  41554. * @returns the input's friendly name.
  41555. */
  41556. getSimpleName(): string;
  41557. private _pointerInput;
  41558. private _onMouseMove;
  41559. /**
  41560. * Rotate camera by mouse offset.
  41561. */
  41562. private rotateCamera;
  41563. }
  41564. }
  41565. declare module BABYLON {
  41566. /**
  41567. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41568. * Screen rotation is taken into account.
  41569. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41570. */
  41571. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41572. private _camera;
  41573. private _screenOrientationAngle;
  41574. private _constantTranform;
  41575. private _screenQuaternion;
  41576. private _alpha;
  41577. private _beta;
  41578. private _gamma;
  41579. /**
  41580. * Instantiates a new input
  41581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41582. */
  41583. constructor();
  41584. /**
  41585. * Define the camera controlled by the input.
  41586. */
  41587. camera: FreeCamera;
  41588. /**
  41589. * Attach the input controls to a specific dom element to get the input from.
  41590. * @param element Defines the element the controls should be listened from
  41591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41592. */
  41593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41594. private _orientationChanged;
  41595. private _deviceOrientation;
  41596. /**
  41597. * Detach the current controls from the specified dom element.
  41598. * @param element Defines the element to stop listening the inputs from
  41599. */
  41600. detachControl(element: Nullable<HTMLElement>): void;
  41601. /**
  41602. * Update the current camera state depending on the inputs that have been used this frame.
  41603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41604. */
  41605. checkInputs(): void;
  41606. /**
  41607. * Gets the class name of the current intput.
  41608. * @returns the class name
  41609. */
  41610. getClassName(): string;
  41611. /**
  41612. * Get the friendly name associated with the input class.
  41613. * @returns the input friendly name
  41614. */
  41615. getSimpleName(): string;
  41616. }
  41617. }
  41618. declare module BABYLON {
  41619. /**
  41620. * Manage the gamepad inputs to control a free camera.
  41621. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41622. */
  41623. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41624. /**
  41625. * Define the camera the input is attached to.
  41626. */
  41627. camera: FreeCamera;
  41628. /**
  41629. * Define the Gamepad controlling the input
  41630. */
  41631. gamepad: Nullable<Gamepad>;
  41632. /**
  41633. * Defines the gamepad rotation sensiblity.
  41634. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41635. */
  41636. gamepadAngularSensibility: number;
  41637. /**
  41638. * Defines the gamepad move sensiblity.
  41639. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41640. */
  41641. gamepadMoveSensibility: number;
  41642. private _onGamepadConnectedObserver;
  41643. private _onGamepadDisconnectedObserver;
  41644. private _cameraTransform;
  41645. private _deltaTransform;
  41646. private _vector3;
  41647. private _vector2;
  41648. /**
  41649. * Attach the input controls to a specific dom element to get the input from.
  41650. * @param element Defines the element the controls should be listened from
  41651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41652. */
  41653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41654. /**
  41655. * Detach the current controls from the specified dom element.
  41656. * @param element Defines the element to stop listening the inputs from
  41657. */
  41658. detachControl(element: Nullable<HTMLElement>): void;
  41659. /**
  41660. * Update the current camera state depending on the inputs that have been used this frame.
  41661. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41662. */
  41663. checkInputs(): void;
  41664. /**
  41665. * Gets the class name of the current intput.
  41666. * @returns the class name
  41667. */
  41668. getClassName(): string;
  41669. /**
  41670. * Get the friendly name associated with the input class.
  41671. * @returns the input friendly name
  41672. */
  41673. getSimpleName(): string;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Manage the keyboard inputs to control the movement of a free camera.
  41679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41680. */
  41681. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41682. /**
  41683. * Defines the camera the input is attached to.
  41684. */
  41685. camera: FreeCamera;
  41686. /**
  41687. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41688. */
  41689. keysUp: number[];
  41690. /**
  41691. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41692. */
  41693. keysDown: number[];
  41694. /**
  41695. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41696. */
  41697. keysLeft: number[];
  41698. /**
  41699. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41700. */
  41701. keysRight: number[];
  41702. private _keys;
  41703. private _onCanvasBlurObserver;
  41704. private _onKeyboardObserver;
  41705. private _engine;
  41706. private _scene;
  41707. /**
  41708. * Attach the input controls to a specific dom element to get the input from.
  41709. * @param element Defines the element the controls should be listened from
  41710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41711. */
  41712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41713. /**
  41714. * Detach the current controls from the specified dom element.
  41715. * @param element Defines the element to stop listening the inputs from
  41716. */
  41717. detachControl(element: Nullable<HTMLElement>): void;
  41718. /**
  41719. * Update the current camera state depending on the inputs that have been used this frame.
  41720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41721. */
  41722. checkInputs(): void;
  41723. /**
  41724. * Gets the class name of the current intput.
  41725. * @returns the class name
  41726. */
  41727. getClassName(): string;
  41728. /** @hidden */
  41729. _onLostFocus(e: FocusEvent): void;
  41730. /**
  41731. * Get the friendly name associated with the input class.
  41732. * @returns the input friendly name
  41733. */
  41734. getSimpleName(): string;
  41735. }
  41736. }
  41737. declare module BABYLON {
  41738. /**
  41739. * Manage the mouse inputs to control the movement of a free camera.
  41740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41741. */
  41742. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41743. /**
  41744. * Define if touch is enabled in the mouse input
  41745. */
  41746. touchEnabled: boolean;
  41747. /**
  41748. * Defines the camera the input is attached to.
  41749. */
  41750. camera: FreeCamera;
  41751. /**
  41752. * Defines the buttons associated with the input to handle camera move.
  41753. */
  41754. buttons: number[];
  41755. /**
  41756. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41757. */
  41758. angularSensibility: number;
  41759. private _pointerInput;
  41760. private _onMouseMove;
  41761. private _observer;
  41762. private previousPosition;
  41763. /**
  41764. * Manage the mouse inputs to control the movement of a free camera.
  41765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41766. * @param touchEnabled Defines if touch is enabled or not
  41767. */
  41768. constructor(
  41769. /**
  41770. * Define if touch is enabled in the mouse input
  41771. */
  41772. touchEnabled?: boolean);
  41773. /**
  41774. * Attach the input controls to a specific dom element to get the input from.
  41775. * @param element Defines the element the controls should be listened from
  41776. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41777. */
  41778. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41779. /**
  41780. * Detach the current controls from the specified dom element.
  41781. * @param element Defines the element to stop listening the inputs from
  41782. */
  41783. detachControl(element: Nullable<HTMLElement>): void;
  41784. /**
  41785. * Gets the class name of the current intput.
  41786. * @returns the class name
  41787. */
  41788. getClassName(): string;
  41789. /**
  41790. * Get the friendly name associated with the input class.
  41791. * @returns the input friendly name
  41792. */
  41793. getSimpleName(): string;
  41794. }
  41795. }
  41796. declare module BABYLON {
  41797. /**
  41798. * Manage the touch inputs to control the movement of a free camera.
  41799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41800. */
  41801. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41802. /**
  41803. * Defines the camera the input is attached to.
  41804. */
  41805. camera: FreeCamera;
  41806. /**
  41807. * Defines the touch sensibility for rotation.
  41808. * The higher the faster.
  41809. */
  41810. touchAngularSensibility: number;
  41811. /**
  41812. * Defines the touch sensibility for move.
  41813. * The higher the faster.
  41814. */
  41815. touchMoveSensibility: number;
  41816. private _offsetX;
  41817. private _offsetY;
  41818. private _pointerPressed;
  41819. private _pointerInput;
  41820. private _observer;
  41821. private _onLostFocus;
  41822. /**
  41823. * Attach the input controls to a specific dom element to get the input from.
  41824. * @param element Defines the element the controls should be listened from
  41825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41826. */
  41827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41828. /**
  41829. * Detach the current controls from the specified dom element.
  41830. * @param element Defines the element to stop listening the inputs from
  41831. */
  41832. detachControl(element: Nullable<HTMLElement>): void;
  41833. /**
  41834. * Update the current camera state depending on the inputs that have been used this frame.
  41835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41836. */
  41837. checkInputs(): void;
  41838. /**
  41839. * Gets the class name of the current intput.
  41840. * @returns the class name
  41841. */
  41842. getClassName(): string;
  41843. /**
  41844. * Get the friendly name associated with the input class.
  41845. * @returns the input friendly name
  41846. */
  41847. getSimpleName(): string;
  41848. }
  41849. }
  41850. declare module BABYLON {
  41851. /**
  41852. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41854. */
  41855. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41856. /**
  41857. * Defines the camera the input is attached to.
  41858. */
  41859. camera: FreeCamera;
  41860. private _leftjoystick;
  41861. private _rightjoystick;
  41862. /**
  41863. * Gets the left stick of the virtual joystick.
  41864. * @returns The virtual Joystick
  41865. */
  41866. getLeftJoystick(): VirtualJoystick;
  41867. /**
  41868. * Gets the right stick of the virtual joystick.
  41869. * @returns The virtual Joystick
  41870. */
  41871. getRightJoystick(): VirtualJoystick;
  41872. /**
  41873. * Update the current camera state depending on the inputs that have been used this frame.
  41874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41875. */
  41876. checkInputs(): void;
  41877. /**
  41878. * Attach the input controls to a specific dom element to get the input from.
  41879. * @param element Defines the element the controls should be listened from
  41880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41881. */
  41882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41883. /**
  41884. * Detach the current controls from the specified dom element.
  41885. * @param element Defines the element to stop listening the inputs from
  41886. */
  41887. detachControl(element: Nullable<HTMLElement>): void;
  41888. /**
  41889. * Gets the class name of the current intput.
  41890. * @returns the class name
  41891. */
  41892. getClassName(): string;
  41893. /**
  41894. * Get the friendly name associated with the input class.
  41895. * @returns the input friendly name
  41896. */
  41897. getSimpleName(): string;
  41898. }
  41899. }
  41900. declare module BABYLON {
  41901. /**
  41902. * This represents all the required metrics to create a VR camera.
  41903. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41904. */
  41905. class VRCameraMetrics {
  41906. /**
  41907. * Define the horizontal resolution off the screen.
  41908. */
  41909. hResolution: number;
  41910. /**
  41911. * Define the vertical resolution off the screen.
  41912. */
  41913. vResolution: number;
  41914. /**
  41915. * Define the horizontal screen size.
  41916. */
  41917. hScreenSize: number;
  41918. /**
  41919. * Define the vertical screen size.
  41920. */
  41921. vScreenSize: number;
  41922. /**
  41923. * Define the vertical screen center position.
  41924. */
  41925. vScreenCenter: number;
  41926. /**
  41927. * Define the distance of the eyes to the screen.
  41928. */
  41929. eyeToScreenDistance: number;
  41930. /**
  41931. * Define the distance between both lenses
  41932. */
  41933. lensSeparationDistance: number;
  41934. /**
  41935. * Define the distance between both viewer's eyes.
  41936. */
  41937. interpupillaryDistance: number;
  41938. /**
  41939. * Define the distortion factor of the VR postprocess.
  41940. * Please, touch with care.
  41941. */
  41942. distortionK: number[];
  41943. /**
  41944. * Define the chromatic aberration correction factors for the VR post process.
  41945. */
  41946. chromaAbCorrection: number[];
  41947. /**
  41948. * Define the scale factor of the post process.
  41949. * The smaller the better but the slower.
  41950. */
  41951. postProcessScaleFactor: number;
  41952. /**
  41953. * Define an offset for the lens center.
  41954. */
  41955. lensCenterOffset: number;
  41956. /**
  41957. * Define if the current vr camera should compensate the distortion of the lense or not.
  41958. */
  41959. compensateDistortion: boolean;
  41960. /**
  41961. * Gets the rendering aspect ratio based on the provided resolutions.
  41962. */
  41963. readonly aspectRatio: number;
  41964. /**
  41965. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41966. */
  41967. readonly aspectRatioFov: number;
  41968. /**
  41969. * @hidden
  41970. */
  41971. readonly leftHMatrix: Matrix;
  41972. /**
  41973. * @hidden
  41974. */
  41975. readonly rightHMatrix: Matrix;
  41976. /**
  41977. * @hidden
  41978. */
  41979. readonly leftPreViewMatrix: Matrix;
  41980. /**
  41981. * @hidden
  41982. */
  41983. readonly rightPreViewMatrix: Matrix;
  41984. /**
  41985. * Get the default VRMetrics based on the most generic setup.
  41986. * @returns the default vr metrics
  41987. */
  41988. static GetDefault(): VRCameraMetrics;
  41989. }
  41990. }
  41991. declare module BABYLON {
  41992. /**
  41993. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41994. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41995. */
  41996. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41997. /**
  41998. * Creates a new VRDeviceOrientationArcRotateCamera
  41999. * @param name defines camera name
  42000. * @param alpha defines the camera rotation along the logitudinal axis
  42001. * @param beta defines the camera rotation along the latitudinal axis
  42002. * @param radius defines the camera distance from its target
  42003. * @param target defines the camera target
  42004. * @param scene defines the scene the camera belongs to
  42005. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42006. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42007. */
  42008. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42009. /**
  42010. * Gets camera class name
  42011. * @returns VRDeviceOrientationArcRotateCamera
  42012. */
  42013. getClassName(): string;
  42014. }
  42015. }
  42016. declare module BABYLON {
  42017. /**
  42018. * Camera used to simulate VR rendering (based on FreeCamera)
  42019. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42020. */
  42021. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42022. /**
  42023. * Creates a new VRDeviceOrientationFreeCamera
  42024. * @param name defines camera name
  42025. * @param position defines the start position of the camera
  42026. * @param scene defines the scene the camera belongs to
  42027. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42028. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42029. */
  42030. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42031. /**
  42032. * Gets camera class name
  42033. * @returns VRDeviceOrientationFreeCamera
  42034. */
  42035. getClassName(): string;
  42036. }
  42037. }
  42038. declare module BABYLON {
  42039. /**
  42040. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42041. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42042. */
  42043. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42044. /**
  42045. * Creates a new VRDeviceOrientationGamepadCamera
  42046. * @param name defines camera name
  42047. * @param position defines the start position of the camera
  42048. * @param scene defines the scene the camera belongs to
  42049. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42050. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42051. */
  42052. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42053. /**
  42054. * Gets camera class name
  42055. * @returns VRDeviceOrientationGamepadCamera
  42056. */
  42057. getClassName(): string;
  42058. }
  42059. }
  42060. declare module BABYLON {
  42061. /**
  42062. * Options to modify the vr teleportation behavior.
  42063. */
  42064. interface VRTeleportationOptions {
  42065. /**
  42066. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42067. */
  42068. floorMeshName?: string;
  42069. /**
  42070. * A list of meshes to be used as the teleportation floor. (default: empty)
  42071. */
  42072. floorMeshes?: Mesh[];
  42073. }
  42074. /**
  42075. * Options to modify the vr experience helper's behavior.
  42076. */
  42077. interface VRExperienceHelperOptions extends WebVROptions {
  42078. /**
  42079. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42080. */
  42081. createDeviceOrientationCamera?: boolean;
  42082. /**
  42083. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42084. */
  42085. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42086. /**
  42087. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42088. */
  42089. laserToggle?: boolean;
  42090. /**
  42091. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42092. */
  42093. floorMeshes?: Mesh[];
  42094. }
  42095. /**
  42096. * Helps to quickly add VR support to an existing scene.
  42097. * See http://doc.babylonjs.com/how_to/webvr_helper
  42098. */
  42099. class VRExperienceHelper {
  42100. /** Options to modify the vr experience helper's behavior. */
  42101. webVROptions: VRExperienceHelperOptions;
  42102. private _scene;
  42103. private _position;
  42104. private _btnVR;
  42105. private _btnVRDisplayed;
  42106. private _webVRsupported;
  42107. private _webVRready;
  42108. private _webVRrequesting;
  42109. private _webVRpresenting;
  42110. private _hasEnteredVR;
  42111. private _fullscreenVRpresenting;
  42112. private _canvas;
  42113. private _webVRCamera;
  42114. private _vrDeviceOrientationCamera;
  42115. private _deviceOrientationCamera;
  42116. private _existingCamera;
  42117. private _onKeyDown;
  42118. private _onVrDisplayPresentChange;
  42119. private _onVRDisplayChanged;
  42120. private _onVRRequestPresentStart;
  42121. private _onVRRequestPresentComplete;
  42122. /**
  42123. * Observable raised when entering VR.
  42124. */
  42125. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42126. /**
  42127. * Observable raised when exiting VR.
  42128. */
  42129. onExitingVRObservable: Observable<VRExperienceHelper>;
  42130. /**
  42131. * Observable raised when controller mesh is loaded.
  42132. */
  42133. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42134. /** Return this.onEnteringVRObservable
  42135. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42136. */
  42137. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42138. /** Return this.onExitingVRObservable
  42139. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42140. */
  42141. readonly onExitingVR: Observable<VRExperienceHelper>;
  42142. /** Return this.onControllerMeshLoadedObservable
  42143. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42144. */
  42145. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42146. private _rayLength;
  42147. private _useCustomVRButton;
  42148. private _teleportationRequested;
  42149. private _teleportActive;
  42150. private _floorMeshName;
  42151. private _floorMeshesCollection;
  42152. private _rotationAllowed;
  42153. private _teleportBackwardsVector;
  42154. private _teleportationTarget;
  42155. private _isDefaultTeleportationTarget;
  42156. private _postProcessMove;
  42157. private _teleportationFillColor;
  42158. private _teleportationBorderColor;
  42159. private _rotationAngle;
  42160. private _haloCenter;
  42161. private _cameraGazer;
  42162. private _padSensibilityUp;
  42163. private _padSensibilityDown;
  42164. private _leftController;
  42165. private _rightController;
  42166. /**
  42167. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42168. */
  42169. onNewMeshSelected: Observable<AbstractMesh>;
  42170. /**
  42171. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42172. */
  42173. onNewMeshPicked: Observable<PickingInfo>;
  42174. private _circleEase;
  42175. /**
  42176. * Observable raised before camera teleportation
  42177. */
  42178. onBeforeCameraTeleport: Observable<Vector3>;
  42179. /**
  42180. * Observable raised after camera teleportation
  42181. */
  42182. onAfterCameraTeleport: Observable<Vector3>;
  42183. /**
  42184. * Observable raised when current selected mesh gets unselected
  42185. */
  42186. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42187. private _raySelectionPredicate;
  42188. /**
  42189. * To be optionaly changed by user to define custom ray selection
  42190. */
  42191. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42192. /**
  42193. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42194. */
  42195. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42196. /**
  42197. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42198. */
  42199. teleportationEnabled: boolean;
  42200. private _defaultHeight;
  42201. private _teleportationInitialized;
  42202. private _interactionsEnabled;
  42203. private _interactionsRequested;
  42204. private _displayGaze;
  42205. private _displayLaserPointer;
  42206. /**
  42207. * The mesh used to display where the user is going to teleport.
  42208. */
  42209. /**
  42210. * Sets the mesh to be used to display where the user is going to teleport.
  42211. */
  42212. teleportationTarget: Mesh;
  42213. /**
  42214. * 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
  42215. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42216. * See http://doc.babylonjs.com/resources/baking_transformations
  42217. */
  42218. gazeTrackerMesh: Mesh;
  42219. /**
  42220. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42221. */
  42222. updateGazeTrackerScale: boolean;
  42223. /**
  42224. * The gaze tracking mesh corresponding to the left controller
  42225. */
  42226. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42227. /**
  42228. * The gaze tracking mesh corresponding to the right controller
  42229. */
  42230. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42231. /**
  42232. * If the ray of the gaze should be displayed.
  42233. */
  42234. /**
  42235. * Sets if the ray of the gaze should be displayed.
  42236. */
  42237. displayGaze: boolean;
  42238. /**
  42239. * If the ray of the LaserPointer should be displayed.
  42240. */
  42241. /**
  42242. * Sets if the ray of the LaserPointer should be displayed.
  42243. */
  42244. displayLaserPointer: boolean;
  42245. /**
  42246. * The deviceOrientationCamera used as the camera when not in VR.
  42247. */
  42248. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42249. /**
  42250. * Based on the current WebVR support, returns the current VR camera used.
  42251. */
  42252. readonly currentVRCamera: Nullable<Camera>;
  42253. /**
  42254. * The webVRCamera which is used when in VR.
  42255. */
  42256. readonly webVRCamera: WebVRFreeCamera;
  42257. /**
  42258. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42259. */
  42260. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42261. private readonly _teleportationRequestInitiated;
  42262. /**
  42263. * Instantiates a VRExperienceHelper.
  42264. * Helps to quickly add VR support to an existing scene.
  42265. * @param scene The scene the VRExperienceHelper belongs to.
  42266. * @param webVROptions Options to modify the vr experience helper's behavior.
  42267. */
  42268. constructor(scene: Scene,
  42269. /** Options to modify the vr experience helper's behavior. */
  42270. webVROptions?: VRExperienceHelperOptions);
  42271. private _onDefaultMeshLoaded;
  42272. private _onResize;
  42273. private _onFullscreenChange;
  42274. /**
  42275. * Gets a value indicating if we are currently in VR mode.
  42276. */
  42277. readonly isInVRMode: boolean;
  42278. private onVrDisplayPresentChange;
  42279. private onVRDisplayChanged;
  42280. private moveButtonToBottomRight;
  42281. private displayVRButton;
  42282. private updateButtonVisibility;
  42283. /**
  42284. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42285. * Otherwise, will use the fullscreen API.
  42286. */
  42287. enterVR(): void;
  42288. /**
  42289. * Attempt to exit VR, or fullscreen.
  42290. */
  42291. exitVR(): void;
  42292. /**
  42293. * The position of the vr experience helper.
  42294. */
  42295. /**
  42296. * Sets the position of the vr experience helper.
  42297. */
  42298. position: Vector3;
  42299. /**
  42300. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42301. */
  42302. enableInteractions(): void;
  42303. private readonly _noControllerIsActive;
  42304. private beforeRender;
  42305. private _isTeleportationFloor;
  42306. /**
  42307. * Adds a floor mesh to be used for teleportation.
  42308. * @param floorMesh the mesh to be used for teleportation.
  42309. */
  42310. addFloorMesh(floorMesh: Mesh): void;
  42311. /**
  42312. * Removes a floor mesh from being used for teleportation.
  42313. * @param floorMesh the mesh to be removed.
  42314. */
  42315. removeFloorMesh(floorMesh: Mesh): void;
  42316. /**
  42317. * Enables interactions and teleportation using the VR controllers and gaze.
  42318. * @param vrTeleportationOptions options to modify teleportation behavior.
  42319. */
  42320. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42321. private _onNewGamepadConnected;
  42322. private _tryEnableInteractionOnController;
  42323. private _onNewGamepadDisconnected;
  42324. private _enableInteractionOnController;
  42325. private _checkTeleportWithRay;
  42326. private _checkRotate;
  42327. private _checkTeleportBackwards;
  42328. private _enableTeleportationOnController;
  42329. private _createTeleportationCircles;
  42330. private _displayTeleportationTarget;
  42331. private _hideTeleportationTarget;
  42332. private _rotateCamera;
  42333. private _moveTeleportationSelectorTo;
  42334. private _workingVector;
  42335. private _workingQuaternion;
  42336. private _workingMatrix;
  42337. /**
  42338. * Teleports the users feet to the desired location
  42339. * @param location The location where the user's feet should be placed
  42340. */
  42341. teleportCamera(location: Vector3): void;
  42342. private _convertNormalToDirectionOfRay;
  42343. private _castRayAndSelectObject;
  42344. private _notifySelectedMeshUnselected;
  42345. /**
  42346. * Sets the color of the laser ray from the vr controllers.
  42347. * @param color new color for the ray.
  42348. */
  42349. changeLaserColor(color: Color3): void;
  42350. /**
  42351. * Sets the color of the ray from the vr headsets gaze.
  42352. * @param color new color for the ray.
  42353. */
  42354. changeGazeColor(color: Color3): void;
  42355. /**
  42356. * Exits VR and disposes of the vr experience helper
  42357. */
  42358. dispose(): void;
  42359. /**
  42360. * Gets the name of the VRExperienceHelper class
  42361. * @returns "VRExperienceHelper"
  42362. */
  42363. getClassName(): string;
  42364. }
  42365. }
  42366. declare module BABYLON {
  42367. /**
  42368. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42369. * IMPORTANT!! The data is right-hand data.
  42370. * @export
  42371. * @interface DevicePose
  42372. */
  42373. interface DevicePose {
  42374. /**
  42375. * The position of the device, values in array are [x,y,z].
  42376. */
  42377. readonly position: Nullable<Float32Array>;
  42378. /**
  42379. * The linearVelocity of the device, values in array are [x,y,z].
  42380. */
  42381. readonly linearVelocity: Nullable<Float32Array>;
  42382. /**
  42383. * The linearAcceleration of the device, values in array are [x,y,z].
  42384. */
  42385. readonly linearAcceleration: Nullable<Float32Array>;
  42386. /**
  42387. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42388. */
  42389. readonly orientation: Nullable<Float32Array>;
  42390. /**
  42391. * The angularVelocity of the device, values in array are [x,y,z].
  42392. */
  42393. readonly angularVelocity: Nullable<Float32Array>;
  42394. /**
  42395. * The angularAcceleration of the device, values in array are [x,y,z].
  42396. */
  42397. readonly angularAcceleration: Nullable<Float32Array>;
  42398. }
  42399. /**
  42400. * Interface representing a pose controlled object in Babylon.
  42401. * A pose controlled object has both regular pose values as well as pose values
  42402. * from an external device such as a VR head mounted display
  42403. */
  42404. interface PoseControlled {
  42405. /**
  42406. * The position of the object in babylon space.
  42407. */
  42408. position: Vector3;
  42409. /**
  42410. * The rotation quaternion of the object in babylon space.
  42411. */
  42412. rotationQuaternion: Quaternion;
  42413. /**
  42414. * The position of the device in babylon space.
  42415. */
  42416. devicePosition?: Vector3;
  42417. /**
  42418. * The rotation quaternion of the device in babylon space.
  42419. */
  42420. deviceRotationQuaternion: Quaternion;
  42421. /**
  42422. * The raw pose coming from the device.
  42423. */
  42424. rawPose: Nullable<DevicePose>;
  42425. /**
  42426. * The scale of the device to be used when translating from device space to babylon space.
  42427. */
  42428. deviceScaleFactor: number;
  42429. /**
  42430. * Updates the poseControlled values based on the input device pose.
  42431. * @param poseData the pose data to update the object with
  42432. */
  42433. updateFromDevice(poseData: DevicePose): void;
  42434. }
  42435. /**
  42436. * Set of options to customize the webVRCamera
  42437. */
  42438. interface WebVROptions {
  42439. /**
  42440. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42441. */
  42442. trackPosition?: boolean;
  42443. /**
  42444. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42445. */
  42446. positionScale?: number;
  42447. /**
  42448. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42449. */
  42450. displayName?: string;
  42451. /**
  42452. * Should the native controller meshes be initialized. (default: true)
  42453. */
  42454. controllerMeshes?: boolean;
  42455. /**
  42456. * Creating a default HemiLight only on controllers. (default: true)
  42457. */
  42458. defaultLightingOnControllers?: boolean;
  42459. /**
  42460. * If you don't want to use the default VR button of the helper. (default: false)
  42461. */
  42462. useCustomVRButton?: boolean;
  42463. /**
  42464. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42465. */
  42466. customVRButton?: HTMLButtonElement;
  42467. /**
  42468. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42469. */
  42470. rayLength?: number;
  42471. /**
  42472. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42473. */
  42474. defaultHeight?: number;
  42475. }
  42476. /**
  42477. * This represents a WebVR camera.
  42478. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42479. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42480. */
  42481. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42482. private webVROptions;
  42483. /**
  42484. * @hidden
  42485. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42486. */
  42487. _vrDevice: any;
  42488. /**
  42489. * The rawPose of the vrDevice.
  42490. */
  42491. rawPose: Nullable<DevicePose>;
  42492. private _onVREnabled;
  42493. private _specsVersion;
  42494. private _attached;
  42495. private _frameData;
  42496. protected _descendants: Array<Node>;
  42497. private _deviceRoomPosition;
  42498. /** @hidden */
  42499. _deviceRoomRotationQuaternion: Quaternion;
  42500. private _standingMatrix;
  42501. /**
  42502. * Represents device position in babylon space.
  42503. */
  42504. devicePosition: Vector3;
  42505. /**
  42506. * Represents device rotation in babylon space.
  42507. */
  42508. deviceRotationQuaternion: Quaternion;
  42509. /**
  42510. * The scale of the device to be used when translating from device space to babylon space.
  42511. */
  42512. deviceScaleFactor: number;
  42513. private _deviceToWorld;
  42514. private _worldToDevice;
  42515. /**
  42516. * References to the webVR controllers for the vrDevice.
  42517. */
  42518. controllers: Array<WebVRController>;
  42519. /**
  42520. * Emits an event when a controller is attached.
  42521. */
  42522. onControllersAttachedObservable: Observable<WebVRController[]>;
  42523. /**
  42524. * Emits an event when a controller's mesh has been loaded;
  42525. */
  42526. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42527. /**
  42528. * Emits an event when the HMD's pose has been updated.
  42529. */
  42530. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42531. private _poseSet;
  42532. /**
  42533. * If the rig cameras be used as parent instead of this camera.
  42534. */
  42535. rigParenting: boolean;
  42536. private _lightOnControllers;
  42537. private _defaultHeight?;
  42538. /**
  42539. * Instantiates a WebVRFreeCamera.
  42540. * @param name The name of the WebVRFreeCamera
  42541. * @param position The starting anchor position for the camera
  42542. * @param scene The scene the camera belongs to
  42543. * @param webVROptions a set of customizable options for the webVRCamera
  42544. */
  42545. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42546. /**
  42547. * Gets the device distance from the ground in meters.
  42548. * @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.
  42549. */
  42550. deviceDistanceToRoomGround(): number;
  42551. /**
  42552. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42553. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42554. */
  42555. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42556. /**
  42557. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42558. * @returns A promise with a boolean set to if the standing matrix is supported.
  42559. */
  42560. useStandingMatrixAsync(): Promise<boolean>;
  42561. /**
  42562. * Disposes the camera
  42563. */
  42564. dispose(): void;
  42565. /**
  42566. * Gets a vrController by name.
  42567. * @param name The name of the controller to retreive
  42568. * @returns the controller matching the name specified or null if not found
  42569. */
  42570. getControllerByName(name: string): Nullable<WebVRController>;
  42571. private _leftController;
  42572. /**
  42573. * The controller corrisponding to the users left hand.
  42574. */
  42575. readonly leftController: Nullable<WebVRController>;
  42576. private _rightController;
  42577. /**
  42578. * The controller corrisponding to the users right hand.
  42579. */
  42580. readonly rightController: Nullable<WebVRController>;
  42581. /**
  42582. * Casts a ray forward from the vrCamera's gaze.
  42583. * @param length Length of the ray (default: 100)
  42584. * @returns the ray corrisponding to the gaze
  42585. */
  42586. getForwardRay(length?: number): Ray;
  42587. /**
  42588. * @hidden
  42589. * Updates the camera based on device's frame data
  42590. */
  42591. _checkInputs(): void;
  42592. /**
  42593. * Updates the poseControlled values based on the input device pose.
  42594. * @param poseData Pose coming from the device
  42595. */
  42596. updateFromDevice(poseData: DevicePose): void;
  42597. private _htmlElementAttached;
  42598. private _detachIfAttached;
  42599. /**
  42600. * WebVR's attach control will start broadcasting frames to the device.
  42601. * Note that in certain browsers (chrome for example) this function must be called
  42602. * within a user-interaction callback. Example:
  42603. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42604. *
  42605. * @param element html element to attach the vrDevice to
  42606. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42607. */
  42608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42609. /**
  42610. * Detaches the camera from the html element and disables VR
  42611. *
  42612. * @param element html element to detach from
  42613. */
  42614. detachControl(element: HTMLElement): void;
  42615. /**
  42616. * @returns the name of this class
  42617. */
  42618. getClassName(): string;
  42619. /**
  42620. * Calls resetPose on the vrDisplay
  42621. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42622. */
  42623. resetToCurrentRotation(): void;
  42624. /**
  42625. * @hidden
  42626. * Updates the rig cameras (left and right eye)
  42627. */
  42628. _updateRigCameras(): void;
  42629. private _workingVector;
  42630. private _oneVector;
  42631. private _workingMatrix;
  42632. private updateCacheCalled;
  42633. private _correctPositionIfNotTrackPosition;
  42634. /**
  42635. * @hidden
  42636. * Updates the cached values of the camera
  42637. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42638. */
  42639. _updateCache(ignoreParentClass?: boolean): void;
  42640. /**
  42641. * @hidden
  42642. * Get current device position in babylon world
  42643. */
  42644. _computeDevicePosition(): void;
  42645. /**
  42646. * Updates the current device position and rotation in the babylon world
  42647. */
  42648. update(): void;
  42649. /**
  42650. * @hidden
  42651. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42652. * @returns an identity matrix
  42653. */
  42654. _getViewMatrix(): Matrix;
  42655. private _tmpMatrix;
  42656. /**
  42657. * This function is called by the two RIG cameras.
  42658. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42659. */
  42660. protected _getWebVRViewMatrix(): Matrix;
  42661. protected _getWebVRProjectionMatrix(): Matrix;
  42662. private _onGamepadConnectedObserver;
  42663. private _onGamepadDisconnectedObserver;
  42664. private _updateCacheWhenTrackingDisabledObserver;
  42665. /**
  42666. * Initializes the controllers and their meshes
  42667. */
  42668. initControllers(): void;
  42669. }
  42670. }
  42671. declare module BABYLON {
  42672. /**
  42673. * WebXR Camera which holds the views for the xrSession
  42674. * @see https://doc.babylonjs.com/how_to/webxr
  42675. */
  42676. class WebXRCamera extends FreeCamera {
  42677. /**
  42678. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42679. * @param name the name of the camera
  42680. * @param scene the scene to add the camera to
  42681. */
  42682. constructor(name: string, scene: BABYLON.Scene);
  42683. private _updateNumberOfRigCameras;
  42684. /** @hidden */
  42685. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42686. }
  42687. }
  42688. declare module BABYLON {
  42689. /** @hidden */
  42690. class _OcclusionDataStorage {
  42691. /** @hidden */
  42692. occlusionInternalRetryCounter: number;
  42693. /** @hidden */
  42694. isOcclusionQueryInProgress: boolean;
  42695. /** @hidden */
  42696. isOccluded: boolean;
  42697. /** @hidden */
  42698. occlusionRetryCount: number;
  42699. /** @hidden */
  42700. occlusionType: number;
  42701. /** @hidden */
  42702. occlusionQueryAlgorithmType: number;
  42703. }
  42704. interface Engine {
  42705. /**
  42706. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42707. * @return the new query
  42708. */
  42709. createQuery(): WebGLQuery;
  42710. /**
  42711. * Delete and release a webGL query
  42712. * @param query defines the query to delete
  42713. * @return the current engine
  42714. */
  42715. deleteQuery(query: WebGLQuery): Engine;
  42716. /**
  42717. * Check if a given query has resolved and got its value
  42718. * @param query defines the query to check
  42719. * @returns true if the query got its value
  42720. */
  42721. isQueryResultAvailable(query: WebGLQuery): boolean;
  42722. /**
  42723. * Gets the value of a given query
  42724. * @param query defines the query to check
  42725. * @returns the value of the query
  42726. */
  42727. getQueryResult(query: WebGLQuery): number;
  42728. /**
  42729. * Initiates an occlusion query
  42730. * @param algorithmType defines the algorithm to use
  42731. * @param query defines the query to use
  42732. * @returns the current engine
  42733. * @see http://doc.babylonjs.com/features/occlusionquery
  42734. */
  42735. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42736. /**
  42737. * Ends an occlusion query
  42738. * @see http://doc.babylonjs.com/features/occlusionquery
  42739. * @param algorithmType defines the algorithm to use
  42740. * @returns the current engine
  42741. */
  42742. endOcclusionQuery(algorithmType: number): Engine;
  42743. /**
  42744. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42745. * Please note that only one query can be issued at a time
  42746. * @returns a time token used to track the time span
  42747. */
  42748. startTimeQuery(): Nullable<_TimeToken>;
  42749. /**
  42750. * Ends a time query
  42751. * @param token defines the token used to measure the time span
  42752. * @returns the time spent (in ns)
  42753. */
  42754. endTimeQuery(token: _TimeToken): int;
  42755. /** @hidden */
  42756. _currentNonTimestampToken: Nullable<_TimeToken>;
  42757. /** @hidden */
  42758. _createTimeQuery(): WebGLQuery;
  42759. /** @hidden */
  42760. _deleteTimeQuery(query: WebGLQuery): void;
  42761. /** @hidden */
  42762. _getGlAlgorithmType(algorithmType: number): number;
  42763. /** @hidden */
  42764. _getTimeQueryResult(query: WebGLQuery): any;
  42765. /** @hidden */
  42766. _getTimeQueryAvailability(query: WebGLQuery): any;
  42767. }
  42768. interface AbstractMesh {
  42769. /**
  42770. * Backing filed
  42771. * @hidden
  42772. */
  42773. __occlusionDataStorage: _OcclusionDataStorage;
  42774. /**
  42775. * Access property
  42776. * @hidden
  42777. */
  42778. _occlusionDataStorage: _OcclusionDataStorage;
  42779. /**
  42780. * 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.
  42781. * The default value is -1 which means don't break the query and wait till the result
  42782. * @see http://doc.babylonjs.com/features/occlusionquery
  42783. */
  42784. occlusionRetryCount: number;
  42785. /**
  42786. * 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:
  42787. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42788. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42789. * * 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.
  42790. * @see http://doc.babylonjs.com/features/occlusionquery
  42791. */
  42792. occlusionType: number;
  42793. /**
  42794. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42795. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42796. * * 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.
  42797. * @see http://doc.babylonjs.com/features/occlusionquery
  42798. */
  42799. occlusionQueryAlgorithmType: number;
  42800. /**
  42801. * 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
  42802. * @see http://doc.babylonjs.com/features/occlusionquery
  42803. */
  42804. isOccluded: boolean;
  42805. /**
  42806. * Flag to check the progress status of the query
  42807. * @see http://doc.babylonjs.com/features/occlusionquery
  42808. */
  42809. isOcclusionQueryInProgress: boolean;
  42810. }
  42811. }
  42812. declare module BABYLON {
  42813. interface Engine {
  42814. /**
  42815. * Creates a webGL transform feedback object
  42816. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42817. * @returns the webGL transform feedback object
  42818. */
  42819. createTransformFeedback(): WebGLTransformFeedback;
  42820. /**
  42821. * Delete a webGL transform feedback object
  42822. * @param value defines the webGL transform feedback object to delete
  42823. */
  42824. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42825. /**
  42826. * Bind a webGL transform feedback object to the webgl context
  42827. * @param value defines the webGL transform feedback object to bind
  42828. */
  42829. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42830. /**
  42831. * Begins a transform feedback operation
  42832. * @param usePoints defines if points or triangles must be used
  42833. */
  42834. beginTransformFeedback(usePoints: boolean): void;
  42835. /**
  42836. * Ends a transform feedback operation
  42837. */
  42838. endTransformFeedback(): void;
  42839. /**
  42840. * Specify the varyings to use with transform feedback
  42841. * @param program defines the associated webGL program
  42842. * @param value defines the list of strings representing the varying names
  42843. */
  42844. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42845. /**
  42846. * Bind a webGL buffer for a transform feedback operation
  42847. * @param value defines the webGL buffer to bind
  42848. */
  42849. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42850. }
  42851. }
  42852. declare module BABYLON {
  42853. /**
  42854. * Google Daydream controller
  42855. */
  42856. class DaydreamController extends WebVRController {
  42857. /**
  42858. * Base Url for the controller model.
  42859. */
  42860. static MODEL_BASE_URL: string;
  42861. /**
  42862. * File name for the controller model.
  42863. */
  42864. static MODEL_FILENAME: string;
  42865. /**
  42866. * Gamepad Id prefix used to identify Daydream Controller.
  42867. */
  42868. static readonly GAMEPAD_ID_PREFIX: string;
  42869. /**
  42870. * Creates a new DaydreamController from a gamepad
  42871. * @param vrGamepad the gamepad that the controller should be created from
  42872. */
  42873. constructor(vrGamepad: any);
  42874. /**
  42875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42876. * @param scene scene in which to add meshes
  42877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42878. */
  42879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42880. /**
  42881. * Called once for each button that changed state since the last frame
  42882. * @param buttonIdx Which button index changed
  42883. * @param state New state of the button
  42884. * @param changes Which properties on the state changed since last frame
  42885. */
  42886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42887. }
  42888. }
  42889. declare module BABYLON {
  42890. /**
  42891. * Gear VR Controller
  42892. */
  42893. class GearVRController extends WebVRController {
  42894. /**
  42895. * Base Url for the controller model.
  42896. */
  42897. static MODEL_BASE_URL: string;
  42898. /**
  42899. * File name for the controller model.
  42900. */
  42901. static MODEL_FILENAME: string;
  42902. /**
  42903. * Gamepad Id prefix used to identify this controller.
  42904. */
  42905. static readonly GAMEPAD_ID_PREFIX: string;
  42906. private readonly _buttonIndexToObservableNameMap;
  42907. /**
  42908. * Creates a new GearVRController from a gamepad
  42909. * @param vrGamepad the gamepad that the controller should be created from
  42910. */
  42911. constructor(vrGamepad: any);
  42912. /**
  42913. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42914. * @param scene scene in which to add meshes
  42915. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42916. */
  42917. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42918. /**
  42919. * Called once for each button that changed state since the last frame
  42920. * @param buttonIdx Which button index changed
  42921. * @param state New state of the button
  42922. * @param changes Which properties on the state changed since last frame
  42923. */
  42924. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42925. }
  42926. }
  42927. declare module BABYLON {
  42928. /**
  42929. * Generic Controller
  42930. */
  42931. class GenericController extends WebVRController {
  42932. /**
  42933. * Base Url for the controller model.
  42934. */
  42935. static readonly MODEL_BASE_URL: string;
  42936. /**
  42937. * File name for the controller model.
  42938. */
  42939. static readonly MODEL_FILENAME: string;
  42940. /**
  42941. * Creates a new GenericController from a gamepad
  42942. * @param vrGamepad the gamepad that the controller should be created from
  42943. */
  42944. constructor(vrGamepad: any);
  42945. /**
  42946. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42947. * @param scene scene in which to add meshes
  42948. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42949. */
  42950. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42951. /**
  42952. * Called once for each button that changed state since the last frame
  42953. * @param buttonIdx Which button index changed
  42954. * @param state New state of the button
  42955. * @param changes Which properties on the state changed since last frame
  42956. */
  42957. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42958. }
  42959. }
  42960. declare module BABYLON {
  42961. /**
  42962. * Oculus Touch Controller
  42963. */
  42964. class OculusTouchController extends WebVRController {
  42965. /**
  42966. * Base Url for the controller model.
  42967. */
  42968. static MODEL_BASE_URL: string;
  42969. /**
  42970. * File name for the left controller model.
  42971. */
  42972. static MODEL_LEFT_FILENAME: string;
  42973. /**
  42974. * File name for the right controller model.
  42975. */
  42976. static MODEL_RIGHT_FILENAME: string;
  42977. /**
  42978. * Fired when the secondary trigger on this controller is modified
  42979. */
  42980. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42981. /**
  42982. * Fired when the thumb rest on this controller is modified
  42983. */
  42984. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42985. /**
  42986. * Creates a new OculusTouchController from a gamepad
  42987. * @param vrGamepad the gamepad that the controller should be created from
  42988. */
  42989. constructor(vrGamepad: any);
  42990. /**
  42991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42992. * @param scene scene in which to add meshes
  42993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42994. */
  42995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42996. /**
  42997. * Fired when the A button on this controller is modified
  42998. */
  42999. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43000. /**
  43001. * Fired when the B button on this controller is modified
  43002. */
  43003. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43004. /**
  43005. * Fired when the X button on this controller is modified
  43006. */
  43007. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43008. /**
  43009. * Fired when the Y button on this controller is modified
  43010. */
  43011. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43012. /**
  43013. * Called once for each button that changed state since the last frame
  43014. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43015. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43016. * 2) secondary trigger (same)
  43017. * 3) A (right) X (left), touch, pressed = value
  43018. * 4) B / Y
  43019. * 5) thumb rest
  43020. * @param buttonIdx Which button index changed
  43021. * @param state New state of the button
  43022. * @param changes Which properties on the state changed since last frame
  43023. */
  43024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43025. }
  43026. }
  43027. declare module BABYLON {
  43028. /**
  43029. * Defines the types of pose enabled controllers that are supported
  43030. */
  43031. enum PoseEnabledControllerType {
  43032. /**
  43033. * HTC Vive
  43034. */
  43035. VIVE = 0,
  43036. /**
  43037. * Oculus Rift
  43038. */
  43039. OCULUS = 1,
  43040. /**
  43041. * Windows mixed reality
  43042. */
  43043. WINDOWS = 2,
  43044. /**
  43045. * Samsung gear VR
  43046. */
  43047. GEAR_VR = 3,
  43048. /**
  43049. * Google Daydream
  43050. */
  43051. DAYDREAM = 4,
  43052. /**
  43053. * Generic
  43054. */
  43055. GENERIC = 5
  43056. }
  43057. /**
  43058. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43059. */
  43060. interface MutableGamepadButton {
  43061. /**
  43062. * Value of the button/trigger
  43063. */
  43064. value: number;
  43065. /**
  43066. * If the button/trigger is currently touched
  43067. */
  43068. touched: boolean;
  43069. /**
  43070. * If the button/trigger is currently pressed
  43071. */
  43072. pressed: boolean;
  43073. }
  43074. /**
  43075. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43076. * @hidden
  43077. */
  43078. interface ExtendedGamepadButton extends GamepadButton {
  43079. /**
  43080. * If the button/trigger is currently pressed
  43081. */
  43082. readonly pressed: boolean;
  43083. /**
  43084. * If the button/trigger is currently touched
  43085. */
  43086. readonly touched: boolean;
  43087. /**
  43088. * Value of the button/trigger
  43089. */
  43090. readonly value: number;
  43091. }
  43092. /**
  43093. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43094. */
  43095. class PoseEnabledControllerHelper {
  43096. /**
  43097. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43098. * @param vrGamepad the gamepad to initialized
  43099. * @returns a vr controller of the type the gamepad identified as
  43100. */
  43101. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43102. }
  43103. /**
  43104. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43105. */
  43106. class PoseEnabledController extends Gamepad implements PoseControlled {
  43107. private _deviceRoomPosition;
  43108. private _deviceRoomRotationQuaternion;
  43109. /**
  43110. * The device position in babylon space
  43111. */
  43112. devicePosition: Vector3;
  43113. /**
  43114. * The device rotation in babylon space
  43115. */
  43116. deviceRotationQuaternion: Quaternion;
  43117. /**
  43118. * The scale factor of the device in babylon space
  43119. */
  43120. deviceScaleFactor: number;
  43121. /**
  43122. * (Likely devicePosition should be used instead) The device position in its room space
  43123. */
  43124. position: Vector3;
  43125. /**
  43126. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43127. */
  43128. rotationQuaternion: Quaternion;
  43129. /**
  43130. * The type of controller (Eg. Windows mixed reality)
  43131. */
  43132. controllerType: PoseEnabledControllerType;
  43133. protected _calculatedPosition: Vector3;
  43134. private _calculatedRotation;
  43135. /**
  43136. * The raw pose from the device
  43137. */
  43138. rawPose: DevicePose;
  43139. private _trackPosition;
  43140. private _maxRotationDistFromHeadset;
  43141. private _draggedRoomRotation;
  43142. /**
  43143. * @hidden
  43144. */
  43145. _disableTrackPosition(fixedPosition: Vector3): void;
  43146. /**
  43147. * Internal, the mesh attached to the controller
  43148. * @hidden
  43149. */
  43150. _mesh: Nullable<AbstractMesh>;
  43151. private _poseControlledCamera;
  43152. private _leftHandSystemQuaternion;
  43153. /**
  43154. * Internal, matrix used to convert room space to babylon space
  43155. * @hidden
  43156. */
  43157. _deviceToWorld: Matrix;
  43158. /**
  43159. * Node to be used when casting a ray from the controller
  43160. * @hidden
  43161. */
  43162. _pointingPoseNode: Nullable<AbstractMesh>;
  43163. /**
  43164. * Name of the child mesh that can be used to cast a ray from the controller
  43165. */
  43166. static readonly POINTING_POSE: string;
  43167. /**
  43168. * Creates a new PoseEnabledController from a gamepad
  43169. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43170. */
  43171. constructor(browserGamepad: any);
  43172. private _workingMatrix;
  43173. /**
  43174. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43175. */
  43176. update(): void;
  43177. /**
  43178. * Updates only the pose device and mesh without doing any button event checking
  43179. */
  43180. protected _updatePoseAndMesh(): void;
  43181. /**
  43182. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43183. * @param poseData raw pose fromthe device
  43184. */
  43185. updateFromDevice(poseData: DevicePose): void;
  43186. /**
  43187. * @hidden
  43188. */
  43189. _meshAttachedObservable: Observable<AbstractMesh>;
  43190. /**
  43191. * Attaches a mesh to the controller
  43192. * @param mesh the mesh to be attached
  43193. */
  43194. attachToMesh(mesh: AbstractMesh): void;
  43195. /**
  43196. * Attaches the controllers mesh to a camera
  43197. * @param camera the camera the mesh should be attached to
  43198. */
  43199. attachToPoseControlledCamera(camera: TargetCamera): void;
  43200. /**
  43201. * Disposes of the controller
  43202. */
  43203. dispose(): void;
  43204. /**
  43205. * The mesh that is attached to the controller
  43206. */
  43207. readonly mesh: Nullable<AbstractMesh>;
  43208. /**
  43209. * Gets the ray of the controller in the direction the controller is pointing
  43210. * @param length the length the resulting ray should be
  43211. * @returns a ray in the direction the controller is pointing
  43212. */
  43213. getForwardRay(length?: number): Ray;
  43214. }
  43215. }
  43216. declare module BABYLON {
  43217. /**
  43218. * Vive Controller
  43219. */
  43220. class ViveController extends WebVRController {
  43221. /**
  43222. * Base Url for the controller model.
  43223. */
  43224. static MODEL_BASE_URL: string;
  43225. /**
  43226. * File name for the controller model.
  43227. */
  43228. static MODEL_FILENAME: string;
  43229. /**
  43230. * Creates a new ViveController from a gamepad
  43231. * @param vrGamepad the gamepad that the controller should be created from
  43232. */
  43233. constructor(vrGamepad: any);
  43234. /**
  43235. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43236. * @param scene scene in which to add meshes
  43237. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43238. */
  43239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43240. /**
  43241. * Fired when the left button on this controller is modified
  43242. */
  43243. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43244. /**
  43245. * Fired when the right button on this controller is modified
  43246. */
  43247. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43248. /**
  43249. * Fired when the menu button on this controller is modified
  43250. */
  43251. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43252. /**
  43253. * Called once for each button that changed state since the last frame
  43254. * Vive mapping:
  43255. * 0: touchpad
  43256. * 1: trigger
  43257. * 2: left AND right buttons
  43258. * 3: menu button
  43259. * @param buttonIdx Which button index changed
  43260. * @param state New state of the button
  43261. * @param changes Which properties on the state changed since last frame
  43262. */
  43263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43264. }
  43265. }
  43266. declare module BABYLON {
  43267. /**
  43268. * Defines the WebVRController object that represents controllers tracked in 3D space
  43269. */
  43270. abstract class WebVRController extends PoseEnabledController {
  43271. /**
  43272. * Internal, the default controller model for the controller
  43273. */
  43274. protected _defaultModel: AbstractMesh;
  43275. /**
  43276. * Fired when the trigger state has changed
  43277. */
  43278. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the main button state has changed
  43281. */
  43282. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Fired when the secondary button state has changed
  43285. */
  43286. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the pad state has changed
  43289. */
  43290. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43291. /**
  43292. * Fired when controllers stick values have changed
  43293. */
  43294. onPadValuesChangedObservable: Observable<StickValues>;
  43295. /**
  43296. * Array of button availible on the controller
  43297. */
  43298. protected _buttons: Array<MutableGamepadButton>;
  43299. private _onButtonStateChange;
  43300. /**
  43301. * Fired when a controller button's state has changed
  43302. * @param callback the callback containing the button that was modified
  43303. */
  43304. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43305. /**
  43306. * X and Y axis corrisponding to the controllers joystick
  43307. */
  43308. pad: StickValues;
  43309. /**
  43310. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43311. */
  43312. hand: string;
  43313. /**
  43314. * The default controller model for the controller
  43315. */
  43316. readonly defaultModel: AbstractMesh;
  43317. /**
  43318. * Creates a new WebVRController from a gamepad
  43319. * @param vrGamepad the gamepad that the WebVRController should be created from
  43320. */
  43321. constructor(vrGamepad: any);
  43322. /**
  43323. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43324. */
  43325. update(): void;
  43326. /**
  43327. * Function to be called when a button is modified
  43328. */
  43329. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43330. /**
  43331. * Loads a mesh and attaches it to the controller
  43332. * @param scene the scene the mesh should be added to
  43333. * @param meshLoaded callback for when the mesh has been loaded
  43334. */
  43335. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43336. private _setButtonValue;
  43337. private _changes;
  43338. private _checkChanges;
  43339. /**
  43340. * Disposes of th webVRCOntroller
  43341. */
  43342. dispose(): void;
  43343. }
  43344. }
  43345. declare module BABYLON {
  43346. /**
  43347. * Defines the WindowsMotionController object that the state of the windows motion controller
  43348. */
  43349. class WindowsMotionController extends WebVRController {
  43350. /**
  43351. * The base url used to load the left and right controller models
  43352. */
  43353. static MODEL_BASE_URL: string;
  43354. /**
  43355. * The name of the left controller model file
  43356. */
  43357. static MODEL_LEFT_FILENAME: string;
  43358. /**
  43359. * The name of the right controller model file
  43360. */
  43361. static MODEL_RIGHT_FILENAME: string;
  43362. /**
  43363. * The controller name prefix for this controller type
  43364. */
  43365. static readonly GAMEPAD_ID_PREFIX: string;
  43366. /**
  43367. * The controller id pattern for this controller type
  43368. */
  43369. private static readonly GAMEPAD_ID_PATTERN;
  43370. private _loadedMeshInfo;
  43371. private readonly _mapping;
  43372. /**
  43373. * Fired when the trackpad on this controller is clicked
  43374. */
  43375. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43376. /**
  43377. * Fired when the trackpad on this controller is modified
  43378. */
  43379. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43380. /**
  43381. * The current x and y values of this controller's trackpad
  43382. */
  43383. trackpad: StickValues;
  43384. /**
  43385. * Creates a new WindowsMotionController from a gamepad
  43386. * @param vrGamepad the gamepad that the controller should be created from
  43387. */
  43388. constructor(vrGamepad: any);
  43389. /**
  43390. * Fired when the trigger on this controller is modified
  43391. */
  43392. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43393. /**
  43394. * Fired when the menu button on this controller is modified
  43395. */
  43396. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43397. /**
  43398. * Fired when the grip button on this controller is modified
  43399. */
  43400. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43401. /**
  43402. * Fired when the thumbstick button on this controller is modified
  43403. */
  43404. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43405. /**
  43406. * Fired when the touchpad button on this controller is modified
  43407. */
  43408. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Fired when the touchpad values on this controller are modified
  43411. */
  43412. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43413. private _updateTrackpad;
  43414. /**
  43415. * Called once per frame by the engine.
  43416. */
  43417. update(): void;
  43418. /**
  43419. * Called once for each button that changed state since the last frame
  43420. * @param buttonIdx Which button index changed
  43421. * @param state New state of the button
  43422. * @param changes Which properties on the state changed since last frame
  43423. */
  43424. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43425. /**
  43426. * Moves the buttons on the controller mesh based on their current state
  43427. * @param buttonName the name of the button to move
  43428. * @param buttonValue the value of the button which determines the buttons new position
  43429. */
  43430. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43431. /**
  43432. * Moves the axis on the controller mesh based on its current state
  43433. * @param axis the index of the axis
  43434. * @param axisValue the value of the axis which determines the meshes new position
  43435. * @hidden
  43436. */
  43437. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43438. /**
  43439. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43440. * @param scene scene in which to add meshes
  43441. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43442. */
  43443. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43444. /**
  43445. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43446. * can be transformed by button presses and axes values, based on this._mapping.
  43447. *
  43448. * @param scene scene in which the meshes exist
  43449. * @param meshes list of meshes that make up the controller model to process
  43450. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43451. */
  43452. private processModel;
  43453. private createMeshInfo;
  43454. /**
  43455. * Gets the ray of the controller in the direction the controller is pointing
  43456. * @param length the length the resulting ray should be
  43457. * @returns a ray in the direction the controller is pointing
  43458. */
  43459. getForwardRay(length?: number): Ray;
  43460. /**
  43461. * Disposes of the controller
  43462. */
  43463. dispose(): void;
  43464. }
  43465. }
  43466. declare module BABYLON {
  43467. /**
  43468. * Interface to implement to create a shadow generator compatible with BJS.
  43469. */
  43470. interface IShadowGenerator {
  43471. /**
  43472. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43473. * @returns The render target texture if present otherwise, null
  43474. */
  43475. getShadowMap(): Nullable<RenderTargetTexture>;
  43476. /**
  43477. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43478. * @returns The render target texture if the shadow map is present otherwise, null
  43479. */
  43480. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43481. /**
  43482. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43483. * @param subMesh The submesh we want to render in the shadow map
  43484. * @param useInstances Defines wether will draw in the map using instances
  43485. * @returns true if ready otherwise, false
  43486. */
  43487. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43488. /**
  43489. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43490. * @param defines Defines of the material we want to update
  43491. * @param lightIndex Index of the light in the enabled light list of the material
  43492. */
  43493. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43494. /**
  43495. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43496. * defined in the generator but impacting the effect).
  43497. * It implies the unifroms available on the materials are the standard BJS ones.
  43498. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43499. * @param effect The effect we are binfing the information for
  43500. */
  43501. bindShadowLight(lightIndex: string, effect: Effect): void;
  43502. /**
  43503. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43504. * (eq to shadow prjection matrix * light transform matrix)
  43505. * @returns The transform matrix used to create the shadow map
  43506. */
  43507. getTransformMatrix(): Matrix;
  43508. /**
  43509. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43510. * Cube and 2D textures for instance.
  43511. */
  43512. recreateShadowMap(): void;
  43513. /**
  43514. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43515. * @param onCompiled Callback triggered at the and of the effects compilation
  43516. * @param options Sets of optional options forcing the compilation with different modes
  43517. */
  43518. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43519. useInstances: boolean;
  43520. }>): void;
  43521. /**
  43522. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43523. * @param options Sets of optional options forcing the compilation with different modes
  43524. * @returns A promise that resolves when the compilation completes
  43525. */
  43526. forceCompilationAsync(options?: Partial<{
  43527. useInstances: boolean;
  43528. }>): Promise<void>;
  43529. /**
  43530. * Serializes the shadow generator setup to a json object.
  43531. * @returns The serialized JSON object
  43532. */
  43533. serialize(): any;
  43534. /**
  43535. * Disposes the Shadow map and related Textures and effects.
  43536. */
  43537. dispose(): void;
  43538. }
  43539. /**
  43540. * Default implementation IShadowGenerator.
  43541. * This is the main object responsible of generating shadows in the framework.
  43542. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43543. */
  43544. class ShadowGenerator implements IShadowGenerator {
  43545. /**
  43546. * Shadow generator mode None: no filtering applied.
  43547. */
  43548. static readonly FILTER_NONE: number;
  43549. /**
  43550. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43551. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43552. */
  43553. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43554. /**
  43555. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43556. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43557. */
  43558. static readonly FILTER_POISSONSAMPLING: number;
  43559. /**
  43560. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43561. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43562. */
  43563. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43564. /**
  43565. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43566. * edge artifacts on steep falloff.
  43567. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43568. */
  43569. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43570. /**
  43571. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43572. * edge artifacts on steep falloff.
  43573. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43574. */
  43575. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43576. /**
  43577. * Shadow generator mode PCF: Percentage Closer Filtering
  43578. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43579. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43580. */
  43581. static readonly FILTER_PCF: number;
  43582. /**
  43583. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43584. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43585. * Contact Hardening
  43586. */
  43587. static readonly FILTER_PCSS: number;
  43588. /**
  43589. * Reserved for PCF and PCSS
  43590. * Highest Quality.
  43591. *
  43592. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43593. *
  43594. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43595. */
  43596. static readonly QUALITY_HIGH: number;
  43597. /**
  43598. * Reserved for PCF and PCSS
  43599. * Good tradeoff for quality/perf cross devices
  43600. *
  43601. * Execute PCF on a 3*3 kernel.
  43602. *
  43603. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43604. */
  43605. static readonly QUALITY_MEDIUM: number;
  43606. /**
  43607. * Reserved for PCF and PCSS
  43608. * The lowest quality but the fastest.
  43609. *
  43610. * Execute PCF on a 1*1 kernel.
  43611. *
  43612. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43613. */
  43614. static readonly QUALITY_LOW: number;
  43615. private _bias;
  43616. /**
  43617. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43618. */
  43619. /**
  43620. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43621. */
  43622. bias: number;
  43623. private _normalBias;
  43624. /**
  43625. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43626. */
  43627. /**
  43628. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43629. */
  43630. normalBias: number;
  43631. private _blurBoxOffset;
  43632. /**
  43633. * Gets the blur box offset: offset applied during the blur pass.
  43634. * Only usefull if useKernelBlur = false
  43635. */
  43636. /**
  43637. * Sets the blur box offset: offset applied during the blur pass.
  43638. * Only usefull if useKernelBlur = false
  43639. */
  43640. blurBoxOffset: number;
  43641. private _blurScale;
  43642. /**
  43643. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43644. * 2 means half of the size.
  43645. */
  43646. /**
  43647. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43648. * 2 means half of the size.
  43649. */
  43650. blurScale: number;
  43651. private _blurKernel;
  43652. /**
  43653. * Gets the blur kernel: kernel size of the blur pass.
  43654. * Only usefull if useKernelBlur = true
  43655. */
  43656. /**
  43657. * Sets the blur kernel: kernel size of the blur pass.
  43658. * Only usefull if useKernelBlur = true
  43659. */
  43660. blurKernel: number;
  43661. private _useKernelBlur;
  43662. /**
  43663. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43664. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43665. */
  43666. /**
  43667. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43668. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43669. */
  43670. useKernelBlur: boolean;
  43671. private _depthScale;
  43672. /**
  43673. * Gets the depth scale used in ESM mode.
  43674. */
  43675. /**
  43676. * Sets the depth scale used in ESM mode.
  43677. * This can override the scale stored on the light.
  43678. */
  43679. depthScale: number;
  43680. private _filter;
  43681. /**
  43682. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43683. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43684. */
  43685. /**
  43686. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43688. */
  43689. filter: number;
  43690. /**
  43691. * Gets if the current filter is set to Poisson Sampling.
  43692. */
  43693. /**
  43694. * Sets the current filter to Poisson Sampling.
  43695. */
  43696. usePoissonSampling: boolean;
  43697. /**
  43698. * Gets if the current filter is set to VSM.
  43699. * DEPRECATED. Should use useExponentialShadowMap instead.
  43700. */
  43701. /**
  43702. * Sets the current filter is to VSM.
  43703. * DEPRECATED. Should use useExponentialShadowMap instead.
  43704. */
  43705. useVarianceShadowMap: boolean;
  43706. /**
  43707. * Gets if the current filter is set to blurred VSM.
  43708. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43709. */
  43710. /**
  43711. * Sets the current filter is to blurred VSM.
  43712. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43713. */
  43714. useBlurVarianceShadowMap: boolean;
  43715. /**
  43716. * Gets if the current filter is set to ESM.
  43717. */
  43718. /**
  43719. * Sets the current filter is to ESM.
  43720. */
  43721. useExponentialShadowMap: boolean;
  43722. /**
  43723. * Gets if the current filter is set to filtered ESM.
  43724. */
  43725. /**
  43726. * Gets if the current filter is set to filtered ESM.
  43727. */
  43728. useBlurExponentialShadowMap: boolean;
  43729. /**
  43730. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43731. * exponential to prevent steep falloff artifacts).
  43732. */
  43733. /**
  43734. * Sets the current filter to "close ESM" (using the inverse of the
  43735. * exponential to prevent steep falloff artifacts).
  43736. */
  43737. useCloseExponentialShadowMap: boolean;
  43738. /**
  43739. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43740. * exponential to prevent steep falloff artifacts).
  43741. */
  43742. /**
  43743. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43744. * exponential to prevent steep falloff artifacts).
  43745. */
  43746. useBlurCloseExponentialShadowMap: boolean;
  43747. /**
  43748. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43749. */
  43750. /**
  43751. * Sets the current filter to "PCF" (percentage closer filtering).
  43752. */
  43753. usePercentageCloserFiltering: boolean;
  43754. private _filteringQuality;
  43755. /**
  43756. * Gets the PCF or PCSS Quality.
  43757. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43758. */
  43759. /**
  43760. * Sets the PCF or PCSS Quality.
  43761. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43762. */
  43763. filteringQuality: number;
  43764. /**
  43765. * Gets if the current filter is set to "PCSS" (contact hardening).
  43766. */
  43767. /**
  43768. * Sets the current filter to "PCSS" (contact hardening).
  43769. */
  43770. useContactHardeningShadow: boolean;
  43771. private _contactHardeningLightSizeUVRatio;
  43772. /**
  43773. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43774. * Using a ratio helps keeping shape stability independently of the map size.
  43775. *
  43776. * It does not account for the light projection as it was having too much
  43777. * instability during the light setup or during light position changes.
  43778. *
  43779. * Only valid if useContactHardeningShadow is true.
  43780. */
  43781. /**
  43782. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43783. * Using a ratio helps keeping shape stability independently of the map size.
  43784. *
  43785. * It does not account for the light projection as it was having too much
  43786. * instability during the light setup or during light position changes.
  43787. *
  43788. * Only valid if useContactHardeningShadow is true.
  43789. */
  43790. contactHardeningLightSizeUVRatio: number;
  43791. private _darkness;
  43792. /**
  43793. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43794. * 0 means strongest and 1 would means no shadow.
  43795. * @returns the darkness.
  43796. */
  43797. getDarkness(): number;
  43798. /**
  43799. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43800. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43801. * @returns the shadow generator allowing fluent coding.
  43802. */
  43803. setDarkness(darkness: number): ShadowGenerator;
  43804. private _transparencyShadow;
  43805. /**
  43806. * Sets the ability to have transparent shadow (boolean).
  43807. * @param transparent True if transparent else False
  43808. * @returns the shadow generator allowing fluent coding
  43809. */
  43810. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43811. private _shadowMap;
  43812. private _shadowMap2;
  43813. /**
  43814. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43815. * @returns The render target texture if present otherwise, null
  43816. */
  43817. getShadowMap(): Nullable<RenderTargetTexture>;
  43818. /**
  43819. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43820. * @returns The render target texture if the shadow map is present otherwise, null
  43821. */
  43822. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43823. /**
  43824. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43825. * @param mesh Mesh to add
  43826. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43827. * @returns the Shadow Generator itself
  43828. */
  43829. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43830. /**
  43831. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43832. * @param mesh Mesh to remove
  43833. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43834. * @returns the Shadow Generator itself
  43835. */
  43836. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43837. /**
  43838. * Controls the extent to which the shadows fade out at the edge of the frustum
  43839. * Used only by directionals and spots
  43840. */
  43841. frustumEdgeFalloff: number;
  43842. private _light;
  43843. /**
  43844. * Returns the associated light object.
  43845. * @returns the light generating the shadow
  43846. */
  43847. getLight(): IShadowLight;
  43848. /**
  43849. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43850. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43851. * It might on the other hand introduce peter panning.
  43852. */
  43853. forceBackFacesOnly: boolean;
  43854. private _scene;
  43855. private _lightDirection;
  43856. private _effect;
  43857. private _viewMatrix;
  43858. private _projectionMatrix;
  43859. private _transformMatrix;
  43860. private _cachedPosition;
  43861. private _cachedDirection;
  43862. private _cachedDefines;
  43863. private _currentRenderID;
  43864. private _boxBlurPostprocess;
  43865. private _kernelBlurXPostprocess;
  43866. private _kernelBlurYPostprocess;
  43867. private _blurPostProcesses;
  43868. private _mapSize;
  43869. private _currentFaceIndex;
  43870. private _currentFaceIndexCache;
  43871. private _textureType;
  43872. private _defaultTextureMatrix;
  43873. /**
  43874. * Creates a ShadowGenerator object.
  43875. * A ShadowGenerator is the required tool to use the shadows.
  43876. * Each light casting shadows needs to use its own ShadowGenerator.
  43877. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43878. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43879. * @param light The light object generating the shadows.
  43880. * @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.
  43881. */
  43882. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43883. private _initializeGenerator;
  43884. private _initializeShadowMap;
  43885. private _initializeBlurRTTAndPostProcesses;
  43886. private _renderForShadowMap;
  43887. private _renderSubMeshForShadowMap;
  43888. private _applyFilterValues;
  43889. /**
  43890. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43891. * @param onCompiled Callback triggered at the and of the effects compilation
  43892. * @param options Sets of optional options forcing the compilation with different modes
  43893. */
  43894. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43895. useInstances: boolean;
  43896. }>): void;
  43897. /**
  43898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43899. * @param options Sets of optional options forcing the compilation with different modes
  43900. * @returns A promise that resolves when the compilation completes
  43901. */
  43902. forceCompilationAsync(options?: Partial<{
  43903. useInstances: boolean;
  43904. }>): Promise<void>;
  43905. /**
  43906. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43907. * @param subMesh The submesh we want to render in the shadow map
  43908. * @param useInstances Defines wether will draw in the map using instances
  43909. * @returns true if ready otherwise, false
  43910. */
  43911. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43912. /**
  43913. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43914. * @param defines Defines of the material we want to update
  43915. * @param lightIndex Index of the light in the enabled light list of the material
  43916. */
  43917. prepareDefines(defines: any, lightIndex: number): void;
  43918. /**
  43919. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43920. * defined in the generator but impacting the effect).
  43921. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43922. * @param effect The effect we are binfing the information for
  43923. */
  43924. bindShadowLight(lightIndex: string, effect: Effect): void;
  43925. /**
  43926. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43927. * (eq to shadow prjection matrix * light transform matrix)
  43928. * @returns The transform matrix used to create the shadow map
  43929. */
  43930. getTransformMatrix(): Matrix;
  43931. /**
  43932. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43933. * Cube and 2D textures for instance.
  43934. */
  43935. recreateShadowMap(): void;
  43936. private _disposeBlurPostProcesses;
  43937. private _disposeRTTandPostProcesses;
  43938. /**
  43939. * Disposes the ShadowGenerator.
  43940. * Returns nothing.
  43941. */
  43942. dispose(): void;
  43943. /**
  43944. * Serializes the shadow generator setup to a json object.
  43945. * @returns The serialized JSON object
  43946. */
  43947. serialize(): any;
  43948. /**
  43949. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43950. * @param parsedShadowGenerator The JSON object to parse
  43951. * @param scene The scene to create the shadow map for
  43952. * @returns The parsed shadow generator
  43953. */
  43954. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43955. }
  43956. }
  43957. declare module BABYLON {
  43958. /**
  43959. * Defines the shadow generator component responsible to manage any shadow generators
  43960. * in a given scene.
  43961. */
  43962. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43963. /**
  43964. * The component name helpfull to identify the component in the list of scene components.
  43965. */
  43966. readonly name: string;
  43967. /**
  43968. * The scene the component belongs to.
  43969. */
  43970. scene: Scene;
  43971. /**
  43972. * Creates a new instance of the component for the given scene
  43973. * @param scene Defines the scene to register the component in
  43974. */
  43975. constructor(scene: Scene);
  43976. /**
  43977. * Registers the component in a given scene
  43978. */
  43979. register(): void;
  43980. /**
  43981. * Rebuilds the elements related to this component in case of
  43982. * context lost for instance.
  43983. */
  43984. rebuild(): void;
  43985. /**
  43986. * Serializes the component data to the specified json object
  43987. * @param serializationObject The object to serialize to
  43988. */
  43989. serialize(serializationObject: any): void;
  43990. /**
  43991. * Adds all the element from the container to the scene
  43992. * @param container the container holding the elements
  43993. */
  43994. addFromContainer(container: AbstractScene): void;
  43995. /**
  43996. * Removes all the elements in the container from the scene
  43997. * @param container contains the elements to remove
  43998. */
  43999. removeFromContainer(container: AbstractScene): void;
  44000. /**
  44001. * Rebuilds the elements related to this component in case of
  44002. * context lost for instance.
  44003. */
  44004. dispose(): void;
  44005. private _gatherRenderTargets;
  44006. }
  44007. }
  44008. declare module BABYLON {
  44009. }
  44010. declare module BABYLON {
  44011. /**
  44012. * Background material used to create an efficient environement around your scene.
  44013. */
  44014. class BackgroundMaterial extends PushMaterial {
  44015. /**
  44016. * Standard reflectance value at parallel view angle.
  44017. */
  44018. static StandardReflectance0: number;
  44019. /**
  44020. * Standard reflectance value at grazing angle.
  44021. */
  44022. static StandardReflectance90: number;
  44023. protected _primaryColor: Color3;
  44024. /**
  44025. * Key light Color (multiply against the environement texture)
  44026. */
  44027. primaryColor: Color3;
  44028. protected __perceptualColor: Nullable<Color3>;
  44029. /**
  44030. * Experimental Internal Use Only.
  44031. *
  44032. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44033. * This acts as a helper to set the primary color to a more "human friendly" value.
  44034. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44035. * output color as close as possible from the chosen value.
  44036. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44037. * part of lighting setup.)
  44038. */
  44039. _perceptualColor: Nullable<Color3>;
  44040. protected _primaryColorShadowLevel: float;
  44041. /**
  44042. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44043. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44044. */
  44045. primaryColorShadowLevel: float;
  44046. protected _primaryColorHighlightLevel: float;
  44047. /**
  44048. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44049. * The primary color is used at the level chosen to define what the white area would look.
  44050. */
  44051. primaryColorHighlightLevel: float;
  44052. protected _reflectionTexture: Nullable<BaseTexture>;
  44053. /**
  44054. * Reflection Texture used in the material.
  44055. * Should be author in a specific way for the best result (refer to the documentation).
  44056. */
  44057. reflectionTexture: Nullable<BaseTexture>;
  44058. protected _reflectionBlur: float;
  44059. /**
  44060. * Reflection Texture level of blur.
  44061. *
  44062. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44063. * texture twice.
  44064. */
  44065. reflectionBlur: float;
  44066. protected _diffuseTexture: Nullable<BaseTexture>;
  44067. /**
  44068. * Diffuse Texture used in the material.
  44069. * Should be author in a specific way for the best result (refer to the documentation).
  44070. */
  44071. diffuseTexture: Nullable<BaseTexture>;
  44072. protected _shadowLights: Nullable<IShadowLight[]>;
  44073. /**
  44074. * Specify the list of lights casting shadow on the material.
  44075. * All scene shadow lights will be included if null.
  44076. */
  44077. shadowLights: Nullable<IShadowLight[]>;
  44078. protected _shadowLevel: float;
  44079. /**
  44080. * Helps adjusting the shadow to a softer level if required.
  44081. * 0 means black shadows and 1 means no shadows.
  44082. */
  44083. shadowLevel: float;
  44084. protected _sceneCenter: Vector3;
  44085. /**
  44086. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44087. * It is usually zero but might be interesting to modify according to your setup.
  44088. */
  44089. sceneCenter: Vector3;
  44090. protected _opacityFresnel: boolean;
  44091. /**
  44092. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44093. * This helps ensuring a nice transition when the camera goes under the ground.
  44094. */
  44095. opacityFresnel: boolean;
  44096. protected _reflectionFresnel: boolean;
  44097. /**
  44098. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44099. * This helps adding a mirror texture on the ground.
  44100. */
  44101. reflectionFresnel: boolean;
  44102. protected _reflectionFalloffDistance: number;
  44103. /**
  44104. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44105. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44106. */
  44107. reflectionFalloffDistance: number;
  44108. protected _reflectionAmount: number;
  44109. /**
  44110. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44111. */
  44112. reflectionAmount: number;
  44113. protected _reflectionReflectance0: number;
  44114. /**
  44115. * This specifies the weight of the reflection at grazing angle.
  44116. */
  44117. reflectionReflectance0: number;
  44118. protected _reflectionReflectance90: number;
  44119. /**
  44120. * This specifies the weight of the reflection at a perpendicular point of view.
  44121. */
  44122. reflectionReflectance90: number;
  44123. /**
  44124. * Sets the reflection reflectance fresnel values according to the default standard
  44125. * empirically know to work well :-)
  44126. */
  44127. reflectionStandardFresnelWeight: number;
  44128. protected _useRGBColor: boolean;
  44129. /**
  44130. * Helps to directly use the maps channels instead of their level.
  44131. */
  44132. useRGBColor: boolean;
  44133. protected _enableNoise: boolean;
  44134. /**
  44135. * This helps reducing the banding effect that could occur on the background.
  44136. */
  44137. enableNoise: boolean;
  44138. /**
  44139. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44140. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44141. * Recommended to be keep at 1.0 except for special cases.
  44142. */
  44143. fovMultiplier: number;
  44144. private _fovMultiplier;
  44145. /**
  44146. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44147. */
  44148. useEquirectangularFOV: boolean;
  44149. private _maxSimultaneousLights;
  44150. /**
  44151. * Number of Simultaneous lights allowed on the material.
  44152. */
  44153. maxSimultaneousLights: int;
  44154. /**
  44155. * Default configuration related to image processing available in the Background Material.
  44156. */
  44157. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44158. /**
  44159. * Keep track of the image processing observer to allow dispose and replace.
  44160. */
  44161. private _imageProcessingObserver;
  44162. /**
  44163. * Attaches a new image processing configuration to the PBR Material.
  44164. * @param configuration (if null the scene configuration will be use)
  44165. */
  44166. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44167. /**
  44168. * Gets the image processing configuration used either in this material.
  44169. */
  44170. /**
  44171. * Sets the Default image processing configuration used either in the this material.
  44172. *
  44173. * If sets to null, the scene one is in use.
  44174. */
  44175. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44176. /**
  44177. * Gets wether the color curves effect is enabled.
  44178. */
  44179. /**
  44180. * Sets wether the color curves effect is enabled.
  44181. */
  44182. cameraColorCurvesEnabled: boolean;
  44183. /**
  44184. * Gets wether the color grading effect is enabled.
  44185. */
  44186. /**
  44187. * Gets wether the color grading effect is enabled.
  44188. */
  44189. cameraColorGradingEnabled: boolean;
  44190. /**
  44191. * Gets wether tonemapping is enabled or not.
  44192. */
  44193. /**
  44194. * Sets wether tonemapping is enabled or not
  44195. */
  44196. cameraToneMappingEnabled: boolean;
  44197. /**
  44198. * The camera exposure used on this material.
  44199. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44200. * This corresponds to a photographic exposure.
  44201. */
  44202. /**
  44203. * The camera exposure used on this material.
  44204. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44205. * This corresponds to a photographic exposure.
  44206. */
  44207. cameraExposure: float;
  44208. /**
  44209. * Gets The camera contrast used on this material.
  44210. */
  44211. /**
  44212. * Sets The camera contrast used on this material.
  44213. */
  44214. cameraContrast: float;
  44215. /**
  44216. * Gets the Color Grading 2D Lookup Texture.
  44217. */
  44218. /**
  44219. * Sets the Color Grading 2D Lookup Texture.
  44220. */
  44221. cameraColorGradingTexture: Nullable<BaseTexture>;
  44222. /**
  44223. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44224. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44225. * 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;
  44226. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44227. */
  44228. /**
  44229. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44230. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44231. * 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;
  44232. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44233. */
  44234. cameraColorCurves: Nullable<ColorCurves>;
  44235. /**
  44236. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44237. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44238. */
  44239. switchToBGR: boolean;
  44240. private _renderTargets;
  44241. private _reflectionControls;
  44242. private _white;
  44243. private _primaryShadowColor;
  44244. private _primaryHighlightColor;
  44245. /**
  44246. * Instantiates a Background Material in the given scene
  44247. * @param name The friendly name of the material
  44248. * @param scene The scene to add the material to
  44249. */
  44250. constructor(name: string, scene: Scene);
  44251. /**
  44252. * Gets a boolean indicating that current material needs to register RTT
  44253. */
  44254. readonly hasRenderTargetTextures: boolean;
  44255. /**
  44256. * The entire material has been created in order to prevent overdraw.
  44257. * @returns false
  44258. */
  44259. needAlphaTesting(): boolean;
  44260. /**
  44261. * The entire material has been created in order to prevent overdraw.
  44262. * @returns true if blending is enable
  44263. */
  44264. needAlphaBlending(): boolean;
  44265. /**
  44266. * Checks wether the material is ready to be rendered for a given mesh.
  44267. * @param mesh The mesh to render
  44268. * @param subMesh The submesh to check against
  44269. * @param useInstances Specify wether or not the material is used with instances
  44270. * @returns true if all the dependencies are ready (Textures, Effects...)
  44271. */
  44272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44273. /**
  44274. * Compute the primary color according to the chosen perceptual color.
  44275. */
  44276. private _computePrimaryColorFromPerceptualColor;
  44277. /**
  44278. * Compute the highlights and shadow colors according to their chosen levels.
  44279. */
  44280. private _computePrimaryColors;
  44281. /**
  44282. * Build the uniform buffer used in the material.
  44283. */
  44284. buildUniformLayout(): void;
  44285. /**
  44286. * Unbind the material.
  44287. */
  44288. unbind(): void;
  44289. /**
  44290. * Bind only the world matrix to the material.
  44291. * @param world The world matrix to bind.
  44292. */
  44293. bindOnlyWorldMatrix(world: Matrix): void;
  44294. /**
  44295. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44296. * @param world The world matrix to bind.
  44297. * @param subMesh The submesh to bind for.
  44298. */
  44299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44300. /**
  44301. * Dispose the material.
  44302. * @param forceDisposeEffect Force disposal of the associated effect.
  44303. * @param forceDisposeTextures Force disposal of the associated textures.
  44304. */
  44305. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44306. /**
  44307. * Clones the material.
  44308. * @param name The cloned name.
  44309. * @returns The cloned material.
  44310. */
  44311. clone(name: string): BackgroundMaterial;
  44312. /**
  44313. * Serializes the current material to its JSON representation.
  44314. * @returns The JSON representation.
  44315. */
  44316. serialize(): any;
  44317. /**
  44318. * Gets the class name of the material
  44319. * @returns "BackgroundMaterial"
  44320. */
  44321. getClassName(): string;
  44322. /**
  44323. * Parse a JSON input to create back a background material.
  44324. * @param source The JSON data to parse
  44325. * @param scene The scene to create the parsed material in
  44326. * @param rootUrl The root url of the assets the material depends upon
  44327. * @returns the instantiated BackgroundMaterial.
  44328. */
  44329. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44330. }
  44331. }
  44332. declare module BABYLON {
  44333. /**
  44334. * The Physically based material base class of BJS.
  44335. *
  44336. * This offers the main features of a standard PBR material.
  44337. * For more information, please refer to the documentation :
  44338. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44339. */
  44340. abstract class PBRBaseMaterial extends PushMaterial {
  44341. /**
  44342. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44343. */
  44344. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44345. /**
  44346. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44347. * to enhance interoperability with other engines.
  44348. */
  44349. static readonly LIGHTFALLOFF_GLTF: number;
  44350. /**
  44351. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44352. * to enhance interoperability with other materials.
  44353. */
  44354. static readonly LIGHTFALLOFF_STANDARD: number;
  44355. /**
  44356. * Intensity of the direct lights e.g. the four lights available in your scene.
  44357. * This impacts both the direct diffuse and specular highlights.
  44358. */
  44359. protected _directIntensity: number;
  44360. /**
  44361. * Intensity of the emissive part of the material.
  44362. * This helps controlling the emissive effect without modifying the emissive color.
  44363. */
  44364. protected _emissiveIntensity: number;
  44365. /**
  44366. * Intensity of the environment e.g. how much the environment will light the object
  44367. * either through harmonics for rough material or through the refelction for shiny ones.
  44368. */
  44369. protected _environmentIntensity: number;
  44370. /**
  44371. * This is a special control allowing the reduction of the specular highlights coming from the
  44372. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44373. */
  44374. protected _specularIntensity: number;
  44375. /**
  44376. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44377. */
  44378. private _lightingInfos;
  44379. /**
  44380. * Debug Control allowing disabling the bump map on this material.
  44381. */
  44382. protected _disableBumpMap: boolean;
  44383. /**
  44384. * AKA Diffuse Texture in standard nomenclature.
  44385. */
  44386. protected _albedoTexture: BaseTexture;
  44387. /**
  44388. * AKA Occlusion Texture in other nomenclature.
  44389. */
  44390. protected _ambientTexture: BaseTexture;
  44391. /**
  44392. * AKA Occlusion Texture Intensity in other nomenclature.
  44393. */
  44394. protected _ambientTextureStrength: number;
  44395. /**
  44396. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44397. * 1 means it completely occludes it
  44398. * 0 mean it has no impact
  44399. */
  44400. protected _ambientTextureImpactOnAnalyticalLights: number;
  44401. /**
  44402. * Stores the alpha values in a texture.
  44403. */
  44404. protected _opacityTexture: BaseTexture;
  44405. /**
  44406. * Stores the reflection values in a texture.
  44407. */
  44408. protected _reflectionTexture: BaseTexture;
  44409. /**
  44410. * Stores the refraction values in a texture.
  44411. */
  44412. protected _refractionTexture: BaseTexture;
  44413. /**
  44414. * Stores the emissive values in a texture.
  44415. */
  44416. protected _emissiveTexture: BaseTexture;
  44417. /**
  44418. * AKA Specular texture in other nomenclature.
  44419. */
  44420. protected _reflectivityTexture: BaseTexture;
  44421. /**
  44422. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44423. */
  44424. protected _metallicTexture: BaseTexture;
  44425. /**
  44426. * Specifies the metallic scalar of the metallic/roughness workflow.
  44427. * Can also be used to scale the metalness values of the metallic texture.
  44428. */
  44429. protected _metallic: Nullable<number>;
  44430. /**
  44431. * Specifies the roughness scalar of the metallic/roughness workflow.
  44432. * Can also be used to scale the roughness values of the metallic texture.
  44433. */
  44434. protected _roughness: Nullable<number>;
  44435. /**
  44436. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44437. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44438. */
  44439. protected _microSurfaceTexture: BaseTexture;
  44440. /**
  44441. * Stores surface normal data used to displace a mesh in a texture.
  44442. */
  44443. protected _bumpTexture: BaseTexture;
  44444. /**
  44445. * Stores the pre-calculated light information of a mesh in a texture.
  44446. */
  44447. protected _lightmapTexture: BaseTexture;
  44448. /**
  44449. * The color of a material in ambient lighting.
  44450. */
  44451. protected _ambientColor: Color3;
  44452. /**
  44453. * AKA Diffuse Color in other nomenclature.
  44454. */
  44455. protected _albedoColor: Color3;
  44456. /**
  44457. * AKA Specular Color in other nomenclature.
  44458. */
  44459. protected _reflectivityColor: Color3;
  44460. /**
  44461. * The color applied when light is reflected from a material.
  44462. */
  44463. protected _reflectionColor: Color3;
  44464. /**
  44465. * The color applied when light is emitted from a material.
  44466. */
  44467. protected _emissiveColor: Color3;
  44468. /**
  44469. * AKA Glossiness in other nomenclature.
  44470. */
  44471. protected _microSurface: number;
  44472. /**
  44473. * source material index of refraction (IOR)' / 'destination material IOR.
  44474. */
  44475. protected _indexOfRefraction: number;
  44476. /**
  44477. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44478. */
  44479. protected _invertRefractionY: boolean;
  44480. /**
  44481. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44482. * Materials half opaque for instance using refraction could benefit from this control.
  44483. */
  44484. protected _linkRefractionWithTransparency: boolean;
  44485. /**
  44486. * Specifies that the material will use the light map as a show map.
  44487. */
  44488. protected _useLightmapAsShadowmap: boolean;
  44489. /**
  44490. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44491. * makes the reflect vector face the model (under horizon).
  44492. */
  44493. protected _useHorizonOcclusion: boolean;
  44494. /**
  44495. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44496. * too much the area relying on ambient texture to define their ambient occlusion.
  44497. */
  44498. protected _useRadianceOcclusion: boolean;
  44499. /**
  44500. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44501. */
  44502. protected _useAlphaFromAlbedoTexture: boolean;
  44503. /**
  44504. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44505. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44506. */
  44507. protected _useSpecularOverAlpha: boolean;
  44508. /**
  44509. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44510. */
  44511. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44512. /**
  44513. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44514. */
  44515. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44516. /**
  44517. * Specifies if the metallic texture contains the roughness information in its green channel.
  44518. */
  44519. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44520. /**
  44521. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44522. */
  44523. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44524. /**
  44525. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44526. */
  44527. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44528. /**
  44529. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44530. */
  44531. protected _useAmbientInGrayScale: boolean;
  44532. /**
  44533. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44534. * The material will try to infer what glossiness each pixel should be.
  44535. */
  44536. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44537. /**
  44538. * Defines the falloff type used in this material.
  44539. * It by default is Physical.
  44540. */
  44541. protected _lightFalloff: number;
  44542. /**
  44543. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44544. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44545. */
  44546. protected _useRadianceOverAlpha: boolean;
  44547. /**
  44548. * Allows using an object space normal map (instead of tangent space).
  44549. */
  44550. protected _useObjectSpaceNormalMap: boolean;
  44551. /**
  44552. * Allows using the bump map in parallax mode.
  44553. */
  44554. protected _useParallax: boolean;
  44555. /**
  44556. * Allows using the bump map in parallax occlusion mode.
  44557. */
  44558. protected _useParallaxOcclusion: boolean;
  44559. /**
  44560. * Controls the scale bias of the parallax mode.
  44561. */
  44562. protected _parallaxScaleBias: number;
  44563. /**
  44564. * If sets to true, disables all the lights affecting the material.
  44565. */
  44566. protected _disableLighting: boolean;
  44567. /**
  44568. * Number of Simultaneous lights allowed on the material.
  44569. */
  44570. protected _maxSimultaneousLights: number;
  44571. /**
  44572. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44573. */
  44574. protected _invertNormalMapX: boolean;
  44575. /**
  44576. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44577. */
  44578. protected _invertNormalMapY: boolean;
  44579. /**
  44580. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44581. */
  44582. protected _twoSidedLighting: boolean;
  44583. /**
  44584. * Defines the alpha limits in alpha test mode.
  44585. */
  44586. protected _alphaCutOff: number;
  44587. /**
  44588. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44589. */
  44590. protected _forceAlphaTest: boolean;
  44591. /**
  44592. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44593. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44594. */
  44595. protected _useAlphaFresnel: boolean;
  44596. /**
  44597. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44598. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44599. */
  44600. protected _useLinearAlphaFresnel: boolean;
  44601. /**
  44602. * The transparency mode of the material.
  44603. */
  44604. protected _transparencyMode: Nullable<number>;
  44605. /**
  44606. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44607. * from cos thetav and roughness:
  44608. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44609. */
  44610. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44611. /**
  44612. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44613. */
  44614. protected _forceIrradianceInFragment: boolean;
  44615. /**
  44616. * Force normal to face away from face.
  44617. */
  44618. protected _forceNormalForward: boolean;
  44619. /**
  44620. * Enables specular anti aliasing in the PBR shader.
  44621. * It will both interacts on the Geometry for analytical and IBL lighting.
  44622. * It also prefilter the roughness map based on the bump values.
  44623. */
  44624. protected _enableSpecularAntiAliasing: boolean;
  44625. /**
  44626. * Default configuration related to image processing available in the PBR Material.
  44627. */
  44628. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44629. /**
  44630. * Keep track of the image processing observer to allow dispose and replace.
  44631. */
  44632. private _imageProcessingObserver;
  44633. /**
  44634. * Attaches a new image processing configuration to the PBR Material.
  44635. * @param configuration
  44636. */
  44637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44638. /**
  44639. * Stores the available render targets.
  44640. */
  44641. private _renderTargets;
  44642. /**
  44643. * Sets the global ambient color for the material used in lighting calculations.
  44644. */
  44645. private _globalAmbientColor;
  44646. /**
  44647. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44648. */
  44649. private _useLogarithmicDepth;
  44650. /**
  44651. * If set to true, no lighting calculations will be applied.
  44652. */
  44653. private _unlit;
  44654. /**
  44655. * Instantiates a new PBRMaterial instance.
  44656. *
  44657. * @param name The material name
  44658. * @param scene The scene the material will be use in.
  44659. */
  44660. constructor(name: string, scene: Scene);
  44661. /**
  44662. * Gets a boolean indicating that current material needs to register RTT
  44663. */
  44664. readonly hasRenderTargetTextures: boolean;
  44665. /**
  44666. * Gets the name of the material class.
  44667. */
  44668. getClassName(): string;
  44669. /**
  44670. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44671. */
  44672. /**
  44673. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44674. */
  44675. useLogarithmicDepth: boolean;
  44676. /**
  44677. * Gets the current transparency mode.
  44678. */
  44679. /**
  44680. * Sets the transparency mode of the material.
  44681. *
  44682. * | Value | Type | Description |
  44683. * | ----- | ----------------------------------- | ----------- |
  44684. * | 0 | OPAQUE | |
  44685. * | 1 | ALPHATEST | |
  44686. * | 2 | ALPHABLEND | |
  44687. * | 3 | ALPHATESTANDBLEND | |
  44688. *
  44689. */
  44690. transparencyMode: Nullable<number>;
  44691. /**
  44692. * Returns true if alpha blending should be disabled.
  44693. */
  44694. private readonly _disableAlphaBlending;
  44695. /**
  44696. * Specifies whether or not this material should be rendered in alpha blend mode.
  44697. */
  44698. needAlphaBlending(): boolean;
  44699. /**
  44700. * Specifies if the mesh will require alpha blending.
  44701. * @param mesh - BJS mesh.
  44702. */
  44703. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44704. /**
  44705. * Specifies whether or not this material should be rendered in alpha test mode.
  44706. */
  44707. needAlphaTesting(): boolean;
  44708. /**
  44709. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44710. */
  44711. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44712. /**
  44713. * Gets the texture used for the alpha test.
  44714. */
  44715. getAlphaTestTexture(): BaseTexture;
  44716. /**
  44717. * Stores the reflectivity values based on metallic roughness workflow.
  44718. */
  44719. private static _scaledReflectivity;
  44720. /**
  44721. * Specifies that the submesh is ready to be used.
  44722. * @param mesh - BJS mesh.
  44723. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44724. * @param useInstances - Specifies that instances should be used.
  44725. * @returns - boolean indicating that the submesh is ready or not.
  44726. */
  44727. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44728. /**
  44729. * Specifies if the material uses metallic roughness workflow.
  44730. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44731. */
  44732. isMetallicWorkflow(): boolean;
  44733. private _prepareEffect;
  44734. private _prepareDefines;
  44735. /**
  44736. * Force shader compilation
  44737. */
  44738. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44739. clipPlane: boolean;
  44740. }>): void;
  44741. /**
  44742. * Initializes the uniform buffer layout for the shader.
  44743. */
  44744. buildUniformLayout(): void;
  44745. /**
  44746. * Unbinds the textures.
  44747. */
  44748. unbind(): void;
  44749. /**
  44750. * Binds the submesh data.
  44751. * @param world - The world matrix.
  44752. * @param mesh - The BJS mesh.
  44753. * @param subMesh - A submesh of the BJS mesh.
  44754. */
  44755. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44756. /**
  44757. * Returns the animatable textures.
  44758. * @returns - Array of animatable textures.
  44759. */
  44760. getAnimatables(): IAnimatable[];
  44761. /**
  44762. * Returns the texture used for reflections.
  44763. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44764. */
  44765. private _getReflectionTexture;
  44766. /**
  44767. * Returns the texture used for refraction or null if none is used.
  44768. * @returns - Refection texture if present. If no refraction texture and refraction
  44769. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44770. */
  44771. private _getRefractionTexture;
  44772. /**
  44773. * Disposes the resources of the material.
  44774. * @param forceDisposeEffect - Forces the disposal of effects.
  44775. * @param forceDisposeTextures - Forces the disposal of all textures.
  44776. */
  44777. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44778. }
  44779. }
  44780. declare module BABYLON {
  44781. /**
  44782. * The Physically based simple base material of BJS.
  44783. *
  44784. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44785. * It is used as the base class for both the specGloss and metalRough conventions.
  44786. */
  44787. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44788. /**
  44789. * Number of Simultaneous lights allowed on the material.
  44790. */
  44791. maxSimultaneousLights: number;
  44792. /**
  44793. * If sets to true, disables all the lights affecting the material.
  44794. */
  44795. disableLighting: boolean;
  44796. /**
  44797. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44798. */
  44799. environmentTexture: BaseTexture;
  44800. /**
  44801. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44802. */
  44803. invertNormalMapX: boolean;
  44804. /**
  44805. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44806. */
  44807. invertNormalMapY: boolean;
  44808. /**
  44809. * Normal map used in the model.
  44810. */
  44811. normalTexture: BaseTexture;
  44812. /**
  44813. * Emissivie color used to self-illuminate the model.
  44814. */
  44815. emissiveColor: Color3;
  44816. /**
  44817. * Emissivie texture used to self-illuminate the model.
  44818. */
  44819. emissiveTexture: BaseTexture;
  44820. /**
  44821. * Occlusion Channel Strenght.
  44822. */
  44823. occlusionStrength: number;
  44824. /**
  44825. * Occlusion Texture of the material (adding extra occlusion effects).
  44826. */
  44827. occlusionTexture: BaseTexture;
  44828. /**
  44829. * Defines the alpha limits in alpha test mode.
  44830. */
  44831. alphaCutOff: number;
  44832. /**
  44833. * Gets the current double sided mode.
  44834. */
  44835. /**
  44836. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44837. */
  44838. doubleSided: boolean;
  44839. /**
  44840. * Stores the pre-calculated light information of a mesh in a texture.
  44841. */
  44842. lightmapTexture: BaseTexture;
  44843. /**
  44844. * If true, the light map contains occlusion information instead of lighting info.
  44845. */
  44846. useLightmapAsShadowmap: boolean;
  44847. /**
  44848. * Return the active textures of the material.
  44849. */
  44850. getActiveTextures(): BaseTexture[];
  44851. hasTexture(texture: BaseTexture): boolean;
  44852. /**
  44853. * Instantiates a new PBRMaterial instance.
  44854. *
  44855. * @param name The material name
  44856. * @param scene The scene the material will be use in.
  44857. */
  44858. constructor(name: string, scene: Scene);
  44859. getClassName(): string;
  44860. }
  44861. }
  44862. declare module BABYLON {
  44863. /**
  44864. * The Physically based material of BJS.
  44865. *
  44866. * This offers the main features of a standard PBR material.
  44867. * For more information, please refer to the documentation :
  44868. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44869. */
  44870. class PBRMaterial extends PBRBaseMaterial {
  44871. /**
  44872. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44873. */
  44874. static readonly PBRMATERIAL_OPAQUE: number;
  44875. /**
  44876. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44877. */
  44878. static readonly PBRMATERIAL_ALPHATEST: number;
  44879. /**
  44880. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44881. */
  44882. static readonly PBRMATERIAL_ALPHABLEND: number;
  44883. /**
  44884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44885. * They are also discarded below the alpha cutoff threshold to improve performances.
  44886. */
  44887. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44888. /**
  44889. * Defines the default value of how much AO map is occluding the analytical lights
  44890. * (point spot...).
  44891. */
  44892. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44893. /**
  44894. * Intensity of the direct lights e.g. the four lights available in your scene.
  44895. * This impacts both the direct diffuse and specular highlights.
  44896. */
  44897. directIntensity: number;
  44898. /**
  44899. * Intensity of the emissive part of the material.
  44900. * This helps controlling the emissive effect without modifying the emissive color.
  44901. */
  44902. emissiveIntensity: number;
  44903. /**
  44904. * Intensity of the environment e.g. how much the environment will light the object
  44905. * either through harmonics for rough material or through the refelction for shiny ones.
  44906. */
  44907. environmentIntensity: number;
  44908. /**
  44909. * This is a special control allowing the reduction of the specular highlights coming from the
  44910. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44911. */
  44912. specularIntensity: number;
  44913. /**
  44914. * Debug Control allowing disabling the bump map on this material.
  44915. */
  44916. disableBumpMap: boolean;
  44917. /**
  44918. * AKA Diffuse Texture in standard nomenclature.
  44919. */
  44920. albedoTexture: BaseTexture;
  44921. /**
  44922. * AKA Occlusion Texture in other nomenclature.
  44923. */
  44924. ambientTexture: BaseTexture;
  44925. /**
  44926. * AKA Occlusion Texture Intensity in other nomenclature.
  44927. */
  44928. 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. ambientTextureImpactOnAnalyticalLights: number;
  44935. /**
  44936. * Stores the alpha values in a texture.
  44937. */
  44938. opacityTexture: BaseTexture;
  44939. /**
  44940. * Stores the reflection values in a texture.
  44941. */
  44942. reflectionTexture: Nullable<BaseTexture>;
  44943. /**
  44944. * Stores the emissive values in a texture.
  44945. */
  44946. emissiveTexture: BaseTexture;
  44947. /**
  44948. * AKA Specular texture in other nomenclature.
  44949. */
  44950. reflectivityTexture: BaseTexture;
  44951. /**
  44952. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44953. */
  44954. metallicTexture: BaseTexture;
  44955. /**
  44956. * Specifies the metallic scalar of the metallic/roughness workflow.
  44957. * Can also be used to scale the metalness values of the metallic texture.
  44958. */
  44959. metallic: Nullable<number>;
  44960. /**
  44961. * Specifies the roughness scalar of the metallic/roughness workflow.
  44962. * Can also be used to scale the roughness values of the metallic texture.
  44963. */
  44964. roughness: Nullable<number>;
  44965. /**
  44966. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44967. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44968. */
  44969. microSurfaceTexture: BaseTexture;
  44970. /**
  44971. * Stores surface normal data used to displace a mesh in a texture.
  44972. */
  44973. bumpTexture: BaseTexture;
  44974. /**
  44975. * Stores the pre-calculated light information of a mesh in a texture.
  44976. */
  44977. lightmapTexture: BaseTexture;
  44978. /**
  44979. * Stores the refracted light information in a texture.
  44980. */
  44981. refractionTexture: BaseTexture;
  44982. /**
  44983. * The color of a material in ambient lighting.
  44984. */
  44985. ambientColor: Color3;
  44986. /**
  44987. * AKA Diffuse Color in other nomenclature.
  44988. */
  44989. albedoColor: Color3;
  44990. /**
  44991. * AKA Specular Color in other nomenclature.
  44992. */
  44993. reflectivityColor: Color3;
  44994. /**
  44995. * The color reflected from the material.
  44996. */
  44997. reflectionColor: Color3;
  44998. /**
  44999. * The color emitted from the material.
  45000. */
  45001. emissiveColor: Color3;
  45002. /**
  45003. * AKA Glossiness in other nomenclature.
  45004. */
  45005. microSurface: number;
  45006. /**
  45007. * source material index of refraction (IOR)' / 'destination material IOR.
  45008. */
  45009. indexOfRefraction: number;
  45010. /**
  45011. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45012. */
  45013. 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. linkRefractionWithTransparency: boolean;
  45019. /**
  45020. * If true, the light map contains occlusion information instead of lighting info.
  45021. */
  45022. useLightmapAsShadowmap: boolean;
  45023. /**
  45024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45025. */
  45026. useAlphaFromAlbedoTexture: boolean;
  45027. /**
  45028. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45029. */
  45030. forceAlphaTest: boolean;
  45031. /**
  45032. * Defines the alpha limits in alpha test mode.
  45033. */
  45034. alphaCutOff: number;
  45035. /**
  45036. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45037. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45038. */
  45039. useSpecularOverAlpha: boolean;
  45040. /**
  45041. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45042. */
  45043. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45044. /**
  45045. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45046. */
  45047. useRoughnessFromMetallicTextureAlpha: boolean;
  45048. /**
  45049. * Specifies if the metallic texture contains the roughness information in its green channel.
  45050. */
  45051. useRoughnessFromMetallicTextureGreen: boolean;
  45052. /**
  45053. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45054. */
  45055. useMetallnessFromMetallicTextureBlue: boolean;
  45056. /**
  45057. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45058. */
  45059. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45060. /**
  45061. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45062. */
  45063. useAmbientInGrayScale: boolean;
  45064. /**
  45065. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45066. * The material will try to infer what glossiness each pixel should be.
  45067. */
  45068. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45069. /**
  45070. * BJS is using an harcoded light falloff based on a manually sets up range.
  45071. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45072. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45073. */
  45074. /**
  45075. * BJS is using an harcoded light falloff based on a manually sets up range.
  45076. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45077. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45078. */
  45079. usePhysicalLightFalloff: boolean;
  45080. /**
  45081. * In order to support the falloff compatibility with gltf, a special mode has been added
  45082. * to reproduce the gltf light falloff.
  45083. */
  45084. /**
  45085. * In order to support the falloff compatibility with gltf, a special mode has been added
  45086. * to reproduce the gltf light falloff.
  45087. */
  45088. useGLTFLightFalloff: boolean;
  45089. /**
  45090. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45091. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45092. */
  45093. useRadianceOverAlpha: boolean;
  45094. /**
  45095. * Allows using an object space normal map (instead of tangent space).
  45096. */
  45097. useObjectSpaceNormalMap: boolean;
  45098. /**
  45099. * Allows using the bump map in parallax mode.
  45100. */
  45101. useParallax: boolean;
  45102. /**
  45103. * Allows using the bump map in parallax occlusion mode.
  45104. */
  45105. useParallaxOcclusion: boolean;
  45106. /**
  45107. * Controls the scale bias of the parallax mode.
  45108. */
  45109. parallaxScaleBias: number;
  45110. /**
  45111. * If sets to true, disables all the lights affecting the material.
  45112. */
  45113. disableLighting: boolean;
  45114. /**
  45115. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45116. */
  45117. forceIrradianceInFragment: boolean;
  45118. /**
  45119. * Number of Simultaneous lights allowed on the material.
  45120. */
  45121. maxSimultaneousLights: number;
  45122. /**
  45123. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45124. */
  45125. invertNormalMapX: boolean;
  45126. /**
  45127. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45128. */
  45129. invertNormalMapY: boolean;
  45130. /**
  45131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45132. */
  45133. twoSidedLighting: boolean;
  45134. /**
  45135. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45136. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45137. */
  45138. useAlphaFresnel: boolean;
  45139. /**
  45140. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45141. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45142. */
  45143. useLinearAlphaFresnel: boolean;
  45144. /**
  45145. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45146. * And/Or occlude the blended part.
  45147. */
  45148. environmentBRDFTexture: Nullable<BaseTexture>;
  45149. /**
  45150. * Force normal to face away from face.
  45151. */
  45152. 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. enableSpecularAntiAliasing: boolean;
  45159. /**
  45160. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45161. * makes the reflect vector face the model (under horizon).
  45162. */
  45163. useHorizonOcclusion: boolean;
  45164. /**
  45165. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45166. * too much the area relying on ambient texture to define their ambient occlusion.
  45167. */
  45168. useRadianceOcclusion: boolean;
  45169. /**
  45170. * If set to true, no lighting calculations will be applied.
  45171. */
  45172. unlit: boolean;
  45173. /**
  45174. * Gets the image processing configuration used either in this material.
  45175. */
  45176. /**
  45177. * Sets the Default image processing configuration used either in the this material.
  45178. *
  45179. * If sets to null, the scene one is in use.
  45180. */
  45181. imageProcessingConfiguration: ImageProcessingConfiguration;
  45182. /**
  45183. * Gets wether the color curves effect is enabled.
  45184. */
  45185. /**
  45186. * Sets wether the color curves effect is enabled.
  45187. */
  45188. cameraColorCurvesEnabled: boolean;
  45189. /**
  45190. * Gets wether the color grading effect is enabled.
  45191. */
  45192. /**
  45193. * Gets wether the color grading effect is enabled.
  45194. */
  45195. cameraColorGradingEnabled: boolean;
  45196. /**
  45197. * Gets wether tonemapping is enabled or not.
  45198. */
  45199. /**
  45200. * Sets wether tonemapping is enabled or not
  45201. */
  45202. cameraToneMappingEnabled: boolean;
  45203. /**
  45204. * The camera exposure used on this material.
  45205. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45206. * This corresponds to a photographic exposure.
  45207. */
  45208. /**
  45209. * The camera exposure used on this material.
  45210. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45211. * This corresponds to a photographic exposure.
  45212. */
  45213. cameraExposure: number;
  45214. /**
  45215. * Gets The camera contrast used on this material.
  45216. */
  45217. /**
  45218. * Sets The camera contrast used on this material.
  45219. */
  45220. cameraContrast: number;
  45221. /**
  45222. * Gets the Color Grading 2D Lookup Texture.
  45223. */
  45224. /**
  45225. * Sets the Color Grading 2D Lookup Texture.
  45226. */
  45227. cameraColorGradingTexture: Nullable<BaseTexture>;
  45228. /**
  45229. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45230. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45231. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45232. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45233. */
  45234. /**
  45235. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45236. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45237. * 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;
  45238. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45239. */
  45240. cameraColorCurves: Nullable<ColorCurves>;
  45241. /**
  45242. * Instantiates a new PBRMaterial instance.
  45243. *
  45244. * @param name The material name
  45245. * @param scene The scene the material will be use in.
  45246. */
  45247. constructor(name: string, scene: Scene);
  45248. /**
  45249. * Returns the name of this material class.
  45250. */
  45251. getClassName(): string;
  45252. /**
  45253. * Returns an array of the actively used textures.
  45254. * @returns - Array of BaseTextures
  45255. */
  45256. getActiveTextures(): BaseTexture[];
  45257. /**
  45258. * Checks to see if a texture is used in the material.
  45259. * @param texture - Base texture to use.
  45260. * @returns - Boolean specifying if a texture is used in the material.
  45261. */
  45262. hasTexture(texture: BaseTexture): boolean;
  45263. /**
  45264. * Makes a duplicate of the current material.
  45265. * @param name - name to use for the new material.
  45266. */
  45267. clone(name: string): PBRMaterial;
  45268. /**
  45269. * Serializes this PBR Material.
  45270. * @returns - An object with the serialized material.
  45271. */
  45272. serialize(): any;
  45273. /**
  45274. * Parses a PBR Material from a serialized object.
  45275. * @param source - Serialized object.
  45276. * @param scene - BJS scene instance.
  45277. * @param rootUrl - url for the scene object
  45278. * @returns - PBRMaterial
  45279. */
  45280. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45281. }
  45282. }
  45283. declare module BABYLON {
  45284. /**
  45285. * The PBR material of BJS following the metal roughness convention.
  45286. *
  45287. * This fits to the PBR convention in the GLTF definition:
  45288. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45289. */
  45290. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45291. /**
  45292. * The base color has two different interpretations depending on the value of metalness.
  45293. * When the material is a metal, the base color is the specific measured reflectance value
  45294. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45295. * of the material.
  45296. */
  45297. baseColor: Color3;
  45298. /**
  45299. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45300. * well as opacity information in the alpha channel.
  45301. */
  45302. baseTexture: BaseTexture;
  45303. /**
  45304. * Specifies the metallic scalar value of the material.
  45305. * Can also be used to scale the metalness values of the metallic texture.
  45306. */
  45307. metallic: number;
  45308. /**
  45309. * Specifies the roughness scalar value of the material.
  45310. * Can also be used to scale the roughness values of the metallic texture.
  45311. */
  45312. roughness: number;
  45313. /**
  45314. * Texture containing both the metallic value in the B channel and the
  45315. * roughness value in the G channel to keep better precision.
  45316. */
  45317. metallicRoughnessTexture: BaseTexture;
  45318. /**
  45319. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45320. *
  45321. * @param name The material name
  45322. * @param scene The scene the material will be use in.
  45323. */
  45324. constructor(name: string, scene: Scene);
  45325. /**
  45326. * Return the currrent class name of the material.
  45327. */
  45328. getClassName(): string;
  45329. /**
  45330. * Return the active textures of the material.
  45331. */
  45332. getActiveTextures(): BaseTexture[];
  45333. /**
  45334. * Checks to see if a texture is used in the material.
  45335. * @param texture - Base texture to use.
  45336. * @returns - Boolean specifying if a texture is used in the material.
  45337. */
  45338. hasTexture(texture: BaseTexture): boolean;
  45339. /**
  45340. * Makes a duplicate of the current material.
  45341. * @param name - name to use for the new material.
  45342. */
  45343. clone(name: string): PBRMetallicRoughnessMaterial;
  45344. /**
  45345. * Serialize the material to a parsable JSON object.
  45346. */
  45347. serialize(): any;
  45348. /**
  45349. * Parses a JSON object correponding to the serialize function.
  45350. */
  45351. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45352. }
  45353. }
  45354. declare module BABYLON {
  45355. /**
  45356. * The PBR material of BJS following the specular glossiness convention.
  45357. *
  45358. * This fits to the PBR convention in the GLTF definition:
  45359. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45360. */
  45361. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45362. /**
  45363. * Specifies the diffuse color of the material.
  45364. */
  45365. diffuseColor: Color3;
  45366. /**
  45367. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45368. * channel.
  45369. */
  45370. diffuseTexture: BaseTexture;
  45371. /**
  45372. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45373. */
  45374. specularColor: Color3;
  45375. /**
  45376. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45377. */
  45378. glossiness: number;
  45379. /**
  45380. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45381. */
  45382. specularGlossinessTexture: BaseTexture;
  45383. /**
  45384. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45385. *
  45386. * @param name The material name
  45387. * @param scene The scene the material will be use in.
  45388. */
  45389. constructor(name: string, scene: Scene);
  45390. /**
  45391. * Return the currrent class name of the material.
  45392. */
  45393. getClassName(): string;
  45394. /**
  45395. * Return the active textures of the material.
  45396. */
  45397. getActiveTextures(): BaseTexture[];
  45398. /**
  45399. * Checks to see if a texture is used in the material.
  45400. * @param texture - Base texture to use.
  45401. * @returns - Boolean specifying if a texture is used in the material.
  45402. */
  45403. hasTexture(texture: BaseTexture): boolean;
  45404. /**
  45405. * Makes a duplicate of the current material.
  45406. * @param name - name to use for the new material.
  45407. */
  45408. clone(name: string): PBRSpecularGlossinessMaterial;
  45409. /**
  45410. * Serialize the material to a parsable JSON object.
  45411. */
  45412. serialize(): any;
  45413. /**
  45414. * Parses a JSON object correponding to the serialize function.
  45415. */
  45416. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45417. }
  45418. }
  45419. declare module BABYLON {
  45420. /**
  45421. * Base class of all the textures in babylon.
  45422. * It groups all the common properties the materials, post process, lights... might need
  45423. * in order to make a correct use of the texture.
  45424. */
  45425. class BaseTexture {
  45426. /**
  45427. * Default anisotropic filtering level for the application.
  45428. * It is set to 4 as a good tradeoff between perf and quality.
  45429. */
  45430. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45431. /**
  45432. * Define the name of the texture.
  45433. */
  45434. name: string;
  45435. private _hasAlpha;
  45436. /**
  45437. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45438. */
  45439. hasAlpha: boolean;
  45440. /**
  45441. * Defines if the alpha value should be determined via the rgb values.
  45442. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45443. */
  45444. getAlphaFromRGB: boolean;
  45445. /**
  45446. * Intensity or strength of the texture.
  45447. * It is commonly used by materials to fine tune the intensity of the texture
  45448. */
  45449. level: number;
  45450. /**
  45451. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45452. * This is part of the texture as textures usually maps to one uv set.
  45453. */
  45454. coordinatesIndex: number;
  45455. private _coordinatesMode;
  45456. /**
  45457. * How a texture is mapped.
  45458. *
  45459. * | Value | Type | Description |
  45460. * | ----- | ----------------------------------- | ----------- |
  45461. * | 0 | EXPLICIT_MODE | |
  45462. * | 1 | SPHERICAL_MODE | |
  45463. * | 2 | PLANAR_MODE | |
  45464. * | 3 | CUBIC_MODE | |
  45465. * | 4 | PROJECTION_MODE | |
  45466. * | 5 | SKYBOX_MODE | |
  45467. * | 6 | INVCUBIC_MODE | |
  45468. * | 7 | EQUIRECTANGULAR_MODE | |
  45469. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45470. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45471. */
  45472. coordinatesMode: number;
  45473. /**
  45474. * | Value | Type | Description |
  45475. * | ----- | ------------------ | ----------- |
  45476. * | 0 | CLAMP_ADDRESSMODE | |
  45477. * | 1 | WRAP_ADDRESSMODE | |
  45478. * | 2 | MIRROR_ADDRESSMODE | |
  45479. */
  45480. wrapU: number;
  45481. /**
  45482. * | Value | Type | Description |
  45483. * | ----- | ------------------ | ----------- |
  45484. * | 0 | CLAMP_ADDRESSMODE | |
  45485. * | 1 | WRAP_ADDRESSMODE | |
  45486. * | 2 | MIRROR_ADDRESSMODE | |
  45487. */
  45488. wrapV: number;
  45489. /**
  45490. * | Value | Type | Description |
  45491. * | ----- | ------------------ | ----------- |
  45492. * | 0 | CLAMP_ADDRESSMODE | |
  45493. * | 1 | WRAP_ADDRESSMODE | |
  45494. * | 2 | MIRROR_ADDRESSMODE | |
  45495. */
  45496. wrapR: number;
  45497. /**
  45498. * With compliant hardware and browser (supporting anisotropic filtering)
  45499. * this defines the level of anisotropic filtering in the texture.
  45500. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45501. */
  45502. anisotropicFilteringLevel: number;
  45503. /**
  45504. * Define if the texture is a cube texture or if false a 2d texture.
  45505. */
  45506. isCube: boolean;
  45507. /**
  45508. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45509. */
  45510. is3D: boolean;
  45511. /**
  45512. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45513. * HDR texture are usually stored in linear space.
  45514. * This only impacts the PBR and Background materials
  45515. */
  45516. gammaSpace: boolean;
  45517. /**
  45518. * Gets whether or not the texture contains RGBD data.
  45519. */
  45520. readonly isRGBD: boolean;
  45521. /**
  45522. * Is Z inverted in the texture (useful in a cube texture).
  45523. */
  45524. invertZ: boolean;
  45525. /**
  45526. * @hidden
  45527. */
  45528. lodLevelInAlpha: boolean;
  45529. /**
  45530. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45531. */
  45532. lodGenerationOffset: number;
  45533. /**
  45534. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45535. */
  45536. lodGenerationScale: number;
  45537. /**
  45538. * Define if the texture is a render target.
  45539. */
  45540. isRenderTarget: boolean;
  45541. /**
  45542. * Define the unique id of the texture in the scene.
  45543. */
  45544. readonly uid: string;
  45545. /**
  45546. * Return a string representation of the texture.
  45547. * @returns the texture as a string
  45548. */
  45549. toString(): string;
  45550. /**
  45551. * Get the class name of the texture.
  45552. * @returns "BaseTexture"
  45553. */
  45554. getClassName(): string;
  45555. /**
  45556. * Define the list of animation attached to the texture.
  45557. */
  45558. animations: Animation[];
  45559. /**
  45560. * An event triggered when the texture is disposed.
  45561. */
  45562. onDisposeObservable: Observable<BaseTexture>;
  45563. private _onDisposeObserver;
  45564. /**
  45565. * Callback triggered when the texture has been disposed.
  45566. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45567. */
  45568. onDispose: () => void;
  45569. /**
  45570. * Define the current state of the loading sequence when in delayed load mode.
  45571. */
  45572. delayLoadState: number;
  45573. private _scene;
  45574. /** @hidden */
  45575. _texture: Nullable<InternalTexture>;
  45576. private _uid;
  45577. /**
  45578. * Define if the texture is preventinga material to render or not.
  45579. * If not and the texture is not ready, the engine will use a default black texture instead.
  45580. */
  45581. readonly isBlocking: boolean;
  45582. /**
  45583. * Instantiates a new BaseTexture.
  45584. * Base class of all the textures in babylon.
  45585. * It groups all the common properties the materials, post process, lights... might need
  45586. * in order to make a correct use of the texture.
  45587. * @param scene Define the scene the texture blongs to
  45588. */
  45589. constructor(scene: Nullable<Scene>);
  45590. /**
  45591. * Get the scene the texture belongs to.
  45592. * @returns the scene or null if undefined
  45593. */
  45594. getScene(): Nullable<Scene>;
  45595. /**
  45596. * Get the texture transform matrix used to offset tile the texture for istance.
  45597. * @returns the transformation matrix
  45598. */
  45599. getTextureMatrix(): Matrix;
  45600. /**
  45601. * Get the texture reflection matrix used to rotate/transform the reflection.
  45602. * @returns the reflection matrix
  45603. */
  45604. getReflectionTextureMatrix(): Matrix;
  45605. /**
  45606. * Get the underlying lower level texture from Babylon.
  45607. * @returns the insternal texture
  45608. */
  45609. getInternalTexture(): Nullable<InternalTexture>;
  45610. /**
  45611. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45612. * @returns true if ready or not blocking
  45613. */
  45614. isReadyOrNotBlocking(): boolean;
  45615. /**
  45616. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45617. * @returns true if fully ready
  45618. */
  45619. isReady(): boolean;
  45620. private _cachedSize;
  45621. /**
  45622. * Get the size of the texture.
  45623. * @returns the texture size.
  45624. */
  45625. getSize(): ISize;
  45626. /**
  45627. * Get the base size of the texture.
  45628. * It can be different from the size if the texture has been resized for POT for instance
  45629. * @returns the base size
  45630. */
  45631. getBaseSize(): ISize;
  45632. /**
  45633. * Scales the texture if is `canRescale()`
  45634. * @param ratio the resize factor we want to use to rescale
  45635. */
  45636. scale(ratio: number): void;
  45637. /**
  45638. * Get if the texture can rescale.
  45639. */
  45640. readonly canRescale: boolean;
  45641. /** @hidden */
  45642. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45643. /** @hidden */
  45644. _rebuild(): void;
  45645. /**
  45646. * Triggers the load sequence in delayed load mode.
  45647. */
  45648. delayLoad(): void;
  45649. /**
  45650. * Clones the texture.
  45651. * @returns the cloned texture
  45652. */
  45653. clone(): Nullable<BaseTexture>;
  45654. /**
  45655. * Get the texture underlying type (INT, FLOAT...)
  45656. */
  45657. readonly textureType: number;
  45658. /**
  45659. * Get the texture underlying format (RGB, RGBA...)
  45660. */
  45661. readonly textureFormat: number;
  45662. /**
  45663. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45664. * This will returns an RGBA array buffer containing either in values (0-255) or
  45665. * float values (0-1) depending of the underlying buffer type.
  45666. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45667. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45668. * @param buffer defines a user defined buffer to fill with data (can be null)
  45669. * @returns The Array buffer containing the pixels data.
  45670. */
  45671. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45672. /**
  45673. * Release and destroy the underlying lower level texture aka internalTexture.
  45674. */
  45675. releaseInternalTexture(): void;
  45676. /**
  45677. * Get the polynomial representation of the texture data.
  45678. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45679. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45680. */
  45681. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45682. /** @hidden */
  45683. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45684. /** @hidden */
  45685. readonly _lodTextureMid: Nullable<BaseTexture>;
  45686. /** @hidden */
  45687. readonly _lodTextureLow: Nullable<BaseTexture>;
  45688. /**
  45689. * Dispose the texture and release its associated resources.
  45690. */
  45691. dispose(): void;
  45692. /**
  45693. * Serialize the texture into a JSON representation that can be parsed later on.
  45694. * @returns the JSON representation of the texture
  45695. */
  45696. serialize(): any;
  45697. /**
  45698. * Helper function to be called back once a list of texture contains only ready textures.
  45699. * @param textures Define the list of textures to wait for
  45700. * @param callback Define the callback triggered once the entire list will be ready
  45701. */
  45702. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45703. }
  45704. }
  45705. declare module BABYLON {
  45706. /**
  45707. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45708. * It can help converting any input color in a desired output one. This can then be used to create effects
  45709. * from sepia, black and white to sixties or futuristic rendering...
  45710. *
  45711. * The only supported format is currently 3dl.
  45712. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45713. */
  45714. class ColorGradingTexture extends BaseTexture {
  45715. /**
  45716. * The current texture matrix. (will always be identity in color grading texture)
  45717. */
  45718. private _textureMatrix;
  45719. /**
  45720. * The texture URL.
  45721. */
  45722. url: string;
  45723. /**
  45724. * Empty line regex stored for GC.
  45725. */
  45726. private static _noneEmptyLineRegex;
  45727. private _engine;
  45728. /**
  45729. * Instantiates a ColorGradingTexture from the following parameters.
  45730. *
  45731. * @param url The location of the color gradind data (currently only supporting 3dl)
  45732. * @param scene The scene the texture will be used in
  45733. */
  45734. constructor(url: string, scene: Scene);
  45735. /**
  45736. * Returns the texture matrix used in most of the material.
  45737. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45738. */
  45739. getTextureMatrix(): Matrix;
  45740. /**
  45741. * Occurs when the file being loaded is a .3dl LUT file.
  45742. */
  45743. private load3dlTexture;
  45744. /**
  45745. * Starts the loading process of the texture.
  45746. */
  45747. private loadTexture;
  45748. /**
  45749. * Clones the color gradind texture.
  45750. */
  45751. clone(): ColorGradingTexture;
  45752. /**
  45753. * Called during delayed load for textures.
  45754. */
  45755. delayLoad(): void;
  45756. /**
  45757. * Parses a color grading texture serialized by Babylon.
  45758. * @param parsedTexture The texture information being parsedTexture
  45759. * @param scene The scene to load the texture in
  45760. * @param rootUrl The root url of the data assets to load
  45761. * @return A color gradind texture
  45762. */
  45763. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45764. /**
  45765. * Serializes the LUT texture to json format.
  45766. */
  45767. serialize(): any;
  45768. }
  45769. }
  45770. declare module BABYLON {
  45771. /**
  45772. * Class for creating a cube texture
  45773. */
  45774. class CubeTexture extends BaseTexture {
  45775. /**
  45776. * The url of the texture
  45777. */
  45778. url: string;
  45779. /**
  45780. * Gets or sets the center of the bounding box associated with the cube texture.
  45781. * It must define where the camera used to render the texture was set
  45782. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45783. */
  45784. boundingBoxPosition: Vector3;
  45785. private _boundingBoxSize;
  45786. /**
  45787. * Gets or sets the size of the bounding box associated with the cube texture
  45788. * When defined, the cubemap will switch to local mode
  45789. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45790. * @example https://www.babylonjs-playground.com/#RNASML
  45791. */
  45792. /**
  45793. * Returns the bounding box size
  45794. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45795. */
  45796. boundingBoxSize: Vector3;
  45797. protected _rotationY: number;
  45798. /**
  45799. * Sets texture matrix rotation angle around Y axis in radians.
  45800. */
  45801. /**
  45802. * Gets texture matrix rotation angle around Y axis radians.
  45803. */
  45804. rotationY: number;
  45805. private _noMipmap;
  45806. private _files;
  45807. private _extensions;
  45808. private _textureMatrix;
  45809. private _format;
  45810. private _createPolynomials;
  45811. /** @hidden */
  45812. readonly _prefiltered: boolean;
  45813. /**
  45814. * Creates a cube texture from an array of image urls
  45815. * @param files defines an array of image urls
  45816. * @param scene defines the hosting scene
  45817. * @param noMipmap specifies if mip maps are not used
  45818. * @returns a cube texture
  45819. */
  45820. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45821. /**
  45822. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45823. * @param url defines the url of the prefiltered texture
  45824. * @param scene defines the scene the texture is attached to
  45825. * @param forcedExtension defines the extension of the file if different from the url
  45826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45827. * @return the prefiltered texture
  45828. */
  45829. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45830. /**
  45831. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45832. * as prefiltered data.
  45833. * @param rootUrl defines the url of the texture or the root name of the six images
  45834. * @param scene defines the scene the texture is attached to
  45835. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45836. * @param noMipmap defines if mipmaps should be created or not
  45837. * @param files defines the six files to load for the different faces
  45838. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45839. * @param onError defines a callback triggered in case of error during load
  45840. * @param format defines the internal format to use for the texture once loaded
  45841. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45842. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45843. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45844. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45845. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45846. * @return the cube texture
  45847. */
  45848. 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);
  45849. /**
  45850. * Delays loading of the cube texture
  45851. */
  45852. delayLoad(): void;
  45853. /**
  45854. * Returns the reflection texture matrix
  45855. * @returns the reflection texture matrix
  45856. */
  45857. getReflectionTextureMatrix(): Matrix;
  45858. /**
  45859. * Sets the reflection texture matrix
  45860. * @param value Reflection texture matrix
  45861. */
  45862. setReflectionTextureMatrix(value: Matrix): void;
  45863. /**
  45864. * Parses text to create a cube texture
  45865. * @param parsedTexture define the serialized text to read from
  45866. * @param scene defines the hosting scene
  45867. * @param rootUrl defines the root url of the cube texture
  45868. * @returns a cube texture
  45869. */
  45870. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45871. /**
  45872. * Makes a clone, or deep copy, of the cube texture
  45873. * @returns a new cube texture
  45874. */
  45875. clone(): CubeTexture;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * A class extending Texture allowing drawing on a texture
  45881. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45882. */
  45883. class DynamicTexture extends Texture {
  45884. private _generateMipMaps;
  45885. private _canvas;
  45886. private _context;
  45887. private _engine;
  45888. /**
  45889. * Creates a DynamicTexture
  45890. * @param name defines the name of the texture
  45891. * @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
  45892. * @param scene defines the scene where you want the texture
  45893. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45894. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45895. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45896. */
  45897. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45898. /**
  45899. * Gets the current state of canRescale
  45900. */
  45901. readonly canRescale: boolean;
  45902. private _recreate;
  45903. /**
  45904. * Scales the texture
  45905. * @param ratio the scale factor to apply to both width and height
  45906. */
  45907. scale(ratio: number): void;
  45908. /**
  45909. * Resizes the texture
  45910. * @param width the new width
  45911. * @param height the new height
  45912. */
  45913. scaleTo(width: number, height: number): void;
  45914. /**
  45915. * Gets the context of the canvas used by the texture
  45916. * @returns the canvas context of the dynamic texture
  45917. */
  45918. getContext(): CanvasRenderingContext2D;
  45919. /**
  45920. * Clears the texture
  45921. */
  45922. clear(): void;
  45923. /**
  45924. * Updates the texture
  45925. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45926. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45927. */
  45928. update(invertY?: boolean, premulAlpha?: boolean): void;
  45929. /**
  45930. * Draws text onto the texture
  45931. * @param text defines the text to be drawn
  45932. * @param x defines the placement of the text from the left
  45933. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45934. * @param font defines the font to be used with font-style, font-size, font-name
  45935. * @param color defines the color used for the text
  45936. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45937. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45938. * @param update defines whether texture is immediately update (default is true)
  45939. */
  45940. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45941. /**
  45942. * Clones the texture
  45943. * @returns the clone of the texture.
  45944. */
  45945. clone(): DynamicTexture;
  45946. /**
  45947. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45948. * @returns a serialized dynamic texture object
  45949. */
  45950. serialize(): any;
  45951. /** @hidden */
  45952. _rebuild(): void;
  45953. }
  45954. }
  45955. declare module BABYLON {
  45956. /**
  45957. * This represents a texture coming from an HDR input.
  45958. *
  45959. * The only supported format is currently panorama picture stored in RGBE format.
  45960. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45961. */
  45962. class HDRCubeTexture extends BaseTexture {
  45963. private static _facesMapping;
  45964. private _generateHarmonics;
  45965. private _noMipmap;
  45966. private _textureMatrix;
  45967. private _size;
  45968. private _onLoad;
  45969. private _onError;
  45970. /**
  45971. * The texture URL.
  45972. */
  45973. url: string;
  45974. /**
  45975. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45976. */
  45977. coordinatesMode: number;
  45978. protected _isBlocking: boolean;
  45979. /**
  45980. * Sets wether or not the texture is blocking during loading.
  45981. */
  45982. /**
  45983. * Gets wether or not the texture is blocking during loading.
  45984. */
  45985. isBlocking: boolean;
  45986. protected _rotationY: number;
  45987. /**
  45988. * Sets texture matrix rotation angle around Y axis in radians.
  45989. */
  45990. /**
  45991. * Gets texture matrix rotation angle around Y axis radians.
  45992. */
  45993. rotationY: number;
  45994. /**
  45995. * Gets or sets the center of the bounding box associated with the cube texture
  45996. * It must define where the camera used to render the texture was set
  45997. */
  45998. boundingBoxPosition: Vector3;
  45999. private _boundingBoxSize;
  46000. /**
  46001. * Gets or sets the size of the bounding box associated with the cube texture
  46002. * When defined, the cubemap will switch to local mode
  46003. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46004. * @example https://www.babylonjs-playground.com/#RNASML
  46005. */
  46006. boundingBoxSize: Vector3;
  46007. /**
  46008. * Instantiates an HDRTexture from the following parameters.
  46009. *
  46010. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46011. * @param scene The scene the texture will be used in
  46012. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46013. * @param noMipmap Forces to not generate the mipmap if true
  46014. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46015. * @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)
  46016. * @param reserved Reserved flag for internal use.
  46017. */
  46018. 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>);
  46019. /**
  46020. * Occurs when the file is raw .hdr file.
  46021. */
  46022. private loadTexture;
  46023. clone(): HDRCubeTexture;
  46024. delayLoad(): void;
  46025. /**
  46026. * Get the texture reflection matrix used to rotate/transform the reflection.
  46027. * @returns the reflection matrix
  46028. */
  46029. getReflectionTextureMatrix(): Matrix;
  46030. /**
  46031. * Set the texture reflection matrix used to rotate/transform the reflection.
  46032. * @param value Define the reflection matrix to set
  46033. */
  46034. setReflectionTextureMatrix(value: Matrix): void;
  46035. /**
  46036. * Parses a JSON representation of an HDR Texture in order to create the texture
  46037. * @param parsedTexture Define the JSON representation
  46038. * @param scene Define the scene the texture should be created in
  46039. * @param rootUrl Define the root url in case we need to load relative dependencies
  46040. * @returns the newly created texture after parsing
  46041. */
  46042. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46043. serialize(): any;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Class used to store data associated with WebGL texture data for the engine
  46049. * This class should not be used directly
  46050. */
  46051. class InternalTexture implements IInternalTextureTracker {
  46052. /**
  46053. * The source of the texture data is unknown
  46054. */
  46055. static DATASOURCE_UNKNOWN: number;
  46056. /**
  46057. * Texture data comes from an URL
  46058. */
  46059. static DATASOURCE_URL: number;
  46060. /**
  46061. * Texture data is only used for temporary storage
  46062. */
  46063. static DATASOURCE_TEMP: number;
  46064. /**
  46065. * Texture data comes from raw data (ArrayBuffer)
  46066. */
  46067. static DATASOURCE_RAW: number;
  46068. /**
  46069. * Texture content is dynamic (video or dynamic texture)
  46070. */
  46071. static DATASOURCE_DYNAMIC: number;
  46072. /**
  46073. * Texture content is generated by rendering to it
  46074. */
  46075. static DATASOURCE_RENDERTARGET: number;
  46076. /**
  46077. * Texture content is part of a multi render target process
  46078. */
  46079. static DATASOURCE_MULTIRENDERTARGET: number;
  46080. /**
  46081. * Texture data comes from a cube data file
  46082. */
  46083. static DATASOURCE_CUBE: number;
  46084. /**
  46085. * Texture data comes from a raw cube data
  46086. */
  46087. static DATASOURCE_CUBERAW: number;
  46088. /**
  46089. * Texture data come from a prefiltered cube data file
  46090. */
  46091. static DATASOURCE_CUBEPREFILTERED: number;
  46092. /**
  46093. * Texture content is raw 3D data
  46094. */
  46095. static DATASOURCE_RAW3D: number;
  46096. /**
  46097. * Texture content is a depth texture
  46098. */
  46099. static DATASOURCE_DEPTHTEXTURE: number;
  46100. /**
  46101. * Texture data comes from a raw cube data encoded with RGBD
  46102. */
  46103. static DATASOURCE_CUBERAW_RGBD: number;
  46104. /**
  46105. * Defines if the texture is ready
  46106. */
  46107. isReady: boolean;
  46108. /**
  46109. * Defines if the texture is a cube texture
  46110. */
  46111. isCube: boolean;
  46112. /**
  46113. * Defines if the texture contains 3D data
  46114. */
  46115. is3D: boolean;
  46116. /**
  46117. * Gets the URL used to load this texture
  46118. */
  46119. url: string;
  46120. /**
  46121. * Gets the sampling mode of the texture
  46122. */
  46123. samplingMode: number;
  46124. /**
  46125. * Gets a boolean indicating if the texture needs mipmaps generation
  46126. */
  46127. generateMipMaps: boolean;
  46128. /**
  46129. * Gets the number of samples used by the texture (WebGL2+ only)
  46130. */
  46131. samples: number;
  46132. /**
  46133. * Gets the type of the texture (int, float...)
  46134. */
  46135. type: number;
  46136. /**
  46137. * Gets the format of the texture (RGB, RGBA...)
  46138. */
  46139. format: number;
  46140. /**
  46141. * Observable called when the texture is loaded
  46142. */
  46143. onLoadedObservable: Observable<InternalTexture>;
  46144. /**
  46145. * Gets the width of the texture
  46146. */
  46147. width: number;
  46148. /**
  46149. * Gets the height of the texture
  46150. */
  46151. height: number;
  46152. /**
  46153. * Gets the depth of the texture
  46154. */
  46155. depth: number;
  46156. /**
  46157. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46158. */
  46159. baseWidth: number;
  46160. /**
  46161. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46162. */
  46163. baseHeight: number;
  46164. /**
  46165. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46166. */
  46167. baseDepth: number;
  46168. /**
  46169. * Gets a boolean indicating if the texture is inverted on Y axis
  46170. */
  46171. invertY: boolean;
  46172. /**
  46173. * Gets or set the previous tracker in the list
  46174. */
  46175. previous: Nullable<IInternalTextureTracker>;
  46176. /**
  46177. * Gets or set the next tracker in the list
  46178. */
  46179. next: Nullable<IInternalTextureTracker>;
  46180. /** @hidden */
  46181. _initialSlot: number;
  46182. /** @hidden */
  46183. _designatedSlot: number;
  46184. /** @hidden */
  46185. _dataSource: number;
  46186. /** @hidden */
  46187. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46188. /** @hidden */
  46189. _bufferView: Nullable<ArrayBufferView>;
  46190. /** @hidden */
  46191. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46192. /** @hidden */
  46193. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46194. /** @hidden */
  46195. _size: number;
  46196. /** @hidden */
  46197. _extension: string;
  46198. /** @hidden */
  46199. _files: Nullable<string[]>;
  46200. /** @hidden */
  46201. _workingCanvas: HTMLCanvasElement;
  46202. /** @hidden */
  46203. _workingContext: CanvasRenderingContext2D;
  46204. /** @hidden */
  46205. _framebuffer: Nullable<WebGLFramebuffer>;
  46206. /** @hidden */
  46207. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46208. /** @hidden */
  46209. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46210. /** @hidden */
  46211. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46212. /** @hidden */
  46213. _attachments: Nullable<number[]>;
  46214. /** @hidden */
  46215. _cachedCoordinatesMode: Nullable<number>;
  46216. /** @hidden */
  46217. _cachedWrapU: Nullable<number>;
  46218. /** @hidden */
  46219. _cachedWrapV: Nullable<number>;
  46220. /** @hidden */
  46221. _cachedWrapR: Nullable<number>;
  46222. /** @hidden */
  46223. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46224. /** @hidden */
  46225. _isDisabled: boolean;
  46226. /** @hidden */
  46227. _compression: Nullable<string>;
  46228. /** @hidden */
  46229. _generateStencilBuffer: boolean;
  46230. /** @hidden */
  46231. _generateDepthBuffer: boolean;
  46232. /** @hidden */
  46233. _comparisonFunction: number;
  46234. /** @hidden */
  46235. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46236. /** @hidden */
  46237. _lodGenerationScale: number;
  46238. /** @hidden */
  46239. _lodGenerationOffset: number;
  46240. /** @hidden */
  46241. _lodTextureHigh: BaseTexture;
  46242. /** @hidden */
  46243. _lodTextureMid: BaseTexture;
  46244. /** @hidden */
  46245. _lodTextureLow: BaseTexture;
  46246. /** @hidden */
  46247. _isRGBD: boolean;
  46248. /** @hidden */
  46249. _webGLTexture: Nullable<WebGLTexture>;
  46250. /** @hidden */
  46251. _references: number;
  46252. private _engine;
  46253. /**
  46254. * Gets the Engine the texture belongs to.
  46255. * @returns The babylon engine
  46256. */
  46257. getEngine(): Engine;
  46258. /**
  46259. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46260. */
  46261. readonly dataSource: number;
  46262. /**
  46263. * Creates a new InternalTexture
  46264. * @param engine defines the engine to use
  46265. * @param dataSource defines the type of data that will be used
  46266. */
  46267. constructor(engine: Engine, dataSource: number);
  46268. /**
  46269. * Increments the number of references (ie. the number of Texture that point to it)
  46270. */
  46271. incrementReferences(): void;
  46272. /**
  46273. * Change the size of the texture (not the size of the content)
  46274. * @param width defines the new width
  46275. * @param height defines the new height
  46276. * @param depth defines the new depth (1 by default)
  46277. */
  46278. updateSize(width: int, height: int, depth?: int): void;
  46279. /** @hidden */
  46280. _rebuild(): void;
  46281. /** @hidden */
  46282. _swapAndDie(target: InternalTexture): void;
  46283. /**
  46284. * Dispose the current allocated resources
  46285. */
  46286. dispose(): void;
  46287. }
  46288. }
  46289. declare module BABYLON {
  46290. /**
  46291. * This represents the required contract to create a new type of texture loader.
  46292. */
  46293. interface IInternalTextureLoader {
  46294. /**
  46295. * Defines wether the loader supports cascade loading the different faces.
  46296. */
  46297. supportCascades: boolean;
  46298. /**
  46299. * This returns if the loader support the current file information.
  46300. * @param extension defines the file extension of the file being loaded
  46301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46302. * @param fallback defines the fallback internal texture if any
  46303. * @param isBase64 defines whether the texture is encoded as a base64
  46304. * @param isBuffer defines whether the texture data are stored as a buffer
  46305. * @returns true if the loader can load the specified file
  46306. */
  46307. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46308. /**
  46309. * Transform the url before loading if required.
  46310. * @param rootUrl the url of the texture
  46311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46312. * @returns the transformed texture
  46313. */
  46314. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46315. /**
  46316. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46317. * @param rootUrl the url of the texture
  46318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46319. * @returns the fallback texture
  46320. */
  46321. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46322. /**
  46323. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46324. * @param data contains the texture data
  46325. * @param texture defines the BabylonJS internal texture
  46326. * @param createPolynomials will be true if polynomials have been requested
  46327. * @param onLoad defines the callback to trigger once the texture is ready
  46328. * @param onError defines the callback to trigger in case of error
  46329. */
  46330. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46331. /**
  46332. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46333. * @param data contains the texture data
  46334. * @param texture defines the BabylonJS internal texture
  46335. * @param callback defines the method to call once ready to upload
  46336. */
  46337. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46338. }
  46339. }
  46340. declare module BABYLON {
  46341. /**
  46342. * Internal interface used to track InternalTexture already bound to the GL context
  46343. */
  46344. interface IInternalTextureTracker {
  46345. /**
  46346. * Gets or set the previous tracker in the list
  46347. */
  46348. previous: Nullable<IInternalTextureTracker>;
  46349. /**
  46350. * Gets or set the next tracker in the list
  46351. */
  46352. next: Nullable<IInternalTextureTracker>;
  46353. }
  46354. /**
  46355. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46356. */
  46357. class DummyInternalTextureTracker {
  46358. /**
  46359. * Gets or set the previous tracker in the list
  46360. */
  46361. previous: Nullable<IInternalTextureTracker>;
  46362. /**
  46363. * Gets or set the next tracker in the list
  46364. */
  46365. next: Nullable<IInternalTextureTracker>;
  46366. }
  46367. }
  46368. declare module BABYLON {
  46369. /**
  46370. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46371. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46372. * You can then easily use it as a reflectionTexture on a flat surface.
  46373. * In case the surface is not a plane, please consider relying on reflection probes.
  46374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46375. */
  46376. class MirrorTexture extends RenderTargetTexture {
  46377. private scene;
  46378. /**
  46379. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46380. * 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.
  46381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46382. */
  46383. mirrorPlane: Plane;
  46384. /**
  46385. * Define the blur ratio used to blur the reflection if needed.
  46386. */
  46387. blurRatio: number;
  46388. /**
  46389. * Define the adaptive blur kernel used to blur the reflection if needed.
  46390. * This will autocompute the closest best match for the `blurKernel`
  46391. */
  46392. adaptiveBlurKernel: number;
  46393. /**
  46394. * Define the blur kernel used to blur the reflection if needed.
  46395. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46396. */
  46397. blurKernel: number;
  46398. /**
  46399. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46400. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46401. */
  46402. blurKernelX: number;
  46403. /**
  46404. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46405. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46406. */
  46407. blurKernelY: number;
  46408. private _autoComputeBlurKernel;
  46409. protected _onRatioRescale(): void;
  46410. private _updateGammaSpace;
  46411. private _imageProcessingConfigChangeObserver;
  46412. private _transformMatrix;
  46413. private _mirrorMatrix;
  46414. private _savedViewMatrix;
  46415. private _blurX;
  46416. private _blurY;
  46417. private _adaptiveBlurKernel;
  46418. private _blurKernelX;
  46419. private _blurKernelY;
  46420. private _blurRatio;
  46421. /**
  46422. * Instantiates a Mirror Texture.
  46423. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46424. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46425. * You can then easily use it as a reflectionTexture on a flat surface.
  46426. * In case the surface is not a plane, please consider relying on reflection probes.
  46427. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46428. * @param name
  46429. * @param size
  46430. * @param scene
  46431. * @param generateMipMaps
  46432. * @param type
  46433. * @param samplingMode
  46434. * @param generateDepthBuffer
  46435. */
  46436. constructor(name: string, size: number | {
  46437. width: number;
  46438. height: number;
  46439. } | {
  46440. ratio: number;
  46441. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46442. private _preparePostProcesses;
  46443. /**
  46444. * Clone the mirror texture.
  46445. * @returns the cloned texture
  46446. */
  46447. clone(): MirrorTexture;
  46448. /**
  46449. * Serialize the texture to a JSON representation you could use in Parse later on
  46450. * @returns the serialized JSON representation
  46451. */
  46452. serialize(): any;
  46453. /**
  46454. * Dispose the texture and release its associated resources.
  46455. */
  46456. dispose(): void;
  46457. }
  46458. }
  46459. declare module BABYLON {
  46460. /**
  46461. * Creation options of the multi render target texture.
  46462. */
  46463. interface IMultiRenderTargetOptions {
  46464. /**
  46465. * Define if the texture needs to create mip maps after render.
  46466. */
  46467. generateMipMaps?: boolean;
  46468. /**
  46469. * Define the types of all the draw buffers we want to create
  46470. */
  46471. types?: number[];
  46472. /**
  46473. * Define the sampling modes of all the draw buffers we want to create
  46474. */
  46475. samplingModes?: number[];
  46476. /**
  46477. * Define if a depth buffer is required
  46478. */
  46479. generateDepthBuffer?: boolean;
  46480. /**
  46481. * Define if a stencil buffer is required
  46482. */
  46483. generateStencilBuffer?: boolean;
  46484. /**
  46485. * Define if a depth texture is required instead of a depth buffer
  46486. */
  46487. generateDepthTexture?: boolean;
  46488. /**
  46489. * Define the number of desired draw buffers
  46490. */
  46491. textureCount?: number;
  46492. /**
  46493. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46494. */
  46495. doNotChangeAspectRatio?: boolean;
  46496. /**
  46497. * Define the default type of the buffers we are creating
  46498. */
  46499. defaultType?: number;
  46500. }
  46501. /**
  46502. * A multi render target, like a render target provides the ability to render to a texture.
  46503. * Unlike the render target, it can render to several draw buffers in one draw.
  46504. * This is specially interesting in deferred rendering or for any effects requiring more than
  46505. * just one color from a single pass.
  46506. */
  46507. class MultiRenderTarget extends RenderTargetTexture {
  46508. private _internalTextures;
  46509. private _textures;
  46510. private _multiRenderTargetOptions;
  46511. /**
  46512. * Get if draw buffers are currently supported by the used hardware and browser.
  46513. */
  46514. readonly isSupported: boolean;
  46515. /**
  46516. * Get the list of textures generated by the multi render target.
  46517. */
  46518. readonly textures: Texture[];
  46519. /**
  46520. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46521. */
  46522. readonly depthTexture: Texture;
  46523. /**
  46524. * Set the wrapping mode on U of all the textures we are rendering to.
  46525. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46526. */
  46527. wrapU: number;
  46528. /**
  46529. * Set the wrapping mode on V of all the textures we are rendering to.
  46530. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46531. */
  46532. wrapV: number;
  46533. /**
  46534. * Instantiate a new multi render target texture.
  46535. * A multi render target, like a render target provides the ability to render to a texture.
  46536. * Unlike the render target, it can render to several draw buffers in one draw.
  46537. * This is specially interesting in deferred rendering or for any effects requiring more than
  46538. * just one color from a single pass.
  46539. * @param name Define the name of the texture
  46540. * @param size Define the size of the buffers to render to
  46541. * @param count Define the number of target we are rendering into
  46542. * @param scene Define the scene the texture belongs to
  46543. * @param options Define the options used to create the multi render target
  46544. */
  46545. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46546. /** @hidden */
  46547. _rebuild(): void;
  46548. private _createInternalTextures;
  46549. private _createTextures;
  46550. /**
  46551. * Define the number of samples used if MSAA is enabled.
  46552. */
  46553. samples: number;
  46554. /**
  46555. * Resize all the textures in the multi render target.
  46556. * Be carrefull as it will recreate all the data in the new texture.
  46557. * @param size Define the new size
  46558. */
  46559. resize(size: any): void;
  46560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46561. /**
  46562. * Dispose the render targets and their associated resources
  46563. */
  46564. dispose(): void;
  46565. /**
  46566. * Release all the underlying texture used as draw buffers.
  46567. */
  46568. releaseInternalTextures(): void;
  46569. }
  46570. }
  46571. declare module BABYLON {
  46572. /**
  46573. * Raw cube texture where the raw buffers are passed in
  46574. */
  46575. class RawCubeTexture extends CubeTexture {
  46576. /**
  46577. * Creates a cube texture where the raw buffers are passed in.
  46578. * @param scene defines the scene the texture is attached to
  46579. * @param data defines the array of data to use to create each face
  46580. * @param size defines the size of the textures
  46581. * @param format defines the format of the data
  46582. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46583. * @param generateMipMaps defines if the engine should generate the mip levels
  46584. * @param invertY defines if data must be stored with Y axis inverted
  46585. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46586. * @param compression defines the compression used (null by default)
  46587. */
  46588. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46589. /**
  46590. * Updates the raw cube texture.
  46591. * @param data defines the data to store
  46592. * @param format defines the data format
  46593. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46594. * @param invertY defines if data must be stored with Y axis inverted
  46595. * @param compression defines the compression used (null by default)
  46596. * @param level defines which level of the texture to update
  46597. */
  46598. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46599. /**
  46600. * Updates a raw cube texture with RGBD encoded data.
  46601. * @param data defines the array of data [mipmap][face] to use to create each face
  46602. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46603. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46604. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46605. * @returns a promsie that resolves when the operation is complete
  46606. */
  46607. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46608. /**
  46609. * Clones the raw cube texture.
  46610. * @return a new cube texture
  46611. */
  46612. clone(): CubeTexture;
  46613. /** @hidden */
  46614. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46615. }
  46616. }
  46617. declare module BABYLON {
  46618. /**
  46619. * Raw texture can help creating a texture directly from an array of data.
  46620. * This can be super useful if you either get the data from an uncompressed source or
  46621. * if you wish to create your texture pixel by pixel.
  46622. */
  46623. class RawTexture extends Texture {
  46624. /**
  46625. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46626. */
  46627. format: number;
  46628. private _engine;
  46629. /**
  46630. * Instantiates a new RawTexture.
  46631. * Raw texture can help creating a texture directly from an array of data.
  46632. * This can be super useful if you either get the data from an uncompressed source or
  46633. * if you wish to create your texture pixel by pixel.
  46634. * @param data define the array of data to use to create the texture
  46635. * @param width define the width of the texture
  46636. * @param height define the height of the texture
  46637. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46638. * @param scene define the scene the texture belongs to
  46639. * @param generateMipMaps define whether mip maps should be generated or not
  46640. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46641. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46642. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46643. */
  46644. constructor(data: ArrayBufferView, width: number, height: number,
  46645. /**
  46646. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46647. */
  46648. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46649. /**
  46650. * Updates the texture underlying data.
  46651. * @param data Define the new data of the texture
  46652. */
  46653. update(data: ArrayBufferView): void;
  46654. /**
  46655. * Creates a luminance texture from some data.
  46656. * @param data Define the texture data
  46657. * @param width Define the width of the texture
  46658. * @param height Define the height of the texture
  46659. * @param scene Define the scene the texture belongs to
  46660. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46663. * @returns the luminance texture
  46664. */
  46665. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46666. /**
  46667. * Creates a luminance alpha texture from some data.
  46668. * @param data Define the texture data
  46669. * @param width Define the width of the texture
  46670. * @param height Define the height of the texture
  46671. * @param scene Define the scene the texture belongs to
  46672. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46673. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46674. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46675. * @returns the luminance alpha texture
  46676. */
  46677. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46678. /**
  46679. * Creates an alpha texture from some data.
  46680. * @param data Define the texture data
  46681. * @param width Define the width of the texture
  46682. * @param height Define the height of the texture
  46683. * @param scene Define the scene the texture belongs to
  46684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46687. * @returns the alpha texture
  46688. */
  46689. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46690. /**
  46691. * Creates a RGB texture from some data.
  46692. * @param data Define the texture data
  46693. * @param width Define the width of the texture
  46694. * @param height Define the height of the texture
  46695. * @param scene Define the scene the texture belongs to
  46696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46699. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46700. * @returns the RGB alpha texture
  46701. */
  46702. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46703. /**
  46704. * Creates a RGBA texture from some data.
  46705. * @param data Define the texture data
  46706. * @param width Define the width of the texture
  46707. * @param height Define the height of the texture
  46708. * @param scene Define the scene the texture belongs to
  46709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46713. * @returns the RGBA texture
  46714. */
  46715. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46716. /**
  46717. * Creates a R texture from some data.
  46718. * @param data Define the texture data
  46719. * @param width Define the width of the texture
  46720. * @param height Define the height of the texture
  46721. * @param scene Define the scene the texture belongs to
  46722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46726. * @returns the R texture
  46727. */
  46728. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46729. }
  46730. }
  46731. declare module BABYLON {
  46732. /**
  46733. * Class used to store 3D textures containing user data
  46734. */
  46735. class RawTexture3D extends Texture {
  46736. /** Gets or sets the texture format to use */
  46737. format: number;
  46738. private _engine;
  46739. /**
  46740. * Create a new RawTexture3D
  46741. * @param data defines the data of the texture
  46742. * @param width defines the width of the texture
  46743. * @param height defines the height of the texture
  46744. * @param depth defines the depth of the texture
  46745. * @param format defines the texture format to use
  46746. * @param scene defines the hosting scene
  46747. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46748. * @param invertY defines if texture must be stored with Y axis inverted
  46749. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46750. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46751. */
  46752. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46753. /** Gets or sets the texture format to use */
  46754. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46755. /**
  46756. * Update the texture with new data
  46757. * @param data defines the data to store in the texture
  46758. */
  46759. update(data: ArrayBufferView): void;
  46760. }
  46761. }
  46762. declare module BABYLON {
  46763. /**
  46764. * Creates a refraction texture used by refraction channel of the standard material.
  46765. * It is like a mirror but to see through a material.
  46766. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46767. */
  46768. class RefractionTexture extends RenderTargetTexture {
  46769. /**
  46770. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46771. * 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.
  46772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46773. */
  46774. refractionPlane: Plane;
  46775. /**
  46776. * Define how deep under the surface we should see.
  46777. */
  46778. depth: number;
  46779. /**
  46780. * Creates a refraction texture used by refraction channel of the standard material.
  46781. * It is like a mirror but to see through a material.
  46782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46783. * @param name Define the texture name
  46784. * @param size Define the size of the underlying texture
  46785. * @param scene Define the scene the refraction belongs to
  46786. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46787. */
  46788. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46789. /**
  46790. * Clone the refraction texture.
  46791. * @returns the cloned texture
  46792. */
  46793. clone(): RefractionTexture;
  46794. /**
  46795. * Serialize the texture to a JSON representation you could use in Parse later on
  46796. * @returns the serialized JSON representation
  46797. */
  46798. serialize(): any;
  46799. }
  46800. }
  46801. declare module BABYLON {
  46802. /**
  46803. * This Helps creating a texture that will be created from a camera in your scene.
  46804. * It is basically a dynamic texture that could be used to create special effects for instance.
  46805. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46806. */
  46807. class RenderTargetTexture extends Texture {
  46808. isCube: boolean;
  46809. /**
  46810. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46811. */
  46812. static readonly REFRESHRATE_RENDER_ONCE: number;
  46813. /**
  46814. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46815. */
  46816. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46817. /**
  46818. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46819. * the central point of your effect and can save a lot of performances.
  46820. */
  46821. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46822. /**
  46823. * Use this predicate to dynamically define the list of mesh you want to render.
  46824. * If set, the renderList property will be overwritten.
  46825. */
  46826. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46827. private _renderList;
  46828. /**
  46829. * Use this list to define the list of mesh you want to render.
  46830. */
  46831. renderList: Nullable<Array<AbstractMesh>>;
  46832. private _hookArray;
  46833. /**
  46834. * Define if particles should be rendered in your texture.
  46835. */
  46836. renderParticles: boolean;
  46837. /**
  46838. * Define if sprites should be rendered in your texture.
  46839. */
  46840. renderSprites: boolean;
  46841. /**
  46842. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46843. */
  46844. coordinatesMode: number;
  46845. /**
  46846. * Define the camera used to render the texture.
  46847. */
  46848. activeCamera: Nullable<Camera>;
  46849. /**
  46850. * Override the render function of the texture with your own one.
  46851. */
  46852. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46853. /**
  46854. * Define if camera post processes should be use while rendering the texture.
  46855. */
  46856. useCameraPostProcesses: boolean;
  46857. /**
  46858. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46859. */
  46860. ignoreCameraViewport: boolean;
  46861. private _postProcessManager;
  46862. private _postProcesses;
  46863. private _resizeObserver;
  46864. /**
  46865. * An event triggered when the texture is unbind.
  46866. */
  46867. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46868. /**
  46869. * An event triggered when the texture is unbind.
  46870. */
  46871. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46872. private _onAfterUnbindObserver;
  46873. /**
  46874. * Set a after unbind callback in the texture.
  46875. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46876. */
  46877. onAfterUnbind: () => void;
  46878. /**
  46879. * An event triggered before rendering the texture
  46880. */
  46881. onBeforeRenderObservable: Observable<number>;
  46882. private _onBeforeRenderObserver;
  46883. /**
  46884. * Set a before render callback in the texture.
  46885. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46886. */
  46887. onBeforeRender: (faceIndex: number) => void;
  46888. /**
  46889. * An event triggered after rendering the texture
  46890. */
  46891. onAfterRenderObservable: Observable<number>;
  46892. private _onAfterRenderObserver;
  46893. /**
  46894. * Set a after render callback in the texture.
  46895. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46896. */
  46897. onAfterRender: (faceIndex: number) => void;
  46898. /**
  46899. * An event triggered after the texture clear
  46900. */
  46901. onClearObservable: Observable<Engine>;
  46902. private _onClearObserver;
  46903. /**
  46904. * Set a clear callback in the texture.
  46905. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46906. */
  46907. onClear: (Engine: Engine) => void;
  46908. /**
  46909. * Define the clear color of the Render Target if it should be different from the scene.
  46910. */
  46911. clearColor: Color4;
  46912. protected _size: number | {
  46913. width: number;
  46914. height: number;
  46915. };
  46916. protected _initialSizeParameter: number | {
  46917. width: number;
  46918. height: number;
  46919. } | {
  46920. ratio: number;
  46921. };
  46922. protected _sizeRatio: Nullable<number>;
  46923. /** @hidden */
  46924. _generateMipMaps: boolean;
  46925. protected _renderingManager: RenderingManager;
  46926. /** @hidden */
  46927. _waitingRenderList: string[];
  46928. protected _doNotChangeAspectRatio: boolean;
  46929. protected _currentRefreshId: number;
  46930. protected _refreshRate: number;
  46931. protected _textureMatrix: Matrix;
  46932. protected _samples: number;
  46933. protected _renderTargetOptions: RenderTargetCreationOptions;
  46934. /**
  46935. * Gets render target creation options that were used.
  46936. */
  46937. readonly renderTargetOptions: RenderTargetCreationOptions;
  46938. protected _engine: Engine;
  46939. protected _onRatioRescale(): void;
  46940. /**
  46941. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46942. * It must define where the camera used to render the texture is set
  46943. */
  46944. boundingBoxPosition: Vector3;
  46945. private _boundingBoxSize;
  46946. /**
  46947. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46948. * When defined, the cubemap will switch to local mode
  46949. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46950. * @example https://www.babylonjs-playground.com/#RNASML
  46951. */
  46952. boundingBoxSize: Vector3;
  46953. /**
  46954. * In case the RTT has been created with a depth texture, get the associated
  46955. * depth texture.
  46956. * Otherwise, return null.
  46957. */
  46958. depthStencilTexture: Nullable<InternalTexture>;
  46959. /**
  46960. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46961. * or used a shadow, depth texture...
  46962. * @param name The friendly name of the texture
  46963. * @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)
  46964. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46965. * @param generateMipMaps True if mip maps need to be generated after render.
  46966. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46967. * @param type The type of the buffer in the RTT (int, half float, float...)
  46968. * @param isCube True if a cube texture needs to be created
  46969. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46970. * @param generateDepthBuffer True to generate a depth buffer
  46971. * @param generateStencilBuffer True to generate a stencil buffer
  46972. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46973. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46974. */
  46975. constructor(name: string, size: number | {
  46976. width: number;
  46977. height: number;
  46978. } | {
  46979. ratio: number;
  46980. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46981. /**
  46982. * Creates a depth stencil texture.
  46983. * This is only available in WebGL 2 or with the depth texture extension available.
  46984. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46985. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46986. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46987. */
  46988. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46989. private _processSizeParameter;
  46990. /**
  46991. * Define the number of samples to use in case of MSAA.
  46992. * It defaults to one meaning no MSAA has been enabled.
  46993. */
  46994. samples: number;
  46995. /**
  46996. * Resets the refresh counter of the texture and start bak from scratch.
  46997. * Could be usefull to regenerate the texture if it is setup to render only once.
  46998. */
  46999. resetRefreshCounter(): void;
  47000. /**
  47001. * Define the refresh rate of the texture or the rendering frequency.
  47002. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47003. */
  47004. refreshRate: number;
  47005. /**
  47006. * Adds a post process to the render target rendering passes.
  47007. * @param postProcess define the post process to add
  47008. */
  47009. addPostProcess(postProcess: PostProcess): void;
  47010. /**
  47011. * Clear all the post processes attached to the render target
  47012. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47013. */
  47014. clearPostProcesses(dispose?: boolean): void;
  47015. /**
  47016. * Remove one of the post process from the list of attached post processes to the texture
  47017. * @param postProcess define the post process to remove from the list
  47018. */
  47019. removePostProcess(postProcess: PostProcess): void;
  47020. /** @hidden */
  47021. _shouldRender(): boolean;
  47022. /**
  47023. * Gets the actual render size of the texture.
  47024. * @returns the width of the render size
  47025. */
  47026. getRenderSize(): number;
  47027. /**
  47028. * Gets the actual render width of the texture.
  47029. * @returns the width of the render size
  47030. */
  47031. getRenderWidth(): number;
  47032. /**
  47033. * Gets the actual render height of the texture.
  47034. * @returns the height of the render size
  47035. */
  47036. getRenderHeight(): number;
  47037. /**
  47038. * Get if the texture can be rescaled or not.
  47039. */
  47040. readonly canRescale: boolean;
  47041. /**
  47042. * Resize the texture using a ratio.
  47043. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47044. */
  47045. scale(ratio: number): void;
  47046. /**
  47047. * Get the texture reflection matrix used to rotate/transform the reflection.
  47048. * @returns the reflection matrix
  47049. */
  47050. getReflectionTextureMatrix(): Matrix;
  47051. /**
  47052. * Resize the texture to a new desired size.
  47053. * Be carrefull as it will recreate all the data in the new texture.
  47054. * @param size Define the new size. It can be:
  47055. * - a number for squared texture,
  47056. * - an object containing { width: number, height: number }
  47057. * - or an object containing a ratio { ratio: number }
  47058. */
  47059. resize(size: number | {
  47060. width: number;
  47061. height: number;
  47062. } | {
  47063. ratio: number;
  47064. }): void;
  47065. /**
  47066. * Renders all the objects from the render list into the texture.
  47067. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47068. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47069. */
  47070. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47071. private _bestReflectionRenderTargetDimension;
  47072. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47073. private renderToTarget;
  47074. /**
  47075. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47076. * This allowed control for front to back rendering or reversly depending of the special needs.
  47077. *
  47078. * @param renderingGroupId The rendering group id corresponding to its index
  47079. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47080. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47081. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47082. */
  47083. 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;
  47084. /**
  47085. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47086. *
  47087. * @param renderingGroupId The rendering group id corresponding to its index
  47088. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47089. */
  47090. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47091. /**
  47092. * Clones the texture.
  47093. * @returns the cloned texture
  47094. */
  47095. clone(): RenderTargetTexture;
  47096. /**
  47097. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47098. * @returns The JSON representation of the texture
  47099. */
  47100. serialize(): any;
  47101. /**
  47102. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47103. */
  47104. disposeFramebufferObjects(): void;
  47105. /**
  47106. * Dispose the texture and release its associated resources.
  47107. */
  47108. dispose(): void;
  47109. /** @hidden */
  47110. _rebuild(): void;
  47111. /**
  47112. * Clear the info related to rendering groups preventing retention point in material dispose.
  47113. */
  47114. freeRenderingGroups(): void;
  47115. }
  47116. }
  47117. declare module BABYLON {
  47118. /**
  47119. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47120. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47121. */
  47122. class Texture extends BaseTexture {
  47123. /** nearest is mag = nearest and min = nearest and mip = linear */
  47124. static readonly NEAREST_SAMPLINGMODE: number;
  47125. /** nearest is mag = nearest and min = nearest and mip = linear */
  47126. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47127. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47128. static readonly BILINEAR_SAMPLINGMODE: number;
  47129. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47130. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47131. /** Trilinear is mag = linear and min = linear and mip = linear */
  47132. static readonly TRILINEAR_SAMPLINGMODE: number;
  47133. /** Trilinear is mag = linear and min = linear and mip = linear */
  47134. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47135. /** mag = nearest and min = nearest and mip = nearest */
  47136. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47137. /** mag = nearest and min = linear and mip = nearest */
  47138. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47139. /** mag = nearest and min = linear and mip = linear */
  47140. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47141. /** mag = nearest and min = linear and mip = none */
  47142. static readonly NEAREST_LINEAR: number;
  47143. /** mag = nearest and min = nearest and mip = none */
  47144. static readonly NEAREST_NEAREST: number;
  47145. /** mag = linear and min = nearest and mip = nearest */
  47146. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47147. /** mag = linear and min = nearest and mip = linear */
  47148. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47149. /** mag = linear and min = linear and mip = none */
  47150. static readonly LINEAR_LINEAR: number;
  47151. /** mag = linear and min = nearest and mip = none */
  47152. static readonly LINEAR_NEAREST: number;
  47153. /** Explicit coordinates mode */
  47154. static readonly EXPLICIT_MODE: number;
  47155. /** Spherical coordinates mode */
  47156. static readonly SPHERICAL_MODE: number;
  47157. /** Planar coordinates mode */
  47158. static readonly PLANAR_MODE: number;
  47159. /** Cubic coordinates mode */
  47160. static readonly CUBIC_MODE: number;
  47161. /** Projection coordinates mode */
  47162. static readonly PROJECTION_MODE: number;
  47163. /** Inverse Cubic coordinates mode */
  47164. static readonly SKYBOX_MODE: number;
  47165. /** Inverse Cubic coordinates mode */
  47166. static readonly INVCUBIC_MODE: number;
  47167. /** Equirectangular coordinates mode */
  47168. static readonly EQUIRECTANGULAR_MODE: number;
  47169. /** Equirectangular Fixed coordinates mode */
  47170. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47171. /** Equirectangular Fixed Mirrored coordinates mode */
  47172. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47173. /** Texture is not repeating outside of 0..1 UVs */
  47174. static readonly CLAMP_ADDRESSMODE: number;
  47175. /** Texture is repeating outside of 0..1 UVs */
  47176. static readonly WRAP_ADDRESSMODE: number;
  47177. /** Texture is repeating and mirrored */
  47178. static readonly MIRROR_ADDRESSMODE: number;
  47179. /**
  47180. * 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
  47181. */
  47182. static UseSerializedUrlIfAny: boolean;
  47183. /**
  47184. * Define the url of the texture.
  47185. */
  47186. url: Nullable<string>;
  47187. /**
  47188. * Define an offset on the texture to offset the u coordinates of the UVs
  47189. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47190. */
  47191. uOffset: number;
  47192. /**
  47193. * Define an offset on the texture to offset the v coordinates of the UVs
  47194. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47195. */
  47196. vOffset: number;
  47197. /**
  47198. * Define an offset on the texture to scale the u coordinates of the UVs
  47199. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47200. */
  47201. uScale: number;
  47202. /**
  47203. * Define an offset on the texture to scale the v coordinates of the UVs
  47204. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47205. */
  47206. vScale: number;
  47207. /**
  47208. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47209. * @see http://doc.babylonjs.com/how_to/more_materials
  47210. */
  47211. uAng: number;
  47212. /**
  47213. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47214. * @see http://doc.babylonjs.com/how_to/more_materials
  47215. */
  47216. vAng: number;
  47217. /**
  47218. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47219. * @see http://doc.babylonjs.com/how_to/more_materials
  47220. */
  47221. wAng: number;
  47222. /**
  47223. * Defines the center of rotation (U)
  47224. */
  47225. uRotationCenter: number;
  47226. /**
  47227. * Defines the center of rotation (V)
  47228. */
  47229. vRotationCenter: number;
  47230. /**
  47231. * Defines the center of rotation (W)
  47232. */
  47233. wRotationCenter: number;
  47234. /**
  47235. * Are mip maps generated for this texture or not.
  47236. */
  47237. readonly noMipmap: boolean;
  47238. private _noMipmap;
  47239. /** @hidden */
  47240. _invertY: boolean;
  47241. private _rowGenerationMatrix;
  47242. private _cachedTextureMatrix;
  47243. private _projectionModeMatrix;
  47244. private _t0;
  47245. private _t1;
  47246. private _t2;
  47247. private _cachedUOffset;
  47248. private _cachedVOffset;
  47249. private _cachedUScale;
  47250. private _cachedVScale;
  47251. private _cachedUAng;
  47252. private _cachedVAng;
  47253. private _cachedWAng;
  47254. private _cachedProjectionMatrixId;
  47255. private _cachedCoordinatesMode;
  47256. /** @hidden */
  47257. _samplingMode: number;
  47258. /** @hidden */
  47259. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47260. private _deleteBuffer;
  47261. protected _format: Nullable<number>;
  47262. private _delayedOnLoad;
  47263. private _delayedOnError;
  47264. /**
  47265. * Observable triggered once the texture has been loaded.
  47266. */
  47267. onLoadObservable: Observable<Texture>;
  47268. protected _isBlocking: boolean;
  47269. /**
  47270. * Is the texture preventing material to render while loading.
  47271. * If false, a default texture will be used instead of the loading one during the preparation step.
  47272. */
  47273. isBlocking: boolean;
  47274. /**
  47275. * Get the current sampling mode associated with the texture.
  47276. */
  47277. readonly samplingMode: number;
  47278. /**
  47279. * Instantiates a new texture.
  47280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47281. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47282. * @param url define the url of the picture to load as a texture
  47283. * @param scene define the scene the texture will belong to
  47284. * @param noMipmap define if the texture will require mip maps or not
  47285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47287. * @param onLoad define a callback triggered when the texture has been loaded
  47288. * @param onError define a callback triggered when an error occurred during the loading session
  47289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47292. */
  47293. 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);
  47294. /**
  47295. * Update the url (and optional buffer) of this texture if url was null during construction.
  47296. * @param url the url of the texture
  47297. * @param buffer the buffer of the texture (defaults to null)
  47298. */
  47299. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47300. /**
  47301. * Finish the loading sequence of a texture flagged as delayed load.
  47302. * @hidden
  47303. */
  47304. delayLoad(): void;
  47305. /**
  47306. * Update the sampling mode of the texture.
  47307. * Default is Trilinear mode.
  47308. *
  47309. * | Value | Type | Description |
  47310. * | ----- | ------------------ | ----------- |
  47311. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47312. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47313. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47314. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47315. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47316. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47317. * | 7 | NEAREST_LINEAR | |
  47318. * | 8 | NEAREST_NEAREST | |
  47319. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47320. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47321. * | 11 | LINEAR_LINEAR | |
  47322. * | 12 | LINEAR_NEAREST | |
  47323. *
  47324. * > _mag_: magnification filter (close to the viewer)
  47325. * > _min_: minification filter (far from the viewer)
  47326. * > _mip_: filter used between mip map levels
  47327. *@param samplingMode Define the new sampling mode of the texture
  47328. */
  47329. updateSamplingMode(samplingMode: number): void;
  47330. private _prepareRowForTextureGeneration;
  47331. /**
  47332. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47333. * @returns the transform matrix of the texture.
  47334. */
  47335. getTextureMatrix(): Matrix;
  47336. /**
  47337. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47338. * @returns The reflection texture transform
  47339. */
  47340. getReflectionTextureMatrix(): Matrix;
  47341. /**
  47342. * Clones the texture.
  47343. * @returns the cloned texture
  47344. */
  47345. clone(): Texture;
  47346. /**
  47347. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47348. * @returns The JSON representation of the texture
  47349. */
  47350. serialize(): any;
  47351. /**
  47352. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47353. * @returns "Texture"
  47354. */
  47355. getClassName(): string;
  47356. /**
  47357. * Dispose the texture and release its associated resources.
  47358. */
  47359. dispose(): void;
  47360. /**
  47361. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47362. * @param parsedTexture Define the JSON representation of the texture
  47363. * @param scene Define the scene the parsed texture should be instantiated in
  47364. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47365. * @returns The parsed texture if successful
  47366. */
  47367. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47368. /**
  47369. * Creates a texture from its base 64 representation.
  47370. * @param data Define the base64 payload without the data: prefix
  47371. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47372. * @param scene Define the scene the texture should belong to
  47373. * @param noMipmap Forces the texture to not create mip map information if true
  47374. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47375. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47376. * @param onLoad define a callback triggered when the texture has been loaded
  47377. * @param onError define a callback triggered when an error occurred during the loading session
  47378. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47379. * @returns the created texture
  47380. */
  47381. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47382. /**
  47383. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47384. * @param data Define the base64 payload without the data: prefix
  47385. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47386. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47387. * @param scene Define the scene the texture should belong to
  47388. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47389. * @param noMipmap Forces the texture to not create mip map information if true
  47390. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47391. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47392. * @param onLoad define a callback triggered when the texture has been loaded
  47393. * @param onError define a callback triggered when an error occurred during the loading session
  47394. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47395. * @returns the created texture
  47396. */
  47397. 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;
  47398. }
  47399. }
  47400. declare module BABYLON {
  47401. /**
  47402. * Settings for finer control over video usage
  47403. */
  47404. interface VideoTextureSettings {
  47405. /**
  47406. * Applies `autoplay` to video, if specified
  47407. */
  47408. autoPlay?: boolean;
  47409. /**
  47410. * Applies `loop` to video, if specified
  47411. */
  47412. loop?: boolean;
  47413. /**
  47414. * Automatically updates internal texture from video at every frame in the render loop
  47415. */
  47416. autoUpdateTexture: boolean;
  47417. /**
  47418. * Image src displayed during the video loading or until the user interacts with the video.
  47419. */
  47420. poster?: string;
  47421. }
  47422. /**
  47423. * If you want to display a video in your scene, this is the special texture for that.
  47424. * This special texture works similar to other textures, with the exception of a few parameters.
  47425. * @see https://doc.babylonjs.com/how_to/video_texture
  47426. */
  47427. class VideoTexture extends Texture {
  47428. /**
  47429. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47430. */
  47431. readonly autoUpdateTexture: boolean;
  47432. /**
  47433. * The video instance used by the texture internally
  47434. */
  47435. readonly video: HTMLVideoElement;
  47436. private _onUserActionRequestedObservable;
  47437. /**
  47438. * Event triggerd when a dom action is required by the user to play the video.
  47439. * This happens due to recent changes in browser policies preventing video to auto start.
  47440. */
  47441. readonly onUserActionRequestedObservable: Observable<Texture>;
  47442. private _generateMipMaps;
  47443. private _engine;
  47444. private _stillImageCaptured;
  47445. private _poster;
  47446. /**
  47447. * Creates a video texture.
  47448. * If you want to display a video in your scene, this is the special texture for that.
  47449. * This special texture works similar to other textures, with the exception of a few parameters.
  47450. * @see https://doc.babylonjs.com/how_to/video_texture
  47451. * @param name optional name, will detect from video source, if not defined
  47452. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47453. * @param scene is obviously the current scene.
  47454. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47455. * @param invertY is false by default but can be used to invert video on Y axis
  47456. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47457. * @param settings allows finer control over video usage
  47458. */
  47459. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47460. private _getName;
  47461. private _getVideo;
  47462. private _createInternalTexture;
  47463. private reset;
  47464. /**
  47465. * @hidden Internal method to initiate `update`.
  47466. */
  47467. _rebuild(): void;
  47468. /**
  47469. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47470. */
  47471. update(): void;
  47472. /**
  47473. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47474. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47475. */
  47476. updateTexture(isVisible: boolean): void;
  47477. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47478. /**
  47479. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47480. * @param url New url.
  47481. */
  47482. updateURL(url: string): void;
  47483. /**
  47484. * Dispose the texture and release its associated resources.
  47485. */
  47486. dispose(): void;
  47487. /**
  47488. * Creates a video texture straight from your WebCam video feed.
  47489. * @param scene Define the scene the texture should be created in
  47490. * @param onReady Define a callback to triggered once the texture will be ready
  47491. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47492. */
  47493. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47494. minWidth: number;
  47495. maxWidth: number;
  47496. minHeight: number;
  47497. maxHeight: number;
  47498. deviceId: string;
  47499. }): void;
  47500. }
  47501. }
  47502. declare var DracoDecoderModule: any;
  47503. declare var WebAssembly: any;
  47504. declare module BABYLON {
  47505. /**
  47506. * Configuration for Draco compression
  47507. */
  47508. interface IDracoCompressionConfiguration {
  47509. /**
  47510. * Configuration for the decoder.
  47511. */
  47512. decoder?: {
  47513. /**
  47514. * The url to the WebAssembly module.
  47515. */
  47516. wasmUrl?: string;
  47517. /**
  47518. * The url to the WebAssembly binary.
  47519. */
  47520. wasmBinaryUrl?: string;
  47521. /**
  47522. * The url to the fallback JavaScript module.
  47523. */
  47524. fallbackUrl?: string;
  47525. };
  47526. }
  47527. /**
  47528. * Draco compression (https://google.github.io/draco/)
  47529. *
  47530. * This class wraps the Draco module.
  47531. *
  47532. * **Encoder**
  47533. *
  47534. * The encoder is not currently implemented.
  47535. *
  47536. * **Decoder**
  47537. *
  47538. * 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.
  47539. *
  47540. * To update the configuration, use the following code:
  47541. * ```javascript
  47542. * BABYLON.DracoCompression.Configuration = {
  47543. * decoder: {
  47544. * wasmUrl: "<url to the WebAssembly library>",
  47545. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47546. * fallbackUrl: "<url to the fallback JavaScript library>",
  47547. * }
  47548. * };
  47549. * ```
  47550. *
  47551. * 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.
  47552. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47553. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47554. *
  47555. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47556. * ```javascript
  47557. * var dracoCompression = new BABYLON.DracoCompression();
  47558. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47559. * [BABYLON.VertexBuffer.PositionKind]: 0
  47560. * });
  47561. * ```
  47562. *
  47563. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47564. */
  47565. class DracoCompression implements IDisposable {
  47566. private static _DecoderModulePromise;
  47567. /**
  47568. * The configuration. Defaults to the following urls:
  47569. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47570. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47571. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47572. */
  47573. static Configuration: IDracoCompressionConfiguration;
  47574. /**
  47575. * Returns true if the decoder is available.
  47576. */
  47577. static readonly DecoderAvailable: boolean;
  47578. /**
  47579. * Constructor
  47580. */
  47581. constructor();
  47582. /**
  47583. * Stop all async operations and release resources.
  47584. */
  47585. dispose(): void;
  47586. /**
  47587. * Decode Draco compressed mesh data to vertex data.
  47588. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47589. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47590. * @returns A promise that resolves with the decoded vertex data
  47591. */
  47592. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47593. [kind: string]: number;
  47594. }): Promise<VertexData>;
  47595. private static _GetDecoderModule;
  47596. private static _LoadScriptAsync;
  47597. private static _LoadFileAsync;
  47598. }
  47599. }
  47600. declare module BABYLON {
  47601. /** @hidden */
  47602. class CannonJSPlugin implements IPhysicsEnginePlugin {
  47603. private _useDeltaForWorldStep;
  47604. world: any;
  47605. name: string;
  47606. private _physicsMaterials;
  47607. private _fixedTimeStep;
  47608. BJSCANNON: any;
  47609. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  47610. setGravity(gravity: Vector3): void;
  47611. setTimeStep(timeStep: number): void;
  47612. getTimeStep(): number;
  47613. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47617. private _processChildMeshes;
  47618. removePhysicsBody(impostor: PhysicsImpostor): void;
  47619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47621. private _addMaterial;
  47622. private _checkWithEpsilon;
  47623. private _createShape;
  47624. private _createHeightmap;
  47625. private _minus90X;
  47626. private _plus90X;
  47627. private _tmpPosition;
  47628. private _tmpDeltaPosition;
  47629. private _tmpUnityRotation;
  47630. private _updatePhysicsBodyTransformation;
  47631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47633. isSupported(): boolean;
  47634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47637. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47638. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47639. getBodyMass(impostor: PhysicsImpostor): number;
  47640. getBodyFriction(impostor: PhysicsImpostor): number;
  47641. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47642. getBodyRestitution(impostor: PhysicsImpostor): number;
  47643. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47644. sleepBody(impostor: PhysicsImpostor): void;
  47645. wakeUpBody(impostor: PhysicsImpostor): void;
  47646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47647. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47650. getRadius(impostor: PhysicsImpostor): number;
  47651. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47652. dispose(): void;
  47653. private _extendNamespace;
  47654. }
  47655. }
  47656. declare module BABYLON {
  47657. /** @hidden */
  47658. class OimoJSPlugin implements IPhysicsEnginePlugin {
  47659. world: any;
  47660. name: string;
  47661. BJSOIMO: any;
  47662. constructor(iterations?: number);
  47663. setGravity(gravity: Vector3): void;
  47664. setTimeStep(timeStep: number): void;
  47665. getTimeStep(): number;
  47666. private _tmpImpostorsArray;
  47667. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47670. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47671. private _tmpPositionVector;
  47672. removePhysicsBody(impostor: PhysicsImpostor): void;
  47673. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47674. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47675. isSupported(): boolean;
  47676. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47677. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47678. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47679. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47680. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47681. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47682. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47683. getBodyMass(impostor: PhysicsImpostor): number;
  47684. getBodyFriction(impostor: PhysicsImpostor): number;
  47685. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47686. getBodyRestitution(impostor: PhysicsImpostor): number;
  47687. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47688. sleepBody(impostor: PhysicsImpostor): void;
  47689. wakeUpBody(impostor: PhysicsImpostor): void;
  47690. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47691. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47692. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47693. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47694. getRadius(impostor: PhysicsImpostor): number;
  47695. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47696. dispose(): void;
  47697. }
  47698. }
  47699. declare module BABYLON {
  47700. /**
  47701. * Particle emitter emitting particles from the inside of a box.
  47702. * It emits the particles randomly between 2 given directions.
  47703. */
  47704. class BoxParticleEmitter implements IParticleEmitterType {
  47705. /**
  47706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47707. */
  47708. direction1: Vector3;
  47709. /**
  47710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47711. */
  47712. direction2: Vector3;
  47713. /**
  47714. * 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.
  47715. */
  47716. minEmitBox: Vector3;
  47717. /**
  47718. * 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.
  47719. */
  47720. maxEmitBox: Vector3;
  47721. /**
  47722. * Creates a new instance BoxParticleEmitter
  47723. */
  47724. constructor();
  47725. /**
  47726. * Called by the particle System when the direction is computed for the created particle.
  47727. * @param worldMatrix is the world matrix of the particle system
  47728. * @param directionToUpdate is the direction vector to update with the result
  47729. * @param particle is the particle we are computed the direction for
  47730. */
  47731. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47732. /**
  47733. * Called by the particle System when the position is computed for the created particle.
  47734. * @param worldMatrix is the world matrix of the particle system
  47735. * @param positionToUpdate is the position vector to update with the result
  47736. * @param particle is the particle we are computed the position for
  47737. */
  47738. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47739. /**
  47740. * Clones the current emitter and returns a copy of it
  47741. * @returns the new emitter
  47742. */
  47743. clone(): BoxParticleEmitter;
  47744. /**
  47745. * Called by the GPUParticleSystem to setup the update shader
  47746. * @param effect defines the update shader
  47747. */
  47748. applyToShader(effect: Effect): void;
  47749. /**
  47750. * Returns a string to use to update the GPU particles update shader
  47751. * @returns a string containng the defines string
  47752. */
  47753. getEffectDefines(): string;
  47754. /**
  47755. * Returns the string "BoxParticleEmitter"
  47756. * @returns a string containing the class name
  47757. */
  47758. getClassName(): string;
  47759. /**
  47760. * Serializes the particle system to a JSON object.
  47761. * @returns the JSON object
  47762. */
  47763. serialize(): any;
  47764. /**
  47765. * Parse properties from a JSON object
  47766. * @param serializationObject defines the JSON object
  47767. */
  47768. parse(serializationObject: any): void;
  47769. }
  47770. }
  47771. declare module BABYLON {
  47772. /**
  47773. * Particle emitter emitting particles from the inside of a cone.
  47774. * It emits the particles alongside the cone volume from the base to the particle.
  47775. * The emission direction might be randomized.
  47776. */
  47777. class ConeParticleEmitter implements IParticleEmitterType {
  47778. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47779. directionRandomizer: number;
  47780. private _radius;
  47781. private _angle;
  47782. private _height;
  47783. /**
  47784. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47785. */
  47786. radiusRange: number;
  47787. /**
  47788. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47789. */
  47790. heightRange: number;
  47791. /**
  47792. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47793. */
  47794. emitFromSpawnPointOnly: boolean;
  47795. /**
  47796. * Gets or sets the radius of the emission cone
  47797. */
  47798. radius: number;
  47799. /**
  47800. * Gets or sets the angle of the emission cone
  47801. */
  47802. angle: number;
  47803. private _buildHeight;
  47804. /**
  47805. * Creates a new instance ConeParticleEmitter
  47806. * @param radius the radius of the emission cone (1 by default)
  47807. * @param angles the cone base angle (PI by default)
  47808. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47809. */
  47810. constructor(radius?: number, angle?: number,
  47811. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47812. directionRandomizer?: number);
  47813. /**
  47814. * Called by the particle System when the direction is computed for the created particle.
  47815. * @param worldMatrix is the world matrix of the particle system
  47816. * @param directionToUpdate is the direction vector to update with the result
  47817. * @param particle is the particle we are computed the direction for
  47818. */
  47819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47820. /**
  47821. * Called by the particle System when the position is computed for the created particle.
  47822. * @param worldMatrix is the world matrix of the particle system
  47823. * @param positionToUpdate is the position vector to update with the result
  47824. * @param particle is the particle we are computed the position for
  47825. */
  47826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47827. /**
  47828. * Clones the current emitter and returns a copy of it
  47829. * @returns the new emitter
  47830. */
  47831. clone(): ConeParticleEmitter;
  47832. /**
  47833. * Called by the GPUParticleSystem to setup the update shader
  47834. * @param effect defines the update shader
  47835. */
  47836. applyToShader(effect: Effect): void;
  47837. /**
  47838. * Returns a string to use to update the GPU particles update shader
  47839. * @returns a string containng the defines string
  47840. */
  47841. getEffectDefines(): string;
  47842. /**
  47843. * Returns the string "ConeParticleEmitter"
  47844. * @returns a string containing the class name
  47845. */
  47846. getClassName(): string;
  47847. /**
  47848. * Serializes the particle system to a JSON object.
  47849. * @returns the JSON object
  47850. */
  47851. serialize(): any;
  47852. /**
  47853. * Parse properties from a JSON object
  47854. * @param serializationObject defines the JSON object
  47855. */
  47856. parse(serializationObject: any): void;
  47857. }
  47858. }
  47859. declare module BABYLON {
  47860. /**
  47861. * Particle emitter emitting particles from the inside of a cylinder.
  47862. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47863. */
  47864. class CylinderParticleEmitter implements IParticleEmitterType {
  47865. /**
  47866. * The radius of the emission cylinder.
  47867. */
  47868. radius: number;
  47869. /**
  47870. * The height of the emission cylinder.
  47871. */
  47872. height: number;
  47873. /**
  47874. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47875. */
  47876. radiusRange: number;
  47877. /**
  47878. * How much to randomize the particle direction [0-1].
  47879. */
  47880. directionRandomizer: number;
  47881. /**
  47882. * Creates a new instance CylinderParticleEmitter
  47883. * @param radius the radius of the emission cylinder (1 by default)
  47884. * @param height the height of the emission cylinder (1 by default)
  47885. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47886. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47887. */
  47888. constructor(
  47889. /**
  47890. * The radius of the emission cylinder.
  47891. */
  47892. radius?: number,
  47893. /**
  47894. * The height of the emission cylinder.
  47895. */
  47896. height?: number,
  47897. /**
  47898. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47899. */
  47900. radiusRange?: number,
  47901. /**
  47902. * How much to randomize the particle direction [0-1].
  47903. */
  47904. directionRandomizer?: number);
  47905. /**
  47906. * Called by the particle System when the direction is computed for the created particle.
  47907. * @param worldMatrix is the world matrix of the particle system
  47908. * @param directionToUpdate is the direction vector to update with the result
  47909. * @param particle is the particle we are computed the direction for
  47910. */
  47911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47912. /**
  47913. * Called by the particle System when the position is computed for the created particle.
  47914. * @param worldMatrix is the world matrix of the particle system
  47915. * @param positionToUpdate is the position vector to update with the result
  47916. * @param particle is the particle we are computed the position for
  47917. */
  47918. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47919. /**
  47920. * Clones the current emitter and returns a copy of it
  47921. * @returns the new emitter
  47922. */
  47923. clone(): CylinderParticleEmitter;
  47924. /**
  47925. * Called by the GPUParticleSystem to setup the update shader
  47926. * @param effect defines the update shader
  47927. */
  47928. applyToShader(effect: Effect): void;
  47929. /**
  47930. * Returns a string to use to update the GPU particles update shader
  47931. * @returns a string containng the defines string
  47932. */
  47933. getEffectDefines(): string;
  47934. /**
  47935. * Returns the string "CylinderParticleEmitter"
  47936. * @returns a string containing the class name
  47937. */
  47938. getClassName(): string;
  47939. /**
  47940. * Serializes the particle system to a JSON object.
  47941. * @returns the JSON object
  47942. */
  47943. serialize(): any;
  47944. /**
  47945. * Parse properties from a JSON object
  47946. * @param serializationObject defines the JSON object
  47947. */
  47948. parse(serializationObject: any): void;
  47949. }
  47950. /**
  47951. * Particle emitter emitting particles from the inside of a cylinder.
  47952. * It emits the particles randomly between two vectors.
  47953. */
  47954. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47955. /**
  47956. * The min limit of the emission direction.
  47957. */
  47958. direction1: Vector3;
  47959. /**
  47960. * The max limit of the emission direction.
  47961. */
  47962. direction2: Vector3;
  47963. /**
  47964. * Creates a new instance CylinderDirectedParticleEmitter
  47965. * @param radius the radius of the emission cylinder (1 by default)
  47966. * @param height the height of the emission cylinder (1 by default)
  47967. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47968. * @param direction1 the min limit of the emission direction (up vector by default)
  47969. * @param direction2 the max limit of the emission direction (up vector by default)
  47970. */
  47971. constructor(radius?: number, height?: number, radiusRange?: number,
  47972. /**
  47973. * The min limit of the emission direction.
  47974. */
  47975. direction1?: Vector3,
  47976. /**
  47977. * The max limit of the emission direction.
  47978. */
  47979. direction2?: Vector3);
  47980. /**
  47981. * Called by the particle System when the direction is computed for the created particle.
  47982. * @param worldMatrix is the world matrix of the particle system
  47983. * @param directionToUpdate is the direction vector to update with the result
  47984. * @param particle is the particle we are computed the direction for
  47985. */
  47986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47987. /**
  47988. * Clones the current emitter and returns a copy of it
  47989. * @returns the new emitter
  47990. */
  47991. clone(): CylinderDirectedParticleEmitter;
  47992. /**
  47993. * Called by the GPUParticleSystem to setup the update shader
  47994. * @param effect defines the update shader
  47995. */
  47996. applyToShader(effect: Effect): void;
  47997. /**
  47998. * Returns a string to use to update the GPU particles update shader
  47999. * @returns a string containng the defines string
  48000. */
  48001. getEffectDefines(): string;
  48002. /**
  48003. * Returns the string "CylinderDirectedParticleEmitter"
  48004. * @returns a string containing the class name
  48005. */
  48006. getClassName(): string;
  48007. /**
  48008. * Serializes the particle system to a JSON object.
  48009. * @returns the JSON object
  48010. */
  48011. serialize(): any;
  48012. /**
  48013. * Parse properties from a JSON object
  48014. * @param serializationObject defines the JSON object
  48015. */
  48016. parse(serializationObject: any): void;
  48017. }
  48018. }
  48019. declare module BABYLON {
  48020. /**
  48021. * Particle emitter emitting particles from the inside of a hemisphere.
  48022. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48023. */
  48024. class HemisphericParticleEmitter implements IParticleEmitterType {
  48025. /**
  48026. * The radius of the emission hemisphere.
  48027. */
  48028. radius: number;
  48029. /**
  48030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48031. */
  48032. radiusRange: number;
  48033. /**
  48034. * How much to randomize the particle direction [0-1].
  48035. */
  48036. directionRandomizer: number;
  48037. /**
  48038. * Creates a new instance HemisphericParticleEmitter
  48039. * @param radius the radius of the emission hemisphere (1 by default)
  48040. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48042. */
  48043. constructor(
  48044. /**
  48045. * The radius of the emission hemisphere.
  48046. */
  48047. radius?: number,
  48048. /**
  48049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48050. */
  48051. radiusRange?: number,
  48052. /**
  48053. * How much to randomize the particle direction [0-1].
  48054. */
  48055. directionRandomizer?: number);
  48056. /**
  48057. * Called by the particle System when the direction is computed for the created particle.
  48058. * @param worldMatrix is the world matrix of the particle system
  48059. * @param directionToUpdate is the direction vector to update with the result
  48060. * @param particle is the particle we are computed the direction for
  48061. */
  48062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48063. /**
  48064. * Called by the particle System when the position is computed for the created particle.
  48065. * @param worldMatrix is the world matrix of the particle system
  48066. * @param positionToUpdate is the position vector to update with the result
  48067. * @param particle is the particle we are computed the position for
  48068. */
  48069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48070. /**
  48071. * Clones the current emitter and returns a copy of it
  48072. * @returns the new emitter
  48073. */
  48074. clone(): HemisphericParticleEmitter;
  48075. /**
  48076. * Called by the GPUParticleSystem to setup the update shader
  48077. * @param effect defines the update shader
  48078. */
  48079. applyToShader(effect: Effect): void;
  48080. /**
  48081. * Returns a string to use to update the GPU particles update shader
  48082. * @returns a string containng the defines string
  48083. */
  48084. getEffectDefines(): string;
  48085. /**
  48086. * Returns the string "HemisphericParticleEmitter"
  48087. * @returns a string containing the class name
  48088. */
  48089. getClassName(): string;
  48090. /**
  48091. * Serializes the particle system to a JSON object.
  48092. * @returns the JSON object
  48093. */
  48094. serialize(): any;
  48095. /**
  48096. * Parse properties from a JSON object
  48097. * @param serializationObject defines the JSON object
  48098. */
  48099. parse(serializationObject: any): void;
  48100. }
  48101. }
  48102. declare module BABYLON {
  48103. /**
  48104. * Particle emitter represents a volume emitting particles.
  48105. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48106. */
  48107. interface IParticleEmitterType {
  48108. /**
  48109. * Called by the particle System when the direction is computed for the created particle.
  48110. * @param worldMatrix is the world matrix of the particle system
  48111. * @param directionToUpdate is the direction vector to update with the result
  48112. * @param particle is the particle we are computed the direction for
  48113. */
  48114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48115. /**
  48116. * Called by the particle System when the position is computed for the created particle.
  48117. * @param worldMatrix is the world matrix of the particle system
  48118. * @param positionToUpdate is the position vector to update with the result
  48119. * @param particle is the particle we are computed the position for
  48120. */
  48121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48122. /**
  48123. * Clones the current emitter and returns a copy of it
  48124. * @returns the new emitter
  48125. */
  48126. clone(): IParticleEmitterType;
  48127. /**
  48128. * Called by the GPUParticleSystem to setup the update shader
  48129. * @param effect defines the update shader
  48130. */
  48131. applyToShader(effect: Effect): void;
  48132. /**
  48133. * Returns a string to use to update the GPU particles update shader
  48134. * @returns the effect defines string
  48135. */
  48136. getEffectDefines(): string;
  48137. /**
  48138. * Returns a string representing the class name
  48139. * @returns a string containing the class name
  48140. */
  48141. getClassName(): string;
  48142. /**
  48143. * Serializes the particle system to a JSON object.
  48144. * @returns the JSON object
  48145. */
  48146. serialize(): any;
  48147. /**
  48148. * Parse properties from a JSON object
  48149. * @param serializationObject defines the JSON object
  48150. */
  48151. parse(serializationObject: any): void;
  48152. }
  48153. }
  48154. declare module BABYLON {
  48155. /**
  48156. * Particle emitter emitting particles from a point.
  48157. * It emits the particles randomly between 2 given directions.
  48158. */
  48159. class PointParticleEmitter implements IParticleEmitterType {
  48160. /**
  48161. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48162. */
  48163. direction1: Vector3;
  48164. /**
  48165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48166. */
  48167. direction2: Vector3;
  48168. /**
  48169. * Creates a new instance PointParticleEmitter
  48170. */
  48171. constructor();
  48172. /**
  48173. * Called by the particle System when the direction is computed for the created particle.
  48174. * @param worldMatrix is the world matrix of the particle system
  48175. * @param directionToUpdate is the direction vector to update with the result
  48176. * @param particle is the particle we are computed the direction for
  48177. */
  48178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48179. /**
  48180. * Called by the particle System when the position is computed for the created particle.
  48181. * @param worldMatrix is the world matrix of the particle system
  48182. * @param positionToUpdate is the position vector to update with the result
  48183. * @param particle is the particle we are computed the position for
  48184. */
  48185. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48186. /**
  48187. * Clones the current emitter and returns a copy of it
  48188. * @returns the new emitter
  48189. */
  48190. clone(): PointParticleEmitter;
  48191. /**
  48192. * Called by the GPUParticleSystem to setup the update shader
  48193. * @param effect defines the update shader
  48194. */
  48195. applyToShader(effect: Effect): void;
  48196. /**
  48197. * Returns a string to use to update the GPU particles update shader
  48198. * @returns a string containng the defines string
  48199. */
  48200. getEffectDefines(): string;
  48201. /**
  48202. * Returns the string "PointParticleEmitter"
  48203. * @returns a string containing the class name
  48204. */
  48205. getClassName(): string;
  48206. /**
  48207. * Serializes the particle system to a JSON object.
  48208. * @returns the JSON object
  48209. */
  48210. serialize(): any;
  48211. /**
  48212. * Parse properties from a JSON object
  48213. * @param serializationObject defines the JSON object
  48214. */
  48215. parse(serializationObject: any): void;
  48216. }
  48217. }
  48218. declare module BABYLON {
  48219. /**
  48220. * Particle emitter emitting particles from the inside of a sphere.
  48221. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48222. */
  48223. class SphereParticleEmitter implements IParticleEmitterType {
  48224. /**
  48225. * The radius of the emission sphere.
  48226. */
  48227. radius: number;
  48228. /**
  48229. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48230. */
  48231. radiusRange: number;
  48232. /**
  48233. * How much to randomize the particle direction [0-1].
  48234. */
  48235. directionRandomizer: number;
  48236. /**
  48237. * Creates a new instance SphereParticleEmitter
  48238. * @param radius the radius of the emission sphere (1 by default)
  48239. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48240. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48241. */
  48242. constructor(
  48243. /**
  48244. * The radius of the emission sphere.
  48245. */
  48246. radius?: number,
  48247. /**
  48248. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48249. */
  48250. radiusRange?: number,
  48251. /**
  48252. * How much to randomize the particle direction [0-1].
  48253. */
  48254. directionRandomizer?: number);
  48255. /**
  48256. * Called by the particle System when the direction is computed for the created particle.
  48257. * @param worldMatrix is the world matrix of the particle system
  48258. * @param directionToUpdate is the direction vector to update with the result
  48259. * @param particle is the particle we are computed the direction for
  48260. */
  48261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48262. /**
  48263. * Called by the particle System when the position is computed for the created particle.
  48264. * @param worldMatrix is the world matrix of the particle system
  48265. * @param positionToUpdate is the position vector to update with the result
  48266. * @param particle is the particle we are computed the position for
  48267. */
  48268. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48269. /**
  48270. * Clones the current emitter and returns a copy of it
  48271. * @returns the new emitter
  48272. */
  48273. clone(): SphereParticleEmitter;
  48274. /**
  48275. * Called by the GPUParticleSystem to setup the update shader
  48276. * @param effect defines the update shader
  48277. */
  48278. applyToShader(effect: Effect): void;
  48279. /**
  48280. * Returns a string to use to update the GPU particles update shader
  48281. * @returns a string containng the defines string
  48282. */
  48283. getEffectDefines(): string;
  48284. /**
  48285. * Returns the string "SphereParticleEmitter"
  48286. * @returns a string containing the class name
  48287. */
  48288. getClassName(): string;
  48289. /**
  48290. * Serializes the particle system to a JSON object.
  48291. * @returns the JSON object
  48292. */
  48293. serialize(): any;
  48294. /**
  48295. * Parse properties from a JSON object
  48296. * @param serializationObject defines the JSON object
  48297. */
  48298. parse(serializationObject: any): void;
  48299. }
  48300. /**
  48301. * Particle emitter emitting particles from the inside of a sphere.
  48302. * It emits the particles randomly between two vectors.
  48303. */
  48304. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48305. /**
  48306. * The min limit of the emission direction.
  48307. */
  48308. direction1: Vector3;
  48309. /**
  48310. * The max limit of the emission direction.
  48311. */
  48312. direction2: Vector3;
  48313. /**
  48314. * Creates a new instance SphereDirectedParticleEmitter
  48315. * @param radius the radius of the emission sphere (1 by default)
  48316. * @param direction1 the min limit of the emission direction (up vector by default)
  48317. * @param direction2 the max limit of the emission direction (up vector by default)
  48318. */
  48319. constructor(radius?: number,
  48320. /**
  48321. * The min limit of the emission direction.
  48322. */
  48323. direction1?: Vector3,
  48324. /**
  48325. * The max limit of the emission direction.
  48326. */
  48327. direction2?: Vector3);
  48328. /**
  48329. * Called by the particle System when the direction is computed for the created particle.
  48330. * @param worldMatrix is the world matrix of the particle system
  48331. * @param directionToUpdate is the direction vector to update with the result
  48332. * @param particle is the particle we are computed the direction for
  48333. */
  48334. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48335. /**
  48336. * Clones the current emitter and returns a copy of it
  48337. * @returns the new emitter
  48338. */
  48339. clone(): SphereDirectedParticleEmitter;
  48340. /**
  48341. * Called by the GPUParticleSystem to setup the update shader
  48342. * @param effect defines the update shader
  48343. */
  48344. applyToShader(effect: Effect): void;
  48345. /**
  48346. * Returns a string to use to update the GPU particles update shader
  48347. * @returns a string containng the defines string
  48348. */
  48349. getEffectDefines(): string;
  48350. /**
  48351. * Returns the string "SphereDirectedParticleEmitter"
  48352. * @returns a string containing the class name
  48353. */
  48354. getClassName(): string;
  48355. /**
  48356. * Serializes the particle system to a JSON object.
  48357. * @returns the JSON object
  48358. */
  48359. serialize(): any;
  48360. /**
  48361. * Parse properties from a JSON object
  48362. * @param serializationObject defines the JSON object
  48363. */
  48364. parse(serializationObject: any): void;
  48365. }
  48366. }
  48367. declare module BABYLON {
  48368. /**
  48369. * This represents a set of one or more post processes in Babylon.
  48370. * A post process can be used to apply a shader to a texture after it is rendered.
  48371. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48372. */
  48373. class PostProcessRenderEffect {
  48374. private _postProcesses;
  48375. private _getPostProcesses;
  48376. private _singleInstance;
  48377. private _cameras;
  48378. private _indicesForCamera;
  48379. /**
  48380. * Name of the effect
  48381. * @hidden
  48382. */
  48383. _name: string;
  48384. /**
  48385. * Instantiates a post process render effect.
  48386. * A post process can be used to apply a shader to a texture after it is rendered.
  48387. * @param engine The engine the effect is tied to
  48388. * @param name The name of the effect
  48389. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48390. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48391. */
  48392. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48393. /**
  48394. * Checks if all the post processes in the effect are supported.
  48395. */
  48396. readonly isSupported: boolean;
  48397. /**
  48398. * Updates the current state of the effect
  48399. * @hidden
  48400. */
  48401. _update(): void;
  48402. /**
  48403. * Attaches the effect on cameras
  48404. * @param cameras The camera to attach to.
  48405. * @hidden
  48406. */
  48407. _attachCameras(cameras: Camera): void;
  48408. /**
  48409. * Attaches the effect on cameras
  48410. * @param cameras The camera to attach to.
  48411. * @hidden
  48412. */
  48413. _attachCameras(cameras: Camera[]): void;
  48414. /**
  48415. * Detatches the effect on cameras
  48416. * @param cameras The camera to detatch from.
  48417. * @hidden
  48418. */
  48419. _detachCameras(cameras: Camera): void;
  48420. /**
  48421. * Detatches the effect on cameras
  48422. * @param cameras The camera to detatch from.
  48423. * @hidden
  48424. */
  48425. _detachCameras(cameras: Camera[]): void;
  48426. /**
  48427. * Enables the effect on given cameras
  48428. * @param cameras The camera to enable.
  48429. * @hidden
  48430. */
  48431. _enable(cameras: Camera): void;
  48432. /**
  48433. * Enables the effect on given cameras
  48434. * @param cameras The camera to enable.
  48435. * @hidden
  48436. */
  48437. _enable(cameras: Nullable<Camera[]>): void;
  48438. /**
  48439. * Disables the effect on the given cameras
  48440. * @param cameras The camera to disable.
  48441. * @hidden
  48442. */
  48443. _disable(cameras: Camera): void;
  48444. /**
  48445. * Disables the effect on the given cameras
  48446. * @param cameras The camera to disable.
  48447. * @hidden
  48448. */
  48449. _disable(cameras: Nullable<Camera[]>): void;
  48450. /**
  48451. * Gets a list of the post processes contained in the effect.
  48452. * @param camera The camera to get the post processes on.
  48453. * @returns The list of the post processes in the effect.
  48454. */
  48455. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48456. }
  48457. }
  48458. declare module BABYLON {
  48459. /**
  48460. * PostProcessRenderPipeline
  48461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48462. */
  48463. class PostProcessRenderPipeline {
  48464. private engine;
  48465. private _renderEffects;
  48466. private _renderEffectsForIsolatedPass;
  48467. /**
  48468. * @hidden
  48469. */
  48470. protected _cameras: Camera[];
  48471. /** @hidden */
  48472. _name: string;
  48473. /**
  48474. * Initializes a PostProcessRenderPipeline
  48475. * @param engine engine to add the pipeline to
  48476. * @param name name of the pipeline
  48477. */
  48478. constructor(engine: Engine, name: string);
  48479. /**
  48480. * "PostProcessRenderPipeline"
  48481. * @returns "PostProcessRenderPipeline"
  48482. */
  48483. getClassName(): string;
  48484. /**
  48485. * If all the render effects in the pipeline are support
  48486. */
  48487. readonly isSupported: boolean;
  48488. /**
  48489. * Adds an effect to the pipeline
  48490. * @param renderEffect the effect to add
  48491. */
  48492. addEffect(renderEffect: PostProcessRenderEffect): void;
  48493. /** @hidden */
  48494. _rebuild(): void;
  48495. /** @hidden */
  48496. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48497. /** @hidden */
  48498. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48499. /** @hidden */
  48500. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48501. /** @hidden */
  48502. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48503. /** @hidden */
  48504. _attachCameras(cameras: Camera, unique: boolean): void;
  48505. /** @hidden */
  48506. _attachCameras(cameras: Camera[], unique: boolean): void;
  48507. /** @hidden */
  48508. _detachCameras(cameras: Camera): void;
  48509. /** @hidden */
  48510. _detachCameras(cameras: Nullable<Camera[]>): void;
  48511. /** @hidden */
  48512. _update(): void;
  48513. /** @hidden */
  48514. _reset(): void;
  48515. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48516. /**
  48517. * Disposes of the pipeline
  48518. */
  48519. dispose(): void;
  48520. }
  48521. }
  48522. declare module BABYLON {
  48523. /**
  48524. * PostProcessRenderPipelineManager class
  48525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48526. */
  48527. class PostProcessRenderPipelineManager {
  48528. private _renderPipelines;
  48529. /**
  48530. * Initializes a PostProcessRenderPipelineManager
  48531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48532. */
  48533. constructor();
  48534. /**
  48535. * Adds a pipeline to the manager
  48536. * @param renderPipeline The pipeline to add
  48537. */
  48538. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48539. /**
  48540. * Attaches a camera to the pipeline
  48541. * @param renderPipelineName The name of the pipeline to attach to
  48542. * @param cameras the camera to attach
  48543. * @param unique if the camera can be attached multiple times to the pipeline
  48544. */
  48545. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48546. /**
  48547. * Detaches a camera from the pipeline
  48548. * @param renderPipelineName The name of the pipeline to detach from
  48549. * @param cameras the camera to detach
  48550. */
  48551. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48552. /**
  48553. * Enables an effect by name on a pipeline
  48554. * @param renderPipelineName the name of the pipeline to enable the effect in
  48555. * @param renderEffectName the name of the effect to enable
  48556. * @param cameras the cameras that the effect should be enabled on
  48557. */
  48558. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48559. /**
  48560. * Disables an effect by name on a pipeline
  48561. * @param renderPipelineName the name of the pipeline to disable the effect in
  48562. * @param renderEffectName the name of the effect to disable
  48563. * @param cameras the cameras that the effect should be disabled on
  48564. */
  48565. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48566. /**
  48567. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48568. */
  48569. update(): void;
  48570. /** @hidden */
  48571. _rebuild(): void;
  48572. /**
  48573. * Disposes of the manager and pipelines
  48574. */
  48575. dispose(): void;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. interface Scene {
  48580. /** @hidden (Backing field) */
  48581. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48582. /**
  48583. * Gets the postprocess render pipeline manager
  48584. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48585. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48586. */
  48587. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48588. }
  48589. /**
  48590. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48591. */
  48592. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48593. /**
  48594. * The component name helpfull to identify the component in the list of scene components.
  48595. */
  48596. readonly name: string;
  48597. /**
  48598. * The scene the component belongs to.
  48599. */
  48600. scene: Scene;
  48601. /**
  48602. * Creates a new instance of the component for the given scene
  48603. * @param scene Defines the scene to register the component in
  48604. */
  48605. constructor(scene: Scene);
  48606. /**
  48607. * Registers the component in a given scene
  48608. */
  48609. register(): void;
  48610. /**
  48611. * Rebuilds the elements related to this component in case of
  48612. * context lost for instance.
  48613. */
  48614. rebuild(): void;
  48615. /**
  48616. * Disposes the component and the associated ressources
  48617. */
  48618. dispose(): void;
  48619. private _gatherRenderTargets;
  48620. }
  48621. }
  48622. declare module BABYLON {
  48623. /**
  48624. * Helper class dealing with the extraction of spherical polynomial dataArray
  48625. * from a cube map.
  48626. */
  48627. class CubeMapToSphericalPolynomialTools {
  48628. private static FileFaces;
  48629. /**
  48630. * Converts a texture to the according Spherical Polynomial data.
  48631. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48632. *
  48633. * @param texture The texture to extract the information from.
  48634. * @return The Spherical Polynomial data.
  48635. */
  48636. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48637. /**
  48638. * Converts a cubemap to the according Spherical Polynomial data.
  48639. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48640. *
  48641. * @param cubeInfo The Cube map to extract the information from.
  48642. * @return The Spherical Polynomial data.
  48643. */
  48644. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48645. }
  48646. }
  48647. declare module BABYLON {
  48648. /**
  48649. * Header information of HDR texture files.
  48650. */
  48651. interface HDRInfo {
  48652. /**
  48653. * The height of the texture in pixels.
  48654. */
  48655. height: number;
  48656. /**
  48657. * The width of the texture in pixels.
  48658. */
  48659. width: number;
  48660. /**
  48661. * The index of the beginning of the data in the binary file.
  48662. */
  48663. dataPosition: number;
  48664. }
  48665. /**
  48666. * This groups tools to convert HDR texture to native colors array.
  48667. */
  48668. class HDRTools {
  48669. private static Ldexp;
  48670. private static Rgbe2float;
  48671. private static readStringLine;
  48672. /**
  48673. * Reads header information from an RGBE texture stored in a native array.
  48674. * More information on this format are available here:
  48675. * https://en.wikipedia.org/wiki/RGBE_image_format
  48676. *
  48677. * @param uint8array The binary file stored in native array.
  48678. * @return The header information.
  48679. */
  48680. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48681. /**
  48682. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48683. * This RGBE texture needs to store the information as a panorama.
  48684. *
  48685. * More information on this format are available here:
  48686. * https://en.wikipedia.org/wiki/RGBE_image_format
  48687. *
  48688. * @param buffer The binary file stored in an array buffer.
  48689. * @param size The expected size of the extracted cubemap.
  48690. * @return The Cube Map information.
  48691. */
  48692. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48693. /**
  48694. * Returns the pixels data extracted from an RGBE texture.
  48695. * This pixels will be stored left to right up to down in the R G B order in one array.
  48696. *
  48697. * More information on this format are available here:
  48698. * https://en.wikipedia.org/wiki/RGBE_image_format
  48699. *
  48700. * @param uint8array The binary file stored in an array buffer.
  48701. * @param hdrInfo The header information of the file.
  48702. * @return The pixels data in RGB right to left up to down order.
  48703. */
  48704. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48705. private static RGBE_ReadPixels_RLE;
  48706. }
  48707. }
  48708. declare module BABYLON {
  48709. /**
  48710. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48711. */
  48712. interface CubeMapInfo {
  48713. /**
  48714. * The pixel array for the front face.
  48715. * This is stored in format, left to right, up to down format.
  48716. */
  48717. front: Nullable<ArrayBufferView>;
  48718. /**
  48719. * The pixel array for the back face.
  48720. * This is stored in format, left to right, up to down format.
  48721. */
  48722. back: Nullable<ArrayBufferView>;
  48723. /**
  48724. * The pixel array for the left face.
  48725. * This is stored in format, left to right, up to down format.
  48726. */
  48727. left: Nullable<ArrayBufferView>;
  48728. /**
  48729. * The pixel array for the right face.
  48730. * This is stored in format, left to right, up to down format.
  48731. */
  48732. right: Nullable<ArrayBufferView>;
  48733. /**
  48734. * The pixel array for the up face.
  48735. * This is stored in format, left to right, up to down format.
  48736. */
  48737. up: Nullable<ArrayBufferView>;
  48738. /**
  48739. * The pixel array for the down face.
  48740. * This is stored in format, left to right, up to down format.
  48741. */
  48742. down: Nullable<ArrayBufferView>;
  48743. /**
  48744. * The size of the cubemap stored.
  48745. *
  48746. * Each faces will be size * size pixels.
  48747. */
  48748. size: number;
  48749. /**
  48750. * The format of the texture.
  48751. *
  48752. * RGBA, RGB.
  48753. */
  48754. format: number;
  48755. /**
  48756. * The type of the texture data.
  48757. *
  48758. * UNSIGNED_INT, FLOAT.
  48759. */
  48760. type: number;
  48761. /**
  48762. * Specifies whether the texture is in gamma space.
  48763. */
  48764. gammaSpace: boolean;
  48765. }
  48766. /**
  48767. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48768. */
  48769. class PanoramaToCubeMapTools {
  48770. private static FACE_FRONT;
  48771. private static FACE_BACK;
  48772. private static FACE_RIGHT;
  48773. private static FACE_LEFT;
  48774. private static FACE_DOWN;
  48775. private static FACE_UP;
  48776. /**
  48777. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48778. *
  48779. * @param float32Array The source data.
  48780. * @param inputWidth The width of the input panorama.
  48781. * @param inputHeight The height of the input panorama.
  48782. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48783. * @return The cubemap data
  48784. */
  48785. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48786. private static CreateCubemapTexture;
  48787. private static CalcProjectionSpherical;
  48788. }
  48789. }
  48790. declare module BABYLON {
  48791. }
  48792. declare module BABYLON {
  48793. }
  48794. declare module BABYLON {
  48795. }
  48796. declare module BABYLON {
  48797. }
  48798. declare module BABYLON {
  48799. /**
  48800. * 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.
  48801. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48802. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48803. */
  48804. class CustomProceduralTexture extends ProceduralTexture {
  48805. private _animate;
  48806. private _time;
  48807. private _config;
  48808. private _texturePath;
  48809. /**
  48810. * Instantiates a new Custom Procedural Texture.
  48811. * 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.
  48812. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48813. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48814. * @param name Define the name of the texture
  48815. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48816. * @param size Define the size of the texture to create
  48817. * @param scene Define the scene the texture belongs to
  48818. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48819. * @param generateMipMaps Define if the texture should creates mip maps or not
  48820. */
  48821. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48822. private _loadJson;
  48823. /**
  48824. * Is the texture ready to be used ? (rendered at least once)
  48825. * @returns true if ready, otherwise, false.
  48826. */
  48827. isReady(): boolean;
  48828. /**
  48829. * Render the texture to its associated render target.
  48830. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48831. */
  48832. render(useCameraPostProcess?: boolean): void;
  48833. /**
  48834. * Update the list of dependant textures samplers in the shader.
  48835. */
  48836. updateTextures(): void;
  48837. /**
  48838. * Update the uniform values of the procedural texture in the shader.
  48839. */
  48840. updateShaderUniforms(): void;
  48841. /**
  48842. * Define if the texture animates or not.
  48843. */
  48844. animate: boolean;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. /**
  48849. * Class used to generate noise procedural textures
  48850. */
  48851. class NoiseProceduralTexture extends ProceduralTexture {
  48852. private _time;
  48853. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48854. brightness: number;
  48855. /** Defines the number of octaves to process */
  48856. octaves: number;
  48857. /** Defines the level of persistence (0.8 by default) */
  48858. persistence: number;
  48859. /** Gets or sets animation speed factor (default is 1) */
  48860. animationSpeedFactor: number;
  48861. /**
  48862. * Creates a new NoiseProceduralTexture
  48863. * @param name defines the name fo the texture
  48864. * @param size defines the size of the texture (default is 256)
  48865. * @param scene defines the hosting scene
  48866. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48867. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48868. */
  48869. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48870. private _updateShaderUniforms;
  48871. protected _getDefines(): string;
  48872. /** Generate the current state of the procedural texture */
  48873. render(useCameraPostProcess?: boolean): void;
  48874. /**
  48875. * Serializes this noise procedural texture
  48876. * @returns a serialized noise procedural texture object
  48877. */
  48878. serialize(): any;
  48879. /**
  48880. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48881. * @param parsedTexture defines parsed texture data
  48882. * @param scene defines the current scene
  48883. * @param rootUrl defines the root URL containing noise procedural texture information
  48884. * @returns a parsed NoiseProceduralTexture
  48885. */
  48886. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48887. }
  48888. }
  48889. declare module BABYLON {
  48890. /**
  48891. * 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.
  48892. * This is the base class of any Procedural texture and contains most of the shareable code.
  48893. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48894. */
  48895. class ProceduralTexture extends Texture {
  48896. isCube: boolean;
  48897. /**
  48898. * Define if the texture is enabled or not (disabled texture will not render)
  48899. */
  48900. isEnabled: boolean;
  48901. /**
  48902. * Define if the texture must be cleared before rendering (default is true)
  48903. */
  48904. autoClear: boolean;
  48905. /**
  48906. * Callback called when the texture is generated
  48907. */
  48908. onGenerated: () => void;
  48909. /**
  48910. * Event raised when the texture is generated
  48911. */
  48912. onGeneratedObservable: Observable<ProceduralTexture>;
  48913. /** @hidden */
  48914. _generateMipMaps: boolean;
  48915. /** @hidden **/
  48916. _effect: Effect;
  48917. /** @hidden */
  48918. _textures: {
  48919. [key: string]: Texture;
  48920. };
  48921. private _size;
  48922. private _currentRefreshId;
  48923. private _refreshRate;
  48924. private _vertexBuffers;
  48925. private _indexBuffer;
  48926. private _uniforms;
  48927. private _samplers;
  48928. private _fragment;
  48929. private _floats;
  48930. private _ints;
  48931. private _floatsArrays;
  48932. private _colors3;
  48933. private _colors4;
  48934. private _vectors2;
  48935. private _vectors3;
  48936. private _matrices;
  48937. private _fallbackTexture;
  48938. private _fallbackTextureUsed;
  48939. private _engine;
  48940. private _cachedDefines;
  48941. private _contentUpdateId;
  48942. private _contentData;
  48943. /**
  48944. * Instantiates a new procedural texture.
  48945. * 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.
  48946. * This is the base class of any Procedural texture and contains most of the shareable code.
  48947. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48948. * @param name Define the name of the texture
  48949. * @param size Define the size of the texture to create
  48950. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48951. * @param scene Define the scene the texture belongs to
  48952. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48953. * @param generateMipMaps Define if the texture should creates mip maps or not
  48954. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48955. */
  48956. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48957. /**
  48958. * The effect that is created when initializing the post process.
  48959. * @returns The created effect corrisponding the the postprocess.
  48960. */
  48961. getEffect(): Effect;
  48962. /**
  48963. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48964. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48965. */
  48966. getContent(): Nullable<ArrayBufferView>;
  48967. private _createIndexBuffer;
  48968. /** @hidden */
  48969. _rebuild(): void;
  48970. /**
  48971. * Resets the texture in order to recreate its associated resources.
  48972. * This can be called in case of context loss
  48973. */
  48974. reset(): void;
  48975. protected _getDefines(): string;
  48976. /**
  48977. * Is the texture ready to be used ? (rendered at least once)
  48978. * @returns true if ready, otherwise, false.
  48979. */
  48980. isReady(): boolean;
  48981. /**
  48982. * Resets the refresh counter of the texture and start bak from scratch.
  48983. * Could be usefull to regenerate the texture if it is setup to render only once.
  48984. */
  48985. resetRefreshCounter(): void;
  48986. /**
  48987. * Set the fragment shader to use in order to render the texture.
  48988. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48989. */
  48990. setFragment(fragment: any): void;
  48991. /**
  48992. * Define the refresh rate of the texture or the rendering frequency.
  48993. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48994. */
  48995. refreshRate: number;
  48996. /** @hidden */
  48997. _shouldRender(): boolean;
  48998. /**
  48999. * Get the size the texture is rendering at.
  49000. * @returns the size (texture is always squared)
  49001. */
  49002. getRenderSize(): number;
  49003. /**
  49004. * Resize the texture to new value.
  49005. * @param size Define the new size the texture should have
  49006. * @param generateMipMaps Define whether the new texture should create mip maps
  49007. */
  49008. resize(size: number, generateMipMaps: boolean): void;
  49009. private _checkUniform;
  49010. /**
  49011. * Set a texture in the shader program used to render.
  49012. * @param name Define the name of the uniform samplers as defined in the shader
  49013. * @param texture Define the texture to bind to this sampler
  49014. * @return the texture itself allowing "fluent" like uniform updates
  49015. */
  49016. setTexture(name: string, texture: Texture): ProceduralTexture;
  49017. /**
  49018. * Set a float in the shader.
  49019. * @param name Define the name of the uniform as defined in the shader
  49020. * @param value Define the value to give to the uniform
  49021. * @return the texture itself allowing "fluent" like uniform updates
  49022. */
  49023. setFloat(name: string, value: number): ProceduralTexture;
  49024. /**
  49025. * Set a int in the shader.
  49026. * @param name Define the name of the uniform as defined in the shader
  49027. * @param value Define the value to give to the uniform
  49028. * @return the texture itself allowing "fluent" like uniform updates
  49029. */
  49030. setInt(name: string, value: number): ProceduralTexture;
  49031. /**
  49032. * Set an array of floats in the shader.
  49033. * @param name Define the name of the uniform as defined in the shader
  49034. * @param value Define the value to give to the uniform
  49035. * @return the texture itself allowing "fluent" like uniform updates
  49036. */
  49037. setFloats(name: string, value: number[]): ProceduralTexture;
  49038. /**
  49039. * Set a vec3 in the shader from a Color3.
  49040. * @param name Define the name of the uniform as defined in the shader
  49041. * @param value Define the value to give to the uniform
  49042. * @return the texture itself allowing "fluent" like uniform updates
  49043. */
  49044. setColor3(name: string, value: Color3): ProceduralTexture;
  49045. /**
  49046. * Set a vec4 in the shader from a Color4.
  49047. * @param name Define the name of the uniform as defined in the shader
  49048. * @param value Define the value to give to the uniform
  49049. * @return the texture itself allowing "fluent" like uniform updates
  49050. */
  49051. setColor4(name: string, value: Color4): ProceduralTexture;
  49052. /**
  49053. * Set a vec2 in the shader from a Vector2.
  49054. * @param name Define the name of the uniform as defined in the shader
  49055. * @param value Define the value to give to the uniform
  49056. * @return the texture itself allowing "fluent" like uniform updates
  49057. */
  49058. setVector2(name: string, value: Vector2): ProceduralTexture;
  49059. /**
  49060. * Set a vec3 in the shader from a Vector3.
  49061. * @param name Define the name of the uniform as defined in the shader
  49062. * @param value Define the value to give to the uniform
  49063. * @return the texture itself allowing "fluent" like uniform updates
  49064. */
  49065. setVector3(name: string, value: Vector3): ProceduralTexture;
  49066. /**
  49067. * Set a mat4 in the shader from a MAtrix.
  49068. * @param name Define the name of the uniform as defined in the shader
  49069. * @param value Define the value to give to the uniform
  49070. * @return the texture itself allowing "fluent" like uniform updates
  49071. */
  49072. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49073. /**
  49074. * Render the texture to its associated render target.
  49075. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49076. */
  49077. render(useCameraPostProcess?: boolean): void;
  49078. /**
  49079. * Clone the texture.
  49080. * @returns the cloned texture
  49081. */
  49082. clone(): ProceduralTexture;
  49083. /**
  49084. * Dispose the texture and release its asoociated resources.
  49085. */
  49086. dispose(): void;
  49087. }
  49088. }
  49089. declare module BABYLON {
  49090. interface AbstractScene {
  49091. /**
  49092. * The list of procedural textures added to the scene
  49093. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49094. */
  49095. proceduralTextures: Array<ProceduralTexture>;
  49096. }
  49097. /**
  49098. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49099. * in a given scene.
  49100. */
  49101. class ProceduralTextureSceneComponent implements ISceneComponent {
  49102. /**
  49103. * The component name helpfull to identify the component in the list of scene components.
  49104. */
  49105. readonly name: string;
  49106. /**
  49107. * The scene the component belongs to.
  49108. */
  49109. scene: Scene;
  49110. /**
  49111. * Creates a new instance of the component for the given scene
  49112. * @param scene Defines the scene to register the component in
  49113. */
  49114. constructor(scene: Scene);
  49115. /**
  49116. * Registers the component in a given scene
  49117. */
  49118. register(): void;
  49119. /**
  49120. * Rebuilds the elements related to this component in case of
  49121. * context lost for instance.
  49122. */
  49123. rebuild(): void;
  49124. /**
  49125. * Disposes the component and the associated ressources.
  49126. */
  49127. dispose(): void;
  49128. private _beforeClear;
  49129. }
  49130. }
  49131. declare module BABYLON {
  49132. /**
  49133. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49134. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49135. */
  49136. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49137. private _scene;
  49138. private _camerasToBeAttached;
  49139. /**
  49140. * ID of the sharpen post process,
  49141. */
  49142. private readonly SharpenPostProcessId;
  49143. /**
  49144. * @ignore
  49145. * ID of the image processing post process;
  49146. */
  49147. readonly ImageProcessingPostProcessId: string;
  49148. /**
  49149. * @ignore
  49150. * ID of the Fast Approximate Anti-Aliasing post process;
  49151. */
  49152. readonly FxaaPostProcessId: string;
  49153. /**
  49154. * ID of the chromatic aberration post process,
  49155. */
  49156. private readonly ChromaticAberrationPostProcessId;
  49157. /**
  49158. * ID of the grain post process
  49159. */
  49160. private readonly GrainPostProcessId;
  49161. /**
  49162. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49163. */
  49164. sharpen: SharpenPostProcess;
  49165. private _sharpenEffect;
  49166. private bloom;
  49167. /**
  49168. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49169. */
  49170. depthOfField: DepthOfFieldEffect;
  49171. /**
  49172. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49173. */
  49174. fxaa: FxaaPostProcess;
  49175. /**
  49176. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49177. */
  49178. imageProcessing: ImageProcessingPostProcess;
  49179. /**
  49180. * Chromatic aberration post process which will shift rgb colors in the image
  49181. */
  49182. chromaticAberration: ChromaticAberrationPostProcess;
  49183. private _chromaticAberrationEffect;
  49184. /**
  49185. * Grain post process which add noise to the image
  49186. */
  49187. grain: GrainPostProcess;
  49188. private _grainEffect;
  49189. /**
  49190. * Glow post process which adds a glow to emmisive areas of the image
  49191. */
  49192. private _glowLayer;
  49193. /**
  49194. * Animations which can be used to tweak settings over a period of time
  49195. */
  49196. animations: Animation[];
  49197. private _imageProcessingConfigurationObserver;
  49198. private _sharpenEnabled;
  49199. private _bloomEnabled;
  49200. private _depthOfFieldEnabled;
  49201. private _depthOfFieldBlurLevel;
  49202. private _fxaaEnabled;
  49203. private _imageProcessingEnabled;
  49204. private _defaultPipelineTextureType;
  49205. private _bloomScale;
  49206. private _chromaticAberrationEnabled;
  49207. private _grainEnabled;
  49208. private _buildAllowed;
  49209. /**
  49210. * Enable or disable the sharpen process from the pipeline
  49211. */
  49212. sharpenEnabled: boolean;
  49213. private _resizeObserver;
  49214. private _hardwareScaleLevel;
  49215. private _bloomKernel;
  49216. /**
  49217. * Specifies the size of the bloom blur kernel, relative to the final output size
  49218. */
  49219. bloomKernel: number;
  49220. /**
  49221. * Specifies the weight of the bloom in the final rendering
  49222. */
  49223. private _bloomWeight;
  49224. /**
  49225. * Specifies the luma threshold for the area that will be blurred by the bloom
  49226. */
  49227. private _bloomThreshold;
  49228. private _hdr;
  49229. /**
  49230. * The strength of the bloom.
  49231. */
  49232. bloomWeight: number;
  49233. /**
  49234. * The strength of the bloom.
  49235. */
  49236. bloomThreshold: number;
  49237. /**
  49238. * The scale of the bloom, lower value will provide better performance.
  49239. */
  49240. bloomScale: number;
  49241. /**
  49242. * Enable or disable the bloom from the pipeline
  49243. */
  49244. bloomEnabled: boolean;
  49245. private _rebuildBloom;
  49246. /**
  49247. * If the depth of field is enabled.
  49248. */
  49249. depthOfFieldEnabled: boolean;
  49250. /**
  49251. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49252. */
  49253. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49254. /**
  49255. * If the anti aliasing is enabled.
  49256. */
  49257. fxaaEnabled: boolean;
  49258. private _samples;
  49259. /**
  49260. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49261. */
  49262. samples: number;
  49263. /**
  49264. * If image processing is enabled.
  49265. */
  49266. imageProcessingEnabled: boolean;
  49267. /**
  49268. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49269. */
  49270. glowLayerEnabled: boolean;
  49271. /**
  49272. * Enable or disable the chromaticAberration process from the pipeline
  49273. */
  49274. chromaticAberrationEnabled: boolean;
  49275. /**
  49276. * Enable or disable the grain process from the pipeline
  49277. */
  49278. grainEnabled: boolean;
  49279. /**
  49280. * @constructor
  49281. * @param name - The rendering pipeline name (default: "")
  49282. * @param hdr - If high dynamic range textures should be used (default: true)
  49283. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49284. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49285. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49286. */
  49287. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49288. /**
  49289. * Force the compilation of the entire pipeline.
  49290. */
  49291. prepare(): void;
  49292. private _hasCleared;
  49293. private _prevPostProcess;
  49294. private _prevPrevPostProcess;
  49295. private _setAutoClearAndTextureSharing;
  49296. private _depthOfFieldSceneObserver;
  49297. private _buildPipeline;
  49298. private _disposePostProcesses;
  49299. /**
  49300. * Adds a camera to the pipeline
  49301. * @param camera the camera to be added
  49302. */
  49303. addCamera(camera: Camera): void;
  49304. /**
  49305. * Removes a camera from the pipeline
  49306. * @param camera the camera to remove
  49307. */
  49308. removeCamera(camera: Camera): void;
  49309. /**
  49310. * Dispose of the pipeline and stop all post processes
  49311. */
  49312. dispose(): void;
  49313. /**
  49314. * Serialize the rendering pipeline (Used when exporting)
  49315. * @returns the serialized object
  49316. */
  49317. serialize(): any;
  49318. /**
  49319. * Parse the serialized pipeline
  49320. * @param source Source pipeline.
  49321. * @param scene The scene to load the pipeline to.
  49322. * @param rootUrl The URL of the serialized pipeline.
  49323. * @returns An instantiated pipeline from the serialized object.
  49324. */
  49325. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49326. }
  49327. }
  49328. declare module BABYLON {
  49329. /**
  49330. * BABYLON.JS Chromatic Aberration GLSL Shader
  49331. * Author: Olivier Guyot
  49332. * Separates very slightly R, G and B colors on the edges of the screen
  49333. * Inspired by Francois Tarlier & Martins Upitis
  49334. */
  49335. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49336. /**
  49337. * @ignore
  49338. * The chromatic aberration PostProcess id in the pipeline
  49339. */
  49340. LensChromaticAberrationEffect: string;
  49341. /**
  49342. * @ignore
  49343. * The highlights enhancing PostProcess id in the pipeline
  49344. */
  49345. HighlightsEnhancingEffect: string;
  49346. /**
  49347. * @ignore
  49348. * The depth-of-field PostProcess id in the pipeline
  49349. */
  49350. LensDepthOfFieldEffect: string;
  49351. private _scene;
  49352. private _depthTexture;
  49353. private _grainTexture;
  49354. private _chromaticAberrationPostProcess;
  49355. private _highlightsPostProcess;
  49356. private _depthOfFieldPostProcess;
  49357. private _edgeBlur;
  49358. private _grainAmount;
  49359. private _chromaticAberration;
  49360. private _distortion;
  49361. private _highlightsGain;
  49362. private _highlightsThreshold;
  49363. private _dofDistance;
  49364. private _dofAperture;
  49365. private _dofDarken;
  49366. private _dofPentagon;
  49367. private _blurNoise;
  49368. /**
  49369. * @constructor
  49370. *
  49371. * Effect parameters are as follow:
  49372. * {
  49373. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49374. * edge_blur: number; // from 0 to x (1 for realism)
  49375. * distortion: number; // from 0 to x (1 for realism)
  49376. * grain_amount: number; // from 0 to 1
  49377. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49378. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49379. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49380. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49381. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49382. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49383. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49384. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49385. * }
  49386. * Note: if an effect parameter is unset, effect is disabled
  49387. *
  49388. * @param name The rendering pipeline name
  49389. * @param parameters - An object containing all parameters (see above)
  49390. * @param scene The scene linked to this pipeline
  49391. * @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)
  49392. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49393. */
  49394. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49395. /**
  49396. * Sets the amount of blur at the edges
  49397. * @param amount blur amount
  49398. */
  49399. setEdgeBlur(amount: number): void;
  49400. /**
  49401. * Sets edge blur to 0
  49402. */
  49403. disableEdgeBlur(): void;
  49404. /**
  49405. * Sets the amout of grain
  49406. * @param amount Amount of grain
  49407. */
  49408. setGrainAmount(amount: number): void;
  49409. /**
  49410. * Set grain amount to 0
  49411. */
  49412. disableGrain(): void;
  49413. /**
  49414. * Sets the chromatic aberration amount
  49415. * @param amount amount of chromatic aberration
  49416. */
  49417. setChromaticAberration(amount: number): void;
  49418. /**
  49419. * Sets chromatic aberration amount to 0
  49420. */
  49421. disableChromaticAberration(): void;
  49422. /**
  49423. * Sets the EdgeDistortion amount
  49424. * @param amount amount of EdgeDistortion
  49425. */
  49426. setEdgeDistortion(amount: number): void;
  49427. /**
  49428. * Sets edge distortion to 0
  49429. */
  49430. disableEdgeDistortion(): void;
  49431. /**
  49432. * Sets the FocusDistance amount
  49433. * @param amount amount of FocusDistance
  49434. */
  49435. setFocusDistance(amount: number): void;
  49436. /**
  49437. * Disables depth of field
  49438. */
  49439. disableDepthOfField(): void;
  49440. /**
  49441. * Sets the Aperture amount
  49442. * @param amount amount of Aperture
  49443. */
  49444. setAperture(amount: number): void;
  49445. /**
  49446. * Sets the DarkenOutOfFocus amount
  49447. * @param amount amount of DarkenOutOfFocus
  49448. */
  49449. setDarkenOutOfFocus(amount: number): void;
  49450. /**
  49451. * Creates a pentagon bokeh effect
  49452. */
  49453. enablePentagonBokeh(): void;
  49454. /**
  49455. * Disables the pentagon bokeh effect
  49456. */
  49457. disablePentagonBokeh(): void;
  49458. /**
  49459. * Enables noise blur
  49460. */
  49461. enableNoiseBlur(): void;
  49462. /**
  49463. * Disables noise blur
  49464. */
  49465. disableNoiseBlur(): void;
  49466. /**
  49467. * Sets the HighlightsGain amount
  49468. * @param amount amount of HighlightsGain
  49469. */
  49470. setHighlightsGain(amount: number): void;
  49471. /**
  49472. * Sets the HighlightsThreshold amount
  49473. * @param amount amount of HighlightsThreshold
  49474. */
  49475. setHighlightsThreshold(amount: number): void;
  49476. /**
  49477. * Disables highlights
  49478. */
  49479. disableHighlights(): void;
  49480. /**
  49481. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49482. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49483. */
  49484. dispose(disableDepthRender?: boolean): void;
  49485. private _createChromaticAberrationPostProcess;
  49486. private _createHighlightsPostProcess;
  49487. private _createDepthOfFieldPostProcess;
  49488. private _createGrainTexture;
  49489. }
  49490. }
  49491. declare module BABYLON {
  49492. /**
  49493. * Render pipeline to produce ssao effect
  49494. */
  49495. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49496. /**
  49497. * @ignore
  49498. * The PassPostProcess id in the pipeline that contains the original scene color
  49499. */
  49500. SSAOOriginalSceneColorEffect: string;
  49501. /**
  49502. * @ignore
  49503. * The SSAO PostProcess id in the pipeline
  49504. */
  49505. SSAORenderEffect: string;
  49506. /**
  49507. * @ignore
  49508. * The horizontal blur PostProcess id in the pipeline
  49509. */
  49510. SSAOBlurHRenderEffect: string;
  49511. /**
  49512. * @ignore
  49513. * The vertical blur PostProcess id in the pipeline
  49514. */
  49515. SSAOBlurVRenderEffect: string;
  49516. /**
  49517. * @ignore
  49518. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49519. */
  49520. SSAOCombineRenderEffect: string;
  49521. /**
  49522. * The output strength of the SSAO post-process. Default value is 1.0.
  49523. */
  49524. totalStrength: number;
  49525. /**
  49526. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49527. */
  49528. maxZ: number;
  49529. /**
  49530. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49531. */
  49532. minZAspect: number;
  49533. private _samples;
  49534. /**
  49535. * Number of samples used for the SSAO calculations. Default value is 8
  49536. */
  49537. samples: number;
  49538. private _textureSamples;
  49539. /**
  49540. * Number of samples to use for antialiasing
  49541. */
  49542. textureSamples: number;
  49543. /**
  49544. * Ratio object used for SSAO ratio and blur ratio
  49545. */
  49546. private _ratio;
  49547. /**
  49548. * Dynamically generated sphere sampler.
  49549. */
  49550. private _sampleSphere;
  49551. /**
  49552. * Blur filter offsets
  49553. */
  49554. private _samplerOffsets;
  49555. private _expensiveBlur;
  49556. /**
  49557. * If bilateral blur should be used
  49558. */
  49559. expensiveBlur: boolean;
  49560. /**
  49561. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49562. */
  49563. radius: number;
  49564. /**
  49565. * The base color of the SSAO post-process
  49566. * The final result is "base + ssao" between [0, 1]
  49567. */
  49568. base: number;
  49569. /**
  49570. * Support test.
  49571. */
  49572. static readonly IsSupported: boolean;
  49573. private _scene;
  49574. private _depthTexture;
  49575. private _normalTexture;
  49576. private _randomTexture;
  49577. private _originalColorPostProcess;
  49578. private _ssaoPostProcess;
  49579. private _blurHPostProcess;
  49580. private _blurVPostProcess;
  49581. private _ssaoCombinePostProcess;
  49582. private _firstUpdate;
  49583. /**
  49584. * @constructor
  49585. * @param name The rendering pipeline name
  49586. * @param scene The scene linked to this pipeline
  49587. * @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 }
  49588. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49589. */
  49590. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49591. /**
  49592. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49593. */
  49594. dispose(disableGeometryBufferRenderer?: boolean): void;
  49595. private _createBlurPostProcess;
  49596. /** @hidden */
  49597. _rebuild(): void;
  49598. private _bits;
  49599. private _radicalInverse_VdC;
  49600. private _hammersley;
  49601. private _hemisphereSample_uniform;
  49602. private _generateHemisphere;
  49603. private _createSSAOPostProcess;
  49604. private _createSSAOCombinePostProcess;
  49605. private _createRandomTexture;
  49606. /**
  49607. * Serialize the rendering pipeline (Used when exporting)
  49608. * @returns the serialized object
  49609. */
  49610. serialize(): any;
  49611. /**
  49612. * Parse the serialized pipeline
  49613. * @param source Source pipeline.
  49614. * @param scene The scene to load the pipeline to.
  49615. * @param rootUrl The URL of the serialized pipeline.
  49616. * @returns An instantiated pipeline from the serialized object.
  49617. */
  49618. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49619. }
  49620. }
  49621. declare module BABYLON {
  49622. /**
  49623. * Render pipeline to produce ssao effect
  49624. */
  49625. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49626. /**
  49627. * @ignore
  49628. * The PassPostProcess id in the pipeline that contains the original scene color
  49629. */
  49630. SSAOOriginalSceneColorEffect: string;
  49631. /**
  49632. * @ignore
  49633. * The SSAO PostProcess id in the pipeline
  49634. */
  49635. SSAORenderEffect: string;
  49636. /**
  49637. * @ignore
  49638. * The horizontal blur PostProcess id in the pipeline
  49639. */
  49640. SSAOBlurHRenderEffect: string;
  49641. /**
  49642. * @ignore
  49643. * The vertical blur PostProcess id in the pipeline
  49644. */
  49645. SSAOBlurVRenderEffect: string;
  49646. /**
  49647. * @ignore
  49648. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49649. */
  49650. SSAOCombineRenderEffect: string;
  49651. /**
  49652. * The output strength of the SSAO post-process. Default value is 1.0.
  49653. */
  49654. totalStrength: number;
  49655. /**
  49656. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49657. */
  49658. radius: number;
  49659. /**
  49660. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49661. * Must not be equal to fallOff and superior to fallOff.
  49662. * Default value is 0.975
  49663. */
  49664. area: number;
  49665. /**
  49666. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49667. * Must not be equal to area and inferior to area.
  49668. * Default value is 0.0
  49669. */
  49670. fallOff: number;
  49671. /**
  49672. * The base color of the SSAO post-process
  49673. * The final result is "base + ssao" between [0, 1]
  49674. */
  49675. base: number;
  49676. private _scene;
  49677. private _depthTexture;
  49678. private _randomTexture;
  49679. private _originalColorPostProcess;
  49680. private _ssaoPostProcess;
  49681. private _blurHPostProcess;
  49682. private _blurVPostProcess;
  49683. private _ssaoCombinePostProcess;
  49684. private _firstUpdate;
  49685. /**
  49686. * @constructor
  49687. * @param name - The rendering pipeline name
  49688. * @param scene - The scene linked to this pipeline
  49689. * @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 }
  49690. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49691. */
  49692. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49693. /**
  49694. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49695. */
  49696. dispose(disableDepthRender?: boolean): void;
  49697. private _createBlurPostProcess;
  49698. /** @hidden */
  49699. _rebuild(): void;
  49700. private _createSSAOPostProcess;
  49701. private _createSSAOCombinePostProcess;
  49702. private _createRandomTexture;
  49703. }
  49704. }
  49705. declare module BABYLON {
  49706. /**
  49707. * Standard rendering pipeline
  49708. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49709. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49710. */
  49711. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49712. /**
  49713. * Public members
  49714. */
  49715. /**
  49716. * Post-process which contains the original scene color before the pipeline applies all the effects
  49717. */
  49718. originalPostProcess: Nullable<PostProcess>;
  49719. /**
  49720. * Post-process used to down scale an image x4
  49721. */
  49722. downSampleX4PostProcess: Nullable<PostProcess>;
  49723. /**
  49724. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49725. */
  49726. brightPassPostProcess: Nullable<PostProcess>;
  49727. /**
  49728. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49729. */
  49730. blurHPostProcesses: PostProcess[];
  49731. /**
  49732. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49733. */
  49734. blurVPostProcesses: PostProcess[];
  49735. /**
  49736. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49737. */
  49738. textureAdderPostProcess: Nullable<PostProcess>;
  49739. /**
  49740. * Post-process used to create volumetric lighting effect
  49741. */
  49742. volumetricLightPostProcess: Nullable<PostProcess>;
  49743. /**
  49744. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49745. */
  49746. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49747. /**
  49748. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49749. */
  49750. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49751. /**
  49752. * Post-process used to merge the volumetric light effect and the real scene color
  49753. */
  49754. volumetricLightMergePostProces: Nullable<PostProcess>;
  49755. /**
  49756. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49757. */
  49758. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49759. /**
  49760. * Base post-process used to calculate the average luminance of the final image for HDR
  49761. */
  49762. luminancePostProcess: Nullable<PostProcess>;
  49763. /**
  49764. * Post-processes used to create down sample post-processes in order to get
  49765. * the average luminance of the final image for HDR
  49766. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49767. */
  49768. luminanceDownSamplePostProcesses: PostProcess[];
  49769. /**
  49770. * Post-process used to create a HDR effect (light adaptation)
  49771. */
  49772. hdrPostProcess: Nullable<PostProcess>;
  49773. /**
  49774. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49775. */
  49776. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49777. /**
  49778. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49779. */
  49780. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49781. /**
  49782. * Post-process used to merge the final HDR post-process and the real scene color
  49783. */
  49784. hdrFinalPostProcess: Nullable<PostProcess>;
  49785. /**
  49786. * Post-process used to create a lens flare effect
  49787. */
  49788. lensFlarePostProcess: Nullable<PostProcess>;
  49789. /**
  49790. * Post-process that merges the result of the lens flare post-process and the real scene color
  49791. */
  49792. lensFlareComposePostProcess: Nullable<PostProcess>;
  49793. /**
  49794. * Post-process used to create a motion blur effect
  49795. */
  49796. motionBlurPostProcess: Nullable<PostProcess>;
  49797. /**
  49798. * Post-process used to create a depth of field effect
  49799. */
  49800. depthOfFieldPostProcess: Nullable<PostProcess>;
  49801. /**
  49802. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49803. */
  49804. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49805. /**
  49806. * Represents the brightness threshold in order to configure the illuminated surfaces
  49807. */
  49808. brightThreshold: number;
  49809. /**
  49810. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49811. */
  49812. blurWidth: number;
  49813. /**
  49814. * Sets if the blur for highlighted surfaces must be only horizontal
  49815. */
  49816. horizontalBlur: boolean;
  49817. /**
  49818. * Sets the overall exposure used by the pipeline
  49819. */
  49820. exposure: number;
  49821. /**
  49822. * Texture used typically to simulate "dirty" on camera lens
  49823. */
  49824. lensTexture: Nullable<Texture>;
  49825. /**
  49826. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49827. */
  49828. volumetricLightCoefficient: number;
  49829. /**
  49830. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49831. */
  49832. volumetricLightPower: number;
  49833. /**
  49834. * Used the set the blur intensity to smooth the volumetric lights
  49835. */
  49836. volumetricLightBlurScale: number;
  49837. /**
  49838. * Light (spot or directional) used to generate the volumetric lights rays
  49839. * The source light must have a shadow generate so the pipeline can get its
  49840. * depth map
  49841. */
  49842. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49843. /**
  49844. * For eye adaptation, represents the minimum luminance the eye can see
  49845. */
  49846. hdrMinimumLuminance: number;
  49847. /**
  49848. * For eye adaptation, represents the decrease luminance speed
  49849. */
  49850. hdrDecreaseRate: number;
  49851. /**
  49852. * For eye adaptation, represents the increase luminance speed
  49853. */
  49854. hdrIncreaseRate: number;
  49855. /**
  49856. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49857. */
  49858. lensColorTexture: Nullable<Texture>;
  49859. /**
  49860. * The overall strengh for the lens flare effect
  49861. */
  49862. lensFlareStrength: number;
  49863. /**
  49864. * Dispersion coefficient for lens flare ghosts
  49865. */
  49866. lensFlareGhostDispersal: number;
  49867. /**
  49868. * Main lens flare halo width
  49869. */
  49870. lensFlareHaloWidth: number;
  49871. /**
  49872. * Based on the lens distortion effect, defines how much the lens flare result
  49873. * is distorted
  49874. */
  49875. lensFlareDistortionStrength: number;
  49876. /**
  49877. * Lens star texture must be used to simulate rays on the flares and is available
  49878. * in the documentation
  49879. */
  49880. lensStarTexture: Nullable<Texture>;
  49881. /**
  49882. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49883. * flare effect by taking account of the dirt texture
  49884. */
  49885. lensFlareDirtTexture: Nullable<Texture>;
  49886. /**
  49887. * Represents the focal length for the depth of field effect
  49888. */
  49889. depthOfFieldDistance: number;
  49890. /**
  49891. * Represents the blur intensity for the blurred part of the depth of field effect
  49892. */
  49893. depthOfFieldBlurWidth: number;
  49894. /**
  49895. * For motion blur, defines how much the image is blurred by the movement
  49896. */
  49897. motionStrength: number;
  49898. /**
  49899. * List of animations for the pipeline (IAnimatable implementation)
  49900. */
  49901. animations: Animation[];
  49902. /**
  49903. * Private members
  49904. */
  49905. private _scene;
  49906. private _currentDepthOfFieldSource;
  49907. private _basePostProcess;
  49908. private _hdrCurrentLuminance;
  49909. private _floatTextureType;
  49910. private _ratio;
  49911. private _bloomEnabled;
  49912. private _depthOfFieldEnabled;
  49913. private _vlsEnabled;
  49914. private _lensFlareEnabled;
  49915. private _hdrEnabled;
  49916. private _motionBlurEnabled;
  49917. private _fxaaEnabled;
  49918. private _motionBlurSamples;
  49919. private _volumetricLightStepsCount;
  49920. private _samples;
  49921. /**
  49922. * @ignore
  49923. * Specifies if the bloom pipeline is enabled
  49924. */
  49925. BloomEnabled: boolean;
  49926. /**
  49927. * @ignore
  49928. * Specifies if the depth of field pipeline is enabed
  49929. */
  49930. DepthOfFieldEnabled: boolean;
  49931. /**
  49932. * @ignore
  49933. * Specifies if the lens flare pipeline is enabed
  49934. */
  49935. LensFlareEnabled: boolean;
  49936. /**
  49937. * @ignore
  49938. * Specifies if the HDR pipeline is enabled
  49939. */
  49940. HDREnabled: boolean;
  49941. /**
  49942. * @ignore
  49943. * Specifies if the volumetric lights scattering effect is enabled
  49944. */
  49945. VLSEnabled: boolean;
  49946. /**
  49947. * @ignore
  49948. * Specifies if the motion blur effect is enabled
  49949. */
  49950. MotionBlurEnabled: boolean;
  49951. /**
  49952. * Specifies if anti-aliasing is enabled
  49953. */
  49954. fxaaEnabled: boolean;
  49955. /**
  49956. * Specifies the number of steps used to calculate the volumetric lights
  49957. * Typically in interval [50, 200]
  49958. */
  49959. volumetricLightStepsCount: number;
  49960. /**
  49961. * Specifies the number of samples used for the motion blur effect
  49962. * Typically in interval [16, 64]
  49963. */
  49964. motionBlurSamples: number;
  49965. /**
  49966. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49967. */
  49968. samples: number;
  49969. /**
  49970. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49971. * @constructor
  49972. * @param name The rendering pipeline name
  49973. * @param scene The scene linked to this pipeline
  49974. * @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)
  49975. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49977. */
  49978. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49979. private _buildPipeline;
  49980. private _createDownSampleX4PostProcess;
  49981. private _createBrightPassPostProcess;
  49982. private _createBlurPostProcesses;
  49983. private _createTextureAdderPostProcess;
  49984. private _createVolumetricLightPostProcess;
  49985. private _createLuminancePostProcesses;
  49986. private _createHdrPostProcess;
  49987. private _createLensFlarePostProcess;
  49988. private _createDepthOfFieldPostProcess;
  49989. private _createMotionBlurPostProcess;
  49990. private _getDepthTexture;
  49991. private _disposePostProcesses;
  49992. /**
  49993. * Dispose of the pipeline and stop all post processes
  49994. */
  49995. dispose(): void;
  49996. /**
  49997. * Serialize the rendering pipeline (Used when exporting)
  49998. * @returns the serialized object
  49999. */
  50000. serialize(): any;
  50001. /**
  50002. * Parse the serialized pipeline
  50003. * @param source Source pipeline.
  50004. * @param scene The scene to load the pipeline to.
  50005. * @param rootUrl The URL of the serialized pipeline.
  50006. * @returns An instantiated pipeline from the serialized object.
  50007. */
  50008. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50009. /**
  50010. * Luminance steps
  50011. */
  50012. static LuminanceSteps: number;
  50013. }
  50014. }