babylon.d.ts 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301
  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. * @see http://doc.babylonjs.com/babylon101/materials
  105. */
  106. materials: Material[];
  107. /**
  108. * The list of morph target managers added to the scene
  109. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110. */
  111. morphTargetManagers: MorphTargetManager[];
  112. /**
  113. * The list of geometries used in the scene.
  114. */
  115. geometries: Geometry[];
  116. /**
  117. * All of the tranform nodes added to this scene
  118. * In the context a the Scene, it is not supposed to be modified manually.
  119. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121. * @see http://doc.babylonjs.com/how_to/transformnode
  122. */
  123. transformNodes: TransformNode[];
  124. /**
  125. * ActionManagers available on the scene.
  126. */
  127. actionManagers: ActionManager[];
  128. /**
  129. * Textures to keep.
  130. */
  131. textures: BaseTexture[];
  132. }
  133. }
  134. declare module BABYLON {
  135. /**
  136. * Set of assets to keep when moving a scene into an asset container.
  137. */
  138. class KeepAssets extends AbstractScene {
  139. }
  140. /**
  141. * Container with a set of assets that can be added or removed from a scene.
  142. */
  143. class AssetContainer extends AbstractScene {
  144. /**
  145. * The scene the AssetContainer belongs to.
  146. */
  147. scene: Scene;
  148. /**
  149. * Instantiates an AssetContainer.
  150. * @param scene The scene the AssetContainer belongs to.
  151. */
  152. constructor(scene: Scene);
  153. /**
  154. * Adds all the assets from the container to the scene.
  155. */
  156. addAllToScene(): void;
  157. /**
  158. * Removes all the assets in the container from the scene
  159. */
  160. removeAllFromScene(): void;
  161. private _moveAssets;
  162. /**
  163. * Removes all the assets contained in the scene and adds them to the container.
  164. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  165. */
  166. moveAllFromScene(keepAssets?: KeepAssets): void;
  167. /**
  168. * 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.
  169. * @returns the root mesh
  170. */
  171. createRootMesh(): Mesh;
  172. }
  173. }
  174. interface Window {
  175. mozIndexedDB: IDBFactory;
  176. webkitIndexedDB: IDBFactory;
  177. msIndexedDB: IDBFactory;
  178. webkitURL: typeof URL;
  179. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  180. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. WebGLRenderingContext: WebGLRenderingContext;
  182. MSGesture: MSGesture;
  183. CANNON: any;
  184. AudioContext: AudioContext;
  185. webkitAudioContext: AudioContext;
  186. PointerEvent: any;
  187. Math: Math;
  188. Uint8Array: Uint8ArrayConstructor;
  189. Float32Array: Float32ArrayConstructor;
  190. mozURL: typeof URL;
  191. msURL: typeof URL;
  192. VRFrameData: any;
  193. DracoDecoderModule: any;
  194. setImmediate(handler: (...args: any[]) => void): number;
  195. }
  196. interface WebGLProgram {
  197. context?: WebGLRenderingContext;
  198. vertexShader?: WebGLShader;
  199. fragmentShader?: WebGLShader;
  200. isParallelCompiled: boolean;
  201. onCompiled?: () => void;
  202. }
  203. interface WebGLRenderingContext {
  204. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  205. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  206. vertexAttribDivisor(index: number, divisor: number): void;
  207. createVertexArray(): any;
  208. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  209. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  210. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  211. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  212. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  213. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  214. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  215. createQuery(): WebGLQuery;
  216. deleteQuery(query: WebGLQuery): void;
  217. beginQuery(target: number, query: WebGLQuery): void;
  218. endQuery(target: number): void;
  219. getQueryParameter(query: WebGLQuery, pname: number): any;
  220. getQuery(target: number, pname: number): any;
  221. MAX_SAMPLES: number;
  222. RGBA8: number;
  223. READ_FRAMEBUFFER: number;
  224. DRAW_FRAMEBUFFER: number;
  225. UNIFORM_BUFFER: number;
  226. HALF_FLOAT_OES: number;
  227. RGBA16F: number;
  228. RGBA32F: number;
  229. R32F: number;
  230. RG32F: number;
  231. RGB32F: number;
  232. R16F: number;
  233. RG16F: number;
  234. RGB16F: number;
  235. RED: number;
  236. RG: number;
  237. R8: number;
  238. RG8: number;
  239. UNSIGNED_INT_24_8: number;
  240. DEPTH24_STENCIL8: number;
  241. drawBuffers(buffers: number[]): void;
  242. readBuffer(src: number): void;
  243. readonly COLOR_ATTACHMENT0: number;
  244. readonly COLOR_ATTACHMENT1: number;
  245. readonly COLOR_ATTACHMENT2: number;
  246. readonly COLOR_ATTACHMENT3: number;
  247. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  248. ANY_SAMPLES_PASSED: number;
  249. QUERY_RESULT_AVAILABLE: number;
  250. QUERY_RESULT: number;
  251. }
  252. interface Document {
  253. mozCancelFullScreen(): void;
  254. msCancelFullScreen(): void;
  255. webkitCancelFullScreen(): void;
  256. requestPointerLock(): void;
  257. exitPointerLock(): void;
  258. fullscreen: boolean;
  259. mozFullScreen: boolean;
  260. msIsFullScreen: boolean;
  261. readonly webkitIsFullScreen: boolean;
  262. readonly pointerLockElement: Element;
  263. mozPointerLockElement: HTMLElement;
  264. msPointerLockElement: HTMLElement;
  265. webkitPointerLockElement: HTMLElement;
  266. }
  267. interface HTMLCanvasElement {
  268. requestPointerLock(): void;
  269. msRequestPointerLock?(): void;
  270. mozRequestPointerLock?(): void;
  271. webkitRequestPointerLock?(): void;
  272. }
  273. interface CanvasRenderingContext2D {
  274. msImageSmoothingEnabled: boolean;
  275. }
  276. interface WebGLBuffer {
  277. references: number;
  278. capacity: number;
  279. is32Bits: boolean;
  280. }
  281. interface WebGLProgram {
  282. transformFeedback?: WebGLTransformFeedback | null;
  283. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  284. }
  285. interface MouseEvent {
  286. mozMovementX: number;
  287. mozMovementY: number;
  288. webkitMovementX: number;
  289. webkitMovementY: number;
  290. msMovementX: number;
  291. msMovementY: number;
  292. }
  293. interface Navigator {
  294. mozGetVRDevices: (any: any) => any;
  295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  298. webkitGetGamepads(): Gamepad[];
  299. msGetGamepads(): Gamepad[];
  300. webkitGamepads(): Gamepad[];
  301. }
  302. interface HTMLVideoElement {
  303. mozSrcObject: any;
  304. }
  305. interface Screen {
  306. readonly orientation: string;
  307. readonly mozOrientation: string;
  308. }
  309. interface Math {
  310. fround(x: number): number;
  311. imul(a: number, b: number): number;
  312. }
  313. interface EXT_disjoint_timer_query {
  314. QUERY_COUNTER_BITS_EXT: number;
  315. TIME_ELAPSED_EXT: number;
  316. TIMESTAMP_EXT: number;
  317. GPU_DISJOINT_EXT: number;
  318. QUERY_RESULT_EXT: number;
  319. QUERY_RESULT_AVAILABLE_EXT: number;
  320. queryCounterEXT(query: WebGLQuery, target: number): void;
  321. createQueryEXT(): WebGLQuery;
  322. beginQueryEXT(target: number, query: WebGLQuery): void;
  323. endQueryEXT(target: number): void;
  324. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  325. deleteQueryEXT(query: WebGLQuery): void;
  326. }
  327. interface WebGLUniformLocation {
  328. _currentState: any;
  329. }
  330. declare module BABYLON {
  331. /**
  332. * Defines how a node can be built from a string name.
  333. */
  334. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  335. /**
  336. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  337. */
  338. class Node implements IBehaviorAware<Node> {
  339. private static _NodeConstructors;
  340. /**
  341. * Add a new node constructor
  342. * @param type defines the type name of the node to construct
  343. * @param constructorFunc defines the constructor function
  344. */
  345. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  346. /**
  347. * Returns a node constructor based on type name
  348. * @param type defines the type name
  349. * @param name defines the new node name
  350. * @param scene defines the hosting scene
  351. * @param options defines optional options to transmit to constructors
  352. * @returns the new constructor or null
  353. */
  354. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  355. /**
  356. * Gets or sets the name of the node
  357. */
  358. name: string;
  359. /**
  360. * Gets or sets the id of the node
  361. */
  362. id: string;
  363. /**
  364. * Gets or sets the unique id of the node
  365. */
  366. uniqueId: number;
  367. /**
  368. * Gets or sets a string used to store user defined state for the node
  369. */
  370. state: string;
  371. /**
  372. * Gets or sets an object used to store user defined information for the node
  373. */
  374. metadata: any;
  375. /**
  376. * Gets or sets a boolean used to define if the node must be serialized
  377. */
  378. doNotSerialize: boolean;
  379. /** @hidden */
  380. _isDisposed: boolean;
  381. /**
  382. * Gets a list of Animations associated with the node
  383. */
  384. animations: Animation[];
  385. protected _ranges: {
  386. [name: string]: Nullable<AnimationRange>;
  387. };
  388. /**
  389. * Callback raised when the node is ready to be used
  390. */
  391. onReady: (node: Node) => void;
  392. private _isEnabled;
  393. private _isParentEnabled;
  394. private _isReady;
  395. /** @hidden */
  396. _currentRenderId: number;
  397. private _parentRenderId;
  398. protected _childRenderId: number;
  399. /** @hidden */
  400. _waitingParentId: Nullable<string>;
  401. /** @hidden */
  402. _scene: Scene;
  403. /** @hidden */
  404. _cache: any;
  405. private _parentNode;
  406. private _children;
  407. /** @hidden */
  408. _worldMatrix: Matrix;
  409. /** @hidden */
  410. _worldMatrixDeterminant: number;
  411. /** @hidden */
  412. private _sceneRootNodesIndex;
  413. /**
  414. * Gets a boolean indicating if the node has been disposed
  415. * @returns true if the node was disposed
  416. */
  417. isDisposed(): boolean;
  418. /**
  419. * Gets or sets the parent of the node
  420. */
  421. parent: Nullable<Node>;
  422. private addToSceneRootNodes;
  423. private removeFromSceneRootNodes;
  424. private _animationPropertiesOverride;
  425. /**
  426. * Gets or sets the animation properties override
  427. */
  428. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  429. /**
  430. * Gets a string idenfifying the name of the class
  431. * @returns "Node" string
  432. */
  433. getClassName(): string;
  434. /**
  435. * An event triggered when the mesh is disposed
  436. */
  437. onDisposeObservable: Observable<Node>;
  438. private _onDisposeObserver;
  439. /**
  440. * Sets a callback that will be raised when the node will be disposed
  441. */
  442. onDispose: () => void;
  443. /**
  444. * Creates a new Node
  445. * @param name the name and id to be given to this node
  446. * @param scene the scene this node will be added to
  447. */
  448. constructor(name: string, scene?: Nullable<Scene>);
  449. /**
  450. * Gets the scene of the node
  451. * @returns a scene
  452. */
  453. getScene(): Scene;
  454. /**
  455. * Gets the engine of the node
  456. * @returns a Engine
  457. */
  458. getEngine(): Engine;
  459. private _behaviors;
  460. /**
  461. * Attach a behavior to the node
  462. * @see http://doc.babylonjs.com/features/behaviour
  463. * @param behavior defines the behavior to attach
  464. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  465. * @returns the current Node
  466. */
  467. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  468. /**
  469. * Remove an attached behavior
  470. * @see http://doc.babylonjs.com/features/behaviour
  471. * @param behavior defines the behavior to attach
  472. * @returns the current Node
  473. */
  474. removeBehavior(behavior: Behavior<Node>): Node;
  475. /**
  476. * Gets the list of attached behaviors
  477. * @see http://doc.babylonjs.com/features/behaviour
  478. */
  479. readonly behaviors: Behavior<Node>[];
  480. /**
  481. * Gets an attached behavior by name
  482. * @param name defines the name of the behavior to look for
  483. * @see http://doc.babylonjs.com/features/behaviour
  484. * @returns null if behavior was not found else the requested behavior
  485. */
  486. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  487. /**
  488. * Returns the latest update of the World matrix
  489. * @returns a Matrix
  490. */
  491. getWorldMatrix(): Matrix;
  492. /** @hidden */
  493. _getWorldMatrixDeterminant(): number;
  494. /**
  495. * Returns directly the latest state of the mesh World matrix.
  496. * A Matrix is returned.
  497. */
  498. readonly worldMatrixFromCache: Matrix;
  499. /** @hidden */
  500. _initCache(): void;
  501. /** @hidden */
  502. updateCache(force?: boolean): void;
  503. /** @hidden */
  504. _updateCache(ignoreParentClass?: boolean): void;
  505. /** @hidden */
  506. _isSynchronized(): boolean;
  507. /** @hidden */
  508. _markSyncedWithParent(): void;
  509. /** @hidden */
  510. isSynchronizedWithParent(): boolean;
  511. /** @hidden */
  512. isSynchronized(): boolean;
  513. /**
  514. * Is this node ready to be used/rendered
  515. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  516. * @return true if the node is ready
  517. */
  518. isReady(completeCheck?: boolean): boolean;
  519. /**
  520. * Is this node enabled?
  521. * 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
  522. * @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
  523. * @return whether this node (and its parent) is enabled
  524. */
  525. isEnabled(checkAncestors?: boolean): boolean;
  526. /** @hidden */
  527. protected _syncParentEnabledState(): void;
  528. /**
  529. * Set the enabled state of this node
  530. * @param value defines the new enabled state
  531. */
  532. setEnabled(value: boolean): void;
  533. /**
  534. * Is this node a descendant of the given node?
  535. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  536. * @param ancestor defines the parent node to inspect
  537. * @returns a boolean indicating if this node is a descendant of the given node
  538. */
  539. isDescendantOf(ancestor: Node): boolean;
  540. /** @hidden */
  541. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  542. /**
  543. * Will return all nodes that have this node as ascendant
  544. * @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
  545. * @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
  546. * @return all children nodes of all types
  547. */
  548. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  549. /**
  550. * Get all child-meshes of this node
  551. * @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
  552. * @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
  553. * @returns an array of AbstractMesh
  554. */
  555. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  556. /**
  557. * Get all child-transformNodes of this node
  558. * @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
  559. * @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
  560. * @returns an array of TransformNode
  561. */
  562. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  563. /**
  564. * Get all direct children of this node
  565. * @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
  566. * @returns an array of Node
  567. */
  568. getChildren(predicate?: (node: Node) => boolean): Node[];
  569. /** @hidden */
  570. _setReady(state: boolean): void;
  571. /**
  572. * Get an animation by name
  573. * @param name defines the name of the animation to look for
  574. * @returns null if not found else the requested animation
  575. */
  576. getAnimationByName(name: string): Nullable<Animation>;
  577. /**
  578. * Creates an animation range for this node
  579. * @param name defines the name of the range
  580. * @param from defines the starting key
  581. * @param to defines the end key
  582. */
  583. createAnimationRange(name: string, from: number, to: number): void;
  584. /**
  585. * Delete a specific animation range
  586. * @param name defines the name of the range to delete
  587. * @param deleteFrames defines if animation frames from the range must be deleted as well
  588. */
  589. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  590. /**
  591. * Get an animation range by name
  592. * @param name defines the name of the animation range to look for
  593. * @returns null if not found else the requested animation range
  594. */
  595. getAnimationRange(name: string): Nullable<AnimationRange>;
  596. /**
  597. * Will start the animation sequence
  598. * @param name defines the range frames for animation sequence
  599. * @param loop defines if the animation should loop (false by default)
  600. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  601. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  602. * @returns the object created for this animation. If range does not exist, it will return null
  603. */
  604. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  605. /**
  606. * Serialize animation ranges into a JSON compatible object
  607. * @returns serialization object
  608. */
  609. serializeAnimationRanges(): any;
  610. /**
  611. * Computes the world matrix of the node
  612. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  613. * @returns the world matrix
  614. */
  615. computeWorldMatrix(force?: boolean): Matrix;
  616. /**
  617. * Releases resources associated with this node.
  618. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  619. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  620. */
  621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  622. /**
  623. * Parse animation range data from a serialization object and store them into a given node
  624. * @param node defines where to store the animation ranges
  625. * @param parsedNode defines the serialization object to read data from
  626. * @param scene defines the hosting scene
  627. */
  628. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  629. }
  630. }
  631. declare module BABYLON {
  632. /**
  633. * Define an interface for all classes that will hold resources
  634. */
  635. interface IDisposable {
  636. /**
  637. * Releases all held resources
  638. */
  639. dispose(): void;
  640. }
  641. /**
  642. * This class is used by the onRenderingGroupObservable
  643. */
  644. class RenderingGroupInfo {
  645. /**
  646. * The Scene that being rendered
  647. */
  648. scene: Scene;
  649. /**
  650. * The camera currently used for the rendering pass
  651. */
  652. camera: Nullable<Camera>;
  653. /**
  654. * The ID of the renderingGroup being processed
  655. */
  656. renderingGroupId: number;
  657. }
  658. /** Interface defining initialization parameters for Scene class */
  659. interface SceneOptions {
  660. /**
  661. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  662. * It will improve performance when the number of geometries becomes important.
  663. */
  664. useGeometryIdsMap?: boolean;
  665. }
  666. /**
  667. * Represents a scene to be rendered by the engine.
  668. * @see http://doc.babylonjs.com/features/scene
  669. */
  670. class Scene extends AbstractScene implements IAnimatable {
  671. private static _uniqueIdCounter;
  672. /** The fog is deactivated */
  673. static readonly FOGMODE_NONE: number;
  674. /** The fog density is following an exponential function */
  675. static readonly FOGMODE_EXP: number;
  676. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  677. static readonly FOGMODE_EXP2: number;
  678. /** The fog density is following a linear function. */
  679. static readonly FOGMODE_LINEAR: number;
  680. /**
  681. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  683. */
  684. static MinDeltaTime: number;
  685. /**
  686. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  687. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  688. */
  689. static MaxDeltaTime: number;
  690. /**
  691. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  692. */
  693. autoClear: boolean;
  694. /**
  695. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  696. */
  697. autoClearDepthAndStencil: boolean;
  698. /**
  699. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  700. */
  701. clearColor: Color4;
  702. /**
  703. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  704. */
  705. ambientColor: Color3;
  706. /** @hidden */
  707. _environmentBRDFTexture: BaseTexture;
  708. /** @hidden */
  709. protected _environmentTexture: BaseTexture;
  710. /**
  711. * Texture used in all pbr material as the reflection texture.
  712. * As in the majority of the scene they are the same (exception for multi room and so on),
  713. * this is easier to reference from here than from all the materials.
  714. */
  715. /**
  716. * Texture used in all pbr material as the reflection texture.
  717. * As in the majority of the scene they are the same (exception for multi room and so on),
  718. * this is easier to set here than in all the materials.
  719. */
  720. environmentTexture: BaseTexture;
  721. /** @hidden */
  722. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  723. /**
  724. * Default image processing configuration used either in the rendering
  725. * Forward main pass or through the imageProcessingPostProcess if present.
  726. * As in the majority of the scene they are the same (exception for multi camera),
  727. * this is easier to reference from here than from all the materials and post process.
  728. *
  729. * No setter as we it is a shared configuration, you can set the values instead.
  730. */
  731. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  732. private _forceWireframe;
  733. /**
  734. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  735. */
  736. forceWireframe: boolean;
  737. private _forcePointsCloud;
  738. /**
  739. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  740. */
  741. forcePointsCloud: boolean;
  742. /**
  743. * Gets or sets the active clipplane 1
  744. */
  745. clipPlane: Nullable<Plane>;
  746. /**
  747. * Gets or sets the active clipplane 2
  748. */
  749. clipPlane2: Nullable<Plane>;
  750. /**
  751. * Gets or sets the active clipplane 3
  752. */
  753. clipPlane3: Nullable<Plane>;
  754. /**
  755. * Gets or sets the active clipplane 4
  756. */
  757. clipPlane4: Nullable<Plane>;
  758. /**
  759. * Gets or sets a boolean indicating if animations are enabled
  760. */
  761. animationsEnabled: boolean;
  762. private _animationPropertiesOverride;
  763. /**
  764. * Gets or sets the animation properties override
  765. */
  766. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  767. /**
  768. * Gets or sets a boolean indicating if a constant deltatime has to be used
  769. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  770. */
  771. useConstantAnimationDeltaTime: boolean;
  772. /**
  773. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  774. * Please note that it requires to run a ray cast through the scene on every frame
  775. */
  776. constantlyUpdateMeshUnderPointer: boolean;
  777. /**
  778. * Defines the HTML cursor to use when hovering over interactive elements
  779. */
  780. hoverCursor: string;
  781. /**
  782. * Defines the HTML default cursor to use (empty by default)
  783. */
  784. defaultCursor: string;
  785. /**
  786. * This is used to call preventDefault() on pointer down
  787. * in order to block unwanted artifacts like system double clicks
  788. */
  789. preventDefaultOnPointerDown: boolean;
  790. /**
  791. * This is used to call preventDefault() on pointer up
  792. * in order to block unwanted artifacts like system double clicks
  793. */
  794. preventDefaultOnPointerUp: boolean;
  795. /**
  796. * Gets or sets user defined metadata
  797. */
  798. metadata: any;
  799. /**
  800. * Gets the name of the plugin used to load this scene (null by default)
  801. */
  802. loadingPluginName: string;
  803. /**
  804. * Use this array to add regular expressions used to disable offline support for specific urls
  805. */
  806. disableOfflineSupportExceptionRules: RegExp[];
  807. /**
  808. * An event triggered when the scene is disposed.
  809. */
  810. onDisposeObservable: Observable<Scene>;
  811. private _onDisposeObserver;
  812. /** Sets a function to be executed when this scene is disposed. */
  813. onDispose: () => void;
  814. /**
  815. * An event triggered before rendering the scene (right after animations and physics)
  816. */
  817. onBeforeRenderObservable: Observable<Scene>;
  818. private _onBeforeRenderObserver;
  819. /** Sets a function to be executed before rendering this scene */
  820. beforeRender: Nullable<() => void>;
  821. /**
  822. * An event triggered after rendering the scene
  823. */
  824. onAfterRenderObservable: Observable<Scene>;
  825. private _onAfterRenderObserver;
  826. /** Sets a function to be executed after rendering this scene */
  827. afterRender: Nullable<() => void>;
  828. /**
  829. * An event triggered before animating the scene
  830. */
  831. onBeforeAnimationsObservable: Observable<Scene>;
  832. /**
  833. * An event triggered after animations processing
  834. */
  835. onAfterAnimationsObservable: Observable<Scene>;
  836. /**
  837. * An event triggered before draw calls are ready to be sent
  838. */
  839. onBeforeDrawPhaseObservable: Observable<Scene>;
  840. /**
  841. * An event triggered after draw calls have been sent
  842. */
  843. onAfterDrawPhaseObservable: Observable<Scene>;
  844. /**
  845. * An event triggered when the scene is ready
  846. */
  847. onReadyObservable: Observable<Scene>;
  848. /**
  849. * An event triggered before rendering a camera
  850. */
  851. onBeforeCameraRenderObservable: Observable<Camera>;
  852. private _onBeforeCameraRenderObserver;
  853. /** Sets a function to be executed before rendering a camera*/
  854. beforeCameraRender: () => void;
  855. /**
  856. * An event triggered after rendering a camera
  857. */
  858. onAfterCameraRenderObservable: Observable<Camera>;
  859. private _onAfterCameraRenderObserver;
  860. /** Sets a function to be executed after rendering a camera*/
  861. afterCameraRender: () => void;
  862. /**
  863. * An event triggered when active meshes evaluation is about to start
  864. */
  865. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  866. /**
  867. * An event triggered when active meshes evaluation is done
  868. */
  869. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  870. /**
  871. * An event triggered when particles rendering is about to start
  872. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  873. */
  874. onBeforeParticlesRenderingObservable: Observable<Scene>;
  875. /**
  876. * An event triggered when particles rendering is done
  877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  878. */
  879. onAfterParticlesRenderingObservable: Observable<Scene>;
  880. /**
  881. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  882. */
  883. onDataLoadedObservable: Observable<Scene>;
  884. /**
  885. * An event triggered when a camera is created
  886. */
  887. onNewCameraAddedObservable: Observable<Camera>;
  888. /**
  889. * An event triggered when a camera is removed
  890. */
  891. onCameraRemovedObservable: Observable<Camera>;
  892. /**
  893. * An event triggered when a light is created
  894. */
  895. onNewLightAddedObservable: Observable<Light>;
  896. /**
  897. * An event triggered when a light is removed
  898. */
  899. onLightRemovedObservable: Observable<Light>;
  900. /**
  901. * An event triggered when a geometry is created
  902. */
  903. onNewGeometryAddedObservable: Observable<Geometry>;
  904. /**
  905. * An event triggered when a geometry is removed
  906. */
  907. onGeometryRemovedObservable: Observable<Geometry>;
  908. /**
  909. * An event triggered when a transform node is created
  910. */
  911. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  912. /**
  913. * An event triggered when a transform node is removed
  914. */
  915. onTransformNodeRemovedObservable: Observable<TransformNode>;
  916. /**
  917. * An event triggered when a mesh is created
  918. */
  919. onNewMeshAddedObservable: Observable<AbstractMesh>;
  920. /**
  921. * An event triggered when a mesh is removed
  922. */
  923. onMeshRemovedObservable: Observable<AbstractMesh>;
  924. /**
  925. * An event triggered when a material is created
  926. */
  927. onNewMaterialAddedObservable: Observable<Material>;
  928. /**
  929. * An event triggered when a material is removed
  930. */
  931. onMaterialRemovedObservable: Observable<Material>;
  932. /**
  933. * An event triggered when a texture is created
  934. */
  935. onNewTextureAddedObservable: Observable<BaseTexture>;
  936. /**
  937. * An event triggered when a texture is removed
  938. */
  939. onTextureRemovedObservable: Observable<BaseTexture>;
  940. /**
  941. * An event triggered when render targets are about to be rendered
  942. * Can happen multiple times per frame.
  943. */
  944. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  945. /**
  946. * An event triggered when render targets were rendered.
  947. * Can happen multiple times per frame.
  948. */
  949. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  950. /**
  951. * An event triggered before calculating deterministic simulation step
  952. */
  953. onBeforeStepObservable: Observable<Scene>;
  954. /**
  955. * An event triggered after calculating deterministic simulation step
  956. */
  957. onAfterStepObservable: Observable<Scene>;
  958. /**
  959. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  960. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  961. * 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)
  962. */
  963. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  964. /**
  965. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  966. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  967. * 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)
  968. */
  969. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  970. /**
  971. * This Observable will when a mesh has been imported into the scene.
  972. */
  973. onMeshImportedObservable: Observable<AbstractMesh>;
  974. private _registeredForLateAnimationBindings;
  975. /**
  976. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  977. */
  978. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  979. /**
  980. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  981. */
  982. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  983. /**
  984. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  985. */
  986. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  987. private _onPointerMove;
  988. private _onPointerDown;
  989. private _onPointerUp;
  990. /** Deprecated. Use onPointerObservable instead */
  991. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  992. /** Deprecated. Use onPointerObservable instead */
  993. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  994. /** Deprecated. Use onPointerObservable instead */
  995. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  996. /** Deprecated. Use onPointerObservable instead */
  997. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  998. /**
  999. * 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).
  1000. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1001. */
  1002. onPrePointerObservable: Observable<PointerInfoPre>;
  1003. /**
  1004. * Observable event triggered each time an input event is received from the rendering canvas
  1005. */
  1006. onPointerObservable: Observable<PointerInfo>;
  1007. /**
  1008. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1009. */
  1010. readonly unTranslatedPointer: Vector2;
  1011. /** The distance in pixel that you have to move to prevent some events */
  1012. static DragMovementThreshold: number;
  1013. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1014. static LongPressDelay: number;
  1015. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1016. static DoubleClickDelay: number;
  1017. /** If you need to check double click without raising a single click at first click, enable this flag */
  1018. static ExclusiveDoubleClickMode: boolean;
  1019. private _initClickEvent;
  1020. private _initActionManager;
  1021. private _delayedSimpleClick;
  1022. private _delayedSimpleClickTimeout;
  1023. private _previousDelayedSimpleClickTimeout;
  1024. private _meshPickProceed;
  1025. private _previousButtonPressed;
  1026. private _currentPickResult;
  1027. private _previousPickResult;
  1028. private _totalPointersPressed;
  1029. private _doubleClickOccured;
  1030. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1031. cameraToUseForPointers: Nullable<Camera>;
  1032. private _pointerX;
  1033. private _pointerY;
  1034. private _unTranslatedPointerX;
  1035. private _unTranslatedPointerY;
  1036. private _startingPointerPosition;
  1037. private _previousStartingPointerPosition;
  1038. private _startingPointerTime;
  1039. private _previousStartingPointerTime;
  1040. private _pointerCaptures;
  1041. private _timeAccumulator;
  1042. private _currentStepId;
  1043. private _currentInternalStep;
  1044. /** @hidden */
  1045. _mirroredCameraPosition: Nullable<Vector3>;
  1046. /**
  1047. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1048. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1049. */
  1050. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1051. /**
  1052. * Observable event triggered each time an keyboard event is received from the hosting window
  1053. */
  1054. onKeyboardObservable: Observable<KeyboardInfo>;
  1055. private _onKeyDown;
  1056. private _onKeyUp;
  1057. private _onCanvasFocusObserver;
  1058. private _onCanvasBlurObserver;
  1059. private _useRightHandedSystem;
  1060. /**
  1061. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1062. */
  1063. useRightHandedSystem: boolean;
  1064. /**
  1065. * Sets the step Id used by deterministic lock step
  1066. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1067. * @param newStepId defines the step Id
  1068. */
  1069. setStepId(newStepId: number): void;
  1070. /**
  1071. * Gets the step Id used by deterministic lock step
  1072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1073. * @returns the step Id
  1074. */
  1075. getStepId(): number;
  1076. /**
  1077. * Gets the internal step used by deterministic lock step
  1078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1079. * @returns the internal step
  1080. */
  1081. getInternalStep(): number;
  1082. private _fogEnabled;
  1083. /**
  1084. * Gets or sets a boolean indicating if fog is enabled on this scene
  1085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1086. * (Default is true)
  1087. */
  1088. fogEnabled: boolean;
  1089. private _fogMode;
  1090. /**
  1091. * Gets or sets the fog mode to use
  1092. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1093. * | mode | value |
  1094. * | --- | --- |
  1095. * | FOGMODE_NONE | 0 |
  1096. * | FOGMODE_EXP | 1 |
  1097. * | FOGMODE_EXP2 | 2 |
  1098. * | FOGMODE_LINEAR | 3 |
  1099. */
  1100. fogMode: number;
  1101. /**
  1102. * Gets or sets the fog color to use
  1103. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1104. * (Default is Color3(0.2, 0.2, 0.3))
  1105. */
  1106. fogColor: Color3;
  1107. /**
  1108. * Gets or sets the fog density to use
  1109. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1110. * (Default is 0.1)
  1111. */
  1112. fogDensity: number;
  1113. /**
  1114. * Gets or sets the fog start distance to use
  1115. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1116. * (Default is 0)
  1117. */
  1118. fogStart: number;
  1119. /**
  1120. * Gets or sets the fog end distance to use
  1121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1122. * (Default is 1000)
  1123. */
  1124. fogEnd: number;
  1125. private _shadowsEnabled;
  1126. /**
  1127. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1128. */
  1129. shadowsEnabled: boolean;
  1130. private _lightsEnabled;
  1131. /**
  1132. * Gets or sets a boolean indicating if lights are enabled on this scene
  1133. */
  1134. lightsEnabled: boolean;
  1135. /** All of the active cameras added to this scene. */
  1136. activeCameras: Camera[];
  1137. /** The current active camera */
  1138. activeCamera: Nullable<Camera>;
  1139. private _defaultMaterial;
  1140. /** The default material used on meshes when no material is affected */
  1141. /** The default material used on meshes when no material is affected */
  1142. defaultMaterial: Material;
  1143. private _texturesEnabled;
  1144. /**
  1145. * Gets or sets a boolean indicating if textures are enabled on this scene
  1146. */
  1147. texturesEnabled: boolean;
  1148. /**
  1149. * Gets or sets a boolean indicating if particles are enabled on this scene
  1150. */
  1151. particlesEnabled: boolean;
  1152. /**
  1153. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1154. */
  1155. spritesEnabled: boolean;
  1156. private _skeletonsEnabled;
  1157. /**
  1158. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1159. */
  1160. skeletonsEnabled: boolean;
  1161. /**
  1162. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1163. */
  1164. lensFlaresEnabled: boolean;
  1165. /**
  1166. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1167. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1168. */
  1169. collisionsEnabled: boolean;
  1170. private _workerCollisions;
  1171. /** @hidden */
  1172. collisionCoordinator: ICollisionCoordinator;
  1173. /**
  1174. * Defines the gravity applied to this scene (used only for collisions)
  1175. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1176. */
  1177. gravity: Vector3;
  1178. /**
  1179. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1180. */
  1181. postProcessesEnabled: boolean;
  1182. /**
  1183. * The list of postprocesses added to the scene
  1184. */
  1185. postProcesses: PostProcess[];
  1186. /**
  1187. * Gets the current postprocess manager
  1188. */
  1189. postProcessManager: PostProcessManager;
  1190. /**
  1191. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1192. */
  1193. renderTargetsEnabled: boolean;
  1194. /**
  1195. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1196. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1197. */
  1198. dumpNextRenderTargets: boolean;
  1199. /**
  1200. * The list of user defined render targets added to the scene
  1201. */
  1202. customRenderTargets: RenderTargetTexture[];
  1203. /**
  1204. * Defines if texture loading must be delayed
  1205. * If true, textures will only be loaded when they need to be rendered
  1206. */
  1207. useDelayedTextureLoading: boolean;
  1208. /**
  1209. * Gets the list of meshes imported to the scene through SceneLoader
  1210. */
  1211. importedMeshesFiles: String[];
  1212. /**
  1213. * Gets or sets a boolean indicating if probes are enabled on this scene
  1214. */
  1215. probesEnabled: boolean;
  1216. /**
  1217. * Gets or sets the current offline provider to use to store scene data
  1218. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1219. */
  1220. offlineProvider: IOfflineProvider;
  1221. /**
  1222. * Gets or sets the action manager associated with the scene
  1223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1224. */
  1225. actionManager: ActionManager;
  1226. private _meshesForIntersections;
  1227. /**
  1228. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1229. */
  1230. proceduralTexturesEnabled: boolean;
  1231. private _engine;
  1232. private _totalVertices;
  1233. /** @hidden */
  1234. _activeIndices: PerfCounter;
  1235. /** @hidden */
  1236. _activeParticles: PerfCounter;
  1237. /** @hidden */
  1238. _activeBones: PerfCounter;
  1239. private _animationRatio;
  1240. private _animationTimeLast;
  1241. private _animationTime;
  1242. /**
  1243. * Gets or sets a general scale for animation speed
  1244. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1245. */
  1246. animationTimeScale: number;
  1247. /** @hidden */
  1248. _cachedMaterial: Nullable<Material>;
  1249. /** @hidden */
  1250. _cachedEffect: Nullable<Effect>;
  1251. /** @hidden */
  1252. _cachedVisibility: Nullable<number>;
  1253. private _renderId;
  1254. private _frameId;
  1255. private _executeWhenReadyTimeoutId;
  1256. private _intermediateRendering;
  1257. private _viewUpdateFlag;
  1258. private _projectionUpdateFlag;
  1259. private _alternateViewUpdateFlag;
  1260. private _alternateProjectionUpdateFlag;
  1261. /** @hidden */
  1262. _toBeDisposed: Nullable<IDisposable>[];
  1263. private _activeRequests;
  1264. private _pendingData;
  1265. private _isDisposed;
  1266. /**
  1267. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1268. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1269. */
  1270. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1271. private _activeMeshes;
  1272. private _processedMaterials;
  1273. private _renderTargets;
  1274. /** @hidden */
  1275. _activeParticleSystems: SmartArray<IParticleSystem>;
  1276. private _activeSkeletons;
  1277. private _softwareSkinnedMeshes;
  1278. private _renderingManager;
  1279. /** @hidden */
  1280. _activeAnimatables: Animatable[];
  1281. private _transformMatrix;
  1282. private _sceneUbo;
  1283. private _alternateSceneUbo;
  1284. private _pickWithRayInverseMatrix;
  1285. private _viewMatrix;
  1286. private _projectionMatrix;
  1287. private _alternateViewMatrix;
  1288. private _alternateProjectionMatrix;
  1289. private _alternateTransformMatrix;
  1290. private _useAlternateCameraConfiguration;
  1291. private _alternateRendering;
  1292. /** @hidden */
  1293. _forcedViewPosition: Nullable<Vector3>;
  1294. /** @hidden */
  1295. readonly _isAlternateRenderingEnabled: boolean;
  1296. private _frustumPlanes;
  1297. /**
  1298. * Gets the list of frustum planes (built from the active camera)
  1299. */
  1300. readonly frustumPlanes: Plane[];
  1301. /**
  1302. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1303. * This is useful if there are more lights that the maximum simulteanous authorized
  1304. */
  1305. requireLightSorting: boolean;
  1306. private _pointerOverMesh;
  1307. private _pickedDownMesh;
  1308. private _pickedUpMesh;
  1309. private _externalData;
  1310. private _uid;
  1311. /**
  1312. * @hidden
  1313. * Backing store of defined scene components.
  1314. */
  1315. _components: ISceneComponent[];
  1316. /**
  1317. * @hidden
  1318. * Backing store of defined scene components.
  1319. */
  1320. _serializableComponents: ISceneSerializableComponent[];
  1321. /**
  1322. * List of components to register on the next registration step.
  1323. */
  1324. private _transientComponents;
  1325. /**
  1326. * Registers the transient components if needed.
  1327. */
  1328. private _registerTransientComponents;
  1329. /**
  1330. * @hidden
  1331. * Add a component to the scene.
  1332. * Note that the ccomponent could be registered on th next frame if this is called after
  1333. * the register component stage.
  1334. * @param component Defines the component to add to the scene
  1335. */
  1336. _addComponent(component: ISceneComponent): void;
  1337. /**
  1338. * @hidden
  1339. * Gets a component from the scene.
  1340. * @param name defines the name of the component to retrieve
  1341. * @returns the component or null if not present
  1342. */
  1343. _getComponent(name: string): Nullable<ISceneComponent>;
  1344. /**
  1345. * @hidden
  1346. * Defines the actions happening before camera updates.
  1347. */
  1348. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1349. /**
  1350. * @hidden
  1351. * Defines the actions happening before clear the canvas.
  1352. */
  1353. _beforeClearStage: Stage<SimpleStageAction>;
  1354. /**
  1355. * @hidden
  1356. * Defines the actions when collecting render targets for the frame.
  1357. */
  1358. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1359. /**
  1360. * @hidden
  1361. * Defines the actions happening for one camera in the frame.
  1362. */
  1363. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1364. /**
  1365. * @hidden
  1366. * Defines the actions happening during the per mesh ready checks.
  1367. */
  1368. _isReadyForMeshStage: Stage<MeshStageAction>;
  1369. /**
  1370. * @hidden
  1371. * Defines the actions happening before evaluate active mesh checks.
  1372. */
  1373. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1374. /**
  1375. * @hidden
  1376. * Defines the actions happening during the evaluate sub mesh checks.
  1377. */
  1378. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1379. /**
  1380. * @hidden
  1381. * Defines the actions happening during the active mesh stage.
  1382. */
  1383. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1384. /**
  1385. * @hidden
  1386. * Defines the actions happening during the per camera render target step.
  1387. */
  1388. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1389. /**
  1390. * @hidden
  1391. * Defines the actions happening just before the active camera is drawing.
  1392. */
  1393. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1394. /**
  1395. * @hidden
  1396. * Defines the actions happening just before a rendering group is drawing.
  1397. */
  1398. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1399. /**
  1400. * @hidden
  1401. * Defines the actions happening just before a mesh is drawing.
  1402. */
  1403. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1404. /**
  1405. * @hidden
  1406. * Defines the actions happening just after a mesh has been drawn.
  1407. */
  1408. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1409. /**
  1410. * @hidden
  1411. * Defines the actions happening just after a rendering group has been drawn.
  1412. */
  1413. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1414. /**
  1415. * @hidden
  1416. * Defines the actions happening just after the active camera has been drawn.
  1417. */
  1418. _afterCameraDrawStage: Stage<CameraStageAction>;
  1419. /**
  1420. * @hidden
  1421. * Defines the actions happening just after rendering all cameras and computing intersections.
  1422. */
  1423. _afterRenderStage: Stage<SimpleStageAction>;
  1424. /**
  1425. * @hidden
  1426. * Defines the actions happening when a pointer move event happens.
  1427. */
  1428. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1429. /**
  1430. * @hidden
  1431. * Defines the actions happening when a pointer down event happens.
  1432. */
  1433. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1434. /**
  1435. * @hidden
  1436. * Defines the actions happening when a pointer up event happens.
  1437. */
  1438. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1439. /**
  1440. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1441. */
  1442. private geometriesById;
  1443. /**
  1444. * Creates a new Scene
  1445. * @param engine defines the engine to use to render this scene
  1446. */
  1447. constructor(engine: Engine, options?: SceneOptions);
  1448. private _defaultMeshCandidates;
  1449. /**
  1450. * @hidden
  1451. */
  1452. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1453. private _defaultSubMeshCandidates;
  1454. /**
  1455. * @hidden
  1456. */
  1457. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1458. /**
  1459. * Sets the default candidate providers for the scene.
  1460. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1461. * and getCollidingSubMeshCandidates to their default function
  1462. */
  1463. setDefaultCandidateProviders(): void;
  1464. /**
  1465. * Gets a boolean indicating if collisions are processed on a web worker
  1466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1467. */
  1468. workerCollisions: boolean;
  1469. /**
  1470. * Gets the mesh that is currently under the pointer
  1471. */
  1472. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1473. /**
  1474. * Gets the current on-screen X position of the pointer
  1475. */
  1476. readonly pointerX: number;
  1477. /**
  1478. * Gets the current on-screen Y position of the pointer
  1479. */
  1480. readonly pointerY: number;
  1481. /**
  1482. * Gets the cached material (ie. the latest rendered one)
  1483. * @returns the cached material
  1484. */
  1485. getCachedMaterial(): Nullable<Material>;
  1486. /**
  1487. * Gets the cached effect (ie. the latest rendered one)
  1488. * @returns the cached effect
  1489. */
  1490. getCachedEffect(): Nullable<Effect>;
  1491. /**
  1492. * Gets the cached visibility state (ie. the latest rendered one)
  1493. * @returns the cached visibility state
  1494. */
  1495. getCachedVisibility(): Nullable<number>;
  1496. /**
  1497. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1498. * @param material defines the current material
  1499. * @param effect defines the current effect
  1500. * @param visibility defines the current visibility state
  1501. * @returns true if one parameter is not cached
  1502. */
  1503. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1504. /**
  1505. * Gets the engine associated with the scene
  1506. * @returns an Engine
  1507. */
  1508. getEngine(): Engine;
  1509. /**
  1510. * Gets the total number of vertices rendered per frame
  1511. * @returns the total number of vertices rendered per frame
  1512. */
  1513. getTotalVertices(): number;
  1514. /**
  1515. * Gets the performance counter for total vertices
  1516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1517. */
  1518. readonly totalVerticesPerfCounter: PerfCounter;
  1519. /**
  1520. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1521. * @returns the total number of active indices rendered per frame
  1522. */
  1523. getActiveIndices(): number;
  1524. /**
  1525. * Gets the performance counter for active indices
  1526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1527. */
  1528. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1529. /**
  1530. * Gets the total number of active particles rendered per frame
  1531. * @returns the total number of active particles rendered per frame
  1532. */
  1533. getActiveParticles(): number;
  1534. /**
  1535. * Gets the performance counter for active particles
  1536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1537. */
  1538. readonly activeParticlesPerfCounter: PerfCounter;
  1539. /**
  1540. * Gets the total number of active bones rendered per frame
  1541. * @returns the total number of active bones rendered per frame
  1542. */
  1543. getActiveBones(): number;
  1544. /**
  1545. * Gets the performance counter for active bones
  1546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1547. */
  1548. readonly activeBonesPerfCounter: PerfCounter;
  1549. /** @hidden */
  1550. getInterFramePerfCounter(): number;
  1551. /** @hidden */
  1552. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1553. /** @hidden */
  1554. getLastFrameDuration(): number;
  1555. /** @hidden */
  1556. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1557. /** @hidden */
  1558. getEvaluateActiveMeshesDuration(): number;
  1559. /** @hidden */
  1560. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1561. /**
  1562. * Gets the array of active meshes
  1563. * @returns an array of AbstractMesh
  1564. */
  1565. getActiveMeshes(): SmartArray<AbstractMesh>;
  1566. /** @hidden */
  1567. getRenderTargetsDuration(): number;
  1568. /** @hidden */
  1569. getRenderDuration(): number;
  1570. /** @hidden */
  1571. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1572. /** @hidden */
  1573. getParticlesDuration(): number;
  1574. /** @hidden */
  1575. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1576. /** @hidden */
  1577. getSpritesDuration(): number;
  1578. /** @hidden */
  1579. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1580. /**
  1581. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1582. * @returns a number
  1583. */
  1584. getAnimationRatio(): number;
  1585. /**
  1586. * Gets an unique Id for the current render phase
  1587. * @returns a number
  1588. */
  1589. getRenderId(): number;
  1590. /**
  1591. * Gets an unique Id for the current frame
  1592. * @returns a number
  1593. */
  1594. getFrameId(): number;
  1595. /** Call this function if you want to manually increment the render Id*/
  1596. incrementRenderId(): void;
  1597. private _updatePointerPosition;
  1598. private _createUbo;
  1599. private _createAlternateUbo;
  1600. private _setRayOnPointerInfo;
  1601. /**
  1602. * Use this method to simulate a pointer move on a mesh
  1603. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1604. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1605. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1606. * @returns the current scene
  1607. */
  1608. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1609. private _processPointerMove;
  1610. private _checkPrePointerObservable;
  1611. /**
  1612. * Use this method to simulate a pointer down on a mesh
  1613. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1614. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1615. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1616. * @returns the current scene
  1617. */
  1618. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1619. private _processPointerDown;
  1620. /**
  1621. * Use this method to simulate a pointer up on a mesh
  1622. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1623. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1624. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1625. * @returns the current scene
  1626. */
  1627. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1628. private _processPointerUp;
  1629. /**
  1630. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1631. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1632. * @returns true if the pointer was captured
  1633. */
  1634. isPointerCaptured(pointerId?: number): boolean;
  1635. /** @hidden */
  1636. _isPointerSwiping(): boolean;
  1637. /**
  1638. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1639. * @param attachUp defines if you want to attach events to pointerup
  1640. * @param attachDown defines if you want to attach events to pointerdown
  1641. * @param attachMove defines if you want to attach events to pointermove
  1642. */
  1643. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1644. /** Detaches all event handlers*/
  1645. detachControl(): void;
  1646. /**
  1647. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1648. * Delay loaded resources are not taking in account
  1649. * @return true if all required resources are ready
  1650. */
  1651. isReady(): boolean;
  1652. /** Resets all cached information relative to material (including effect and visibility) */
  1653. resetCachedMaterial(): void;
  1654. /**
  1655. * Registers a function to be called before every frame render
  1656. * @param func defines the function to register
  1657. */
  1658. registerBeforeRender(func: () => void): void;
  1659. /**
  1660. * Unregisters a function called before every frame render
  1661. * @param func defines the function to unregister
  1662. */
  1663. unregisterBeforeRender(func: () => void): void;
  1664. /**
  1665. * Registers a function to be called after every frame render
  1666. * @param func defines the function to register
  1667. */
  1668. registerAfterRender(func: () => void): void;
  1669. /**
  1670. * Unregisters a function called after every frame render
  1671. * @param func defines the function to unregister
  1672. */
  1673. unregisterAfterRender(func: () => void): void;
  1674. private _executeOnceBeforeRender;
  1675. /**
  1676. * The provided function will run before render once and will be disposed afterwards.
  1677. * A timeout delay can be provided so that the function will be executed in N ms.
  1678. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1679. * @param func The function to be executed.
  1680. * @param timeout optional delay in ms
  1681. */
  1682. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1683. /** @hidden */
  1684. _addPendingData(data: any): void;
  1685. /** @hidden */
  1686. _removePendingData(data: any): void;
  1687. /**
  1688. * Returns the number of items waiting to be loaded
  1689. * @returns the number of items waiting to be loaded
  1690. */
  1691. getWaitingItemsCount(): number;
  1692. /**
  1693. * Returns a boolean indicating if the scene is still loading data
  1694. */
  1695. readonly isLoading: boolean;
  1696. /**
  1697. * Registers a function to be executed when the scene is ready
  1698. * @param {Function} func - the function to be executed
  1699. */
  1700. executeWhenReady(func: () => void): void;
  1701. /**
  1702. * Returns a promise that resolves when the scene is ready
  1703. * @returns A promise that resolves when the scene is ready
  1704. */
  1705. whenReadyAsync(): Promise<void>;
  1706. /** @hidden */
  1707. _checkIsReady(): void;
  1708. /**
  1709. * Will start the animation sequence of a given target
  1710. * @param target defines the target
  1711. * @param from defines from which frame should animation start
  1712. * @param to defines until which frame should animation run.
  1713. * @param weight defines the weight to apply to the animation (1.0 by default)
  1714. * @param loop defines if the animation loops
  1715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1716. * @param onAnimationEnd defines the function to be executed when the animation ends
  1717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1718. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1719. * @returns the animatable object created for this animation
  1720. */
  1721. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1722. /**
  1723. * Will start the animation sequence of a given target
  1724. * @param target defines the target
  1725. * @param from defines from which frame should animation start
  1726. * @param to defines until which frame should animation run.
  1727. * @param loop defines if the animation loops
  1728. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1729. * @param onAnimationEnd defines the function to be executed when the animation ends
  1730. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1731. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1732. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1733. * @returns the animatable object created for this animation
  1734. */
  1735. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1736. /**
  1737. * Begin a new animation on a given node
  1738. * @param target defines the target where the animation will take place
  1739. * @param animations defines the list of animations to start
  1740. * @param from defines the initial value
  1741. * @param to defines the final value
  1742. * @param loop defines if you want animation to loop (off by default)
  1743. * @param speedRatio defines the speed ratio to apply to all animations
  1744. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1745. * @returns the list of created animatables
  1746. */
  1747. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1748. /**
  1749. * Begin a new animation on a given node and its hierarchy
  1750. * @param target defines the root node where the animation will take place
  1751. * @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.
  1752. * @param animations defines the list of animations to start
  1753. * @param from defines the initial value
  1754. * @param to defines the final value
  1755. * @param loop defines if you want animation to loop (off by default)
  1756. * @param speedRatio defines the speed ratio to apply to all animations
  1757. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1758. * @returns the list of animatables created for all nodes
  1759. */
  1760. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1761. /**
  1762. * Gets the animatable associated with a specific target
  1763. * @param target defines the target of the animatable
  1764. * @returns the required animatable if found
  1765. */
  1766. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1767. /**
  1768. * Gets all animatables associated with a given target
  1769. * @param target defines the target to look animatables for
  1770. * @returns an array of Animatables
  1771. */
  1772. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1773. /**
  1774. * Gets all animatable attached to the scene
  1775. */
  1776. readonly animatables: Animatable[];
  1777. /**
  1778. * Will stop the animation of the given target
  1779. * @param target - the target
  1780. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1781. * @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)
  1782. */
  1783. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1784. /**
  1785. * Stops and removes all animations that have been applied to the scene
  1786. */
  1787. stopAllAnimations(): void;
  1788. private _animate;
  1789. /** @hidden */
  1790. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1791. private _processLateAnimationBindingsForMatrices;
  1792. private _processLateAnimationBindingsForQuaternions;
  1793. private _processLateAnimationBindings;
  1794. /** @hidden */
  1795. _switchToAlternateCameraConfiguration(active: boolean): void;
  1796. /**
  1797. * Gets the current view matrix
  1798. * @returns a Matrix
  1799. */
  1800. getViewMatrix(): Matrix;
  1801. /**
  1802. * Gets the current projection matrix
  1803. * @returns a Matrix
  1804. */
  1805. getProjectionMatrix(): Matrix;
  1806. /**
  1807. * Gets the current transform matrix
  1808. * @returns a Matrix made of View * Projection
  1809. */
  1810. getTransformMatrix(): Matrix;
  1811. /**
  1812. * Sets the current transform matrix
  1813. * @param view defines the View matrix to use
  1814. * @param projection defines the Projection matrix to use
  1815. */
  1816. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1817. /** @hidden */
  1818. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1819. /**
  1820. * Gets the uniform buffer used to store scene data
  1821. * @returns a UniformBuffer
  1822. */
  1823. getSceneUniformBuffer(): UniformBuffer;
  1824. /**
  1825. * Gets an unique (relatively to the current scene) Id
  1826. * @returns an unique number for the scene
  1827. */
  1828. getUniqueId(): number;
  1829. /**
  1830. * Add a mesh to the list of scene's meshes
  1831. * @param newMesh defines the mesh to add
  1832. * @param recursive if all child meshes should also be added to the scene
  1833. */
  1834. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1835. /**
  1836. * Remove a mesh for the list of scene's meshes
  1837. * @param toRemove defines the mesh to remove
  1838. * @param recursive if all child meshes should also be removed from the scene
  1839. * @returns the index where the mesh was in the mesh list
  1840. */
  1841. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1842. /**
  1843. * Add a transform node to the list of scene's transform nodes
  1844. * @param newTransformNode defines the transform node to add
  1845. */
  1846. addTransformNode(newTransformNode: TransformNode): void;
  1847. /**
  1848. * Remove a transform node for the list of scene's transform nodes
  1849. * @param toRemove defines the transform node to remove
  1850. * @returns the index where the transform node was in the transform node list
  1851. */
  1852. removeTransformNode(toRemove: TransformNode): number;
  1853. /**
  1854. * Remove a skeleton for the list of scene's skeletons
  1855. * @param toRemove defines the skeleton to remove
  1856. * @returns the index where the skeleton was in the skeleton list
  1857. */
  1858. removeSkeleton(toRemove: Skeleton): number;
  1859. /**
  1860. * Remove a morph target for the list of scene's morph targets
  1861. * @param toRemove defines the morph target to remove
  1862. * @returns the index where the morph target was in the morph target list
  1863. */
  1864. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1865. /**
  1866. * Remove a light for the list of scene's lights
  1867. * @param toRemove defines the light to remove
  1868. * @returns the index where the light was in the light list
  1869. */
  1870. removeLight(toRemove: Light): number;
  1871. /**
  1872. * Remove a camera for the list of scene's cameras
  1873. * @param toRemove defines the camera to remove
  1874. * @returns the index where the camera was in the camera list
  1875. */
  1876. removeCamera(toRemove: Camera): number;
  1877. /**
  1878. * Remove a particle system for the list of scene's particle systems
  1879. * @param toRemove defines the particle system to remove
  1880. * @returns the index where the particle system was in the particle system list
  1881. */
  1882. removeParticleSystem(toRemove: IParticleSystem): number;
  1883. /**
  1884. * Remove a animation for the list of scene's animations
  1885. * @param toRemove defines the animation to remove
  1886. * @returns the index where the animation was in the animation list
  1887. */
  1888. removeAnimation(toRemove: Animation): number;
  1889. /**
  1890. * Removes the given animation group from this scene.
  1891. * @param toRemove The animation group to remove
  1892. * @returns The index of the removed animation group
  1893. */
  1894. removeAnimationGroup(toRemove: AnimationGroup): number;
  1895. /**
  1896. * Removes the given multi-material from this scene.
  1897. * @param toRemove The multi-material to remove
  1898. * @returns The index of the removed multi-material
  1899. */
  1900. removeMultiMaterial(toRemove: MultiMaterial): number;
  1901. /**
  1902. * Removes the given material from this scene.
  1903. * @param toRemove The material to remove
  1904. * @returns The index of the removed material
  1905. */
  1906. removeMaterial(toRemove: Material): number;
  1907. /**
  1908. * Removes the given action manager from this scene.
  1909. * @param toRemove The action manager to remove
  1910. * @returns The index of the removed action manager
  1911. */
  1912. removeActionManager(toRemove: ActionManager): number;
  1913. /**
  1914. * Removes the given texture from this scene.
  1915. * @param toRemove The texture to remove
  1916. * @returns The index of the removed texture
  1917. */
  1918. removeTexture(toRemove: BaseTexture): number;
  1919. /**
  1920. * Adds the given light to this scene
  1921. * @param newLight The light to add
  1922. */
  1923. addLight(newLight: Light): void;
  1924. /**
  1925. * Sorts the list list based on light priorities
  1926. */
  1927. sortLightsByPriority(): void;
  1928. /**
  1929. * Adds the given camera to this scene
  1930. * @param newCamera The camera to add
  1931. */
  1932. addCamera(newCamera: Camera): void;
  1933. /**
  1934. * Adds the given skeleton to this scene
  1935. * @param newSkeleton The skeleton to add
  1936. */
  1937. addSkeleton(newSkeleton: Skeleton): void;
  1938. /**
  1939. * Adds the given particle system to this scene
  1940. * @param newParticleSystem The particle system to add
  1941. */
  1942. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1943. /**
  1944. * Adds the given animation to this scene
  1945. * @param newAnimation The animation to add
  1946. */
  1947. addAnimation(newAnimation: Animation): void;
  1948. /**
  1949. * Adds the given animation group to this scene.
  1950. * @param newAnimationGroup The animation group to add
  1951. */
  1952. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1953. /**
  1954. * Adds the given multi-material to this scene
  1955. * @param newMultiMaterial The multi-material to add
  1956. */
  1957. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1958. /**
  1959. * Adds the given material to this scene
  1960. * @param newMaterial The material to add
  1961. */
  1962. addMaterial(newMaterial: Material): void;
  1963. /**
  1964. * Adds the given morph target to this scene
  1965. * @param newMorphTargetManager The morph target to add
  1966. */
  1967. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1968. /**
  1969. * Adds the given geometry to this scene
  1970. * @param newGeometry The geometry to add
  1971. */
  1972. addGeometry(newGeometry: Geometry): void;
  1973. /**
  1974. * Adds the given action manager to this scene
  1975. * @param newActionManager The action manager to add
  1976. */
  1977. addActionManager(newActionManager: ActionManager): void;
  1978. /**
  1979. * Adds the given texture to this scene.
  1980. * @param newTexture The texture to add
  1981. */
  1982. addTexture(newTexture: BaseTexture): void;
  1983. /**
  1984. * Switch active camera
  1985. * @param newCamera defines the new active camera
  1986. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1987. */
  1988. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1989. /**
  1990. * sets the active camera of the scene using its ID
  1991. * @param id defines the camera's ID
  1992. * @return the new active camera or null if none found.
  1993. */
  1994. setActiveCameraByID(id: string): Nullable<Camera>;
  1995. /**
  1996. * sets the active camera of the scene using its name
  1997. * @param name defines the camera's name
  1998. * @returns the new active camera or null if none found.
  1999. */
  2000. setActiveCameraByName(name: string): Nullable<Camera>;
  2001. /**
  2002. * get an animation group using its name
  2003. * @param name defines the material's name
  2004. * @return the animation group or null if none found.
  2005. */
  2006. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2007. /**
  2008. * get a material using its id
  2009. * @param id defines the material's ID
  2010. * @return the material or null if none found.
  2011. */
  2012. getMaterialByID(id: string): Nullable<Material>;
  2013. /**
  2014. * Gets a material using its name
  2015. * @param name defines the material's name
  2016. * @return the material or null if none found.
  2017. */
  2018. getMaterialByName(name: string): Nullable<Material>;
  2019. /**
  2020. * Gets a camera using its id
  2021. * @param id defines the id to look for
  2022. * @returns the camera or null if not found
  2023. */
  2024. getCameraByID(id: string): Nullable<Camera>;
  2025. /**
  2026. * Gets a camera using its unique id
  2027. * @param uniqueId defines the unique id to look for
  2028. * @returns the camera or null if not found
  2029. */
  2030. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2031. /**
  2032. * Gets a camera using its name
  2033. * @param name defines the camera's name
  2034. * @return the camera or null if none found.
  2035. */
  2036. getCameraByName(name: string): Nullable<Camera>;
  2037. /**
  2038. * Gets a bone using its id
  2039. * @param id defines the bone's id
  2040. * @return the bone or null if not found
  2041. */
  2042. getBoneByID(id: string): Nullable<Bone>;
  2043. /**
  2044. * Gets a bone using its id
  2045. * @param name defines the bone's name
  2046. * @return the bone or null if not found
  2047. */
  2048. getBoneByName(name: string): Nullable<Bone>;
  2049. /**
  2050. * Gets a light node using its name
  2051. * @param name defines the the light's name
  2052. * @return the light or null if none found.
  2053. */
  2054. getLightByName(name: string): Nullable<Light>;
  2055. /**
  2056. * Gets a light node using its id
  2057. * @param id defines the light's id
  2058. * @return the light or null if none found.
  2059. */
  2060. getLightByID(id: string): Nullable<Light>;
  2061. /**
  2062. * Gets a light node using its scene-generated unique ID
  2063. * @param uniqueId defines the light's unique id
  2064. * @return the light or null if none found.
  2065. */
  2066. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2067. /**
  2068. * Gets a particle system by id
  2069. * @param id defines the particle system id
  2070. * @return the corresponding system or null if none found
  2071. */
  2072. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2073. /**
  2074. * Gets a geometry using its ID
  2075. * @param id defines the geometry's id
  2076. * @return the geometry or null if none found.
  2077. */
  2078. getGeometryByID(id: string): Nullable<Geometry>;
  2079. /**
  2080. * Add a new geometry to this scene
  2081. * @param geometry defines the geometry to be added to the scene.
  2082. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2083. * @return a boolean defining if the geometry was added or not
  2084. */
  2085. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2086. /**
  2087. * Removes an existing geometry
  2088. * @param geometry defines the geometry to be removed from the scene
  2089. * @return a boolean defining if the geometry was removed or not
  2090. */
  2091. removeGeometry(geometry: Geometry): boolean;
  2092. /**
  2093. * Gets the list of geometries attached to the scene
  2094. * @returns an array of Geometry
  2095. */
  2096. getGeometries(): Geometry[];
  2097. /**
  2098. * Gets the first added mesh found of a given ID
  2099. * @param id defines the id to search for
  2100. * @return the mesh found or null if not found at all
  2101. */
  2102. getMeshByID(id: string): Nullable<AbstractMesh>;
  2103. /**
  2104. * Gets a list of meshes using their id
  2105. * @param id defines the id to search for
  2106. * @returns a list of meshes
  2107. */
  2108. getMeshesByID(id: string): Array<AbstractMesh>;
  2109. /**
  2110. * Gets the first added transform node found of a given ID
  2111. * @param id defines the id to search for
  2112. * @return the found transform node or null if not found at all.
  2113. */
  2114. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2115. /**
  2116. * Gets a list of transform nodes using their id
  2117. * @param id defines the id to search for
  2118. * @returns a list of transform nodes
  2119. */
  2120. getTransformNodesByID(id: string): Array<TransformNode>;
  2121. /**
  2122. * Gets a mesh with its auto-generated unique id
  2123. * @param uniqueId defines the unique id to search for
  2124. * @return the found mesh or null if not found at all.
  2125. */
  2126. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2127. /**
  2128. * Gets a the last added mesh using a given id
  2129. * @param id defines the id to search for
  2130. * @return the found mesh or null if not found at all.
  2131. */
  2132. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2133. /**
  2134. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2135. * @param id defines the id to search for
  2136. * @return the found node or null if not found at all
  2137. */
  2138. getLastEntryByID(id: string): Nullable<Node>;
  2139. /**
  2140. * Gets a node (Mesh, Camera, Light) using a given id
  2141. * @param id defines the id to search for
  2142. * @return the found node or null if not found at all
  2143. */
  2144. getNodeByID(id: string): Nullable<Node>;
  2145. /**
  2146. * Gets a node (Mesh, Camera, Light) using a given name
  2147. * @param name defines the name to search for
  2148. * @return the found node or null if not found at all.
  2149. */
  2150. getNodeByName(name: string): Nullable<Node>;
  2151. /**
  2152. * Gets a mesh using a given name
  2153. * @param name defines the name to search for
  2154. * @return the found mesh or null if not found at all.
  2155. */
  2156. getMeshByName(name: string): Nullable<AbstractMesh>;
  2157. /**
  2158. * Gets a transform node using a given name
  2159. * @param name defines the name to search for
  2160. * @return the found transform node or null if not found at all.
  2161. */
  2162. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2163. /**
  2164. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2165. * @param id defines the id to search for
  2166. * @return the found skeleton or null if not found at all.
  2167. */
  2168. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2169. /**
  2170. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2171. * @param id defines the id to search for
  2172. * @return the found skeleton or null if not found at all.
  2173. */
  2174. getSkeletonById(id: string): Nullable<Skeleton>;
  2175. /**
  2176. * Gets a skeleton using a given name
  2177. * @param name defines the name to search for
  2178. * @return the found skeleton or null if not found at all.
  2179. */
  2180. getSkeletonByName(name: string): Nullable<Skeleton>;
  2181. /**
  2182. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2183. * @param id defines the id to search for
  2184. * @return the found morph target manager or null if not found at all.
  2185. */
  2186. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2187. /**
  2188. * Gets a boolean indicating if the given mesh is active
  2189. * @param mesh defines the mesh to look for
  2190. * @returns true if the mesh is in the active list
  2191. */
  2192. isActiveMesh(mesh: AbstractMesh): boolean;
  2193. /**
  2194. * Return a unique id as a string which can serve as an identifier for the scene
  2195. */
  2196. readonly uid: string;
  2197. /**
  2198. * Add an externaly attached data from its key.
  2199. * This method call will fail and return false, if such key already exists.
  2200. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2201. * @param key the unique key that identifies the data
  2202. * @param data the data object to associate to the key for this Engine instance
  2203. * @return true if no such key were already present and the data was added successfully, false otherwise
  2204. */
  2205. addExternalData<T>(key: string, data: T): boolean;
  2206. /**
  2207. * Get an externaly attached data from its key
  2208. * @param key the unique key that identifies the data
  2209. * @return the associated data, if present (can be null), or undefined if not present
  2210. */
  2211. getExternalData<T>(key: string): Nullable<T>;
  2212. /**
  2213. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2214. * @param key the unique key that identifies the data
  2215. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2216. * @return the associated data, can be null if the factory returned null.
  2217. */
  2218. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2219. /**
  2220. * Remove an externaly attached data from the Engine instance
  2221. * @param key the unique key that identifies the data
  2222. * @return true if the data was successfully removed, false if it doesn't exist
  2223. */
  2224. removeExternalData(key: string): boolean;
  2225. private _evaluateSubMesh;
  2226. /**
  2227. * Clear the processed materials smart array preventing retention point in material dispose.
  2228. */
  2229. freeProcessedMaterials(): void;
  2230. /**
  2231. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2232. */
  2233. freeActiveMeshes(): void;
  2234. /**
  2235. * Clear the info related to rendering groups preventing retention points during dispose.
  2236. */
  2237. freeRenderingGroups(): void;
  2238. /** @hidden */
  2239. _isInIntermediateRendering(): boolean;
  2240. /**
  2241. * Lambda returning the list of potentially active meshes.
  2242. */
  2243. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2244. /**
  2245. * Lambda returning the list of potentially active sub meshes.
  2246. */
  2247. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2248. /**
  2249. * Lambda returning the list of potentially intersecting sub meshes.
  2250. */
  2251. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2252. /**
  2253. * Lambda returning the list of potentially colliding sub meshes.
  2254. */
  2255. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2256. private _activeMeshesFrozen;
  2257. /**
  2258. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2259. * @returns the current scene
  2260. */
  2261. freezeActiveMeshes(): Scene;
  2262. /**
  2263. * Use this function to restart evaluating active meshes on every frame
  2264. * @returns the current scene
  2265. */
  2266. unfreezeActiveMeshes(): Scene;
  2267. private _evaluateActiveMeshes;
  2268. private _activeMesh;
  2269. /**
  2270. * Update the transform matrix to update from the current active camera
  2271. * @param force defines a boolean used to force the update even if cache is up to date
  2272. */
  2273. updateTransformMatrix(force?: boolean): void;
  2274. /**
  2275. * 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)
  2276. * @param alternateCamera defines the camera to use
  2277. */
  2278. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2279. /** @hidden */
  2280. _allowPostProcessClearColor: boolean;
  2281. private _renderForCamera;
  2282. private _processSubCameras;
  2283. private _checkIntersections;
  2284. /** @hidden */
  2285. _advancePhysicsEngineStep(step: number): void;
  2286. /**
  2287. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2288. */
  2289. getDeterministicFrameTime: () => number;
  2290. /**
  2291. * Render the scene
  2292. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2293. */
  2294. render(updateCameras?: boolean): void;
  2295. /**
  2296. * Freeze all materials
  2297. * A frozen material will not be updatable but should be faster to render
  2298. */
  2299. freezeMaterials(): void;
  2300. /**
  2301. * Unfreeze all materials
  2302. * A frozen material will not be updatable but should be faster to render
  2303. */
  2304. unfreezeMaterials(): void;
  2305. /**
  2306. * Releases all held ressources
  2307. */
  2308. dispose(): void;
  2309. /**
  2310. * Gets if the scene is already disposed
  2311. */
  2312. readonly isDisposed: boolean;
  2313. /**
  2314. * Call this function to reduce memory footprint of the scene.
  2315. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2316. */
  2317. clearCachedVertexData(): void;
  2318. /**
  2319. * This function will remove the local cached buffer data from texture.
  2320. * It will save memory but will prevent the texture from being rebuilt
  2321. */
  2322. cleanCachedTextureBuffer(): void;
  2323. /**
  2324. * Get the world extend vectors with an optional filter
  2325. *
  2326. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2327. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2328. */
  2329. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2330. min: Vector3;
  2331. max: Vector3;
  2332. };
  2333. /**
  2334. * Creates a ray that can be used to pick in the scene
  2335. * @param x defines the x coordinate of the origin (on-screen)
  2336. * @param y defines the y coordinate of the origin (on-screen)
  2337. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2338. * @param camera defines the camera to use for the picking
  2339. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2340. * @returns a Ray
  2341. */
  2342. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2343. /**
  2344. * Creates a ray that can be used to pick in the scene
  2345. * @param x defines the x coordinate of the origin (on-screen)
  2346. * @param y defines the y coordinate of the origin (on-screen)
  2347. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2348. * @param result defines the ray where to store the picking ray
  2349. * @param camera defines the camera to use for the picking
  2350. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2351. * @returns the current scene
  2352. */
  2353. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2354. /**
  2355. * Creates a ray that can be used to pick in the scene
  2356. * @param x defines the x coordinate of the origin (on-screen)
  2357. * @param y defines the y coordinate of the origin (on-screen)
  2358. * @param camera defines the camera to use for the picking
  2359. * @returns a Ray
  2360. */
  2361. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2362. /**
  2363. * Creates a ray that can be used to pick in the scene
  2364. * @param x defines the x coordinate of the origin (on-screen)
  2365. * @param y defines the y coordinate of the origin (on-screen)
  2366. * @param result defines the ray where to store the picking ray
  2367. * @param camera defines the camera to use for the picking
  2368. * @returns the current scene
  2369. */
  2370. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2371. private _internalPick;
  2372. private _internalMultiPick;
  2373. private _tempPickingRay;
  2374. /** Launch a ray to try to pick a mesh in the scene
  2375. * @param x position on screen
  2376. * @param y position on screen
  2377. * @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
  2378. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2379. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2380. * @returns a PickingInfo
  2381. */
  2382. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2383. private _cachedRayForTransform;
  2384. /** Use the given ray to pick a mesh in the scene
  2385. * @param ray The ray to use to pick meshes
  2386. * @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
  2387. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2388. * @returns a PickingInfo
  2389. */
  2390. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2391. /**
  2392. * Launch a ray to try to pick a mesh in the scene
  2393. * @param x X position on screen
  2394. * @param y Y position on screen
  2395. * @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
  2396. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2397. * @returns an array of PickingInfo
  2398. */
  2399. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2400. /**
  2401. * Launch a ray to try to pick a mesh in the scene
  2402. * @param ray Ray to use
  2403. * @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
  2404. * @returns an array of PickingInfo
  2405. */
  2406. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2407. /**
  2408. * Force the value of meshUnderPointer
  2409. * @param mesh defines the mesh to use
  2410. */
  2411. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2412. /**
  2413. * Gets the mesh under the pointer
  2414. * @returns a Mesh or null if no mesh is under the pointer
  2415. */
  2416. getPointerOverMesh(): Nullable<AbstractMesh>;
  2417. /** @hidden */
  2418. _rebuildGeometries(): void;
  2419. /** @hidden */
  2420. _rebuildTextures(): void;
  2421. private _getByTags;
  2422. /**
  2423. * Get a list of meshes by tags
  2424. * @param tagsQuery defines the tags query to use
  2425. * @param forEach defines a predicate used to filter results
  2426. * @returns an array of Mesh
  2427. */
  2428. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2429. /**
  2430. * Get a list of cameras by tags
  2431. * @param tagsQuery defines the tags query to use
  2432. * @param forEach defines a predicate used to filter results
  2433. * @returns an array of Camera
  2434. */
  2435. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2436. /**
  2437. * Get a list of lights by tags
  2438. * @param tagsQuery defines the tags query to use
  2439. * @param forEach defines a predicate used to filter results
  2440. * @returns an array of Light
  2441. */
  2442. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2443. /**
  2444. * Get a list of materials by tags
  2445. * @param tagsQuery defines the tags query to use
  2446. * @param forEach defines a predicate used to filter results
  2447. * @returns an array of Material
  2448. */
  2449. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2450. /**
  2451. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2452. * This allowed control for front to back rendering or reversly depending of the special needs.
  2453. *
  2454. * @param renderingGroupId The rendering group id corresponding to its index
  2455. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2456. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2457. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2458. */
  2459. 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;
  2460. /**
  2461. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2462. *
  2463. * @param renderingGroupId The rendering group id corresponding to its index
  2464. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2465. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2466. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2467. */
  2468. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2469. /**
  2470. * Gets the current auto clear configuration for one rendering group of the rendering
  2471. * manager.
  2472. * @param index the rendering group index to get the information for
  2473. * @returns The auto clear setup for the requested rendering group
  2474. */
  2475. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2476. private _blockMaterialDirtyMechanism;
  2477. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2478. blockMaterialDirtyMechanism: boolean;
  2479. /**
  2480. * Will flag all materials as dirty to trigger new shader compilation
  2481. * @param flag defines the flag used to specify which material part must be marked as dirty
  2482. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2483. */
  2484. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2485. /** @hidden */
  2486. _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;
  2487. /** @hidden */
  2488. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2489. }
  2490. }
  2491. declare module BABYLON {
  2492. /**
  2493. * Groups all the scene component constants in one place to ease maintenance.
  2494. * @hidden
  2495. */
  2496. class SceneComponentConstants {
  2497. static readonly NAME_EFFECTLAYER: string;
  2498. static readonly NAME_LAYER: string;
  2499. static readonly NAME_LENSFLARESYSTEM: string;
  2500. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2501. static readonly NAME_PARTICLESYSTEM: string;
  2502. static readonly NAME_GAMEPAD: string;
  2503. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2504. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2505. static readonly NAME_DEPTHRENDERER: string;
  2506. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2507. static readonly NAME_SPRITE: string;
  2508. static readonly NAME_OUTLINERENDERER: string;
  2509. static readonly NAME_PROCEDURALTEXTURE: string;
  2510. static readonly NAME_SHADOWGENERATOR: string;
  2511. static readonly NAME_OCTREE: string;
  2512. static readonly NAME_PHYSICSENGINE: string;
  2513. static readonly NAME_AUDIO: string;
  2514. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2515. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2516. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2517. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2518. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2519. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2520. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2521. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2522. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2523. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2524. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2525. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2526. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2527. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2528. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2529. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2530. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2531. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2532. static readonly STEP_AFTERRENDER_AUDIO: number;
  2533. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2534. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2535. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2536. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2537. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2538. static readonly STEP_POINTERMOVE_SPRITE: number;
  2539. static readonly STEP_POINTERDOWN_SPRITE: number;
  2540. static readonly STEP_POINTERUP_SPRITE: number;
  2541. }
  2542. /**
  2543. * This represents a scene component.
  2544. *
  2545. * This is used to decouple the dependency the scene is having on the different workloads like
  2546. * layers, post processes...
  2547. */
  2548. interface ISceneComponent {
  2549. /**
  2550. * The name of the component. Each component must have a unique name.
  2551. */
  2552. name: string;
  2553. /**
  2554. * The scene the component belongs to.
  2555. */
  2556. scene: Scene;
  2557. /**
  2558. * Register the component to one instance of a scene.
  2559. */
  2560. register(): void;
  2561. /**
  2562. * Rebuilds the elements related to this component in case of
  2563. * context lost for instance.
  2564. */
  2565. rebuild(): void;
  2566. /**
  2567. * Disposes the component and the associated ressources.
  2568. */
  2569. dispose(): void;
  2570. }
  2571. /**
  2572. * This represents a SERIALIZABLE scene component.
  2573. *
  2574. * This extends Scene Component to add Serialization methods on top.
  2575. */
  2576. interface ISceneSerializableComponent extends ISceneComponent {
  2577. /**
  2578. * Adds all the element from the container to the scene
  2579. * @param container the container holding the elements
  2580. */
  2581. addFromContainer(container: AbstractScene): void;
  2582. /**
  2583. * Removes all the elements in the container from the scene
  2584. * @param container contains the elements to remove
  2585. */
  2586. removeFromContainer(container: AbstractScene): void;
  2587. /**
  2588. * Serializes the component data to the specified json object
  2589. * @param serializationObject The object to serialize to
  2590. */
  2591. serialize(serializationObject: any): void;
  2592. }
  2593. /**
  2594. * Strong typing of a Mesh related stage step action
  2595. */
  2596. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2597. /**
  2598. * Strong typing of a Evaluate Sub Mesh related stage step action
  2599. */
  2600. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2601. /**
  2602. * Strong typing of a Active Mesh related stage step action
  2603. */
  2604. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2605. /**
  2606. * Strong typing of a Camera related stage step action
  2607. */
  2608. type CameraStageAction = (camera: Camera) => void;
  2609. /**
  2610. * Strong typing of a RenderingGroup related stage step action
  2611. */
  2612. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2613. /**
  2614. * Strong typing of a Mesh Render related stage step action
  2615. */
  2616. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2617. /**
  2618. * Strong typing of a simple stage step action
  2619. */
  2620. type SimpleStageAction = () => void;
  2621. /**
  2622. * Strong typing of a render target action.
  2623. */
  2624. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2625. /**
  2626. * Strong typing of a pointer move action.
  2627. */
  2628. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2629. /**
  2630. * Strong typing of a pointer up/down action.
  2631. */
  2632. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2633. /**
  2634. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2635. * @hidden
  2636. */
  2637. class Stage<T extends Function> extends Array<{
  2638. index: number;
  2639. component: ISceneComponent;
  2640. action: T;
  2641. }> {
  2642. /**
  2643. * Hide ctor from the rest of the world.
  2644. * @param items The items to add.
  2645. */
  2646. private constructor();
  2647. /**
  2648. * Creates a new Stage.
  2649. * @returns A new instance of a Stage
  2650. */
  2651. static Create<T extends Function>(): Stage<T>;
  2652. /**
  2653. * Registers a step in an ordered way in the targeted stage.
  2654. * @param index Defines the position to register the step in
  2655. * @param component Defines the component attached to the step
  2656. * @param action Defines the action to launch during the step
  2657. */
  2658. registerStep(index: number, component: ISceneComponent, action: T): void;
  2659. /**
  2660. * Clears all the steps from the stage.
  2661. */
  2662. clear(): void;
  2663. }
  2664. }
  2665. declare module BABYLON {
  2666. /** Alias type for value that can be null */
  2667. type Nullable<T> = T | null;
  2668. /**
  2669. * Alias type for number that are floats
  2670. * @ignorenaming
  2671. */
  2672. type float = number;
  2673. /**
  2674. * Alias type for number that are doubles.
  2675. * @ignorenaming
  2676. */
  2677. type double = number;
  2678. /**
  2679. * Alias type for number that are integer
  2680. * @ignorenaming
  2681. */
  2682. type int = number;
  2683. /** Alias type for number array or Float32Array */
  2684. type FloatArray = number[] | Float32Array;
  2685. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2686. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2687. /**
  2688. * Alias for types that can be used by a Buffer or VertexBuffer.
  2689. */
  2690. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2691. }
  2692. declare module BABYLON {
  2693. /**
  2694. * The action to be carried out following a trigger
  2695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2696. */
  2697. class Action {
  2698. /** the trigger, with or without parameters, for the action */
  2699. triggerOptions: any;
  2700. /**
  2701. * Trigger for the action
  2702. */
  2703. trigger: number;
  2704. /**
  2705. * Internal only - manager for action
  2706. * @hidden
  2707. */
  2708. _actionManager: ActionManager;
  2709. private _nextActiveAction;
  2710. private _child;
  2711. private _condition?;
  2712. private _triggerParameter;
  2713. /**
  2714. * An event triggered prior to action being executed.
  2715. */
  2716. onBeforeExecuteObservable: Observable<Action>;
  2717. /**
  2718. * Creates a new Action
  2719. * @param triggerOptions the trigger, with or without parameters, for the action
  2720. * @param condition an optional determinant of action
  2721. */
  2722. constructor(
  2723. /** the trigger, with or without parameters, for the action */
  2724. triggerOptions: any, condition?: Condition);
  2725. /**
  2726. * Internal only
  2727. * @hidden
  2728. */
  2729. _prepare(): void;
  2730. /**
  2731. * Gets the trigger parameters
  2732. * @returns the trigger parameters
  2733. */
  2734. getTriggerParameter(): any;
  2735. /**
  2736. * Internal only - executes current action event
  2737. * @hidden
  2738. */
  2739. _executeCurrent(evt?: ActionEvent): void;
  2740. /**
  2741. * Execute placeholder for child classes
  2742. * @param evt optional action event
  2743. */
  2744. execute(evt?: ActionEvent): void;
  2745. /**
  2746. * Skips to next active action
  2747. */
  2748. skipToNextActiveAction(): void;
  2749. /**
  2750. * Adds action to chain of actions, may be a DoNothingAction
  2751. * @param action defines the next action to execute
  2752. * @returns The action passed in
  2753. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2754. */
  2755. then(action: Action): Action;
  2756. /**
  2757. * Internal only
  2758. * @hidden
  2759. */
  2760. _getProperty(propertyPath: string): string;
  2761. /**
  2762. * Internal only
  2763. * @hidden
  2764. */
  2765. _getEffectiveTarget(target: any, propertyPath: string): any;
  2766. /**
  2767. * Serialize placeholder for child classes
  2768. * @param parent of child
  2769. * @returns the serialized object
  2770. */
  2771. serialize(parent: any): any;
  2772. /**
  2773. * Internal only called by serialize
  2774. * @hidden
  2775. */
  2776. protected _serialize(serializedAction: any, parent?: any): any;
  2777. /**
  2778. * Internal only
  2779. * @hidden
  2780. */
  2781. static _SerializeValueAsString: (value: any) => string;
  2782. /**
  2783. * Internal only
  2784. * @hidden
  2785. */
  2786. static _GetTargetProperty: (target: Scene | Node) => {
  2787. name: string;
  2788. targetType: string;
  2789. value: string;
  2790. };
  2791. }
  2792. }
  2793. declare module BABYLON {
  2794. /**
  2795. * ActionEvent is the event being sent when an action is triggered.
  2796. */
  2797. class ActionEvent {
  2798. /** The mesh or sprite that triggered the action */
  2799. source: any;
  2800. /** The X mouse cursor position at the time of the event */
  2801. pointerX: number;
  2802. /** The Y mouse cursor position at the time of the event */
  2803. pointerY: number;
  2804. /** The mesh that is currently pointed at (can be null) */
  2805. meshUnderPointer: Nullable<AbstractMesh>;
  2806. /** the original (browser) event that triggered the ActionEvent */
  2807. sourceEvent?: any;
  2808. /** additional data for the event */
  2809. additionalData?: any;
  2810. /**
  2811. * Creates a new ActionEvent
  2812. * @param source The mesh or sprite that triggered the action
  2813. * @param pointerX The X mouse cursor position at the time of the event
  2814. * @param pointerY The Y mouse cursor position at the time of the event
  2815. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2816. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2817. * @param additionalData additional data for the event
  2818. */
  2819. constructor(
  2820. /** The mesh or sprite that triggered the action */
  2821. source: any,
  2822. /** The X mouse cursor position at the time of the event */
  2823. pointerX: number,
  2824. /** The Y mouse cursor position at the time of the event */
  2825. pointerY: number,
  2826. /** The mesh that is currently pointed at (can be null) */
  2827. meshUnderPointer: Nullable<AbstractMesh>,
  2828. /** the original (browser) event that triggered the ActionEvent */
  2829. sourceEvent?: any,
  2830. /** additional data for the event */
  2831. additionalData?: any);
  2832. /**
  2833. * Helper function to auto-create an ActionEvent from a source mesh.
  2834. * @param source The source mesh that triggered the event
  2835. * @param evt The original (browser) event
  2836. * @param additionalData additional data for the event
  2837. * @returns the new ActionEvent
  2838. */
  2839. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2840. /**
  2841. * Helper function to auto-create an ActionEvent from a source sprite
  2842. * @param source The source sprite that triggered the event
  2843. * @param scene Scene associated with the sprite
  2844. * @param evt The original (browser) event
  2845. * @param additionalData additional data for the event
  2846. * @returns the new ActionEvent
  2847. */
  2848. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2849. /**
  2850. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2851. * @param scene the scene where the event occurred
  2852. * @param evt The original (browser) event
  2853. * @returns the new ActionEvent
  2854. */
  2855. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2856. /**
  2857. * Helper function to auto-create an ActionEvent from a primitive
  2858. * @param prim defines the target primitive
  2859. * @param pointerPos defines the pointer position
  2860. * @param evt The original (browser) event
  2861. * @param additionalData additional data for the event
  2862. * @returns the new ActionEvent
  2863. */
  2864. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2865. }
  2866. /**
  2867. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2868. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2870. */
  2871. class ActionManager {
  2872. /**
  2873. * Nothing
  2874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2875. */
  2876. static readonly NothingTrigger: number;
  2877. /**
  2878. * On pick
  2879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2880. */
  2881. static readonly OnPickTrigger: number;
  2882. /**
  2883. * On left pick
  2884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2885. */
  2886. static readonly OnLeftPickTrigger: number;
  2887. /**
  2888. * On right pick
  2889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2890. */
  2891. static readonly OnRightPickTrigger: number;
  2892. /**
  2893. * On center pick
  2894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2895. */
  2896. static readonly OnCenterPickTrigger: number;
  2897. /**
  2898. * On pick down
  2899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2900. */
  2901. static readonly OnPickDownTrigger: number;
  2902. /**
  2903. * On double pick
  2904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2905. */
  2906. static readonly OnDoublePickTrigger: number;
  2907. /**
  2908. * On pick up
  2909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2910. */
  2911. static readonly OnPickUpTrigger: number;
  2912. /**
  2913. * On pick out.
  2914. * This trigger will only be raised if you also declared a OnPickDown
  2915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2916. */
  2917. static readonly OnPickOutTrigger: number;
  2918. /**
  2919. * On long press
  2920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2921. */
  2922. static readonly OnLongPressTrigger: number;
  2923. /**
  2924. * On pointer over
  2925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2926. */
  2927. static readonly OnPointerOverTrigger: number;
  2928. /**
  2929. * On pointer out
  2930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2931. */
  2932. static readonly OnPointerOutTrigger: number;
  2933. /**
  2934. * On every frame
  2935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2936. */
  2937. static readonly OnEveryFrameTrigger: number;
  2938. /**
  2939. * On intersection enter
  2940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2941. */
  2942. static readonly OnIntersectionEnterTrigger: number;
  2943. /**
  2944. * On intersection exit
  2945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2946. */
  2947. static readonly OnIntersectionExitTrigger: number;
  2948. /**
  2949. * On key down
  2950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2951. */
  2952. static readonly OnKeyDownTrigger: number;
  2953. /**
  2954. * On key up
  2955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2956. */
  2957. static readonly OnKeyUpTrigger: number;
  2958. /** Gets the list of active triggers */
  2959. static Triggers: {
  2960. [key: string]: number;
  2961. };
  2962. /** Gets the list of actions */
  2963. actions: Action[];
  2964. /** Gets the cursor to use when hovering items */
  2965. hoverCursor: string;
  2966. private _scene;
  2967. /**
  2968. * Creates a new action manager
  2969. * @param scene defines the hosting scene
  2970. */
  2971. constructor(scene: Scene);
  2972. /**
  2973. * Releases all associated resources
  2974. */
  2975. dispose(): void;
  2976. /**
  2977. * Gets hosting scene
  2978. * @returns the hosting scene
  2979. */
  2980. getScene(): Scene;
  2981. /**
  2982. * Does this action manager handles actions of any of the given triggers
  2983. * @param triggers defines the triggers to be tested
  2984. * @return a boolean indicating whether one (or more) of the triggers is handled
  2985. */
  2986. hasSpecificTriggers(triggers: number[]): boolean;
  2987. /**
  2988. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  2989. * speed.
  2990. * @param triggerA defines the trigger to be tested
  2991. * @param triggerB defines the trigger to be tested
  2992. * @return a boolean indicating whether one (or more) of the triggers is handled
  2993. */
  2994. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  2995. /**
  2996. * Does this action manager handles actions of a given trigger
  2997. * @param trigger defines the trigger to be tested
  2998. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2999. * @return whether the trigger is handled
  3000. */
  3001. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3002. /**
  3003. * Does this action manager has pointer triggers
  3004. */
  3005. readonly hasPointerTriggers: boolean;
  3006. /**
  3007. * Does this action manager has pick triggers
  3008. */
  3009. readonly hasPickTriggers: boolean;
  3010. /**
  3011. * Does exist one action manager with at least one trigger
  3012. **/
  3013. static readonly HasTriggers: boolean;
  3014. /**
  3015. * Does exist one action manager with at least one pick trigger
  3016. **/
  3017. static readonly HasPickTriggers: boolean;
  3018. /**
  3019. * Does exist one action manager that handles actions of a given trigger
  3020. * @param trigger defines the trigger to be tested
  3021. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3022. **/
  3023. static HasSpecificTrigger(trigger: number): boolean;
  3024. /**
  3025. * Registers an action to this action manager
  3026. * @param action defines the action to be registered
  3027. * @return the action amended (prepared) after registration
  3028. */
  3029. registerAction(action: Action): Nullable<Action>;
  3030. /**
  3031. * Unregisters an action to this action manager
  3032. * @param action defines the action to be unregistered
  3033. * @return a boolean indicating whether the action has been unregistered
  3034. */
  3035. unregisterAction(action: Action): Boolean;
  3036. /**
  3037. * Process a specific trigger
  3038. * @param trigger defines the trigger to process
  3039. * @param evt defines the event details to be processed
  3040. */
  3041. processTrigger(trigger: number, evt?: ActionEvent): void;
  3042. /** @hidden */
  3043. _getEffectiveTarget(target: any, propertyPath: string): any;
  3044. /** @hidden */
  3045. _getProperty(propertyPath: string): string;
  3046. /**
  3047. * Serialize this manager to a JSON object
  3048. * @param name defines the property name to store this manager
  3049. * @returns a JSON representation of this manager
  3050. */
  3051. serialize(name: string): any;
  3052. /**
  3053. * Creates a new ActionManager from a JSON data
  3054. * @param parsedActions defines the JSON data to read from
  3055. * @param object defines the hosting mesh
  3056. * @param scene defines the hosting scene
  3057. */
  3058. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3059. /**
  3060. * Get a trigger name by index
  3061. * @param trigger defines the trigger index
  3062. * @returns a trigger name
  3063. */
  3064. static GetTriggerName(trigger: number): string;
  3065. }
  3066. }
  3067. declare module BABYLON {
  3068. /**
  3069. * A Condition applied to an Action
  3070. */
  3071. class Condition {
  3072. /**
  3073. * Internal only - manager for action
  3074. * @hidden
  3075. */
  3076. _actionManager: ActionManager;
  3077. /**
  3078. * Internal only
  3079. * @hidden
  3080. */
  3081. _evaluationId: number;
  3082. /**
  3083. * Internal only
  3084. * @hidden
  3085. */
  3086. _currentResult: boolean;
  3087. /**
  3088. * Creates a new Condition
  3089. * @param actionManager the manager of the action the condition is applied to
  3090. */
  3091. constructor(actionManager: ActionManager);
  3092. /**
  3093. * Check if the current condition is valid
  3094. * @returns a boolean
  3095. */
  3096. isValid(): boolean;
  3097. /**
  3098. * Internal only
  3099. * @hidden
  3100. */
  3101. _getProperty(propertyPath: string): string;
  3102. /**
  3103. * Internal only
  3104. * @hidden
  3105. */
  3106. _getEffectiveTarget(target: any, propertyPath: string): any;
  3107. /**
  3108. * Serialize placeholder for child classes
  3109. * @returns the serialized object
  3110. */
  3111. serialize(): any;
  3112. /**
  3113. * Internal only
  3114. * @hidden
  3115. */
  3116. protected _serialize(serializedCondition: any): any;
  3117. }
  3118. /**
  3119. * Defines specific conditional operators as extensions of Condition
  3120. */
  3121. class ValueCondition extends Condition {
  3122. /** path to specify the property of the target the conditional operator uses */
  3123. propertyPath: string;
  3124. /** the value compared by the conditional operator against the current value of the property */
  3125. value: any;
  3126. /** the conditional operator, default ValueCondition.IsEqual */
  3127. operator: number;
  3128. /**
  3129. * Internal only
  3130. * @hidden
  3131. */
  3132. private static _IsEqual;
  3133. /**
  3134. * Internal only
  3135. * @hidden
  3136. */
  3137. private static _IsDifferent;
  3138. /**
  3139. * Internal only
  3140. * @hidden
  3141. */
  3142. private static _IsGreater;
  3143. /**
  3144. * Internal only
  3145. * @hidden
  3146. */
  3147. private static _IsLesser;
  3148. /**
  3149. * returns the number for IsEqual
  3150. */
  3151. static readonly IsEqual: number;
  3152. /**
  3153. * Returns the number for IsDifferent
  3154. */
  3155. static readonly IsDifferent: number;
  3156. /**
  3157. * Returns the number for IsGreater
  3158. */
  3159. static readonly IsGreater: number;
  3160. /**
  3161. * Returns the number for IsLesser
  3162. */
  3163. static readonly IsLesser: number;
  3164. /**
  3165. * Internal only The action manager for the condition
  3166. * @hidden
  3167. */
  3168. _actionManager: ActionManager;
  3169. /**
  3170. * Internal only
  3171. * @hidden
  3172. */
  3173. private _target;
  3174. /**
  3175. * Internal only
  3176. * @hidden
  3177. */
  3178. private _effectiveTarget;
  3179. /**
  3180. * Internal only
  3181. * @hidden
  3182. */
  3183. private _property;
  3184. /**
  3185. * Creates a new ValueCondition
  3186. * @param actionManager manager for the action the condition applies to
  3187. * @param target for the action
  3188. * @param propertyPath path to specify the property of the target the conditional operator uses
  3189. * @param value the value compared by the conditional operator against the current value of the property
  3190. * @param operator the conditional operator, default ValueCondition.IsEqual
  3191. */
  3192. constructor(actionManager: ActionManager, target: any,
  3193. /** path to specify the property of the target the conditional operator uses */
  3194. propertyPath: string,
  3195. /** the value compared by the conditional operator against the current value of the property */
  3196. value: any,
  3197. /** the conditional operator, default ValueCondition.IsEqual */
  3198. operator?: number);
  3199. /**
  3200. * Compares the given value with the property value for the specified conditional operator
  3201. * @returns the result of the comparison
  3202. */
  3203. isValid(): boolean;
  3204. /**
  3205. * Serialize the ValueCondition into a JSON compatible object
  3206. * @returns serialization object
  3207. */
  3208. serialize(): any;
  3209. /**
  3210. * Gets the name of the conditional operator for the ValueCondition
  3211. * @param operator the conditional operator
  3212. * @returns the name
  3213. */
  3214. static GetOperatorName(operator: number): string;
  3215. }
  3216. /**
  3217. * Defines a predicate condition as an extension of Condition
  3218. */
  3219. class PredicateCondition extends Condition {
  3220. /** defines the predicate function used to validate the condition */
  3221. predicate: () => boolean;
  3222. /**
  3223. * Internal only - manager for action
  3224. * @hidden
  3225. */
  3226. _actionManager: ActionManager;
  3227. /**
  3228. * Creates a new PredicateCondition
  3229. * @param actionManager manager for the action the condition applies to
  3230. * @param predicate defines the predicate function used to validate the condition
  3231. */
  3232. constructor(actionManager: ActionManager,
  3233. /** defines the predicate function used to validate the condition */
  3234. predicate: () => boolean);
  3235. /**
  3236. * @returns the validity of the predicate condition
  3237. */
  3238. isValid(): boolean;
  3239. }
  3240. /**
  3241. * Defines a state condition as an extension of Condition
  3242. */
  3243. class StateCondition extends Condition {
  3244. /** Value to compare with target state */
  3245. value: string;
  3246. /**
  3247. * Internal only - manager for action
  3248. * @hidden
  3249. */
  3250. _actionManager: ActionManager;
  3251. /**
  3252. * Internal only
  3253. * @hidden
  3254. */
  3255. private _target;
  3256. /**
  3257. * Creates a new StateCondition
  3258. * @param actionManager manager for the action the condition applies to
  3259. * @param target of the condition
  3260. * @param value to compare with target state
  3261. */
  3262. constructor(actionManager: ActionManager, target: any,
  3263. /** Value to compare with target state */
  3264. value: string);
  3265. /**
  3266. * Gets a boolean indicating if the current condition is met
  3267. * @returns the validity of the state
  3268. */
  3269. isValid(): boolean;
  3270. /**
  3271. * Serialize the StateCondition into a JSON compatible object
  3272. * @returns serialization object
  3273. */
  3274. serialize(): any;
  3275. }
  3276. }
  3277. declare module BABYLON {
  3278. /**
  3279. * This defines an action responsible to toggle a boolean once triggered.
  3280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3281. */
  3282. class SwitchBooleanAction extends Action {
  3283. /**
  3284. * The path to the boolean property in the target object
  3285. */
  3286. propertyPath: string;
  3287. private _target;
  3288. private _effectiveTarget;
  3289. private _property;
  3290. /**
  3291. * Instantiate the action
  3292. * @param triggerOptions defines the trigger options
  3293. * @param target defines the object containing the boolean
  3294. * @param propertyPath defines the path to the boolean property in the target object
  3295. * @param condition defines the trigger related conditions
  3296. */
  3297. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3298. /** @hidden */
  3299. _prepare(): void;
  3300. /**
  3301. * Execute the action toggle the boolean value.
  3302. */
  3303. execute(): void;
  3304. /**
  3305. * Serializes the actions and its related information.
  3306. * @param parent defines the object to serialize in
  3307. * @returns the serialized object
  3308. */
  3309. serialize(parent: any): any;
  3310. }
  3311. /**
  3312. * This defines an action responsible to set a the state field of the target
  3313. * to a desired value once triggered.
  3314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3315. */
  3316. class SetStateAction extends Action {
  3317. /**
  3318. * The value to store in the state field.
  3319. */
  3320. value: string;
  3321. private _target;
  3322. /**
  3323. * Instantiate the action
  3324. * @param triggerOptions defines the trigger options
  3325. * @param target defines the object containing the state property
  3326. * @param value defines the value to store in the state field
  3327. * @param condition defines the trigger related conditions
  3328. */
  3329. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3330. /**
  3331. * Execute the action and store the value on the target state property.
  3332. */
  3333. execute(): void;
  3334. /**
  3335. * Serializes the actions and its related information.
  3336. * @param parent defines the object to serialize in
  3337. * @returns the serialized object
  3338. */
  3339. serialize(parent: any): any;
  3340. }
  3341. /**
  3342. * This defines an action responsible to set a property of the target
  3343. * to a desired value once triggered.
  3344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3345. */
  3346. class SetValueAction extends Action {
  3347. /**
  3348. * The path of the property to set in the target.
  3349. */
  3350. propertyPath: string;
  3351. /**
  3352. * The value to set in the property
  3353. */
  3354. value: any;
  3355. private _target;
  3356. private _effectiveTarget;
  3357. private _property;
  3358. /**
  3359. * Instantiate the action
  3360. * @param triggerOptions defines the trigger options
  3361. * @param target defines the object containing the property
  3362. * @param propertyPath defines the path of the property to set in the target
  3363. * @param value defines the value to set in the property
  3364. * @param condition defines the trigger related conditions
  3365. */
  3366. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3367. /** @hidden */
  3368. _prepare(): void;
  3369. /**
  3370. * Execute the action and set the targetted property to the desired value.
  3371. */
  3372. execute(): void;
  3373. /**
  3374. * Serializes the actions and its related information.
  3375. * @param parent defines the object to serialize in
  3376. * @returns the serialized object
  3377. */
  3378. serialize(parent: any): any;
  3379. }
  3380. /**
  3381. * This defines an action responsible to increment the target value
  3382. * to a desired value once triggered.
  3383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3384. */
  3385. class IncrementValueAction extends Action {
  3386. /**
  3387. * The path of the property to increment in the target.
  3388. */
  3389. propertyPath: string;
  3390. /**
  3391. * The value we should increment the property by.
  3392. */
  3393. value: any;
  3394. private _target;
  3395. private _effectiveTarget;
  3396. private _property;
  3397. /**
  3398. * Instantiate the action
  3399. * @param triggerOptions defines the trigger options
  3400. * @param target defines the object containing the property
  3401. * @param propertyPath defines the path of the property to increment in the target
  3402. * @param value defines the value value we should increment the property by
  3403. * @param condition defines the trigger related conditions
  3404. */
  3405. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3406. /** @hidden */
  3407. _prepare(): void;
  3408. /**
  3409. * Execute the action and increment the target of the value amount.
  3410. */
  3411. execute(): void;
  3412. /**
  3413. * Serializes the actions and its related information.
  3414. * @param parent defines the object to serialize in
  3415. * @returns the serialized object
  3416. */
  3417. serialize(parent: any): any;
  3418. }
  3419. /**
  3420. * This defines an action responsible to start an animation once triggered.
  3421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3422. */
  3423. class PlayAnimationAction extends Action {
  3424. /**
  3425. * Where the animation should start (animation frame)
  3426. */
  3427. from: number;
  3428. /**
  3429. * Where the animation should stop (animation frame)
  3430. */
  3431. to: number;
  3432. /**
  3433. * Define if the animation should loop or stop after the first play.
  3434. */
  3435. loop?: boolean;
  3436. private _target;
  3437. /**
  3438. * Instantiate the action
  3439. * @param triggerOptions defines the trigger options
  3440. * @param target defines the target animation or animation name
  3441. * @param from defines from where the animation should start (animation frame)
  3442. * @param end defines where the animation should stop (animation frame)
  3443. * @param loop defines if the animation should loop or stop after the first play
  3444. * @param condition defines the trigger related conditions
  3445. */
  3446. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3447. /** @hidden */
  3448. _prepare(): void;
  3449. /**
  3450. * Execute the action and play the animation.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to stop an animation once triggered.
  3462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3463. */
  3464. class StopAnimationAction extends Action {
  3465. private _target;
  3466. /**
  3467. * Instantiate the action
  3468. * @param triggerOptions defines the trigger options
  3469. * @param target defines the target animation or animation name
  3470. * @param condition defines the trigger related conditions
  3471. */
  3472. constructor(triggerOptions: any, target: any, condition?: Condition);
  3473. /** @hidden */
  3474. _prepare(): void;
  3475. /**
  3476. * Execute the action and stop the animation.
  3477. */
  3478. execute(): void;
  3479. /**
  3480. * Serializes the actions and its related information.
  3481. * @param parent defines the object to serialize in
  3482. * @returns the serialized object
  3483. */
  3484. serialize(parent: any): any;
  3485. }
  3486. /**
  3487. * This defines an action responsible that does nothing once triggered.
  3488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3489. */
  3490. class DoNothingAction extends Action {
  3491. /**
  3492. * Instantiate the action
  3493. * @param triggerOptions defines the trigger options
  3494. * @param condition defines the trigger related conditions
  3495. */
  3496. constructor(triggerOptions?: any, condition?: Condition);
  3497. /**
  3498. * Execute the action and do nothing.
  3499. */
  3500. execute(): void;
  3501. /**
  3502. * Serializes the actions and its related information.
  3503. * @param parent defines the object to serialize in
  3504. * @returns the serialized object
  3505. */
  3506. serialize(parent: any): any;
  3507. }
  3508. /**
  3509. * This defines an action responsible to trigger several actions once triggered.
  3510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3511. */
  3512. class CombineAction extends Action {
  3513. /**
  3514. * The list of aggregated animations to run.
  3515. */
  3516. children: Action[];
  3517. /**
  3518. * Instantiate the action
  3519. * @param triggerOptions defines the trigger options
  3520. * @param children defines the list of aggregated animations to run
  3521. * @param condition defines the trigger related conditions
  3522. */
  3523. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3524. /** @hidden */
  3525. _prepare(): void;
  3526. /**
  3527. * Execute the action and executes all the aggregated actions.
  3528. */
  3529. execute(evt: ActionEvent): void;
  3530. /**
  3531. * Serializes the actions and its related information.
  3532. * @param parent defines the object to serialize in
  3533. * @returns the serialized object
  3534. */
  3535. serialize(parent: any): any;
  3536. }
  3537. /**
  3538. * This defines an action responsible to run code (external event) once triggered.
  3539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3540. */
  3541. class ExecuteCodeAction extends Action {
  3542. /**
  3543. * The callback function to run.
  3544. */
  3545. func: (evt: ActionEvent) => void;
  3546. /**
  3547. * Instantiate the action
  3548. * @param triggerOptions defines the trigger options
  3549. * @param func defines the callback function to run
  3550. * @param condition defines the trigger related conditions
  3551. */
  3552. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3553. /**
  3554. * Execute the action and run the attached code.
  3555. */
  3556. execute(evt: ActionEvent): void;
  3557. }
  3558. /**
  3559. * This defines an action responsible to set the parent property of the target once triggered.
  3560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3561. */
  3562. class SetParentAction extends Action {
  3563. private _parent;
  3564. private _target;
  3565. /**
  3566. * Instantiate the action
  3567. * @param triggerOptions defines the trigger options
  3568. * @param target defines the target containing the parent property
  3569. * @param parent defines from where the animation should start (animation frame)
  3570. * @param condition defines the trigger related conditions
  3571. */
  3572. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3573. /** @hidden */
  3574. _prepare(): void;
  3575. /**
  3576. * Execute the action and set the parent property.
  3577. */
  3578. execute(): void;
  3579. /**
  3580. * Serializes the actions and its related information.
  3581. * @param parent defines the object to serialize in
  3582. * @returns the serialized object
  3583. */
  3584. serialize(parent: any): any;
  3585. }
  3586. }
  3587. declare module BABYLON {
  3588. /**
  3589. * This defines an action helpful to play a defined sound on a triggered action.
  3590. */
  3591. class PlaySoundAction extends Action {
  3592. private _sound;
  3593. /**
  3594. * Instantiate the action
  3595. * @param triggerOptions defines the trigger options
  3596. * @param sound defines the sound to play
  3597. * @param condition defines the trigger related conditions
  3598. */
  3599. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3600. /** @hidden */
  3601. _prepare(): void;
  3602. /**
  3603. * Execute the action and play the sound.
  3604. */
  3605. execute(): void;
  3606. /**
  3607. * Serializes the actions and its related information.
  3608. * @param parent defines the object to serialize in
  3609. * @returns the serialized object
  3610. */
  3611. serialize(parent: any): any;
  3612. }
  3613. /**
  3614. * This defines an action helpful to stop a defined sound on a triggered action.
  3615. */
  3616. class StopSoundAction extends Action {
  3617. private _sound;
  3618. /**
  3619. * Instantiate the action
  3620. * @param triggerOptions defines the trigger options
  3621. * @param sound defines the sound to stop
  3622. * @param condition defines the trigger related conditions
  3623. */
  3624. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3625. /** @hidden */
  3626. _prepare(): void;
  3627. /**
  3628. * Execute the action and stop the sound.
  3629. */
  3630. execute(): void;
  3631. /**
  3632. * Serializes the actions and its related information.
  3633. * @param parent defines the object to serialize in
  3634. * @returns the serialized object
  3635. */
  3636. serialize(parent: any): any;
  3637. }
  3638. }
  3639. declare module BABYLON {
  3640. /**
  3641. * This defines an action responsible to change the value of a property
  3642. * by interpolating between its current value and the newly set one once triggered.
  3643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3644. */
  3645. class InterpolateValueAction extends Action {
  3646. /**
  3647. * Defines the path of the property where the value should be interpolated
  3648. */
  3649. propertyPath: string;
  3650. /**
  3651. * Defines the target value at the end of the interpolation.
  3652. */
  3653. value: any;
  3654. /**
  3655. * Defines the time it will take for the property to interpolate to the value.
  3656. */
  3657. duration: number;
  3658. /**
  3659. * Defines if the other scene animations should be stopped when the action has been triggered
  3660. */
  3661. stopOtherAnimations?: boolean;
  3662. /**
  3663. * Defines a callback raised once the interpolation animation has been done.
  3664. */
  3665. onInterpolationDone?: () => void;
  3666. /**
  3667. * Observable triggered once the interpolation animation has been done.
  3668. */
  3669. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3670. private _target;
  3671. private _effectiveTarget;
  3672. private _property;
  3673. /**
  3674. * Instantiate the action
  3675. * @param triggerOptions defines the trigger options
  3676. * @param target defines the object containing the value to interpolate
  3677. * @param propertyPath defines the path to the property in the target object
  3678. * @param value defines the target value at the end of the interpolation
  3679. * @param duration deines the time it will take for the property to interpolate to the value.
  3680. * @param condition defines the trigger related conditions
  3681. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3682. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3683. */
  3684. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3685. /** @hidden */
  3686. _prepare(): void;
  3687. /**
  3688. * Execute the action starts the value interpolation.
  3689. */
  3690. execute(): void;
  3691. /**
  3692. * Serializes the actions and its related information.
  3693. * @param parent defines the object to serialize in
  3694. * @returns the serialized object
  3695. */
  3696. serialize(parent: any): any;
  3697. }
  3698. }
  3699. declare module BABYLON {
  3700. /**
  3701. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3703. */
  3704. class Analyser {
  3705. /**
  3706. * Gets or sets the smoothing
  3707. * @ignorenaming
  3708. */
  3709. SMOOTHING: number;
  3710. /**
  3711. * Gets or sets the FFT table size
  3712. * @ignorenaming
  3713. */
  3714. FFT_SIZE: number;
  3715. /**
  3716. * Gets or sets the bar graph amplitude
  3717. * @ignorenaming
  3718. */
  3719. BARGRAPHAMPLITUDE: number;
  3720. /**
  3721. * Gets or sets the position of the debug canvas
  3722. * @ignorenaming
  3723. */
  3724. DEBUGCANVASPOS: {
  3725. x: number;
  3726. y: number;
  3727. };
  3728. /**
  3729. * Gets or sets the debug canvas size
  3730. * @ignorenaming
  3731. */
  3732. DEBUGCANVASSIZE: {
  3733. width: number;
  3734. height: number;
  3735. };
  3736. private _byteFreqs;
  3737. private _byteTime;
  3738. private _floatFreqs;
  3739. private _webAudioAnalyser;
  3740. private _debugCanvas;
  3741. private _debugCanvasContext;
  3742. private _scene;
  3743. private _registerFunc;
  3744. private _audioEngine;
  3745. /**
  3746. * Creates a new analyser
  3747. * @param scene defines hosting scene
  3748. */
  3749. constructor(scene: Scene);
  3750. /**
  3751. * Get the number of data values you will have to play with for the visualization
  3752. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3753. * @returns a number
  3754. */
  3755. getFrequencyBinCount(): number;
  3756. /**
  3757. * Gets the current frequency data as a byte array
  3758. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3759. * @returns a Uint8Array
  3760. */
  3761. getByteFrequencyData(): Uint8Array;
  3762. /**
  3763. * Gets the current waveform as a byte array
  3764. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3765. * @returns a Uint8Array
  3766. */
  3767. getByteTimeDomainData(): Uint8Array;
  3768. /**
  3769. * Gets the current frequency data as a float array
  3770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3771. * @returns a Float32Array
  3772. */
  3773. getFloatFrequencyData(): Float32Array;
  3774. /**
  3775. * Renders the debug canvas
  3776. */
  3777. drawDebugCanvas(): void;
  3778. /**
  3779. * Stops rendering the debug canvas and removes it
  3780. */
  3781. stopDebugCanvas(): void;
  3782. /**
  3783. * Connects two audio nodes
  3784. * @param inputAudioNode defines first node to connect
  3785. * @param outputAudioNode defines second node to connect
  3786. */
  3787. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3788. /**
  3789. * Releases all associated resources
  3790. */
  3791. dispose(): void;
  3792. }
  3793. }
  3794. declare module BABYLON {
  3795. /**
  3796. * This represents an audio engine and it is responsible
  3797. * to play, synchronize and analyse sounds throughout the application.
  3798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3799. */
  3800. interface IAudioEngine extends IDisposable {
  3801. /**
  3802. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3803. */
  3804. readonly canUseWebAudio: boolean;
  3805. /**
  3806. * Gets the current AudioContext if available.
  3807. */
  3808. readonly audioContext: Nullable<AudioContext>;
  3809. /**
  3810. * The master gain node defines the global audio volume of your audio engine.
  3811. */
  3812. readonly masterGain: GainNode;
  3813. /**
  3814. * Gets whether or not mp3 are supported by your browser.
  3815. */
  3816. readonly isMP3supported: boolean;
  3817. /**
  3818. * Gets whether or not ogg are supported by your browser.
  3819. */
  3820. readonly isOGGsupported: boolean;
  3821. /**
  3822. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3823. * @ignoreNaming
  3824. */
  3825. WarnedWebAudioUnsupported: boolean;
  3826. /**
  3827. * Defines if the audio engine relies on a custom unlocked button.
  3828. * In this case, the embedded button will not be displayed.
  3829. */
  3830. useCustomUnlockedButton: boolean;
  3831. /**
  3832. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  3833. */
  3834. readonly unlocked: boolean;
  3835. /**
  3836. * Event raised when audio has been unlocked on the browser.
  3837. */
  3838. onAudioUnlockedObservable: Observable<AudioEngine>;
  3839. /**
  3840. * Event raised when audio has been locked on the browser.
  3841. */
  3842. onAudioLockedObservable: Observable<AudioEngine>;
  3843. /**
  3844. * Flags the audio engine in Locked state.
  3845. * This happens due to new browser policies preventing audio to autoplay.
  3846. */
  3847. lock(): void;
  3848. /**
  3849. * Unlocks the audio engine once a user action has been done on the dom.
  3850. * This is helpful to resume play once browser policies have been satisfied.
  3851. */
  3852. unlock(): void;
  3853. }
  3854. /**
  3855. * This represents the default audio engine used in babylon.
  3856. * It is responsible to play, synchronize and analyse sounds throughout the application.
  3857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3858. */
  3859. class AudioEngine implements IAudioEngine {
  3860. private _audioContext;
  3861. private _audioContextInitialized;
  3862. private _muteButton;
  3863. private _hostElement;
  3864. /**
  3865. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  3866. */
  3867. canUseWebAudio: boolean;
  3868. /**
  3869. * The master gain node defines the global audio volume of your audio engine.
  3870. */
  3871. masterGain: GainNode;
  3872. /**
  3873. * Defines if Babylon should emit a warning if WebAudio is not supported.
  3874. * @ignoreNaming
  3875. */
  3876. WarnedWebAudioUnsupported: boolean;
  3877. /**
  3878. * Gets whether or not mp3 are supported by your browser.
  3879. */
  3880. isMP3supported: boolean;
  3881. /**
  3882. * Gets whether or not ogg are supported by your browser.
  3883. */
  3884. isOGGsupported: boolean;
  3885. /**
  3886. * Gets whether audio has been unlocked on the device.
  3887. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  3888. * a user interaction has happened.
  3889. */
  3890. unlocked: boolean;
  3891. /**
  3892. * Defines if the audio engine relies on a custom unlocked button.
  3893. * In this case, the embedded button will not be displayed.
  3894. */
  3895. useCustomUnlockedButton: boolean;
  3896. /**
  3897. * Event raised when audio has been unlocked on the browser.
  3898. */
  3899. onAudioUnlockedObservable: Observable<AudioEngine>;
  3900. /**
  3901. * Event raised when audio has been locked on the browser.
  3902. */
  3903. onAudioLockedObservable: Observable<AudioEngine>;
  3904. /**
  3905. * Gets the current AudioContext if available.
  3906. */
  3907. readonly audioContext: Nullable<AudioContext>;
  3908. private _connectedAnalyser;
  3909. /**
  3910. * Instantiates a new audio engine.
  3911. *
  3912. * There should be only one per page as some browsers restrict the number
  3913. * of audio contexts you can create.
  3914. * @param hostElement defines the host element where to display the mute icon if necessary
  3915. */
  3916. constructor(hostElement?: Nullable<HTMLElement>);
  3917. /**
  3918. * Flags the audio engine in Locked state.
  3919. * This happens due to new browser policies preventing audio to autoplay.
  3920. */
  3921. lock(): void;
  3922. /**
  3923. * Unlocks the audio engine once a user action has been done on the dom.
  3924. * This is helpful to resume play once browser policies have been satisfied.
  3925. */
  3926. unlock(): void;
  3927. private _resumeAudioContext;
  3928. private _initializeAudioContext;
  3929. private _tryToRun;
  3930. private _triggerRunningState;
  3931. private _triggerSuspendedState;
  3932. private _displayMuteButton;
  3933. private _moveButtonToTopLeft;
  3934. private _onResize;
  3935. private _hideMuteButton;
  3936. /**
  3937. * Destroy and release the resources associated with the audio ccontext.
  3938. */
  3939. dispose(): void;
  3940. /**
  3941. * Gets the global volume sets on the master gain.
  3942. * @returns the global volume if set or -1 otherwise
  3943. */
  3944. getGlobalVolume(): number;
  3945. /**
  3946. * Sets the global volume of your experience (sets on the master gain).
  3947. * @param newVolume Defines the new global volume of the application
  3948. */
  3949. setGlobalVolume(newVolume: number): void;
  3950. /**
  3951. * Connect the audio engine to an audio analyser allowing some amazing
  3952. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  3953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  3954. * @param analyser The analyser to connect to the engine
  3955. */
  3956. connectToAnalyser(analyser: Analyser): void;
  3957. }
  3958. }
  3959. declare module BABYLON {
  3960. interface AbstractScene {
  3961. /**
  3962. * The list of sounds used in the scene.
  3963. */
  3964. sounds: Nullable<Array<Sound>>;
  3965. }
  3966. interface Scene {
  3967. /**
  3968. * @hidden
  3969. * Backing field
  3970. */
  3971. _mainSoundTrack: SoundTrack;
  3972. /**
  3973. * The main sound track played by the scene.
  3974. * It cotains your primary collection of sounds.
  3975. */
  3976. mainSoundTrack: SoundTrack;
  3977. /**
  3978. * The list of sound tracks added to the scene
  3979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3980. */
  3981. soundTracks: Nullable<Array<SoundTrack>>;
  3982. /**
  3983. * Gets a sound using a given name
  3984. * @param name defines the name to search for
  3985. * @return the found sound or null if not found at all.
  3986. */
  3987. getSoundByName(name: string): Nullable<Sound>;
  3988. /**
  3989. * Gets or sets if audio support is enabled
  3990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3991. */
  3992. audioEnabled: boolean;
  3993. /**
  3994. * Gets or sets if audio will be output to headphones
  3995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3996. */
  3997. headphone: boolean;
  3998. }
  3999. /**
  4000. * Defines the sound scene component responsible to manage any sounds
  4001. * in a given scene.
  4002. */
  4003. class AudioSceneComponent implements ISceneSerializableComponent {
  4004. /**
  4005. * The component name helpfull to identify the component in the list of scene components.
  4006. */
  4007. readonly name: string;
  4008. /**
  4009. * The scene the component belongs to.
  4010. */
  4011. scene: Scene;
  4012. private _audioEnabled;
  4013. /**
  4014. * Gets whether audio is enabled or not.
  4015. * Please use related enable/disable method to switch state.
  4016. */
  4017. readonly audioEnabled: boolean;
  4018. private _headphone;
  4019. /**
  4020. * Gets whether audio is outputing to headphone or not.
  4021. * Please use the according Switch methods to change output.
  4022. */
  4023. readonly headphone: boolean;
  4024. /**
  4025. * Creates a new instance of the component for the given scene
  4026. * @param scene Defines the scene to register the component in
  4027. */
  4028. constructor(scene: Scene);
  4029. /**
  4030. * Registers the component in a given scene
  4031. */
  4032. register(): void;
  4033. /**
  4034. * Rebuilds the elements related to this component in case of
  4035. * context lost for instance.
  4036. */
  4037. rebuild(): void;
  4038. /**
  4039. * Serializes the component data to the specified json object
  4040. * @param serializationObject The object to serialize to
  4041. */
  4042. serialize(serializationObject: any): void;
  4043. /**
  4044. * Adds all the element from the container to the scene
  4045. * @param container the container holding the elements
  4046. */
  4047. addFromContainer(container: AbstractScene): void;
  4048. /**
  4049. * Removes all the elements in the container from the scene
  4050. * @param container contains the elements to remove
  4051. */
  4052. removeFromContainer(container: AbstractScene): void;
  4053. /**
  4054. * Disposes the component and the associated ressources.
  4055. */
  4056. dispose(): void;
  4057. /**
  4058. * Disables audio in the associated scene.
  4059. */
  4060. disableAudio(): void;
  4061. /**
  4062. * Enables audio in the associated scene.
  4063. */
  4064. enableAudio(): void;
  4065. /**
  4066. * Switch audio to headphone output.
  4067. */
  4068. switchAudioModeForHeadphones(): void;
  4069. /**
  4070. * Switch audio to normal speakers.
  4071. */
  4072. switchAudioModeForNormalSpeakers(): void;
  4073. private _afterRender;
  4074. }
  4075. }
  4076. declare module BABYLON {
  4077. /**
  4078. * Defines a sound that can be played in the application.
  4079. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  4080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  4081. */
  4082. class Sound {
  4083. /**
  4084. * The name of the sound in the scene.
  4085. */
  4086. name: string;
  4087. /**
  4088. * Does the sound autoplay once loaded.
  4089. */
  4090. autoplay: boolean;
  4091. /**
  4092. * Does the sound loop after it finishes playing once.
  4093. */
  4094. loop: boolean;
  4095. /**
  4096. * Does the sound use a custom attenuation curve to simulate the falloff
  4097. * happening when the source gets further away from the camera.
  4098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4099. */
  4100. useCustomAttenuation: boolean;
  4101. /**
  4102. * The sound track id this sound belongs to.
  4103. */
  4104. soundTrackId: number;
  4105. /**
  4106. * Is this sound currently played.
  4107. */
  4108. isPlaying: boolean;
  4109. /**
  4110. * Is this sound currently paused.
  4111. */
  4112. isPaused: boolean;
  4113. /**
  4114. * Does this sound enables spatial sound.
  4115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4116. */
  4117. spatialSound: boolean;
  4118. /**
  4119. * Define the reference distance the sound should be heard perfectly.
  4120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4121. */
  4122. refDistance: number;
  4123. /**
  4124. * Define the roll off factor of spatial sounds.
  4125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4126. */
  4127. rolloffFactor: number;
  4128. /**
  4129. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  4130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4131. */
  4132. maxDistance: number;
  4133. /**
  4134. * Define the distance attenuation model the sound will follow.
  4135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4136. */
  4137. distanceModel: string;
  4138. /**
  4139. * @hidden
  4140. * Back Compat
  4141. **/
  4142. onended: () => any;
  4143. /**
  4144. * Observable event when the current playing sound finishes.
  4145. */
  4146. onEndedObservable: Observable<Sound>;
  4147. private _panningModel;
  4148. private _playbackRate;
  4149. private _streaming;
  4150. private _startTime;
  4151. private _startOffset;
  4152. private _position;
  4153. /** @hidden */
  4154. _positionInEmitterSpace: boolean;
  4155. private _localDirection;
  4156. private _volume;
  4157. private _isReadyToPlay;
  4158. private _isDirectional;
  4159. private _readyToPlayCallback;
  4160. private _audioBuffer;
  4161. private _soundSource;
  4162. private _streamingSource;
  4163. private _soundPanner;
  4164. private _soundGain;
  4165. private _inputAudioNode;
  4166. private _outputAudioNode;
  4167. private _coneInnerAngle;
  4168. private _coneOuterAngle;
  4169. private _coneOuterGain;
  4170. private _scene;
  4171. private _connectedMesh;
  4172. private _customAttenuationFunction;
  4173. private _registerFunc;
  4174. private _isOutputConnected;
  4175. private _htmlAudioElement;
  4176. private _urlType;
  4177. /**
  4178. * Create a sound and attach it to a scene
  4179. * @param name Name of your sound
  4180. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  4181. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  4182. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  4183. */
  4184. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  4185. /**
  4186. * Release the sound and its associated resources
  4187. */
  4188. dispose(): void;
  4189. /**
  4190. * Gets if the sounds is ready to be played or not.
  4191. * @returns true if ready, otherwise false
  4192. */
  4193. isReady(): boolean;
  4194. private _soundLoaded;
  4195. /**
  4196. * Sets the data of the sound from an audiobuffer
  4197. * @param audioBuffer The audioBuffer containing the data
  4198. */
  4199. setAudioBuffer(audioBuffer: AudioBuffer): void;
  4200. /**
  4201. * Updates the current sounds options such as maxdistance, loop...
  4202. * @param options A JSON object containing values named as the object properties
  4203. */
  4204. updateOptions(options: any): void;
  4205. private _createSpatialParameters;
  4206. private _updateSpatialParameters;
  4207. /**
  4208. * Switch the panning model to HRTF:
  4209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4211. */
  4212. switchPanningModelToHRTF(): void;
  4213. /**
  4214. * Switch the panning model to Equal Power:
  4215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4217. */
  4218. switchPanningModelToEqualPower(): void;
  4219. private _switchPanningModel;
  4220. /**
  4221. * Connect this sound to a sound track audio node like gain...
  4222. * @param soundTrackAudioNode the sound track audio node to connect to
  4223. */
  4224. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  4225. /**
  4226. * Transform this sound into a directional source
  4227. * @param coneInnerAngle Size of the inner cone in degree
  4228. * @param coneOuterAngle Size of the outer cone in degree
  4229. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  4230. */
  4231. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  4232. /**
  4233. * Gets or sets the inner angle for the directional cone.
  4234. */
  4235. /**
  4236. * Gets or sets the inner angle for the directional cone.
  4237. */
  4238. directionalConeInnerAngle: number;
  4239. /**
  4240. * Gets or sets the outer angle for the directional cone.
  4241. */
  4242. /**
  4243. * Gets or sets the outer angle for the directional cone.
  4244. */
  4245. directionalConeOuterAngle: number;
  4246. /**
  4247. * Sets the position of the emitter if spatial sound is enabled
  4248. * @param newPosition Defines the new posisiton
  4249. */
  4250. setPosition(newPosition: Vector3): void;
  4251. /**
  4252. * Sets the local direction of the emitter if spatial sound is enabled
  4253. * @param newLocalDirection Defines the new local direction
  4254. */
  4255. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  4256. private _updateDirection;
  4257. /** @hidden */
  4258. updateDistanceFromListener(): void;
  4259. /**
  4260. * Sets a new custom attenuation function for the sound.
  4261. * @param callback Defines the function used for the attenuation
  4262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  4263. */
  4264. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  4265. /**
  4266. * Play the sound
  4267. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  4268. * @param offset (optional) Start the sound setting it at a specific time
  4269. */
  4270. play(time?: number, offset?: number): void;
  4271. private _onended;
  4272. /**
  4273. * Stop the sound
  4274. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  4275. */
  4276. stop(time?: number): void;
  4277. /**
  4278. * Put the sound in pause
  4279. */
  4280. pause(): void;
  4281. /**
  4282. * Sets a dedicated volume for this sounds
  4283. * @param newVolume Define the new volume of the sound
  4284. * @param time Define in how long the sound should be at this value
  4285. */
  4286. setVolume(newVolume: number, time?: number): void;
  4287. /**
  4288. * Set the sound play back rate
  4289. * @param newPlaybackRate Define the playback rate the sound should be played at
  4290. */
  4291. setPlaybackRate(newPlaybackRate: number): void;
  4292. /**
  4293. * Gets the volume of the sound.
  4294. * @returns the volume of the sound
  4295. */
  4296. getVolume(): number;
  4297. /**
  4298. * Attach the sound to a dedicated mesh
  4299. * @param meshToConnectTo The mesh to connect the sound with
  4300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4301. */
  4302. attachToMesh(meshToConnectTo: AbstractMesh): void;
  4303. /**
  4304. * Detach the sound from the previously attached mesh
  4305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  4306. */
  4307. detachFromMesh(): void;
  4308. private _onRegisterAfterWorldMatrixUpdate;
  4309. /**
  4310. * Clone the current sound in the scene.
  4311. * @returns the new sound clone
  4312. */
  4313. clone(): Nullable<Sound>;
  4314. /**
  4315. * Gets the current underlying audio buffer containing the data
  4316. * @returns the audio buffer
  4317. */
  4318. getAudioBuffer(): Nullable<AudioBuffer>;
  4319. /**
  4320. * Serializes the Sound in a JSON representation
  4321. * @returns the JSON representation of the sound
  4322. */
  4323. serialize(): any;
  4324. /**
  4325. * Parse a JSON representation of a sound to innstantiate in a given scene
  4326. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  4327. * @param scene Define the scene the new parsed sound should be created in
  4328. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  4329. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  4330. * @returns the newly parsed sound
  4331. */
  4332. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  4333. }
  4334. }
  4335. declare module BABYLON {
  4336. /**
  4337. * Options allowed during the creation of a sound track.
  4338. */
  4339. interface ISoundTrackOptions {
  4340. /**
  4341. * The volume the sound track should take during creation
  4342. */
  4343. volume?: number;
  4344. /**
  4345. * Define if the sound track is the main sound track of the scene
  4346. */
  4347. mainTrack?: boolean;
  4348. }
  4349. /**
  4350. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  4351. * It will be also used in a future release to apply effects on a specific track.
  4352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4353. */
  4354. class SoundTrack {
  4355. /**
  4356. * The unique identifier of the sound track in the scene.
  4357. */
  4358. id: number;
  4359. /**
  4360. * The list of sounds included in the sound track.
  4361. */
  4362. soundCollection: Array<Sound>;
  4363. private _outputAudioNode;
  4364. private _scene;
  4365. private _isMainTrack;
  4366. private _connectedAnalyser;
  4367. private _options;
  4368. private _isInitialized;
  4369. /**
  4370. * Creates a new sound track.
  4371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  4372. * @param scene Define the scene the sound track belongs to
  4373. * @param options
  4374. */
  4375. constructor(scene: Scene, options?: ISoundTrackOptions);
  4376. private _initializeSoundTrackAudioGraph;
  4377. /**
  4378. * Release the sound track and its associated resources
  4379. */
  4380. dispose(): void;
  4381. /**
  4382. * Adds a sound to this sound track
  4383. * @param sound define the cound to add
  4384. * @ignoreNaming
  4385. */
  4386. AddSound(sound: Sound): void;
  4387. /**
  4388. * Removes a sound to this sound track
  4389. * @param sound define the cound to remove
  4390. * @ignoreNaming
  4391. */
  4392. RemoveSound(sound: Sound): void;
  4393. /**
  4394. * Set a global volume for the full sound track.
  4395. * @param newVolume Define the new volume of the sound track
  4396. */
  4397. setVolume(newVolume: number): void;
  4398. /**
  4399. * Switch the panning model to HRTF:
  4400. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  4401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4402. */
  4403. switchPanningModelToHRTF(): void;
  4404. /**
  4405. * Switch the panning model to Equal Power:
  4406. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  4407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  4408. */
  4409. switchPanningModelToEqualPower(): void;
  4410. /**
  4411. * Connect the sound track to an audio analyser allowing some amazing
  4412. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  4413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  4414. * @param analyser The analyser to connect to the engine
  4415. */
  4416. connectToAnalyser(analyser: Analyser): void;
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /**
  4421. * Wraps one or more Sound objects and selects one with random weight for playback.
  4422. */
  4423. class WeightedSound {
  4424. /** When true a Sound will be selected and played when the current playing Sound completes. */
  4425. loop: boolean;
  4426. private _coneInnerAngle;
  4427. private _coneOuterAngle;
  4428. private _volume;
  4429. /** A Sound is currently playing. */
  4430. isPlaying: boolean;
  4431. /** A Sound is currently paused. */
  4432. isPaused: boolean;
  4433. private _sounds;
  4434. private _weights;
  4435. private _currentIndex?;
  4436. /**
  4437. * Creates a new WeightedSound from the list of sounds given.
  4438. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  4439. * @param sounds Array of Sounds that will be selected from.
  4440. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  4441. */
  4442. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  4443. /**
  4444. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  4445. */
  4446. /**
  4447. * The size of cone in degress for a directional sound in which there will be no attenuation.
  4448. */
  4449. directionalConeInnerAngle: number;
  4450. /**
  4451. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4452. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4453. */
  4454. /**
  4455. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  4456. * Listener angles between innerAngle and outerAngle will falloff linearly.
  4457. */
  4458. directionalConeOuterAngle: number;
  4459. /**
  4460. * Playback volume.
  4461. */
  4462. /**
  4463. * Playback volume.
  4464. */
  4465. volume: number;
  4466. private _onended;
  4467. /**
  4468. * Suspend playback
  4469. */
  4470. pause(): void;
  4471. /**
  4472. * Stop playback
  4473. */
  4474. stop(): void;
  4475. /**
  4476. * Start playback.
  4477. * @param startOffset Position the clip head at a specific time in seconds.
  4478. */
  4479. play(startOffset?: number): void;
  4480. }
  4481. }
  4482. declare module BABYLON {
  4483. /**
  4484. * Class used to store an actual running animation
  4485. */
  4486. class Animatable {
  4487. /** defines the target object */
  4488. target: any;
  4489. /** defines the starting frame number (default is 0) */
  4490. fromFrame: number;
  4491. /** defines the ending frame number (default is 100) */
  4492. toFrame: number;
  4493. /** defines if the animation must loop (default is false) */
  4494. loopAnimation: boolean;
  4495. /** defines a callback to call when animation ends if it is not looping */
  4496. onAnimationEnd?: (() => void) | null | undefined;
  4497. private _localDelayOffset;
  4498. private _pausedDelay;
  4499. private _runtimeAnimations;
  4500. private _paused;
  4501. private _scene;
  4502. private _speedRatio;
  4503. private _weight;
  4504. private _syncRoot;
  4505. /**
  4506. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  4507. * This will only apply for non looping animation (default is true)
  4508. */
  4509. disposeOnEnd: boolean;
  4510. /**
  4511. * Gets a boolean indicating if the animation has started
  4512. */
  4513. animationStarted: boolean;
  4514. /**
  4515. * Observer raised when the animation ends
  4516. */
  4517. onAnimationEndObservable: Observable<Animatable>;
  4518. /**
  4519. * Gets the root Animatable used to synchronize and normalize animations
  4520. */
  4521. readonly syncRoot: Animatable;
  4522. /**
  4523. * Gets the current frame of the first RuntimeAnimation
  4524. * Used to synchronize Animatables
  4525. */
  4526. readonly masterFrame: number;
  4527. /**
  4528. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  4529. */
  4530. weight: number;
  4531. /**
  4532. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  4533. */
  4534. speedRatio: number;
  4535. /**
  4536. * Creates a new Animatable
  4537. * @param scene defines the hosting scene
  4538. * @param target defines the target object
  4539. * @param fromFrame defines the starting frame number (default is 0)
  4540. * @param toFrame defines the ending frame number (default is 100)
  4541. * @param loopAnimation defines if the animation must loop (default is false)
  4542. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  4543. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  4544. * @param animations defines a group of animation to add to the new Animatable
  4545. */
  4546. constructor(scene: Scene,
  4547. /** defines the target object */
  4548. target: any,
  4549. /** defines the starting frame number (default is 0) */
  4550. fromFrame?: number,
  4551. /** defines the ending frame number (default is 100) */
  4552. toFrame?: number,
  4553. /** defines if the animation must loop (default is false) */
  4554. loopAnimation?: boolean, speedRatio?: number,
  4555. /** defines a callback to call when animation ends if it is not looping */
  4556. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  4557. /**
  4558. * Synchronize and normalize current Animatable with a source Animatable
  4559. * This is useful when using animation weights and when animations are not of the same length
  4560. * @param root defines the root Animatable to synchronize with
  4561. * @returns the current Animatable
  4562. */
  4563. syncWith(root: Animatable): Animatable;
  4564. /**
  4565. * Gets the list of runtime animations
  4566. * @returns an array of RuntimeAnimation
  4567. */
  4568. getAnimations(): RuntimeAnimation[];
  4569. /**
  4570. * Adds more animations to the current animatable
  4571. * @param target defines the target of the animations
  4572. * @param animations defines the new animations to add
  4573. */
  4574. appendAnimations(target: any, animations: Animation[]): void;
  4575. /**
  4576. * Gets the source animation for a specific property
  4577. * @param property defines the propertyu to look for
  4578. * @returns null or the source animation for the given property
  4579. */
  4580. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  4581. /**
  4582. * Gets the runtime animation for a specific property
  4583. * @param property defines the propertyu to look for
  4584. * @returns null or the runtime animation for the given property
  4585. */
  4586. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  4587. /**
  4588. * Resets the animatable to its original state
  4589. */
  4590. reset(): void;
  4591. /**
  4592. * Allows the animatable to blend with current running animations
  4593. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4594. * @param blendingSpeed defines the blending speed to use
  4595. */
  4596. enableBlending(blendingSpeed: number): void;
  4597. /**
  4598. * Disable animation blending
  4599. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  4600. */
  4601. disableBlending(): void;
  4602. /**
  4603. * Jump directly to a given frame
  4604. * @param frame defines the frame to jump to
  4605. */
  4606. goToFrame(frame: number): void;
  4607. /**
  4608. * Pause the animation
  4609. */
  4610. pause(): void;
  4611. /**
  4612. * Restart the animation
  4613. */
  4614. restart(): void;
  4615. private _raiseOnAnimationEnd;
  4616. /**
  4617. * Stop and delete the current animation
  4618. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  4619. * @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)
  4620. */
  4621. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  4622. /**
  4623. * Wait asynchronously for the animation to end
  4624. * @returns a promise which will be fullfilled when the animation ends
  4625. */
  4626. waitAsync(): Promise<Animatable>;
  4627. /** @hidden */
  4628. _animate(delay: number): boolean;
  4629. }
  4630. }
  4631. declare module BABYLON {
  4632. /**
  4633. * Represents the range of an animation
  4634. */
  4635. class AnimationRange {
  4636. /**The name of the animation range**/
  4637. name: string;
  4638. /**The starting frame of the animation */
  4639. from: number;
  4640. /**The ending frame of the animation*/
  4641. to: number;
  4642. /**
  4643. * Initializes the range of an animation
  4644. * @param name The name of the animation range
  4645. * @param from The starting frame of the animation
  4646. * @param to The ending frame of the animation
  4647. */
  4648. constructor(
  4649. /**The name of the animation range**/
  4650. name: string,
  4651. /**The starting frame of the animation */
  4652. from: number,
  4653. /**The ending frame of the animation*/
  4654. to: number);
  4655. /**
  4656. * Makes a copy of the animation range
  4657. * @returns A copy of the animation range
  4658. */
  4659. clone(): AnimationRange;
  4660. }
  4661. /**
  4662. * Composed of a frame, and an action function
  4663. */
  4664. class AnimationEvent {
  4665. /** The frame for which the event is triggered **/
  4666. frame: number;
  4667. /** The event to perform when triggered **/
  4668. action: (currentFrame: number) => void;
  4669. /** Specifies if the event should be triggered only once**/
  4670. onlyOnce?: boolean | undefined;
  4671. /**
  4672. * Specifies if the animation event is done
  4673. */
  4674. isDone: boolean;
  4675. /**
  4676. * Initializes the animation event
  4677. * @param frame The frame for which the event is triggered
  4678. * @param action The event to perform when triggered
  4679. * @param onlyOnce Specifies if the event should be triggered only once
  4680. */
  4681. constructor(
  4682. /** The frame for which the event is triggered **/
  4683. frame: number,
  4684. /** The event to perform when triggered **/
  4685. action: (currentFrame: number) => void,
  4686. /** Specifies if the event should be triggered only once**/
  4687. onlyOnce?: boolean | undefined);
  4688. /** @hidden */
  4689. _clone(): AnimationEvent;
  4690. }
  4691. /**
  4692. * A cursor which tracks a point on a path
  4693. */
  4694. class PathCursor {
  4695. private path;
  4696. /**
  4697. * Stores path cursor callbacks for when an onchange event is triggered
  4698. */
  4699. private _onchange;
  4700. /**
  4701. * The value of the path cursor
  4702. */
  4703. value: number;
  4704. /**
  4705. * The animation array of the path cursor
  4706. */
  4707. animations: Animation[];
  4708. /**
  4709. * Initializes the path cursor
  4710. * @param path The path to track
  4711. */
  4712. constructor(path: Path2);
  4713. /**
  4714. * Gets the cursor point on the path
  4715. * @returns A point on the path cursor at the cursor location
  4716. */
  4717. getPoint(): Vector3;
  4718. /**
  4719. * Moves the cursor ahead by the step amount
  4720. * @param step The amount to move the cursor forward
  4721. * @returns This path cursor
  4722. */
  4723. moveAhead(step?: number): PathCursor;
  4724. /**
  4725. * Moves the cursor behind by the step amount
  4726. * @param step The amount to move the cursor back
  4727. * @returns This path cursor
  4728. */
  4729. moveBack(step?: number): PathCursor;
  4730. /**
  4731. * Moves the cursor by the step amount
  4732. * If the step amount is greater than one, an exception is thrown
  4733. * @param step The amount to move the cursor
  4734. * @returns This path cursor
  4735. */
  4736. move(step: number): PathCursor;
  4737. /**
  4738. * Ensures that the value is limited between zero and one
  4739. * @returns This path cursor
  4740. */
  4741. private ensureLimits;
  4742. /**
  4743. * Runs onchange callbacks on change (used by the animation engine)
  4744. * @returns This path cursor
  4745. */
  4746. private raiseOnChange;
  4747. /**
  4748. * Executes a function on change
  4749. * @param f A path cursor onchange callback
  4750. * @returns This path cursor
  4751. */
  4752. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4753. }
  4754. /**
  4755. * Defines an interface which represents an animation key frame
  4756. */
  4757. interface IAnimationKey {
  4758. /**
  4759. * Frame of the key frame
  4760. */
  4761. frame: number;
  4762. /**
  4763. * Value at the specifies key frame
  4764. */
  4765. value: any;
  4766. /**
  4767. * The input tangent for the cubic hermite spline
  4768. */
  4769. inTangent?: any;
  4770. /**
  4771. * The output tangent for the cubic hermite spline
  4772. */
  4773. outTangent?: any;
  4774. /**
  4775. * The animation interpolation type
  4776. */
  4777. interpolation?: AnimationKeyInterpolation;
  4778. }
  4779. /**
  4780. * Enum for the animation key frame interpolation type
  4781. */
  4782. enum AnimationKeyInterpolation {
  4783. /**
  4784. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4785. */
  4786. STEP = 1
  4787. }
  4788. /**
  4789. * Class used to store any kind of animation
  4790. */
  4791. class Animation {
  4792. /**Name of the animation */
  4793. name: string;
  4794. /**Property to animate */
  4795. targetProperty: string;
  4796. /**The frames per second of the animation */
  4797. framePerSecond: number;
  4798. /**The data type of the animation */
  4799. dataType: number;
  4800. /**The loop mode of the animation */
  4801. loopMode?: number | undefined;
  4802. /**Specifies if blending should be enabled */
  4803. enableBlending?: boolean | undefined;
  4804. /**
  4805. * Use matrix interpolation instead of using direct key value when animating matrices
  4806. */
  4807. static AllowMatricesInterpolation: boolean;
  4808. /**
  4809. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4810. */
  4811. static AllowMatrixDecomposeForInterpolation: boolean;
  4812. /**
  4813. * Stores the key frames of the animation
  4814. */
  4815. private _keys;
  4816. /**
  4817. * Stores the easing function of the animation
  4818. */
  4819. private _easingFunction;
  4820. /**
  4821. * @hidden Internal use only
  4822. */
  4823. _runtimeAnimations: RuntimeAnimation[];
  4824. /**
  4825. * The set of event that will be linked to this animation
  4826. */
  4827. private _events;
  4828. /**
  4829. * Stores an array of target property paths
  4830. */
  4831. targetPropertyPath: string[];
  4832. /**
  4833. * Stores the blending speed of the animation
  4834. */
  4835. blendingSpeed: number;
  4836. /**
  4837. * Stores the animation ranges for the animation
  4838. */
  4839. private _ranges;
  4840. /**
  4841. * @hidden Internal use
  4842. */
  4843. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4844. /**
  4845. * Sets up an animation
  4846. * @param property The property to animate
  4847. * @param animationType The animation type to apply
  4848. * @param framePerSecond The frames per second of the animation
  4849. * @param easingFunction The easing function used in the animation
  4850. * @returns The created animation
  4851. */
  4852. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4853. /**
  4854. * Create and start an animation on a node
  4855. * @param name defines the name of the global animation that will be run on all nodes
  4856. * @param node defines the root node where the animation will take place
  4857. * @param targetProperty defines property to animate
  4858. * @param framePerSecond defines the number of frame per second yo use
  4859. * @param totalFrame defines the number of frames in total
  4860. * @param from defines the initial value
  4861. * @param to defines the final value
  4862. * @param loopMode defines which loop mode you want to use (off by default)
  4863. * @param easingFunction defines the easing function to use (linear by default)
  4864. * @param onAnimationEnd defines the callback to call when animation end
  4865. * @returns the animatable created for this animation
  4866. */
  4867. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4868. /**
  4869. * Create and start an animation on a node and its descendants
  4870. * @param name defines the name of the global animation that will be run on all nodes
  4871. * @param node defines the root node where the animation will take place
  4872. * @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
  4873. * @param targetProperty defines property to animate
  4874. * @param framePerSecond defines the number of frame per second to use
  4875. * @param totalFrame defines the number of frames in total
  4876. * @param from defines the initial value
  4877. * @param to defines the final value
  4878. * @param loopMode defines which loop mode you want to use (off by default)
  4879. * @param easingFunction defines the easing function to use (linear by default)
  4880. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4881. * @returns the list of animatables created for all nodes
  4882. * @example https://www.babylonjs-playground.com/#MH0VLI
  4883. */
  4884. 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[]>;
  4885. /**
  4886. * Creates a new animation, merges it with the existing animations and starts it
  4887. * @param name Name of the animation
  4888. * @param node Node which contains the scene that begins the animations
  4889. * @param targetProperty Specifies which property to animate
  4890. * @param framePerSecond The frames per second of the animation
  4891. * @param totalFrame The total number of frames
  4892. * @param from The frame at the beginning of the animation
  4893. * @param to The frame at the end of the animation
  4894. * @param loopMode Specifies the loop mode of the animation
  4895. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4896. * @param onAnimationEnd Callback to run once the animation is complete
  4897. * @returns Nullable animation
  4898. */
  4899. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4900. /**
  4901. * Transition property of an host to the target Value
  4902. * @param property The property to transition
  4903. * @param targetValue The target Value of the property
  4904. * @param host The object where the property to animate belongs
  4905. * @param scene Scene used to run the animation
  4906. * @param frameRate Framerate (in frame/s) to use
  4907. * @param transition The transition type we want to use
  4908. * @param duration The duration of the animation, in milliseconds
  4909. * @param onAnimationEnd Callback trigger at the end of the animation
  4910. * @returns Nullable animation
  4911. */
  4912. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4913. /**
  4914. * Return the array of runtime animations currently using this animation
  4915. */
  4916. readonly runtimeAnimations: RuntimeAnimation[];
  4917. /**
  4918. * Specifies if any of the runtime animations are currently running
  4919. */
  4920. readonly hasRunningRuntimeAnimations: boolean;
  4921. /**
  4922. * Initializes the animation
  4923. * @param name Name of the animation
  4924. * @param targetProperty Property to animate
  4925. * @param framePerSecond The frames per second of the animation
  4926. * @param dataType The data type of the animation
  4927. * @param loopMode The loop mode of the animation
  4928. * @param enableBlendings Specifies if blending should be enabled
  4929. */
  4930. constructor(
  4931. /**Name of the animation */
  4932. name: string,
  4933. /**Property to animate */
  4934. targetProperty: string,
  4935. /**The frames per second of the animation */
  4936. framePerSecond: number,
  4937. /**The data type of the animation */
  4938. dataType: number,
  4939. /**The loop mode of the animation */
  4940. loopMode?: number | undefined,
  4941. /**Specifies if blending should be enabled */
  4942. enableBlending?: boolean | undefined);
  4943. /**
  4944. * Converts the animation to a string
  4945. * @param fullDetails support for multiple levels of logging within scene loading
  4946. * @returns String form of the animation
  4947. */
  4948. toString(fullDetails?: boolean): string;
  4949. /**
  4950. * Add an event to this animation
  4951. * @param event Event to add
  4952. */
  4953. addEvent(event: AnimationEvent): void;
  4954. /**
  4955. * Remove all events found at the given frame
  4956. * @param frame The frame to remove events from
  4957. */
  4958. removeEvents(frame: number): void;
  4959. /**
  4960. * Retrieves all the events from the animation
  4961. * @returns Events from the animation
  4962. */
  4963. getEvents(): AnimationEvent[];
  4964. /**
  4965. * Creates an animation range
  4966. * @param name Name of the animation range
  4967. * @param from Starting frame of the animation range
  4968. * @param to Ending frame of the animation
  4969. */
  4970. createRange(name: string, from: number, to: number): void;
  4971. /**
  4972. * Deletes an animation range by name
  4973. * @param name Name of the animation range to delete
  4974. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4975. */
  4976. deleteRange(name: string, deleteFrames?: boolean): void;
  4977. /**
  4978. * Gets the animation range by name, or null if not defined
  4979. * @param name Name of the animation range
  4980. * @returns Nullable animation range
  4981. */
  4982. getRange(name: string): Nullable<AnimationRange>;
  4983. /**
  4984. * Gets the key frames from the animation
  4985. * @returns The key frames of the animation
  4986. */
  4987. getKeys(): Array<IAnimationKey>;
  4988. /**
  4989. * Gets the highest frame rate of the animation
  4990. * @returns Highest frame rate of the animation
  4991. */
  4992. getHighestFrame(): number;
  4993. /**
  4994. * Gets the easing function of the animation
  4995. * @returns Easing function of the animation
  4996. */
  4997. getEasingFunction(): IEasingFunction;
  4998. /**
  4999. * Sets the easing function of the animation
  5000. * @param easingFunction A custom mathematical formula for animation
  5001. */
  5002. setEasingFunction(easingFunction: EasingFunction): void;
  5003. /**
  5004. * Interpolates a scalar linearly
  5005. * @param startValue Start value of the animation curve
  5006. * @param endValue End value of the animation curve
  5007. * @param gradient Scalar amount to interpolate
  5008. * @returns Interpolated scalar value
  5009. */
  5010. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  5011. /**
  5012. * Interpolates a scalar cubically
  5013. * @param startValue Start value of the animation curve
  5014. * @param outTangent End tangent of the animation
  5015. * @param endValue End value of the animation curve
  5016. * @param inTangent Start tangent of the animation curve
  5017. * @param gradient Scalar amount to interpolate
  5018. * @returns Interpolated scalar value
  5019. */
  5020. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  5021. /**
  5022. * Interpolates a quaternion using a spherical linear interpolation
  5023. * @param startValue Start value of the animation curve
  5024. * @param endValue End value of the animation curve
  5025. * @param gradient Scalar amount to interpolate
  5026. * @returns Interpolated quaternion value
  5027. */
  5028. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  5029. /**
  5030. * Interpolates a quaternion cubically
  5031. * @param startValue Start value of the animation curve
  5032. * @param outTangent End tangent of the animation curve
  5033. * @param endValue End value of the animation curve
  5034. * @param inTangent Start tangent of the animation curve
  5035. * @param gradient Scalar amount to interpolate
  5036. * @returns Interpolated quaternion value
  5037. */
  5038. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  5039. /**
  5040. * Interpolates a Vector3 linearl
  5041. * @param startValue Start value of the animation curve
  5042. * @param endValue End value of the animation curve
  5043. * @param gradient Scalar amount to interpolate
  5044. * @returns Interpolated scalar value
  5045. */
  5046. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  5047. /**
  5048. * Interpolates a Vector3 cubically
  5049. * @param startValue Start value of the animation curve
  5050. * @param outTangent End tangent of the animation
  5051. * @param endValue End value of the animation curve
  5052. * @param inTangent Start tangent of the animation curve
  5053. * @param gradient Scalar amount to interpolate
  5054. * @returns InterpolatedVector3 value
  5055. */
  5056. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  5057. /**
  5058. * Interpolates a Vector2 linearly
  5059. * @param startValue Start value of the animation curve
  5060. * @param endValue End value of the animation curve
  5061. * @param gradient Scalar amount to interpolate
  5062. * @returns Interpolated Vector2 value
  5063. */
  5064. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  5065. /**
  5066. * Interpolates a Vector2 cubically
  5067. * @param startValue Start value of the animation curve
  5068. * @param outTangent End tangent of the animation
  5069. * @param endValue End value of the animation curve
  5070. * @param inTangent Start tangent of the animation curve
  5071. * @param gradient Scalar amount to interpolate
  5072. * @returns Interpolated Vector2 value
  5073. */
  5074. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  5075. /**
  5076. * Interpolates a size linearly
  5077. * @param startValue Start value of the animation curve
  5078. * @param endValue End value of the animation curve
  5079. * @param gradient Scalar amount to interpolate
  5080. * @returns Interpolated Size value
  5081. */
  5082. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  5083. /**
  5084. * Interpolates a Color3 linearly
  5085. * @param startValue Start value of the animation curve
  5086. * @param endValue End value of the animation curve
  5087. * @param gradient Scalar amount to interpolate
  5088. * @returns Interpolated Color3 value
  5089. */
  5090. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  5091. /**
  5092. * @hidden Internal use only
  5093. */
  5094. _getKeyValue(value: any): any;
  5095. /**
  5096. * @hidden Internal use only
  5097. */
  5098. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  5099. /**
  5100. * Defines the function to use to interpolate matrices
  5101. * @param startValue defines the start matrix
  5102. * @param endValue defines the end matrix
  5103. * @param gradient defines the gradient between both matrices
  5104. * @param result defines an optional target matrix where to store the interpolation
  5105. * @returns the interpolated matrix
  5106. */
  5107. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  5108. /**
  5109. * Makes a copy of the animation
  5110. * @returns Cloned animation
  5111. */
  5112. clone(): Animation;
  5113. /**
  5114. * Sets the key frames of the animation
  5115. * @param values The animation key frames to set
  5116. */
  5117. setKeys(values: Array<IAnimationKey>): void;
  5118. /**
  5119. * Serializes the animation to an object
  5120. * @returns Serialized object
  5121. */
  5122. serialize(): any;
  5123. /**
  5124. * Float animation type
  5125. */
  5126. private static _ANIMATIONTYPE_FLOAT;
  5127. /**
  5128. * Vector3 animation type
  5129. */
  5130. private static _ANIMATIONTYPE_VECTOR3;
  5131. /**
  5132. * Quaternion animation type
  5133. */
  5134. private static _ANIMATIONTYPE_QUATERNION;
  5135. /**
  5136. * Matrix animation type
  5137. */
  5138. private static _ANIMATIONTYPE_MATRIX;
  5139. /**
  5140. * Color3 animation type
  5141. */
  5142. private static _ANIMATIONTYPE_COLOR3;
  5143. /**
  5144. * Vector2 animation type
  5145. */
  5146. private static _ANIMATIONTYPE_VECTOR2;
  5147. /**
  5148. * Size animation type
  5149. */
  5150. private static _ANIMATIONTYPE_SIZE;
  5151. /**
  5152. * Relative Loop Mode
  5153. */
  5154. private static _ANIMATIONLOOPMODE_RELATIVE;
  5155. /**
  5156. * Cycle Loop Mode
  5157. */
  5158. private static _ANIMATIONLOOPMODE_CYCLE;
  5159. /**
  5160. * Constant Loop Mode
  5161. */
  5162. private static _ANIMATIONLOOPMODE_CONSTANT;
  5163. /**
  5164. * Get the float animation type
  5165. */
  5166. static readonly ANIMATIONTYPE_FLOAT: number;
  5167. /**
  5168. * Get the Vector3 animation type
  5169. */
  5170. static readonly ANIMATIONTYPE_VECTOR3: number;
  5171. /**
  5172. * Get the Vector2 animation type
  5173. */
  5174. static readonly ANIMATIONTYPE_VECTOR2: number;
  5175. /**
  5176. * Get the Size animation type
  5177. */
  5178. static readonly ANIMATIONTYPE_SIZE: number;
  5179. /**
  5180. * Get the Quaternion animation type
  5181. */
  5182. static readonly ANIMATIONTYPE_QUATERNION: number;
  5183. /**
  5184. * Get the Matrix animation type
  5185. */
  5186. static readonly ANIMATIONTYPE_MATRIX: number;
  5187. /**
  5188. * Get the Color3 animation type
  5189. */
  5190. static readonly ANIMATIONTYPE_COLOR3: number;
  5191. /**
  5192. * Get the Relative Loop Mode
  5193. */
  5194. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  5195. /**
  5196. * Get the Cycle Loop Mode
  5197. */
  5198. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  5199. /**
  5200. * Get the Constant Loop Mode
  5201. */
  5202. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  5203. /** @hidden */
  5204. static _UniversalLerp(left: any, right: any, amount: number): any;
  5205. /**
  5206. * Parses an animation object and creates an animation
  5207. * @param parsedAnimation Parsed animation object
  5208. * @returns Animation object
  5209. */
  5210. static Parse(parsedAnimation: any): Animation;
  5211. /**
  5212. * Appends the serialized animations from the source animations
  5213. * @param source Source containing the animations
  5214. * @param destination Target to store the animations
  5215. */
  5216. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  5217. }
  5218. }
  5219. declare module BABYLON {
  5220. /**
  5221. * This class defines the direct association between an animation and a target
  5222. */
  5223. class TargetedAnimation {
  5224. /**
  5225. * Animation to perform
  5226. */
  5227. animation: Animation;
  5228. /**
  5229. * Target to animate
  5230. */
  5231. target: any;
  5232. }
  5233. /**
  5234. * Use this class to create coordinated animations on multiple targets
  5235. */
  5236. class AnimationGroup implements IDisposable {
  5237. /** The name of the animation group */
  5238. name: string;
  5239. private _scene;
  5240. private _targetedAnimations;
  5241. private _animatables;
  5242. private _from;
  5243. private _to;
  5244. private _isStarted;
  5245. private _speedRatio;
  5246. /**
  5247. * This observable will notify when one animation have ended.
  5248. */
  5249. onAnimationEndObservable: Observable<TargetedAnimation>;
  5250. /**
  5251. * This observable will notify when all animations have ended.
  5252. */
  5253. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  5254. /**
  5255. * This observable will notify when all animations have paused.
  5256. */
  5257. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  5258. /**
  5259. * Gets the first frame
  5260. */
  5261. readonly from: number;
  5262. /**
  5263. * Gets the last frame
  5264. */
  5265. readonly to: number;
  5266. /**
  5267. * Define if the animations are started
  5268. */
  5269. readonly isStarted: boolean;
  5270. /**
  5271. * Gets or sets the speed ratio to use for all animations
  5272. */
  5273. /**
  5274. * Gets or sets the speed ratio to use for all animations
  5275. */
  5276. speedRatio: number;
  5277. /**
  5278. * Gets the targeted animations for this animation group
  5279. */
  5280. readonly targetedAnimations: Array<TargetedAnimation>;
  5281. /**
  5282. * returning the list of animatables controlled by this animation group.
  5283. */
  5284. readonly animatables: Array<Animatable>;
  5285. /**
  5286. * Instantiates a new Animation Group.
  5287. * This helps managing several animations at once.
  5288. * @see http://doc.babylonjs.com/how_to/group
  5289. * @param name Defines the name of the group
  5290. * @param scene Defines the scene the group belongs to
  5291. */
  5292. constructor(
  5293. /** The name of the animation group */
  5294. name: string, scene?: Nullable<Scene>);
  5295. /**
  5296. * Add an animation (with its target) in the group
  5297. * @param animation defines the animation we want to add
  5298. * @param target defines the target of the animation
  5299. * @returns the TargetedAnimation object
  5300. */
  5301. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  5302. /**
  5303. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  5304. * It can add constant keys at begin or end
  5305. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  5306. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  5307. * @returns the animation group
  5308. */
  5309. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  5310. /**
  5311. * Start all animations on given targets
  5312. * @param loop defines if animations must loop
  5313. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  5314. * @param from defines the from key (optional)
  5315. * @param to defines the to key (optional)
  5316. * @returns the current animation group
  5317. */
  5318. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  5319. /**
  5320. * Pause all animations
  5321. * @returns the animation group
  5322. */
  5323. pause(): AnimationGroup;
  5324. /**
  5325. * Play all animations to initial state
  5326. * This function will start() the animations if they were not started or will restart() them if they were paused
  5327. * @param loop defines if animations must loop
  5328. * @returns the animation group
  5329. */
  5330. play(loop?: boolean): AnimationGroup;
  5331. /**
  5332. * Reset all animations to initial state
  5333. * @returns the animation group
  5334. */
  5335. reset(): AnimationGroup;
  5336. /**
  5337. * Restart animations from key 0
  5338. * @returns the animation group
  5339. */
  5340. restart(): AnimationGroup;
  5341. /**
  5342. * Stop all animations
  5343. * @returns the animation group
  5344. */
  5345. stop(): AnimationGroup;
  5346. /**
  5347. * Set animation weight for all animatables
  5348. * @param weight defines the weight to use
  5349. * @return the animationGroup
  5350. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5351. */
  5352. setWeightForAllAnimatables(weight: number): AnimationGroup;
  5353. /**
  5354. * Synchronize and normalize all animatables with a source animatable
  5355. * @param root defines the root animatable to synchronize with
  5356. * @return the animationGroup
  5357. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  5358. */
  5359. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  5360. /**
  5361. * Goes to a specific frame in this animation group
  5362. * @param frame the frame number to go to
  5363. * @return the animationGroup
  5364. */
  5365. goToFrame(frame: number): AnimationGroup;
  5366. /**
  5367. * Dispose all associated resources
  5368. */
  5369. dispose(): void;
  5370. private _checkAnimationGroupEnded;
  5371. /**
  5372. * Returns a new AnimationGroup object parsed from the source provided.
  5373. * @param parsedAnimationGroup defines the source
  5374. * @param scene defines the scene that will receive the animationGroup
  5375. * @returns a new AnimationGroup
  5376. */
  5377. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  5378. /**
  5379. * Returns the string "AnimationGroup"
  5380. * @returns "AnimationGroup"
  5381. */
  5382. getClassName(): string;
  5383. /**
  5384. * Creates a detailled string about the object
  5385. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  5386. * @returns a string representing the object
  5387. */
  5388. toString(fullDetails?: boolean): string;
  5389. }
  5390. }
  5391. declare module BABYLON {
  5392. /**
  5393. * Class used to override all child animations of a given target
  5394. */
  5395. class AnimationPropertiesOverride {
  5396. /**
  5397. * Gets or sets a value indicating if animation blending must be used
  5398. */
  5399. enableBlending: boolean;
  5400. /**
  5401. * Gets or sets the blending speed to use when enableBlending is true
  5402. */
  5403. blendingSpeed: number;
  5404. /**
  5405. * Gets or sets the default loop mode to use
  5406. */
  5407. loopMode: number;
  5408. }
  5409. }
  5410. declare module BABYLON {
  5411. /**
  5412. * This represents the main contract an easing function should follow.
  5413. * Easing functions are used throughout the animation system.
  5414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5415. */
  5416. interface IEasingFunction {
  5417. /**
  5418. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5419. * of the easing function.
  5420. * The link below provides some of the most common examples of easing functions.
  5421. * @see https://easings.net/
  5422. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5423. * @returns the corresponding value on the curve defined by the easing function
  5424. */
  5425. ease(gradient: number): number;
  5426. }
  5427. /**
  5428. * Base class used for every default easing function.
  5429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5430. */
  5431. class EasingFunction implements IEasingFunction {
  5432. /**
  5433. * Interpolation follows the mathematical formula associated with the easing function.
  5434. */
  5435. static readonly EASINGMODE_EASEIN: number;
  5436. /**
  5437. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5438. */
  5439. static readonly EASINGMODE_EASEOUT: number;
  5440. /**
  5441. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5442. */
  5443. static readonly EASINGMODE_EASEINOUT: number;
  5444. private _easingMode;
  5445. /**
  5446. * Sets the easing mode of the current function.
  5447. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5448. */
  5449. setEasingMode(easingMode: number): void;
  5450. /**
  5451. * Gets the current easing mode.
  5452. * @returns the easing mode
  5453. */
  5454. getEasingMode(): number;
  5455. /**
  5456. * @hidden
  5457. */
  5458. easeInCore(gradient: number): number;
  5459. /**
  5460. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5461. * of the easing function.
  5462. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5463. * @returns the corresponding value on the curve defined by the easing function
  5464. */
  5465. ease(gradient: number): number;
  5466. }
  5467. /**
  5468. * Easing function with a circle shape (see link below).
  5469. * @see https://easings.net/#easeInCirc
  5470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5471. */
  5472. class CircleEase extends EasingFunction implements IEasingFunction {
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. /**
  5477. * Easing function with a ease back shape (see link below).
  5478. * @see https://easings.net/#easeInBack
  5479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5480. */
  5481. class BackEase extends EasingFunction implements IEasingFunction {
  5482. /** Defines the amplitude of the function */
  5483. amplitude: number;
  5484. /**
  5485. * Instantiates a back ease easing
  5486. * @see https://easings.net/#easeInBack
  5487. * @param amplitude Defines the amplitude of the function
  5488. */
  5489. constructor(
  5490. /** Defines the amplitude of the function */
  5491. amplitude?: number);
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. /**
  5496. * Easing function with a bouncing shape (see link below).
  5497. * @see https://easings.net/#easeInBounce
  5498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5499. */
  5500. class BounceEase extends EasingFunction implements IEasingFunction {
  5501. /** Defines the number of bounces */
  5502. bounces: number;
  5503. /** Defines the amplitude of the bounce */
  5504. bounciness: number;
  5505. /**
  5506. * Instantiates a bounce easing
  5507. * @see https://easings.net/#easeInBounce
  5508. * @param bounces Defines the number of bounces
  5509. * @param bounciness Defines the amplitude of the bounce
  5510. */
  5511. constructor(
  5512. /** Defines the number of bounces */
  5513. bounces?: number,
  5514. /** Defines the amplitude of the bounce */
  5515. bounciness?: number);
  5516. /** @hidden */
  5517. easeInCore(gradient: number): number;
  5518. }
  5519. /**
  5520. * Easing function with a power of 3 shape (see link below).
  5521. * @see https://easings.net/#easeInCubic
  5522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5523. */
  5524. class CubicEase extends EasingFunction implements IEasingFunction {
  5525. /** @hidden */
  5526. easeInCore(gradient: number): number;
  5527. }
  5528. /**
  5529. * Easing function with an elastic shape (see link below).
  5530. * @see https://easings.net/#easeInElastic
  5531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5532. */
  5533. class ElasticEase extends EasingFunction implements IEasingFunction {
  5534. /** Defines the number of oscillations*/
  5535. oscillations: number;
  5536. /** Defines the amplitude of the oscillations*/
  5537. springiness: number;
  5538. /**
  5539. * Instantiates an elastic easing function
  5540. * @see https://easings.net/#easeInElastic
  5541. * @param oscillations Defines the number of oscillations
  5542. * @param springiness Defines the amplitude of the oscillations
  5543. */
  5544. constructor(
  5545. /** Defines the number of oscillations*/
  5546. oscillations?: number,
  5547. /** Defines the amplitude of the oscillations*/
  5548. springiness?: number);
  5549. /** @hidden */
  5550. easeInCore(gradient: number): number;
  5551. }
  5552. /**
  5553. * Easing function with an exponential shape (see link below).
  5554. * @see https://easings.net/#easeInExpo
  5555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5556. */
  5557. class ExponentialEase extends EasingFunction implements IEasingFunction {
  5558. /** Defines the exponent of the function */
  5559. exponent: number;
  5560. /**
  5561. * Instantiates an exponential easing function
  5562. * @see https://easings.net/#easeInExpo
  5563. * @param exponent Defines the exponent of the function
  5564. */
  5565. constructor(
  5566. /** Defines the exponent of the function */
  5567. exponent?: number);
  5568. /** @hidden */
  5569. easeInCore(gradient: number): number;
  5570. }
  5571. /**
  5572. * Easing function with a power shape (see link below).
  5573. * @see https://easings.net/#easeInQuad
  5574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5575. */
  5576. class PowerEase extends EasingFunction implements IEasingFunction {
  5577. /** Defines the power of the function */
  5578. power: number;
  5579. /**
  5580. * Instantiates an power base easing function
  5581. * @see https://easings.net/#easeInQuad
  5582. * @param power Defines the power of the function
  5583. */
  5584. constructor(
  5585. /** Defines the power of the function */
  5586. power?: number);
  5587. /** @hidden */
  5588. easeInCore(gradient: number): number;
  5589. }
  5590. /**
  5591. * Easing function with a power of 2 shape (see link below).
  5592. * @see https://easings.net/#easeInQuad
  5593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5594. */
  5595. class QuadraticEase extends EasingFunction implements IEasingFunction {
  5596. /** @hidden */
  5597. easeInCore(gradient: number): number;
  5598. }
  5599. /**
  5600. * Easing function with a power of 4 shape (see link below).
  5601. * @see https://easings.net/#easeInQuart
  5602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5603. */
  5604. class QuarticEase extends EasingFunction implements IEasingFunction {
  5605. /** @hidden */
  5606. easeInCore(gradient: number): number;
  5607. }
  5608. /**
  5609. * Easing function with a power of 5 shape (see link below).
  5610. * @see https://easings.net/#easeInQuint
  5611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5612. */
  5613. class QuinticEase extends EasingFunction implements IEasingFunction {
  5614. /** @hidden */
  5615. easeInCore(gradient: number): number;
  5616. }
  5617. /**
  5618. * Easing function with a sin shape (see link below).
  5619. * @see https://easings.net/#easeInSine
  5620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5621. */
  5622. class SineEase extends EasingFunction implements IEasingFunction {
  5623. /** @hidden */
  5624. easeInCore(gradient: number): number;
  5625. }
  5626. /**
  5627. * Easing function with a bezier shape (see link below).
  5628. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5630. */
  5631. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5632. /** Defines the x component of the start tangent in the bezier curve */
  5633. x1: number;
  5634. /** Defines the y component of the start tangent in the bezier curve */
  5635. y1: number;
  5636. /** Defines the x component of the end tangent in the bezier curve */
  5637. x2: number;
  5638. /** Defines the y component of the end tangent in the bezier curve */
  5639. y2: number;
  5640. /**
  5641. * Instantiates a bezier function
  5642. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5643. * @param x1 Defines the x component of the start tangent in the bezier curve
  5644. * @param y1 Defines the y component of the start tangent in the bezier curve
  5645. * @param x2 Defines the x component of the end tangent in the bezier curve
  5646. * @param y2 Defines the y component of the end tangent in the bezier curve
  5647. */
  5648. constructor(
  5649. /** Defines the x component of the start tangent in the bezier curve */
  5650. x1?: number,
  5651. /** Defines the y component of the start tangent in the bezier curve */
  5652. y1?: number,
  5653. /** Defines the x component of the end tangent in the bezier curve */
  5654. x2?: number,
  5655. /** Defines the y component of the end tangent in the bezier curve */
  5656. y2?: number);
  5657. /** @hidden */
  5658. easeInCore(gradient: number): number;
  5659. }
  5660. }
  5661. declare module BABYLON {
  5662. /**
  5663. * Defines a runtime animation
  5664. */
  5665. class RuntimeAnimation {
  5666. private _events;
  5667. /**
  5668. * The current frame of the runtime animation
  5669. */
  5670. private _currentFrame;
  5671. /**
  5672. * The animation used by the runtime animation
  5673. */
  5674. private _animation;
  5675. /**
  5676. * The target of the runtime animation
  5677. */
  5678. private _target;
  5679. /**
  5680. * The initiating animatable
  5681. */
  5682. private _host;
  5683. /**
  5684. * The original value of the runtime animation
  5685. */
  5686. private _originalValue;
  5687. /**
  5688. * The original blend value of the runtime animation
  5689. */
  5690. private _originalBlendValue;
  5691. /**
  5692. * The offsets cache of the runtime animation
  5693. */
  5694. private _offsetsCache;
  5695. /**
  5696. * The high limits cache of the runtime animation
  5697. */
  5698. private _highLimitsCache;
  5699. /**
  5700. * Specifies if the runtime animation has been stopped
  5701. */
  5702. private _stopped;
  5703. /**
  5704. * The blending factor of the runtime animation
  5705. */
  5706. private _blendingFactor;
  5707. /**
  5708. * The BabylonJS scene
  5709. */
  5710. private _scene;
  5711. /**
  5712. * The current value of the runtime animation
  5713. */
  5714. private _currentValue;
  5715. /** @hidden */
  5716. _workValue: any;
  5717. /**
  5718. * The active target of the runtime animation
  5719. */
  5720. private _activeTarget;
  5721. /**
  5722. * The target path of the runtime animation
  5723. */
  5724. private _targetPath;
  5725. /**
  5726. * The weight of the runtime animation
  5727. */
  5728. private _weight;
  5729. /**
  5730. * The ratio offset of the runtime animation
  5731. */
  5732. private _ratioOffset;
  5733. /**
  5734. * The previous delay of the runtime animation
  5735. */
  5736. private _previousDelay;
  5737. /**
  5738. * The previous ratio of the runtime animation
  5739. */
  5740. private _previousRatio;
  5741. /**
  5742. * Gets the current frame of the runtime animation
  5743. */
  5744. readonly currentFrame: number;
  5745. /**
  5746. * Gets the weight of the runtime animation
  5747. */
  5748. readonly weight: number;
  5749. /**
  5750. * Gets the current value of the runtime animation
  5751. */
  5752. readonly currentValue: any;
  5753. /**
  5754. * Gets the target path of the runtime animation
  5755. */
  5756. readonly targetPath: string;
  5757. /**
  5758. * Gets the actual target of the runtime animation
  5759. */
  5760. readonly target: any;
  5761. /**
  5762. * Create a new RuntimeAnimation object
  5763. * @param target defines the target of the animation
  5764. * @param animation defines the source animation object
  5765. * @param scene defines the hosting scene
  5766. * @param host defines the initiating Animatable
  5767. */
  5768. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5769. /**
  5770. * Gets the animation from the runtime animation
  5771. */
  5772. readonly animation: Animation;
  5773. /**
  5774. * Resets the runtime animation to the beginning
  5775. * @param restoreOriginal defines whether to restore the target property to the original value
  5776. */
  5777. reset(restoreOriginal?: boolean): void;
  5778. /**
  5779. * Specifies if the runtime animation is stopped
  5780. * @returns Boolean specifying if the runtime animation is stopped
  5781. */
  5782. isStopped(): boolean;
  5783. /**
  5784. * Disposes of the runtime animation
  5785. */
  5786. dispose(): void;
  5787. /**
  5788. * Interpolates the animation from the current frame
  5789. * @param currentFrame The frame to interpolate the animation to
  5790. * @param repeatCount The number of times that the animation should loop
  5791. * @param loopMode The type of looping mode to use
  5792. * @param offsetValue Animation offset value
  5793. * @param highLimitValue The high limit value
  5794. * @returns The interpolated value
  5795. */
  5796. private _interpolate;
  5797. /**
  5798. * Apply the interpolated value to the target
  5799. * @param currentValue defines the value computed by the animation
  5800. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5801. */
  5802. setValue(currentValue: any, weight?: number): void;
  5803. private _setValue;
  5804. /**
  5805. * Gets the loop pmode of the runtime animation
  5806. * @returns Loop Mode
  5807. */
  5808. private _getCorrectLoopMode;
  5809. /**
  5810. * Move the current animation to a given frame
  5811. * @param frame defines the frame to move to
  5812. */
  5813. goToFrame(frame: number): void;
  5814. /**
  5815. * @hidden Internal use only
  5816. */
  5817. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5818. /**
  5819. * Execute the current animation
  5820. * @param delay defines the delay to add to the current frame
  5821. * @param from defines the lower bound of the animation range
  5822. * @param to defines the upper bound of the animation range
  5823. * @param loop defines if the current animation must loop
  5824. * @param speedRatio defines the current speed ratio
  5825. * @param weight defines the weight of the animation (default is -1 so no weight)
  5826. * @returns a boolean indicating if the animation is running
  5827. */
  5828. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5829. }
  5830. }
  5831. declare module BABYLON {
  5832. /**
  5833. * Interface used to define a behavior
  5834. */
  5835. interface Behavior<T> {
  5836. /** gets or sets behavior's name */
  5837. name: string;
  5838. /**
  5839. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5840. */
  5841. init(): void;
  5842. /**
  5843. * Called when the behavior is attached to a target
  5844. * @param target defines the target where the behavior is attached to
  5845. */
  5846. attach(target: T): void;
  5847. /**
  5848. * Called when the behavior is detached from its target
  5849. */
  5850. detach(): void;
  5851. }
  5852. /**
  5853. * Interface implemented by classes supporting behaviors
  5854. */
  5855. interface IBehaviorAware<T> {
  5856. /**
  5857. * Attach a behavior
  5858. * @param behavior defines the behavior to attach
  5859. * @returns the current host
  5860. */
  5861. addBehavior(behavior: Behavior<T>): T;
  5862. /**
  5863. * Remove a behavior from the current object
  5864. * @param behavior defines the behavior to detach
  5865. * @returns the current host
  5866. */
  5867. removeBehavior(behavior: Behavior<T>): T;
  5868. /**
  5869. * Gets a behavior using its name to search
  5870. * @param name defines the name to search
  5871. * @returns the behavior or null if not found
  5872. */
  5873. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Class used to store bone information
  5879. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5880. */
  5881. class Bone extends Node {
  5882. /**
  5883. * defines the bone name
  5884. */
  5885. name: string;
  5886. private static _tmpVecs;
  5887. private static _tmpQuat;
  5888. private static _tmpMats;
  5889. /**
  5890. * Gets the list of child bones
  5891. */
  5892. children: Bone[];
  5893. /** Gets the animations associated with this bone */
  5894. animations: Animation[];
  5895. /**
  5896. * Gets or sets bone length
  5897. */
  5898. length: number;
  5899. /**
  5900. * @hidden Internal only
  5901. * Set this value to map this bone to a different index in the transform matrices
  5902. * Set this value to -1 to exclude the bone from the transform matrices
  5903. */
  5904. _index: Nullable<number>;
  5905. private _skeleton;
  5906. private _localMatrix;
  5907. private _restPose;
  5908. private _baseMatrix;
  5909. private _absoluteTransform;
  5910. private _invertedAbsoluteTransform;
  5911. private _parent;
  5912. private _scalingDeterminant;
  5913. private _worldTransform;
  5914. private _localScaling;
  5915. private _localRotation;
  5916. private _localPosition;
  5917. private _needToDecompose;
  5918. private _needToCompose;
  5919. /** @hidden */
  5920. /** @hidden */
  5921. _matrix: Matrix;
  5922. /**
  5923. * Create a new bone
  5924. * @param name defines the bone name
  5925. * @param skeleton defines the parent skeleton
  5926. * @param parentBone defines the parent (can be null if the bone is the root)
  5927. * @param localMatrix defines the local matrix
  5928. * @param restPose defines the rest pose matrix
  5929. * @param baseMatrix defines the base matrix
  5930. * @param index defines index of the bone in the hiearchy
  5931. */
  5932. constructor(
  5933. /**
  5934. * defines the bone name
  5935. */
  5936. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5937. /**
  5938. * Gets the parent skeleton
  5939. * @returns a skeleton
  5940. */
  5941. getSkeleton(): Skeleton;
  5942. /**
  5943. * Gets parent bone
  5944. * @returns a bone or null if the bone is the root of the bone hierarchy
  5945. */
  5946. getParent(): Nullable<Bone>;
  5947. /**
  5948. * Sets the parent bone
  5949. * @param parent defines the parent (can be null if the bone is the root)
  5950. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5951. */
  5952. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5953. /**
  5954. * Gets the local matrix
  5955. * @returns a matrix
  5956. */
  5957. getLocalMatrix(): Matrix;
  5958. /**
  5959. * Gets the base matrix (initial matrix which remains unchanged)
  5960. * @returns a matrix
  5961. */
  5962. getBaseMatrix(): Matrix;
  5963. /**
  5964. * Gets the rest pose matrix
  5965. * @returns a matrix
  5966. */
  5967. getRestPose(): Matrix;
  5968. /**
  5969. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5970. */
  5971. getWorldMatrix(): Matrix;
  5972. /**
  5973. * Sets the local matrix to rest pose matrix
  5974. */
  5975. returnToRest(): void;
  5976. /**
  5977. * Gets the inverse of the absolute transform matrix.
  5978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  5979. * @returns a matrix
  5980. */
  5981. getInvertedAbsoluteTransform(): Matrix;
  5982. /**
  5983. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  5984. * @returns a matrix
  5985. */
  5986. getAbsoluteTransform(): Matrix;
  5987. /** Gets or sets current position (in local space) */
  5988. position: Vector3;
  5989. /** Gets or sets current rotation (in local space) */
  5990. rotation: Vector3;
  5991. /** Gets or sets current rotation quaternion (in local space) */
  5992. rotationQuaternion: Quaternion;
  5993. /** Gets or sets current scaling (in local space) */
  5994. scaling: Vector3;
  5995. /**
  5996. * Gets the animation properties override
  5997. */
  5998. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5999. private _decompose;
  6000. private _compose;
  6001. /**
  6002. * Update the base and local matrices
  6003. * @param matrix defines the new base or local matrix
  6004. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6005. * @param updateLocalMatrix defines if the local matrix should be updated
  6006. */
  6007. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6008. /** @hidden */
  6009. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6010. /**
  6011. * Flag the bone as dirty (Forcing it to update everything)
  6012. */
  6013. markAsDirty(): void;
  6014. private _markAsDirtyAndCompose;
  6015. private _markAsDirtyAndDecompose;
  6016. /**
  6017. * Copy an animation range from another bone
  6018. * @param source defines the source bone
  6019. * @param rangeName defines the range name to copy
  6020. * @param frameOffset defines the frame offset
  6021. * @param rescaleAsRequired defines if rescaling must be applied if required
  6022. * @param skelDimensionsRatio defines the scaling ratio
  6023. * @returns true if operation was successful
  6024. */
  6025. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6026. /**
  6027. * Translate the bone in local or world space
  6028. * @param vec The amount to translate the bone
  6029. * @param space The space that the translation is in
  6030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6031. */
  6032. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6033. /**
  6034. * Set the postion of the bone in local or world space
  6035. * @param position The position to set the bone
  6036. * @param space The space that the position is in
  6037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6038. */
  6039. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6040. /**
  6041. * Set the absolute position of the bone (world space)
  6042. * @param position The position to set the bone
  6043. * @param mesh The mesh that this bone is attached to
  6044. */
  6045. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6046. /**
  6047. * Scale the bone on the x, y and z axes (in local space)
  6048. * @param x The amount to scale the bone on the x axis
  6049. * @param y The amount to scale the bone on the y axis
  6050. * @param z The amount to scale the bone on the z axis
  6051. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6052. */
  6053. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6054. /**
  6055. * Set the bone scaling in local space
  6056. * @param scale defines the scaling vector
  6057. */
  6058. setScale(scale: Vector3): void;
  6059. /**
  6060. * Gets the current scaling in local space
  6061. * @returns the current scaling vector
  6062. */
  6063. getScale(): Vector3;
  6064. /**
  6065. * Gets the current scaling in local space and stores it in a target vector
  6066. * @param result defines the target vector
  6067. */
  6068. getScaleToRef(result: Vector3): void;
  6069. /**
  6070. * Set the yaw, pitch, and roll of the bone in local or world space
  6071. * @param yaw The rotation of the bone on the y axis
  6072. * @param pitch The rotation of the bone on the x axis
  6073. * @param roll The rotation of the bone on the z axis
  6074. * @param space The space that the axes of rotation are in
  6075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6076. */
  6077. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6078. /**
  6079. * Add a rotation to the bone on an axis in local or world space
  6080. * @param axis The axis to rotate the bone on
  6081. * @param amount The amount to rotate the bone
  6082. * @param space The space that the axis is in
  6083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6084. */
  6085. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6086. /**
  6087. * Set the rotation of the bone to a particular axis angle in local or world space
  6088. * @param axis The axis to rotate the bone on
  6089. * @param angle The angle that the bone should be rotated to
  6090. * @param space The space that the axis is in
  6091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6092. */
  6093. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6094. /**
  6095. * Set the euler rotation of the bone in local of world space
  6096. * @param rotation The euler rotation that the bone should be set to
  6097. * @param space The space that the rotation is in
  6098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6099. */
  6100. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6101. /**
  6102. * Set the quaternion rotation of the bone in local of world space
  6103. * @param quat The quaternion rotation that the bone should be set to
  6104. * @param space The space that the rotation is in
  6105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6106. */
  6107. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6108. /**
  6109. * Set the rotation matrix of the bone in local of world space
  6110. * @param rotMat The rotation matrix that the bone should be set to
  6111. * @param space The space that the rotation is in
  6112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6113. */
  6114. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6115. private _rotateWithMatrix;
  6116. private _getNegativeRotationToRef;
  6117. /**
  6118. * Get the position of the bone in local or world space
  6119. * @param space The space that the returned position is in
  6120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6121. * @returns The position of the bone
  6122. */
  6123. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6124. /**
  6125. * Copy the position of the bone to a vector3 in local or world space
  6126. * @param space The space that the returned position is in
  6127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6128. * @param result The vector3 to copy the position to
  6129. */
  6130. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6131. /**
  6132. * Get the absolute position of the bone (world space)
  6133. * @param mesh The mesh that this bone is attached to
  6134. * @returns The absolute position of the bone
  6135. */
  6136. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6137. /**
  6138. * Copy the absolute position of the bone (world space) to the result param
  6139. * @param mesh The mesh that this bone is attached to
  6140. * @param result The vector3 to copy the absolute position to
  6141. */
  6142. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6143. /**
  6144. * Compute the absolute transforms of this bone and its children
  6145. */
  6146. computeAbsoluteTransforms(): void;
  6147. /**
  6148. * Get the world direction from an axis that is in the local space of the bone
  6149. * @param localAxis The local direction that is used to compute the world direction
  6150. * @param mesh The mesh that this bone is attached to
  6151. * @returns The world direction
  6152. */
  6153. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6154. /**
  6155. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6156. * @param localAxis The local direction that is used to compute the world direction
  6157. * @param mesh The mesh that this bone is attached to
  6158. * @param result The vector3 that the world direction will be copied to
  6159. */
  6160. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6161. /**
  6162. * Get the euler rotation of the bone in local or world space
  6163. * @param space The space that the rotation should be in
  6164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6165. * @returns The euler rotation
  6166. */
  6167. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6168. /**
  6169. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6170. * @param space The space that the rotation should be in
  6171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6172. * @param result The vector3 that the rotation should be copied to
  6173. */
  6174. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6175. /**
  6176. * Get the quaternion rotation of the bone in either local or world space
  6177. * @param space The space that the rotation should be in
  6178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6179. * @returns The quaternion rotation
  6180. */
  6181. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6182. /**
  6183. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6184. * @param space The space that the rotation should be in
  6185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6186. * @param result The quaternion that the rotation should be copied to
  6187. */
  6188. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6189. /**
  6190. * Get the rotation matrix of the bone in local or world space
  6191. * @param space The space that the rotation should be in
  6192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6193. * @returns The rotation matrix
  6194. */
  6195. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6196. /**
  6197. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6198. * @param space The space that the rotation should be in
  6199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6200. * @param result The quaternion that the rotation should be copied to
  6201. */
  6202. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6203. /**
  6204. * Get the world position of a point that is in the local space of the bone
  6205. * @param position The local position
  6206. * @param mesh The mesh that this bone is attached to
  6207. * @returns The world position
  6208. */
  6209. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6210. /**
  6211. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6212. * @param position The local position
  6213. * @param mesh The mesh that this bone is attached to
  6214. * @param result The vector3 that the world position should be copied to
  6215. */
  6216. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6217. /**
  6218. * Get the local position of a point that is in world space
  6219. * @param position The world position
  6220. * @param mesh The mesh that this bone is attached to
  6221. * @returns The local position
  6222. */
  6223. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6224. /**
  6225. * Get the local position of a point that is in world space and copy it to the result param
  6226. * @param position The world position
  6227. * @param mesh The mesh that this bone is attached to
  6228. * @param result The vector3 that the local position should be copied to
  6229. */
  6230. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6231. }
  6232. }
  6233. declare module BABYLON {
  6234. /**
  6235. * Class used to apply inverse kinematics to bones
  6236. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6237. */
  6238. class BoneIKController {
  6239. private static _tmpVecs;
  6240. private static _tmpQuat;
  6241. private static _tmpMats;
  6242. /**
  6243. * Gets or sets the target mesh
  6244. */
  6245. targetMesh: AbstractMesh;
  6246. /** Gets or sets the mesh used as pole */
  6247. poleTargetMesh: AbstractMesh;
  6248. /**
  6249. * Gets or sets the bone used as pole
  6250. */
  6251. poleTargetBone: Nullable<Bone>;
  6252. /**
  6253. * Gets or sets the target position
  6254. */
  6255. targetPosition: Vector3;
  6256. /**
  6257. * Gets or sets the pole target position
  6258. */
  6259. poleTargetPosition: Vector3;
  6260. /**
  6261. * Gets or sets the pole target local offset
  6262. */
  6263. poleTargetLocalOffset: Vector3;
  6264. /**
  6265. * Gets or sets the pole angle
  6266. */
  6267. poleAngle: number;
  6268. /**
  6269. * Gets or sets the mesh associated with the controller
  6270. */
  6271. mesh: AbstractMesh;
  6272. /**
  6273. * 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)
  6274. */
  6275. slerpAmount: number;
  6276. private _bone1Quat;
  6277. private _bone1Mat;
  6278. private _bone2Ang;
  6279. private _bone1;
  6280. private _bone2;
  6281. private _bone1Length;
  6282. private _bone2Length;
  6283. private _maxAngle;
  6284. private _maxReach;
  6285. private _rightHandedSystem;
  6286. private _bendAxis;
  6287. private _slerping;
  6288. private _adjustRoll;
  6289. /**
  6290. * Gets or sets maximum allowed angle
  6291. */
  6292. maxAngle: number;
  6293. /**
  6294. * Creates a new BoneIKController
  6295. * @param mesh defines the mesh to control
  6296. * @param bone defines the bone to control
  6297. * @param options defines options to set up the controller
  6298. */
  6299. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6300. targetMesh?: AbstractMesh;
  6301. poleTargetMesh?: AbstractMesh;
  6302. poleTargetBone?: Bone;
  6303. poleTargetLocalOffset?: Vector3;
  6304. poleAngle?: number;
  6305. bendAxis?: Vector3;
  6306. maxAngle?: number;
  6307. slerpAmount?: number;
  6308. });
  6309. private _setMaxAngle;
  6310. /**
  6311. * Force the controller to update the bones
  6312. */
  6313. update(): void;
  6314. }
  6315. }
  6316. declare module BABYLON {
  6317. /**
  6318. * Class used to make a bone look toward a point in space
  6319. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6320. */
  6321. class BoneLookController {
  6322. private static _tmpVecs;
  6323. private static _tmpQuat;
  6324. private static _tmpMats;
  6325. /**
  6326. * The target Vector3 that the bone will look at
  6327. */
  6328. target: Vector3;
  6329. /**
  6330. * The mesh that the bone is attached to
  6331. */
  6332. mesh: AbstractMesh;
  6333. /**
  6334. * The bone that will be looking to the target
  6335. */
  6336. bone: Bone;
  6337. /**
  6338. * The up axis of the coordinate system that is used when the bone is rotated
  6339. */
  6340. upAxis: Vector3;
  6341. /**
  6342. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6343. */
  6344. upAxisSpace: Space;
  6345. /**
  6346. * Used to make an adjustment to the yaw of the bone
  6347. */
  6348. adjustYaw: number;
  6349. /**
  6350. * Used to make an adjustment to the pitch of the bone
  6351. */
  6352. adjustPitch: number;
  6353. /**
  6354. * Used to make an adjustment to the roll of the bone
  6355. */
  6356. adjustRoll: number;
  6357. /**
  6358. * 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)
  6359. */
  6360. slerpAmount: number;
  6361. private _minYaw;
  6362. private _maxYaw;
  6363. private _minPitch;
  6364. private _maxPitch;
  6365. private _minYawSin;
  6366. private _minYawCos;
  6367. private _maxYawSin;
  6368. private _maxYawCos;
  6369. private _midYawConstraint;
  6370. private _minPitchTan;
  6371. private _maxPitchTan;
  6372. private _boneQuat;
  6373. private _slerping;
  6374. private _transformYawPitch;
  6375. private _transformYawPitchInv;
  6376. private _firstFrameSkipped;
  6377. private _yawRange;
  6378. private _fowardAxis;
  6379. /**
  6380. * Gets or sets the minimum yaw angle that the bone can look to
  6381. */
  6382. minYaw: number;
  6383. /**
  6384. * Gets or sets the maximum yaw angle that the bone can look to
  6385. */
  6386. maxYaw: number;
  6387. /**
  6388. * Gets or sets the minimum pitch angle that the bone can look to
  6389. */
  6390. minPitch: number;
  6391. /**
  6392. * Gets or sets the maximum pitch angle that the bone can look to
  6393. */
  6394. maxPitch: number;
  6395. /**
  6396. * Create a BoneLookController
  6397. * @param mesh the mesh that the bone belongs to
  6398. * @param bone the bone that will be looking to the target
  6399. * @param target the target Vector3 to look at
  6400. * @param settings optional settings:
  6401. * * maxYaw: the maximum angle the bone will yaw to
  6402. * * minYaw: the minimum angle the bone will yaw to
  6403. * * maxPitch: the maximum angle the bone will pitch to
  6404. * * minPitch: the minimum angle the bone will yaw to
  6405. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6406. * * upAxis: the up axis of the coordinate system
  6407. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6408. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6409. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6410. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6411. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6412. * * adjustRoll: used to make an adjustment to the roll of the bone
  6413. **/
  6414. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6415. maxYaw?: number;
  6416. minYaw?: number;
  6417. maxPitch?: number;
  6418. minPitch?: number;
  6419. slerpAmount?: number;
  6420. upAxis?: Vector3;
  6421. upAxisSpace?: Space;
  6422. yawAxis?: Vector3;
  6423. pitchAxis?: Vector3;
  6424. adjustYaw?: number;
  6425. adjustPitch?: number;
  6426. adjustRoll?: number;
  6427. });
  6428. /**
  6429. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6430. */
  6431. update(): void;
  6432. private _getAngleDiff;
  6433. private _getAngleBetween;
  6434. private _isAngleBetween;
  6435. }
  6436. }
  6437. declare module BABYLON {
  6438. /**
  6439. * Class used to handle skinning animations
  6440. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6441. */
  6442. class Skeleton implements IAnimatable {
  6443. /** defines the skeleton name */
  6444. name: string;
  6445. /** defines the skeleton Id */
  6446. id: string;
  6447. /**
  6448. * Gets the list of child bones
  6449. */
  6450. bones: Bone[];
  6451. /**
  6452. * Gets an estimate of the dimension of the skeleton at rest
  6453. */
  6454. dimensionsAtRest: Vector3;
  6455. /**
  6456. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6457. */
  6458. needInitialSkinMatrix: boolean;
  6459. /**
  6460. * Gets the list of animations attached to this skeleton
  6461. */
  6462. animations: Array<Animation>;
  6463. private _scene;
  6464. private _isDirty;
  6465. private _transformMatrices;
  6466. private _meshesWithPoseMatrix;
  6467. private _animatables;
  6468. private _identity;
  6469. private _synchronizedWithMesh;
  6470. private _ranges;
  6471. private _lastAbsoluteTransformsUpdateId;
  6472. /**
  6473. * Specifies if the skeleton should be serialized
  6474. */
  6475. doNotSerialize: boolean;
  6476. private _animationPropertiesOverride;
  6477. /**
  6478. * Gets or sets the animation properties override
  6479. */
  6480. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6481. /**
  6482. * An observable triggered before computing the skeleton's matrices
  6483. */
  6484. onBeforeComputeObservable: Observable<Skeleton>;
  6485. /**
  6486. * Creates a new skeleton
  6487. * @param name defines the skeleton name
  6488. * @param id defines the skeleton Id
  6489. * @param scene defines the hosting scene
  6490. */
  6491. constructor(
  6492. /** defines the skeleton name */
  6493. name: string,
  6494. /** defines the skeleton Id */
  6495. id: string, scene: Scene);
  6496. /**
  6497. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6499. * @returns a Float32Array containing matrices data
  6500. */
  6501. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6502. /**
  6503. * Gets the current hosting scene
  6504. * @returns a scene object
  6505. */
  6506. getScene(): Scene;
  6507. /**
  6508. * Gets a string representing the current skeleton data
  6509. * @param fullDetails defines a boolean indicating if we want a verbose version
  6510. * @returns a string representing the current skeleton data
  6511. */
  6512. toString(fullDetails?: boolean): string;
  6513. /**
  6514. * Get bone's index searching by name
  6515. * @param name defines bone's name to search for
  6516. * @return the indice of the bone. Returns -1 if not found
  6517. */
  6518. getBoneIndexByName(name: string): number;
  6519. /**
  6520. * Creater a new animation range
  6521. * @param name defines the name of the range
  6522. * @param from defines the start key
  6523. * @param to defines the end key
  6524. */
  6525. createAnimationRange(name: string, from: number, to: number): void;
  6526. /**
  6527. * Delete a specific animation range
  6528. * @param name defines the name of the range
  6529. * @param deleteFrames defines if frames must be removed as well
  6530. */
  6531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6532. /**
  6533. * Gets a specific animation range
  6534. * @param name defines the name of the range to look for
  6535. * @returns the requested animation range or null if not found
  6536. */
  6537. getAnimationRange(name: string): Nullable<AnimationRange>;
  6538. /**
  6539. * Gets the list of all animation ranges defined on this skeleton
  6540. * @returns an array
  6541. */
  6542. getAnimationRanges(): Nullable<AnimationRange>[];
  6543. /**
  6544. * Copy animation range from a source skeleton.
  6545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6546. * @param source defines the source skeleton
  6547. * @param name defines the name of the range to copy
  6548. * @param rescaleAsRequired defines if rescaling must be applied if required
  6549. * @returns true if operation was successful
  6550. */
  6551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6552. /**
  6553. * Forces the skeleton to go to rest pose
  6554. */
  6555. returnToRest(): void;
  6556. private _getHighestAnimationFrame;
  6557. /**
  6558. * Begin a specific animation range
  6559. * @param name defines the name of the range to start
  6560. * @param loop defines if looping must be turned on (false by default)
  6561. * @param speedRatio defines the speed ratio to apply (1 by default)
  6562. * @param onAnimationEnd defines a callback which will be called when animation will end
  6563. * @returns a new animatable
  6564. */
  6565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6566. /** @hidden */
  6567. _markAsDirty(): void;
  6568. /** @hidden */
  6569. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6570. /** @hidden */
  6571. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6572. /** @hidden */
  6573. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6574. /**
  6575. * Build all resources required to render a skeleton
  6576. */
  6577. prepare(): void;
  6578. /**
  6579. * Gets the list of animatables currently running for this skeleton
  6580. * @returns an array of animatables
  6581. */
  6582. getAnimatables(): IAnimatable[];
  6583. /**
  6584. * Clone the current skeleton
  6585. * @param name defines the name of the new skeleton
  6586. * @param id defines the id of the enw skeleton
  6587. * @returns the new skeleton
  6588. */
  6589. clone(name: string, id: string): Skeleton;
  6590. /**
  6591. * Enable animation blending for this skeleton
  6592. * @param blendingSpeed defines the blending speed to apply
  6593. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6594. */
  6595. enableBlending(blendingSpeed?: number): void;
  6596. /**
  6597. * Releases all resources associated with the current skeleton
  6598. */
  6599. dispose(): void;
  6600. /**
  6601. * Serialize the skeleton in a JSON object
  6602. * @returns a JSON object
  6603. */
  6604. serialize(): any;
  6605. /**
  6606. * Creates a new skeleton from serialized data
  6607. * @param parsedSkeleton defines the serialized data
  6608. * @param scene defines the hosting scene
  6609. * @returns a new skeleton
  6610. */
  6611. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6612. /**
  6613. * Compute all node absolute transforms
  6614. * @param forceUpdate defines if computation must be done even if cache is up to date
  6615. */
  6616. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6617. /**
  6618. * Gets the root pose matrix
  6619. * @returns a matrix
  6620. */
  6621. getPoseMatrix(): Nullable<Matrix>;
  6622. /**
  6623. * Sorts bones per internal index
  6624. */
  6625. sortBones(): void;
  6626. private _sortBones;
  6627. }
  6628. }
  6629. declare module BABYLON {
  6630. /** @hidden */
  6631. class Collider {
  6632. /** Define if a collision was found */
  6633. collisionFound: boolean;
  6634. /**
  6635. * Define last intersection point in local space
  6636. */
  6637. intersectionPoint: Vector3;
  6638. /**
  6639. * Define last collided mesh
  6640. */
  6641. collidedMesh: Nullable<AbstractMesh>;
  6642. private _collisionPoint;
  6643. private _planeIntersectionPoint;
  6644. private _tempVector;
  6645. private _tempVector2;
  6646. private _tempVector3;
  6647. private _tempVector4;
  6648. private _edge;
  6649. private _baseToVertex;
  6650. private _destinationPoint;
  6651. private _slidePlaneNormal;
  6652. private _displacementVector;
  6653. /** @hidden */
  6654. _radius: Vector3;
  6655. /** @hidden */
  6656. _retry: number;
  6657. private _velocity;
  6658. private _basePoint;
  6659. private _epsilon;
  6660. /** @hidden */
  6661. _velocityWorldLength: number;
  6662. /** @hidden */
  6663. _basePointWorld: Vector3;
  6664. private _velocityWorld;
  6665. private _normalizedVelocity;
  6666. /** @hidden */
  6667. _initialVelocity: Vector3;
  6668. /** @hidden */
  6669. _initialPosition: Vector3;
  6670. private _nearestDistance;
  6671. private _collisionMask;
  6672. collisionMask: number;
  6673. /**
  6674. * Gets the plane normal used to compute the sliding response (in local space)
  6675. */
  6676. readonly slidePlaneNormal: Vector3;
  6677. /** @hidden */
  6678. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6679. /** @hidden */
  6680. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6681. /** @hidden */
  6682. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6683. /** @hidden */
  6684. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6685. /** @hidden */
  6686. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6687. /** @hidden */
  6688. _getResponse(pos: Vector3, vel: Vector3): void;
  6689. }
  6690. }
  6691. declare module BABYLON {
  6692. /** @hidden */
  6693. var CollisionWorker: string;
  6694. /** @hidden */
  6695. interface ICollisionCoordinator {
  6696. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6697. init(scene: Scene): void;
  6698. destroy(): void;
  6699. onMeshAdded(mesh: AbstractMesh): void;
  6700. onMeshUpdated(mesh: AbstractMesh): void;
  6701. onMeshRemoved(mesh: AbstractMesh): void;
  6702. onGeometryAdded(geometry: Geometry): void;
  6703. onGeometryUpdated(geometry: Geometry): void;
  6704. onGeometryDeleted(geometry: Geometry): void;
  6705. }
  6706. /** @hidden */
  6707. interface SerializedMesh {
  6708. id: string;
  6709. name: string;
  6710. uniqueId: number;
  6711. geometryId: Nullable<string>;
  6712. sphereCenter: Array<number>;
  6713. sphereRadius: number;
  6714. boxMinimum: Array<number>;
  6715. boxMaximum: Array<number>;
  6716. worldMatrixFromCache: any;
  6717. subMeshes: Array<SerializedSubMesh>;
  6718. checkCollisions: boolean;
  6719. }
  6720. /** @hidden */
  6721. interface SerializedSubMesh {
  6722. position: number;
  6723. verticesStart: number;
  6724. verticesCount: number;
  6725. indexStart: number;
  6726. indexCount: number;
  6727. hasMaterial: boolean;
  6728. sphereCenter: Array<number>;
  6729. sphereRadius: number;
  6730. boxMinimum: Array<number>;
  6731. boxMaximum: Array<number>;
  6732. }
  6733. /**
  6734. * Interface describing the value associated with a geometry.
  6735. * @hidden
  6736. */
  6737. interface SerializedGeometry {
  6738. /**
  6739. * Defines the unique ID of the geometry
  6740. */
  6741. id: string;
  6742. /**
  6743. * Defines the array containing the positions
  6744. */
  6745. positions: Float32Array;
  6746. /**
  6747. * Defines the array containing the indices
  6748. */
  6749. indices: Uint32Array;
  6750. /**
  6751. * Defines the array containing the normals
  6752. */
  6753. normals: Float32Array;
  6754. }
  6755. /** @hidden */
  6756. interface BabylonMessage {
  6757. taskType: WorkerTaskType;
  6758. payload: InitPayload | CollidePayload | UpdatePayload;
  6759. }
  6760. /** @hidden */
  6761. interface SerializedColliderToWorker {
  6762. position: Array<number>;
  6763. velocity: Array<number>;
  6764. radius: Array<number>;
  6765. }
  6766. /** Defines supported task for worker process */
  6767. enum WorkerTaskType {
  6768. /** Initialization */
  6769. INIT = 0,
  6770. /** Update of geometry */
  6771. UPDATE = 1,
  6772. /** Evaluate collision */
  6773. COLLIDE = 2
  6774. }
  6775. /** @hidden */
  6776. interface WorkerReply {
  6777. error: WorkerReplyType;
  6778. taskType: WorkerTaskType;
  6779. payload?: any;
  6780. }
  6781. /** @hidden */
  6782. interface CollisionReplyPayload {
  6783. newPosition: Array<number>;
  6784. collisionId: number;
  6785. collidedMeshUniqueId: number;
  6786. }
  6787. /** @hidden */
  6788. interface InitPayload {
  6789. }
  6790. /** @hidden */
  6791. interface CollidePayload {
  6792. collisionId: number;
  6793. collider: SerializedColliderToWorker;
  6794. maximumRetry: number;
  6795. excludedMeshUniqueId: Nullable<number>;
  6796. }
  6797. /** @hidden */
  6798. interface UpdatePayload {
  6799. updatedMeshes: {
  6800. [n: number]: SerializedMesh;
  6801. };
  6802. updatedGeometries: {
  6803. [s: string]: SerializedGeometry;
  6804. };
  6805. removedMeshes: Array<number>;
  6806. removedGeometries: Array<string>;
  6807. }
  6808. /** Defines kind of replies returned by worker */
  6809. enum WorkerReplyType {
  6810. /** Success */
  6811. SUCCESS = 0,
  6812. /** Unkown error */
  6813. UNKNOWN_ERROR = 1
  6814. }
  6815. /** @hidden */
  6816. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6817. private _scene;
  6818. private _scaledPosition;
  6819. private _scaledVelocity;
  6820. private _collisionsCallbackArray;
  6821. private _init;
  6822. private _runningUpdated;
  6823. private _worker;
  6824. private _addUpdateMeshesList;
  6825. private _addUpdateGeometriesList;
  6826. private _toRemoveMeshesArray;
  6827. private _toRemoveGeometryArray;
  6828. constructor();
  6829. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6830. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6831. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6832. init(scene: Scene): void;
  6833. destroy(): void;
  6834. onMeshAdded(mesh: AbstractMesh): void;
  6835. onMeshUpdated: (transformNode: TransformNode) => void;
  6836. onMeshRemoved(mesh: AbstractMesh): void;
  6837. onGeometryAdded(geometry: Geometry): void;
  6838. onGeometryUpdated: (geometry: Geometry) => void;
  6839. onGeometryDeleted(geometry: Geometry): void;
  6840. private _afterRender;
  6841. private _onMessageFromWorker;
  6842. }
  6843. /** @hidden */
  6844. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6845. private _scene;
  6846. private _scaledPosition;
  6847. private _scaledVelocity;
  6848. private _finalPosition;
  6849. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6850. init(scene: Scene): void;
  6851. destroy(): void;
  6852. onMeshAdded(mesh: AbstractMesh): void;
  6853. onMeshUpdated(mesh: AbstractMesh): void;
  6854. onMeshRemoved(mesh: AbstractMesh): void;
  6855. onGeometryAdded(geometry: Geometry): void;
  6856. onGeometryUpdated(geometry: Geometry): void;
  6857. onGeometryDeleted(geometry: Geometry): void;
  6858. private _collideWithWorld;
  6859. }
  6860. }
  6861. declare function importScripts(...urls: string[]): void;
  6862. declare const safePostMessage: any;
  6863. declare module BABYLON {
  6864. /** @hidden */
  6865. var WorkerIncluded: boolean;
  6866. /** @hidden */
  6867. class CollisionCache {
  6868. private _meshes;
  6869. private _geometries;
  6870. getMeshes(): {
  6871. [n: number]: SerializedMesh;
  6872. };
  6873. getGeometries(): {
  6874. [s: number]: SerializedGeometry;
  6875. };
  6876. getMesh(id: any): SerializedMesh;
  6877. addMesh(mesh: SerializedMesh): void;
  6878. removeMesh(uniqueId: number): void;
  6879. getGeometry(id: string): SerializedGeometry;
  6880. addGeometry(geometry: SerializedGeometry): void;
  6881. removeGeometry(id: string): void;
  6882. }
  6883. /** @hidden */
  6884. class CollideWorker {
  6885. collider: Collider;
  6886. private _collisionCache;
  6887. private finalPosition;
  6888. private collisionsScalingMatrix;
  6889. private collisionTranformationMatrix;
  6890. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  6891. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  6892. private checkCollision;
  6893. private processCollisionsForSubMeshes;
  6894. private collideForSubMesh;
  6895. private checkSubmeshCollision;
  6896. }
  6897. /** @hidden */
  6898. interface ICollisionDetector {
  6899. onInit(payload: InitPayload): void;
  6900. onUpdate(payload: UpdatePayload): void;
  6901. onCollision(payload: CollidePayload): void;
  6902. }
  6903. /** @hidden */
  6904. class CollisionDetectorTransferable implements ICollisionDetector {
  6905. private _collisionCache;
  6906. onInit(payload: InitPayload): void;
  6907. onUpdate(payload: UpdatePayload): void;
  6908. onCollision(payload: CollidePayload): void;
  6909. }
  6910. }
  6911. declare module BABYLON {
  6912. /**
  6913. * @hidden
  6914. */
  6915. class IntersectionInfo {
  6916. bu: Nullable<number>;
  6917. bv: Nullable<number>;
  6918. distance: number;
  6919. faceId: number;
  6920. subMeshId: number;
  6921. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6922. }
  6923. /**
  6924. * Information about the result of picking within a scene
  6925. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  6926. */
  6927. class PickingInfo {
  6928. /**
  6929. * If the pick collided with an object
  6930. */
  6931. hit: boolean;
  6932. /**
  6933. * Distance away where the pick collided
  6934. */
  6935. distance: number;
  6936. /**
  6937. * The location of pick collision
  6938. */
  6939. pickedPoint: Nullable<Vector3>;
  6940. /**
  6941. * The mesh corresponding the the pick collision
  6942. */
  6943. pickedMesh: Nullable<AbstractMesh>;
  6944. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  6945. bu: number;
  6946. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  6947. bv: number;
  6948. /** The id of the face on the mesh that was picked */
  6949. faceId: number;
  6950. /** Id of the the submesh that was picked */
  6951. subMeshId: number;
  6952. /** If a sprite was picked, this will be the sprite the pick collided with */
  6953. pickedSprite: Nullable<Sprite>;
  6954. /**
  6955. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  6956. */
  6957. originMesh: Nullable<AbstractMesh>;
  6958. /**
  6959. * The ray that was used to perform the picking.
  6960. */
  6961. ray: Nullable<Ray>;
  6962. /**
  6963. * Gets the normal correspodning to the face the pick collided with
  6964. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  6965. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  6966. * @returns The normal correspodning to the face the pick collided with
  6967. */
  6968. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  6969. /**
  6970. * Gets the texture coordinates of where the pick occured
  6971. * @returns the vector containing the coordnates of the texture
  6972. */
  6973. getTextureCoordinates(): Nullable<Vector2>;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /**
  6978. * Class used to store bounding box information
  6979. */
  6980. class BoundingBox implements ICullable {
  6981. /**
  6982. * Gets the 8 vectors representing the bounding box in local space
  6983. */
  6984. vectors: Vector3[];
  6985. /**
  6986. * Gets the center of the bounding box in local space
  6987. */
  6988. center: Vector3;
  6989. /**
  6990. * Gets the center of the bounding box in world space
  6991. */
  6992. centerWorld: Vector3;
  6993. /**
  6994. * Gets the extend size in local space
  6995. */
  6996. extendSize: Vector3;
  6997. /**
  6998. * Gets the extend size in world space
  6999. */
  7000. extendSizeWorld: Vector3;
  7001. /**
  7002. * Gets the OBB (object bounding box) directions
  7003. */
  7004. directions: Vector3[];
  7005. /**
  7006. * Gets the 8 vectors representing the bounding box in world space
  7007. */
  7008. vectorsWorld: Vector3[];
  7009. /**
  7010. * Gets the minimum vector in world space
  7011. */
  7012. minimumWorld: Vector3;
  7013. /**
  7014. * Gets the maximum vector in world space
  7015. */
  7016. maximumWorld: Vector3;
  7017. /**
  7018. * Gets the minimum vector in local space
  7019. */
  7020. minimum: Vector3;
  7021. /**
  7022. * Gets the maximum vector in local space
  7023. */
  7024. maximum: Vector3;
  7025. private _worldMatrix;
  7026. private static TmpVector3;
  7027. /**
  7028. * @hidden
  7029. */
  7030. _tag: number;
  7031. /**
  7032. * Creates a new bounding box
  7033. * @param min defines the minimum vector (in local space)
  7034. * @param max defines the maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  7038. /**
  7039. * Recreates the entire bounding box from scratch
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7045. /**
  7046. * Scale the current bounding box by applying a scale factor
  7047. * @param factor defines the scale factor to apply
  7048. * @returns the current bounding box
  7049. */
  7050. scale(factor: number): BoundingBox;
  7051. /**
  7052. * Gets the world matrix of the bounding box
  7053. * @returns a matrix
  7054. */
  7055. getWorldMatrix(): Matrix;
  7056. /**
  7057. * Sets the world matrix stored in the bounding box
  7058. * @param matrix defines the matrix to store
  7059. * @returns current bounding box
  7060. */
  7061. setWorldMatrix(matrix: Matrix): BoundingBox;
  7062. /** @hidden */
  7063. _update(world: Matrix): void;
  7064. /**
  7065. * Tests if the bounding box is intersecting the frustum planes
  7066. * @param frustumPlanes defines the frustum planes to test
  7067. * @returns true if there is an intersection
  7068. */
  7069. isInFrustum(frustumPlanes: Plane[]): boolean;
  7070. /**
  7071. * Tests if the bounding box is entirely inside the frustum planes
  7072. * @param frustumPlanes defines the frustum planes to test
  7073. * @returns true if there is an inclusion
  7074. */
  7075. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7076. /**
  7077. * Tests if a point is inside the bounding box
  7078. * @param point defines the point to test
  7079. * @returns true if the point is inside the bounding box
  7080. */
  7081. intersectsPoint(point: Vector3): boolean;
  7082. /**
  7083. * Tests if the bounding box intersects with a bounding sphere
  7084. * @param sphere defines the sphere to test
  7085. * @returns true if there is an intersection
  7086. */
  7087. intersectsSphere(sphere: BoundingSphere): boolean;
  7088. /**
  7089. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7090. * @param min defines the min vector to use
  7091. * @param max defines the max vector to use
  7092. * @returns true if there is an intersection
  7093. */
  7094. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  7095. /**
  7096. * Tests if two bounding boxes are intersections
  7097. * @param box0 defines the first box to test
  7098. * @param box1 defines the second box to test
  7099. * @returns true if there is an intersection
  7100. */
  7101. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  7102. /**
  7103. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7104. * @param minPoint defines the minimum vector of the bounding box
  7105. * @param maxPoint defines the maximum vector of the bounding box
  7106. * @param sphereCenter defines the sphere center
  7107. * @param sphereRadius defines the sphere radius
  7108. * @returns true if there is an intersection
  7109. */
  7110. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  7111. /**
  7112. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7113. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7114. * @param frustumPlanes defines the frustum planes to test
  7115. * @return true if there is an inclusion
  7116. */
  7117. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7118. /**
  7119. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7120. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7121. * @param frustumPlanes defines the frustum planes to test
  7122. * @return true if there is an intersection
  7123. */
  7124. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Interface for cullable objects
  7130. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7131. */
  7132. interface ICullable {
  7133. /**
  7134. * Checks if the object or part of the object is in the frustum
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isInFrustum(frustumPlanes: Plane[]): boolean;
  7139. /**
  7140. * Checks if a cullable object (mesh...) is in the camera frustum
  7141. * Unlike isInFrustum this cheks the full bounding box
  7142. * @param frustumPlanes Camera near/planes
  7143. * @returns true if the object is in frustum otherwise false
  7144. */
  7145. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7146. }
  7147. /**
  7148. * Info for a bounding data of a mesh
  7149. */
  7150. class BoundingInfo implements ICullable {
  7151. /**
  7152. * Bounding box for the mesh
  7153. */
  7154. boundingBox: BoundingBox;
  7155. /**
  7156. * Bounding sphere for the mesh
  7157. */
  7158. boundingSphere: BoundingSphere;
  7159. private _isLocked;
  7160. /**
  7161. * Constructs bounding info
  7162. * @param minimum min vector of the bounding box/sphere
  7163. * @param maximum max vector of the bounding box/sphere
  7164. * @param worldMatrix defines the new world matrix
  7165. */
  7166. constructor(minimum: Vector3, maximum: Vector3, worldMatrix?: Matrix);
  7167. /**
  7168. * Recreates the entire bounding info from scratch
  7169. * @param min defines the new minimum vector (in local space)
  7170. * @param max defines the new maximum vector (in local space)
  7171. * @param worldMatrix defines the new world matrix
  7172. */
  7173. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7174. /**
  7175. * min vector of the bounding box/sphere
  7176. */
  7177. readonly minimum: Vector3;
  7178. /**
  7179. * max vector of the bounding box/sphere
  7180. */
  7181. readonly maximum: Vector3;
  7182. /**
  7183. * If the info is locked and won't be updated to avoid perf overhead
  7184. */
  7185. isLocked: boolean;
  7186. /**
  7187. * Updates the boudning sphere and box
  7188. * @param world world matrix to be used to update
  7189. */
  7190. update(world: Matrix): void;
  7191. /**
  7192. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7193. * @param center New center of the bounding info
  7194. * @param extend New extend of the bounding info
  7195. * @returns the current bounding info
  7196. */
  7197. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  7198. /**
  7199. * Scale the current bounding info by applying a scale factor
  7200. * @param factor defines the scale factor to apply
  7201. * @returns the current bounding info
  7202. */
  7203. scale(factor: number): BoundingInfo;
  7204. /**
  7205. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7206. * @param frustumPlanes defines the frustum to test
  7207. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7208. * @returns true if the bounding info is in the frustum planes
  7209. */
  7210. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  7211. /**
  7212. * Gets the world distance between the min and max points of the bounding box
  7213. */
  7214. readonly diagonalLength: number;
  7215. /**
  7216. * Checks if a cullable object (mesh...) is in the camera frustum
  7217. * Unlike isInFrustum this cheks the full bounding box
  7218. * @param frustumPlanes Camera near/planes
  7219. * @returns true if the object is in frustum otherwise false
  7220. */
  7221. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7222. /** @hidden */
  7223. _checkCollision(collider: Collider): boolean;
  7224. /**
  7225. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7226. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7227. * @param point the point to check intersection with
  7228. * @returns if the point intersects
  7229. */
  7230. intersectsPoint(point: Vector3): boolean;
  7231. /**
  7232. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7233. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7234. * @param boundingInfo the bounding info to check intersection with
  7235. * @param precise if the intersection should be done using OBB
  7236. * @returns if the bounding info intersects
  7237. */
  7238. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  7239. }
  7240. }
  7241. declare module BABYLON {
  7242. /**
  7243. * Class used to store bounding sphere information
  7244. */
  7245. class BoundingSphere {
  7246. /**
  7247. * Gets the center of the bounding sphere in local space
  7248. */
  7249. center: Vector3;
  7250. /**
  7251. * Radius of the bounding sphere in local space
  7252. */
  7253. radius: number;
  7254. /**
  7255. * Gets the center of the bounding sphere in world space
  7256. */
  7257. centerWorld: Vector3;
  7258. /**
  7259. * Radius of the bounding sphere in world space
  7260. */
  7261. radiusWorld: number;
  7262. /**
  7263. * Gets the minimum vector in local space
  7264. */
  7265. minimum: Vector3;
  7266. /**
  7267. * Gets the maximum vector in local space
  7268. */
  7269. maximum: Vector3;
  7270. private static TmpVector3;
  7271. /**
  7272. * Creates a new bounding sphere
  7273. * @param min defines the minimum vector (in local space)
  7274. * @param max defines the maximum vector (in local space)
  7275. * @param worldMatrix defines the new world matrix
  7276. */
  7277. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  7278. /**
  7279. * Recreates the entire bounding sphere from scratch
  7280. * @param min defines the new minimum vector (in local space)
  7281. * @param max defines the new maximum vector (in local space)
  7282. * @param worldMatrix defines the new world matrix
  7283. */
  7284. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  7285. /**
  7286. * Scale the current bounding sphere by applying a scale factor
  7287. * @param factor defines the scale factor to apply
  7288. * @returns the current bounding box
  7289. */
  7290. scale(factor: number): BoundingSphere;
  7291. /** @hidden */
  7292. _update(world: Matrix): void;
  7293. /**
  7294. * Tests if the bounding sphere is intersecting the frustum planes
  7295. * @param frustumPlanes defines the frustum planes to test
  7296. * @returns true if there is an intersection
  7297. */
  7298. isInFrustum(frustumPlanes: Plane[]): boolean;
  7299. /**
  7300. * Tests if a point is inside the bounding sphere
  7301. * @param point defines the point to test
  7302. * @returns true if the point is inside the bounding sphere
  7303. */
  7304. intersectsPoint(point: Vector3): boolean;
  7305. /**
  7306. * Checks if two sphere intersct
  7307. * @param sphere0 sphere 0
  7308. * @param sphere1 sphere 1
  7309. * @returns true if the speres intersect
  7310. */
  7311. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  7312. }
  7313. }
  7314. declare module BABYLON {
  7315. /**
  7316. * Class representing a ray with position and direction
  7317. */
  7318. class Ray {
  7319. /** origin point */
  7320. origin: Vector3;
  7321. /** direction */
  7322. direction: Vector3;
  7323. /** length of the ray */
  7324. length: number;
  7325. private _edge1;
  7326. private _edge2;
  7327. private _pvec;
  7328. private _tvec;
  7329. private _qvec;
  7330. private _tmpRay;
  7331. /**
  7332. * Creates a new ray
  7333. * @param origin origin point
  7334. * @param direction direction
  7335. * @param length length of the ray
  7336. */
  7337. constructor(
  7338. /** origin point */
  7339. origin: Vector3,
  7340. /** direction */
  7341. direction: Vector3,
  7342. /** length of the ray */
  7343. length?: number);
  7344. /**
  7345. * Checks if the ray intersects a box
  7346. * @param minimum bound of the box
  7347. * @param maximum bound of the box
  7348. * @returns if the box was hit
  7349. */
  7350. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  7351. /**
  7352. * Checks if the ray intersects a box
  7353. * @param box the bounding box to check
  7354. * @returns if the box was hit
  7355. */
  7356. intersectsBox(box: BoundingBox): boolean;
  7357. /**
  7358. * If the ray hits a sphere
  7359. * @param sphere the bounding sphere to check
  7360. * @returns true if it hits the sphere
  7361. */
  7362. intersectsSphere(sphere: BoundingSphere): boolean;
  7363. /**
  7364. * If the ray hits a triange
  7365. * @param vertex0 triangle vertex
  7366. * @param vertex1 triangle vertex
  7367. * @param vertex2 triangle vertex
  7368. * @returns intersection information if hit
  7369. */
  7370. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  7371. /**
  7372. * Checks if ray intersects a plane
  7373. * @param plane the plane to check
  7374. * @returns the distance away it was hit
  7375. */
  7376. intersectsPlane(plane: Plane): Nullable<number>;
  7377. /**
  7378. * Checks if ray intersects a mesh
  7379. * @param mesh the mesh to check
  7380. * @param fastCheck if only the bounding box should checked
  7381. * @returns picking info of the intersecton
  7382. */
  7383. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  7384. /**
  7385. * Checks if ray intersects a mesh
  7386. * @param meshes the meshes to check
  7387. * @param fastCheck if only the bounding box should checked
  7388. * @param results array to store result in
  7389. * @returns Array of picking infos
  7390. */
  7391. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7392. private _comparePickingInfo;
  7393. private static smallnum;
  7394. private static rayl;
  7395. /**
  7396. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7397. * @param sega the first point of the segment to test the intersection against
  7398. * @param segb the second point of the segment to test the intersection against
  7399. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7400. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7401. */
  7402. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  7403. /**
  7404. * Update the ray from viewport position
  7405. * @param x position
  7406. * @param y y position
  7407. * @param viewportWidth viewport width
  7408. * @param viewportHeight viewport height
  7409. * @param world world matrix
  7410. * @param view view matrix
  7411. * @param projection projection matrix
  7412. * @returns this ray updated
  7413. */
  7414. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7415. /**
  7416. * Creates a ray with origin and direction of 0,0,0
  7417. * @returns the new ray
  7418. */
  7419. static Zero(): Ray;
  7420. /**
  7421. * Creates a new ray from screen space and viewport
  7422. * @param x position
  7423. * @param y y position
  7424. * @param viewportWidth viewport width
  7425. * @param viewportHeight viewport height
  7426. * @param world world matrix
  7427. * @param view view matrix
  7428. * @param projection projection matrix
  7429. * @returns new ray
  7430. */
  7431. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  7432. /**
  7433. * 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
  7434. * transformed to the given world matrix.
  7435. * @param origin The origin point
  7436. * @param end The end point
  7437. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7438. * @returns the new ray
  7439. */
  7440. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  7441. /**
  7442. * Transforms a ray by a matrix
  7443. * @param ray ray to transform
  7444. * @param matrix matrix to apply
  7445. * @returns the resulting new ray
  7446. */
  7447. static Transform(ray: Ray, matrix: Matrix): Ray;
  7448. /**
  7449. * Transforms a ray by a matrix
  7450. * @param ray ray to transform
  7451. * @param matrix matrix to apply
  7452. * @param result ray to store result in
  7453. */
  7454. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  7455. }
  7456. }
  7457. declare module BABYLON {
  7458. /**
  7459. * This represents an orbital type of camera.
  7460. *
  7461. * 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.
  7462. * 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.
  7463. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7464. */
  7465. class ArcRotateCamera extends TargetCamera {
  7466. /**
  7467. * Defines the rotation angle of the camera along the longitudinal axis.
  7468. */
  7469. alpha: number;
  7470. /**
  7471. * Defines the rotation angle of the camera along the latitudinal axis.
  7472. */
  7473. beta: number;
  7474. /**
  7475. * Defines the radius of the camera from it s target point.
  7476. */
  7477. radius: number;
  7478. protected _target: Vector3;
  7479. protected _targetHost: Nullable<AbstractMesh>;
  7480. /**
  7481. * Defines the target point of the camera.
  7482. * The camera looks towards it form the radius distance.
  7483. */
  7484. target: Vector3;
  7485. /**
  7486. * Current inertia value on the longitudinal axis.
  7487. * The bigger this number the longer it will take for the camera to stop.
  7488. */
  7489. inertialAlphaOffset: number;
  7490. /**
  7491. * Current inertia value on the latitudinal axis.
  7492. * The bigger this number the longer it will take for the camera to stop.
  7493. */
  7494. inertialBetaOffset: number;
  7495. /**
  7496. * Current inertia value on the radius axis.
  7497. * The bigger this number the longer it will take for the camera to stop.
  7498. */
  7499. inertialRadiusOffset: number;
  7500. /**
  7501. * Minimum allowed angle on the longitudinal axis.
  7502. * This can help limiting how the Camera is able to move in the scene.
  7503. */
  7504. lowerAlphaLimit: Nullable<number>;
  7505. /**
  7506. * Maximum allowed angle on the longitudinal axis.
  7507. * This can help limiting how the Camera is able to move in the scene.
  7508. */
  7509. upperAlphaLimit: Nullable<number>;
  7510. /**
  7511. * Minimum allowed angle on the latitudinal axis.
  7512. * This can help limiting how the Camera is able to move in the scene.
  7513. */
  7514. lowerBetaLimit: number;
  7515. /**
  7516. * Maximum allowed angle on the latitudinal axis.
  7517. * This can help limiting how the Camera is able to move in the scene.
  7518. */
  7519. upperBetaLimit: number;
  7520. /**
  7521. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7522. * This can help limiting how the Camera is able to move in the scene.
  7523. */
  7524. lowerRadiusLimit: Nullable<number>;
  7525. /**
  7526. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7527. * This can help limiting how the Camera is able to move in the scene.
  7528. */
  7529. upperRadiusLimit: Nullable<number>;
  7530. /**
  7531. * Defines the current inertia value used during panning of the camera along the X axis.
  7532. */
  7533. inertialPanningX: number;
  7534. /**
  7535. * Defines the current inertia value used during panning of the camera along the Y axis.
  7536. */
  7537. inertialPanningY: number;
  7538. /**
  7539. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7540. * Basically if your fingers moves away from more than this distance you will be considered
  7541. * in pinch mode.
  7542. */
  7543. pinchToPanMaxDistance: number;
  7544. /**
  7545. * Defines the maximum distance the camera can pan.
  7546. * This could help keeping the cammera always in your scene.
  7547. */
  7548. panningDistanceLimit: Nullable<number>;
  7549. /**
  7550. * Defines the target of the camera before paning.
  7551. */
  7552. panningOriginTarget: Vector3;
  7553. /**
  7554. * Defines the value of the inertia used during panning.
  7555. * 0 would mean stop inertia and one would mean no decelleration at all.
  7556. */
  7557. panningInertia: number;
  7558. /**
  7559. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7560. */
  7561. angularSensibilityX: number;
  7562. /**
  7563. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7564. */
  7565. angularSensibilityY: number;
  7566. /**
  7567. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7568. */
  7569. pinchPrecision: number;
  7570. /**
  7571. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7572. * It will be used instead of pinchDeltaPrecision if different from 0.
  7573. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7574. */
  7575. pinchDeltaPercentage: number;
  7576. /**
  7577. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7578. */
  7579. panningSensibility: number;
  7580. /**
  7581. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7582. */
  7583. keysUp: number[];
  7584. /**
  7585. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7586. */
  7587. keysDown: number[];
  7588. /**
  7589. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7590. */
  7591. keysLeft: number[];
  7592. /**
  7593. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7594. */
  7595. keysRight: number[];
  7596. /**
  7597. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7598. */
  7599. wheelPrecision: number;
  7600. /**
  7601. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7602. * It will be used instead of pinchDeltaPrecision if different from 0.
  7603. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7604. */
  7605. wheelDeltaPercentage: number;
  7606. /**
  7607. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7608. */
  7609. zoomOnFactor: number;
  7610. /**
  7611. * Defines a screen offset for the camera position.
  7612. */
  7613. targetScreenOffset: Vector2;
  7614. /**
  7615. * Allows the camera to be completely reversed.
  7616. * If false the camera can not arrive upside down.
  7617. */
  7618. allowUpsideDown: boolean;
  7619. /**
  7620. * Define if double tap/click is used to restore the previously saved state of the camera.
  7621. */
  7622. useInputToRestoreState: boolean;
  7623. /** @hidden */
  7624. _viewMatrix: Matrix;
  7625. /** @hidden */
  7626. _useCtrlForPanning: boolean;
  7627. /** @hidden */
  7628. _panningMouseButton: number;
  7629. /**
  7630. * Defines the inpute associated to the camera.
  7631. */
  7632. inputs: ArcRotateCameraInputsManager;
  7633. /** @hidden */
  7634. _reset: () => void;
  7635. /**
  7636. * Defines the allowed panning axis.
  7637. */
  7638. panningAxis: Vector3;
  7639. protected _localDirection: Vector3;
  7640. protected _transformedDirection: Vector3;
  7641. private _bouncingBehavior;
  7642. /**
  7643. * Gets the bouncing behavior of the camera if it has been enabled.
  7644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7645. */
  7646. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7647. /**
  7648. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7650. */
  7651. useBouncingBehavior: boolean;
  7652. private _framingBehavior;
  7653. /**
  7654. * Gets the framing behavior of the camera if it has been enabled.
  7655. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7656. */
  7657. readonly framingBehavior: Nullable<FramingBehavior>;
  7658. /**
  7659. * Defines if the framing behavior of the camera is enabled on the camera.
  7660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7661. */
  7662. useFramingBehavior: boolean;
  7663. private _autoRotationBehavior;
  7664. /**
  7665. * Gets the auto rotation behavior of the camera if it has been enabled.
  7666. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7667. */
  7668. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7669. /**
  7670. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7672. */
  7673. useAutoRotationBehavior: boolean;
  7674. /**
  7675. * Observable triggered when the mesh target has been changed on the camera.
  7676. */
  7677. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7678. /**
  7679. * Event raised when the camera is colliding with a mesh.
  7680. */
  7681. onCollide: (collidedMesh: AbstractMesh) => void;
  7682. /**
  7683. * Defines whether the camera should check collision with the objects oh the scene.
  7684. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7685. */
  7686. checkCollisions: boolean;
  7687. /**
  7688. * Defines the collision radius of the camera.
  7689. * This simulates a sphere around the camera.
  7690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7691. */
  7692. collisionRadius: Vector3;
  7693. protected _collider: Collider;
  7694. protected _previousPosition: Vector3;
  7695. protected _collisionVelocity: Vector3;
  7696. protected _newPosition: Vector3;
  7697. protected _previousAlpha: number;
  7698. protected _previousBeta: number;
  7699. protected _previousRadius: number;
  7700. protected _collisionTriggered: boolean;
  7701. protected _targetBoundingCenter: Nullable<Vector3>;
  7702. private _computationVector;
  7703. /**
  7704. * Instantiates a new ArcRotateCamera in a given scene
  7705. * @param name Defines the name of the camera
  7706. * @param alpha Defines the camera rotation along the logitudinal axis
  7707. * @param beta Defines the camera rotation along the latitudinal axis
  7708. * @param radius Defines the camera distance from its target
  7709. * @param target Defines the camera target
  7710. * @param scene Defines the scene the camera belongs to
  7711. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7712. */
  7713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7714. /** @hidden */
  7715. _initCache(): void;
  7716. /** @hidden */
  7717. _updateCache(ignoreParentClass?: boolean): void;
  7718. protected _getTargetPosition(): Vector3;
  7719. private _storedAlpha;
  7720. private _storedBeta;
  7721. private _storedRadius;
  7722. private _storedTarget;
  7723. /**
  7724. * Stores the current state of the camera (alpha, beta, radius and target)
  7725. * @returns the camera itself
  7726. */
  7727. storeState(): Camera;
  7728. /**
  7729. * @hidden
  7730. * Restored camera state. You must call storeState() first
  7731. */
  7732. _restoreStateValues(): boolean;
  7733. /** @hidden */
  7734. _isSynchronizedViewMatrix(): boolean;
  7735. /**
  7736. * Attached controls to the current camera.
  7737. * @param element Defines the element the controls should be listened from
  7738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7739. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7740. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7741. */
  7742. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7743. /**
  7744. * Detach the current controls from the camera.
  7745. * The camera will stop reacting to inputs.
  7746. * @param element Defines the element to stop listening the inputs from
  7747. */
  7748. detachControl(element: HTMLElement): void;
  7749. /** @hidden */
  7750. _checkInputs(): void;
  7751. protected _checkLimits(): void;
  7752. /**
  7753. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7754. */
  7755. rebuildAnglesAndRadius(): void;
  7756. /**
  7757. * Use a position to define the current camera related information like aplha, beta and radius
  7758. * @param position Defines the position to set the camera at
  7759. */
  7760. setPosition(position: Vector3): void;
  7761. /**
  7762. * Defines the target the camera should look at.
  7763. * This will automatically adapt alpha beta and radius to fit within the new target.
  7764. * @param target Defines the new target as a Vector or a mesh
  7765. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7766. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7767. */
  7768. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7769. /** @hidden */
  7770. _getViewMatrix(): Matrix;
  7771. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7772. /**
  7773. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7774. * @param meshes Defines the mesh to zoom on
  7775. * @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)
  7776. */
  7777. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7778. /**
  7779. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7780. * The target will be changed but the radius
  7781. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7782. * @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)
  7783. */
  7784. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7785. min: Vector3;
  7786. max: Vector3;
  7787. distance: number;
  7788. }, doNotUpdateMaxZ?: boolean): void;
  7789. /**
  7790. * @override
  7791. * Override Camera.createRigCamera
  7792. */
  7793. createRigCamera(name: string, cameraIndex: number): Camera;
  7794. /**
  7795. * @hidden
  7796. * @override
  7797. * Override Camera._updateRigCameras
  7798. */
  7799. _updateRigCameras(): void;
  7800. /**
  7801. * Destroy the camera and release the current resources hold by it.
  7802. */
  7803. dispose(): void;
  7804. /**
  7805. * Gets the current object class name.
  7806. * @return the class name
  7807. */
  7808. getClassName(): string;
  7809. }
  7810. }
  7811. declare module BABYLON {
  7812. /**
  7813. * Default Inputs manager for the ArcRotateCamera.
  7814. * It groups all the default supported inputs for ease of use.
  7815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7816. */
  7817. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7818. /**
  7819. * Instantiates a new ArcRotateCameraInputsManager.
  7820. * @param camera Defines the camera the inputs belong to
  7821. */
  7822. constructor(camera: ArcRotateCamera);
  7823. /**
  7824. * Add mouse wheel input support to the input manager.
  7825. * @returns the current input manager
  7826. */
  7827. addMouseWheel(): ArcRotateCameraInputsManager;
  7828. /**
  7829. * Add pointers input support to the input manager.
  7830. * @returns the current input manager
  7831. */
  7832. addPointers(): ArcRotateCameraInputsManager;
  7833. /**
  7834. * Add keyboard input support to the input manager.
  7835. * @returns the current input manager
  7836. */
  7837. addKeyboard(): ArcRotateCameraInputsManager;
  7838. /**
  7839. * Add orientation input support to the input manager.
  7840. * @returns the current input manager
  7841. */
  7842. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7843. }
  7844. }
  7845. declare module BABYLON {
  7846. /**
  7847. * This is the base class of all the camera used in the application.
  7848. * @see http://doc.babylonjs.com/features/cameras
  7849. */
  7850. class Camera extends Node {
  7851. /**
  7852. * This is the default projection mode used by the cameras.
  7853. * It helps recreating a feeling of perspective and better appreciate depth.
  7854. * This is the best way to simulate real life cameras.
  7855. */
  7856. static readonly PERSPECTIVE_CAMERA: number;
  7857. /**
  7858. * This helps creating camera with an orthographic mode.
  7859. * 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.
  7860. */
  7861. static readonly ORTHOGRAPHIC_CAMERA: number;
  7862. /**
  7863. * This is the default FOV mode for perspective cameras.
  7864. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7865. */
  7866. static readonly FOVMODE_VERTICAL_FIXED: number;
  7867. /**
  7868. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7869. */
  7870. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7871. /**
  7872. * This specifies ther is no need for a camera rig.
  7873. * Basically only one eye is rendered corresponding to the camera.
  7874. */
  7875. static readonly RIG_MODE_NONE: number;
  7876. /**
  7877. * Simulates a camera Rig with one blue eye and one red eye.
  7878. * This can be use with 3d blue and red glasses.
  7879. */
  7880. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7881. /**
  7882. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7883. */
  7884. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7885. /**
  7886. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7887. */
  7888. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7889. /**
  7890. * Defines that both eyes of the camera will be rendered over under each other.
  7891. */
  7892. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7893. /**
  7894. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7895. */
  7896. static readonly RIG_MODE_VR: number;
  7897. /**
  7898. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7899. */
  7900. static readonly RIG_MODE_WEBVR: number;
  7901. /**
  7902. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7903. */
  7904. static readonly RIG_MODE_CUSTOM: number;
  7905. /**
  7906. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7907. */
  7908. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7909. /**
  7910. * @hidden
  7911. * Might be removed once multiview will be a thing
  7912. */
  7913. static UseAlternateWebVRRendering: boolean;
  7914. /**
  7915. * Define the input manager associated with the camera.
  7916. */
  7917. inputs: CameraInputsManager<Camera>;
  7918. /**
  7919. * Define the current local position of the camera in the scene
  7920. */
  7921. position: Vector3;
  7922. /**
  7923. * The vector the camera should consider as up.
  7924. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7925. */
  7926. upVector: Vector3;
  7927. /**
  7928. * Define the current limit on the left side for an orthographic camera
  7929. * In scene unit
  7930. */
  7931. orthoLeft: Nullable<number>;
  7932. /**
  7933. * Define the current limit on the right side for an orthographic camera
  7934. * In scene unit
  7935. */
  7936. orthoRight: Nullable<number>;
  7937. /**
  7938. * Define the current limit on the bottom side for an orthographic camera
  7939. * In scene unit
  7940. */
  7941. orthoBottom: Nullable<number>;
  7942. /**
  7943. * Define the current limit on the top side for an orthographic camera
  7944. * In scene unit
  7945. */
  7946. orthoTop: Nullable<number>;
  7947. /**
  7948. * Field Of View is set in Radians. (default is 0.8)
  7949. */
  7950. fov: number;
  7951. /**
  7952. * Define the minimum distance the camera can see from.
  7953. * This is important to note that the depth buffer are not infinite and the closer it starts
  7954. * the more your scene might encounter depth fighting issue.
  7955. */
  7956. minZ: number;
  7957. /**
  7958. * Define the maximum distance the camera can see to.
  7959. * This is important to note that the depth buffer are not infinite and the further it end
  7960. * the more your scene might encounter depth fighting issue.
  7961. */
  7962. maxZ: number;
  7963. /**
  7964. * Define the default inertia of the camera.
  7965. * This helps giving a smooth feeling to the camera movement.
  7966. */
  7967. inertia: number;
  7968. /**
  7969. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7970. */
  7971. mode: number;
  7972. /**
  7973. * Define wether the camera is intermediate.
  7974. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7975. */
  7976. isIntermediate: boolean;
  7977. /**
  7978. * Define the viewport of the camera.
  7979. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7980. */
  7981. viewport: Viewport;
  7982. /**
  7983. * Restricts the camera to viewing objects with the same layerMask.
  7984. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7985. */
  7986. layerMask: number;
  7987. /**
  7988. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7989. */
  7990. fovMode: number;
  7991. /**
  7992. * Rig mode of the camera.
  7993. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7994. * This is normally controlled byt the camera themselves as internal use.
  7995. */
  7996. cameraRigMode: number;
  7997. /**
  7998. * Defines the distance between both "eyes" in case of a RIG
  7999. */
  8000. interaxialDistance: number;
  8001. /**
  8002. * Defines if stereoscopic rendering is done side by side or over under.
  8003. */
  8004. isStereoscopicSideBySide: boolean;
  8005. /**
  8006. * Defines the list of custom render target the camera should render to.
  8007. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8008. * else in the scene.
  8009. */
  8010. customRenderTargets: RenderTargetTexture[];
  8011. /**
  8012. * When set, the camera will render to this render target instead of the default canvas
  8013. */
  8014. customDefaultRenderTarget: Nullable<RenderTargetTexture>;
  8015. /**
  8016. * Observable triggered when the camera view matrix has changed.
  8017. */
  8018. onViewMatrixChangedObservable: Observable<Camera>;
  8019. /**
  8020. * Observable triggered when the camera Projection matrix has changed.
  8021. */
  8022. onProjectionMatrixChangedObservable: Observable<Camera>;
  8023. /**
  8024. * Observable triggered when the inputs have been processed.
  8025. */
  8026. onAfterCheckInputsObservable: Observable<Camera>;
  8027. /**
  8028. * Observable triggered when reset has been called and applied to the camera.
  8029. */
  8030. onRestoreStateObservable: Observable<Camera>;
  8031. /** @hidden */
  8032. _cameraRigParams: any;
  8033. /** @hidden */
  8034. _rigCameras: Camera[];
  8035. /** @hidden */
  8036. _rigPostProcess: Nullable<PostProcess>;
  8037. protected _webvrViewMatrix: Matrix;
  8038. /** @hidden */
  8039. _skipRendering: boolean;
  8040. /** @hidden */
  8041. _alternateCamera: Camera;
  8042. /** @hidden */
  8043. _projectionMatrix: Matrix;
  8044. /** @hidden */
  8045. _postProcesses: Nullable<PostProcess>[];
  8046. /** @hidden */
  8047. _activeMeshes: SmartArray<AbstractMesh>;
  8048. protected _globalPosition: Vector3;
  8049. private _computedViewMatrix;
  8050. private _doNotComputeProjectionMatrix;
  8051. private _transformMatrix;
  8052. private _frustumPlanes;
  8053. private _refreshFrustumPlanes;
  8054. private _storedFov;
  8055. private _stateStored;
  8056. /**
  8057. * Instantiates a new camera object.
  8058. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8059. * @see http://doc.babylonjs.com/features/cameras
  8060. * @param name Defines the name of the camera in the scene
  8061. * @param position Defines the position of the camera
  8062. * @param scene Defines the scene the camera belongs too
  8063. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8064. */
  8065. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8066. /**
  8067. * Store current camera state (fov, position, etc..)
  8068. * @returns the camera
  8069. */
  8070. storeState(): Camera;
  8071. /**
  8072. * Restores the camera state values if it has been stored. You must call storeState() first
  8073. */
  8074. protected _restoreStateValues(): boolean;
  8075. /**
  8076. * Restored camera state. You must call storeState() first.
  8077. * @returns true if restored and false otherwise
  8078. */
  8079. restoreState(): boolean;
  8080. /**
  8081. * Gets the class name of the camera.
  8082. * @returns the class name
  8083. */
  8084. getClassName(): string;
  8085. /**
  8086. * Gets a string representation of the camera usefull for debug purpose.
  8087. * @param fullDetails Defines that a more verboe level of logging is required
  8088. * @returns the string representation
  8089. */
  8090. toString(fullDetails?: boolean): string;
  8091. /**
  8092. * Gets the current world space position of the camera.
  8093. */
  8094. readonly globalPosition: Vector3;
  8095. /**
  8096. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8097. * @returns the active meshe list
  8098. */
  8099. getActiveMeshes(): SmartArray<AbstractMesh>;
  8100. /**
  8101. * Check wether a mesh is part of the current active mesh list of the camera
  8102. * @param mesh Defines the mesh to check
  8103. * @returns true if active, false otherwise
  8104. */
  8105. isActiveMesh(mesh: Mesh): boolean;
  8106. /**
  8107. * Is this camera ready to be used/rendered
  8108. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8109. * @return true if the camera is ready
  8110. */
  8111. isReady(completeCheck?: boolean): boolean;
  8112. /** @hidden */
  8113. _initCache(): void;
  8114. /** @hidden */
  8115. _updateCache(ignoreParentClass?: boolean): void;
  8116. /** @hidden */
  8117. _isSynchronized(): boolean;
  8118. /** @hidden */
  8119. _isSynchronizedViewMatrix(): boolean;
  8120. /** @hidden */
  8121. _isSynchronizedProjectionMatrix(): boolean;
  8122. /**
  8123. * Attach the input controls to a specific dom element to get the input from.
  8124. * @param element Defines the element the controls should be listened from
  8125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8126. */
  8127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8128. /**
  8129. * Detach the current controls from the specified dom element.
  8130. * @param element Defines the element to stop listening the inputs from
  8131. */
  8132. detachControl(element: HTMLElement): void;
  8133. /**
  8134. * Update the camera state according to the different inputs gathered during the frame.
  8135. */
  8136. update(): void;
  8137. /** @hidden */
  8138. _checkInputs(): void;
  8139. /** @hidden */
  8140. readonly rigCameras: Camera[];
  8141. /**
  8142. * Gets the post process used by the rig cameras
  8143. */
  8144. readonly rigPostProcess: Nullable<PostProcess>;
  8145. /**
  8146. * Internal, gets the first post proces.
  8147. * @returns the first post process to be run on this camera.
  8148. */
  8149. _getFirstPostProcess(): Nullable<PostProcess>;
  8150. private _cascadePostProcessesToRigCams;
  8151. /**
  8152. * Attach a post process to the camera.
  8153. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8154. * @param postProcess The post process to attach to the camera
  8155. * @param insertAt The position of the post process in case several of them are in use in the scene
  8156. * @returns the position the post process has been inserted at
  8157. */
  8158. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8159. /**
  8160. * Detach a post process to the camera.
  8161. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8162. * @param postProcess The post process to detach from the camera
  8163. */
  8164. detachPostProcess(postProcess: PostProcess): void;
  8165. /**
  8166. * Gets the current world matrix of the camera
  8167. */
  8168. getWorldMatrix(): Matrix;
  8169. /** @hidden */
  8170. protected _getViewMatrix(): Matrix;
  8171. /**
  8172. * Gets the current view matrix of the camera.
  8173. * @param force forces the camera to recompute the matrix without looking at the cached state
  8174. * @returns the view matrix
  8175. */
  8176. getViewMatrix(force?: boolean): Matrix;
  8177. /**
  8178. * Freeze the projection matrix.
  8179. * It will prevent the cache check of the camera projection compute and can speed up perf
  8180. * if no parameter of the camera are meant to change
  8181. * @param projection Defines manually a projection if necessary
  8182. */
  8183. freezeProjectionMatrix(projection?: Matrix): void;
  8184. /**
  8185. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8186. */
  8187. unfreezeProjectionMatrix(): void;
  8188. /**
  8189. * Gets the current projection matrix of the camera.
  8190. * @param force forces the camera to recompute the matrix without looking at the cached state
  8191. * @returns the projection matrix
  8192. */
  8193. getProjectionMatrix(force?: boolean): Matrix;
  8194. /**
  8195. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8196. * @returns a Matrix
  8197. */
  8198. getTransformationMatrix(): Matrix;
  8199. private _updateFrustumPlanes;
  8200. /**
  8201. * Checks if a cullable object (mesh...) is in the camera frustum
  8202. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8203. * @param target The object to check
  8204. * @returns true if the object is in frustum otherwise false
  8205. */
  8206. isInFrustum(target: ICullable): boolean;
  8207. /**
  8208. * Checks if a cullable object (mesh...) is in the camera frustum
  8209. * Unlike isInFrustum this cheks the full bounding box
  8210. * @param target The object to check
  8211. * @returns true if the object is in frustum otherwise false
  8212. */
  8213. isCompletelyInFrustum(target: ICullable): boolean;
  8214. /**
  8215. * Gets a ray in the forward direction from the camera.
  8216. * @param length Defines the length of the ray to create
  8217. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8218. * @param origin Defines the start point of the ray which defaults to the camera position
  8219. * @returns the forward ray
  8220. */
  8221. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8222. /**
  8223. * Releases resources associated with this node.
  8224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8226. */
  8227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8228. /**
  8229. * Gets the left camera of a rig setup in case of Rigged Camera
  8230. */
  8231. readonly leftCamera: Nullable<FreeCamera>;
  8232. /**
  8233. * Gets the right camera of a rig setup in case of Rigged Camera
  8234. */
  8235. readonly rightCamera: Nullable<FreeCamera>;
  8236. /**
  8237. * Gets the left camera target of a rig setup in case of Rigged Camera
  8238. * @returns the target position
  8239. */
  8240. getLeftTarget(): Nullable<Vector3>;
  8241. /**
  8242. * Gets the right camera target of a rig setup in case of Rigged Camera
  8243. * @returns the target position
  8244. */
  8245. getRightTarget(): Nullable<Vector3>;
  8246. /**
  8247. * @hidden
  8248. */
  8249. setCameraRigMode(mode: number, rigParams: any): void;
  8250. private _getVRProjectionMatrix;
  8251. protected _updateCameraRotationMatrix(): void;
  8252. protected _updateWebVRCameraRotationMatrix(): void;
  8253. /**
  8254. * This function MUST be overwritten by the different WebVR cameras available.
  8255. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8256. */
  8257. protected _getWebVRProjectionMatrix(): Matrix;
  8258. /**
  8259. * This function MUST be overwritten by the different WebVR cameras available.
  8260. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8261. */
  8262. protected _getWebVRViewMatrix(): Matrix;
  8263. /** @hidden */
  8264. setCameraRigParameter(name: string, value: any): void;
  8265. /**
  8266. * needs to be overridden by children so sub has required properties to be copied
  8267. * @hidden
  8268. */
  8269. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8270. /**
  8271. * May need to be overridden by children
  8272. * @hidden
  8273. */
  8274. _updateRigCameras(): void;
  8275. /** @hidden */
  8276. _setupInputs(): void;
  8277. /**
  8278. * Serialiaze the camera setup to a json represention
  8279. * @returns the JSON representation
  8280. */
  8281. serialize(): any;
  8282. /**
  8283. * Clones the current camera.
  8284. * @param name The cloned camera name
  8285. * @returns the cloned camera
  8286. */
  8287. clone(name: string): Camera;
  8288. /**
  8289. * Gets the direction of the camera relative to a given local axis.
  8290. * @param localAxis Defines the reference axis to provide a relative direction.
  8291. * @return the direction
  8292. */
  8293. getDirection(localAxis: Vector3): Vector3;
  8294. /**
  8295. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8296. * @param localAxis Defines the reference axis to provide a relative direction.
  8297. * @param result Defines the vector to store the result in
  8298. */
  8299. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8300. /**
  8301. * Gets a camera constructor for a given camera type
  8302. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8303. * @param name The name of the camera the result will be able to instantiate
  8304. * @param scene The scene the result will construct the camera in
  8305. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8306. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8307. * @returns a factory method to construc the camera
  8308. */
  8309. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8310. /**
  8311. * Compute the world matrix of the camera.
  8312. * @returns the camera workd matrix
  8313. */
  8314. computeWorldMatrix(): Matrix;
  8315. /**
  8316. * Parse a JSON and creates the camera from the parsed information
  8317. * @param parsedCamera The JSON to parse
  8318. * @param scene The scene to instantiate the camera in
  8319. * @returns the newly constructed camera
  8320. */
  8321. static Parse(parsedCamera: any, scene: Scene): Camera;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * @ignore
  8327. * This is a list of all the different input types that are available in the application.
  8328. * Fo instance: ArcRotateCameraGamepadInput...
  8329. */
  8330. var CameraInputTypes: {};
  8331. /**
  8332. * This is the contract to implement in order to create a new input class.
  8333. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8334. */
  8335. interface ICameraInput<TCamera extends Camera> {
  8336. /**
  8337. * Defines the camera the input is attached to.
  8338. */
  8339. camera: Nullable<TCamera>;
  8340. /**
  8341. * Gets the class name of the current intput.
  8342. * @returns the class name
  8343. */
  8344. getClassName(): string;
  8345. /**
  8346. * Get the friendly name associated with the input class.
  8347. * @returns the input friendly name
  8348. */
  8349. getSimpleName(): string;
  8350. /**
  8351. * Attach the input controls to a specific dom element to get the input from.
  8352. * @param element Defines the element the controls should be listened from
  8353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8354. */
  8355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8356. /**
  8357. * Detach the current controls from the specified dom element.
  8358. * @param element Defines the element to stop listening the inputs from
  8359. */
  8360. detachControl(element: Nullable<HTMLElement>): void;
  8361. /**
  8362. * Update the current camera state depending on the inputs that have been used this frame.
  8363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8364. */
  8365. checkInputs?: () => void;
  8366. }
  8367. /**
  8368. * Represents a map of input types to input instance or input index to input instance.
  8369. */
  8370. interface CameraInputsMap<TCamera extends Camera> {
  8371. /**
  8372. * Accessor to the input by input type.
  8373. */
  8374. [name: string]: ICameraInput<TCamera>;
  8375. /**
  8376. * Accessor to the input by input index.
  8377. */
  8378. [idx: number]: ICameraInput<TCamera>;
  8379. }
  8380. /**
  8381. * This represents the input manager used within a camera.
  8382. * It helps dealing with all the different kind of input attached to a camera.
  8383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8384. */
  8385. class CameraInputsManager<TCamera extends Camera> {
  8386. /**
  8387. * Defines the list of inputs attahed to the camera.
  8388. */
  8389. attached: CameraInputsMap<TCamera>;
  8390. /**
  8391. * Defines the dom element the camera is collecting inputs from.
  8392. * This is null if the controls have not been attached.
  8393. */
  8394. attachedElement: Nullable<HTMLElement>;
  8395. /**
  8396. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8397. */
  8398. noPreventDefault: boolean;
  8399. /**
  8400. * Defined the camera the input manager belongs to.
  8401. */
  8402. camera: TCamera;
  8403. /**
  8404. * Update the current camera state depending on the inputs that have been used this frame.
  8405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8406. */
  8407. checkInputs: () => void;
  8408. /**
  8409. * Instantiate a new Camera Input Manager.
  8410. * @param camera Defines the camera the input manager blongs to
  8411. */
  8412. constructor(camera: TCamera);
  8413. /**
  8414. * Add an input method to a camera
  8415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8416. * @param input camera input method
  8417. */
  8418. add(input: ICameraInput<TCamera>): void;
  8419. /**
  8420. * Remove a specific input method from a camera
  8421. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8422. * @param inputToRemove camera input method
  8423. */
  8424. remove(inputToRemove: ICameraInput<TCamera>): void;
  8425. /**
  8426. * Remove a specific input type from a camera
  8427. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8428. * @param inputType the type of the input to remove
  8429. */
  8430. removeByType(inputType: string): void;
  8431. private _addCheckInputs;
  8432. /**
  8433. * Attach the input controls to the currently attached dom element to listen the events from.
  8434. * @param input Defines the input to attach
  8435. */
  8436. attachInput(input: ICameraInput<TCamera>): void;
  8437. /**
  8438. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8439. * @param element Defines the dom element to collect the events from
  8440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8441. */
  8442. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8443. /**
  8444. * Detach the current manager inputs controls from a specific dom element.
  8445. * @param element Defines the dom element to collect the events from
  8446. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8447. */
  8448. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8449. /**
  8450. * Rebuild the dynamic inputCheck function from the current list of
  8451. * defined inputs in the manager.
  8452. */
  8453. rebuildInputCheck(): void;
  8454. /**
  8455. * Remove all attached input methods from a camera
  8456. */
  8457. clear(): void;
  8458. /**
  8459. * Serialize the current input manager attached to a camera.
  8460. * This ensures than once parsed,
  8461. * the input associated to the camera will be identical to the current ones
  8462. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8463. */
  8464. serialize(serializedCamera: any): void;
  8465. /**
  8466. * Parses an input manager serialized JSON to restore the previous list of inputs
  8467. * and states associated to a camera.
  8468. * @param parsedCamera Defines the JSON to parse
  8469. */
  8470. parse(parsedCamera: any): void;
  8471. }
  8472. }
  8473. declare module BABYLON {
  8474. /**
  8475. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8476. * being tilted forward or back and left or right.
  8477. */
  8478. class DeviceOrientationCamera extends FreeCamera {
  8479. private _initialQuaternion;
  8480. private _quaternionCache;
  8481. /**
  8482. * Creates a new device orientation camera
  8483. * @param name The name of the camera
  8484. * @param position The start position camera
  8485. * @param scene The scene the camera belongs to
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene);
  8488. /**
  8489. * Gets the current instance class name ("DeviceOrientationCamera").
  8490. * This helps avoiding instanceof at run time.
  8491. * @returns the class name
  8492. */
  8493. getClassName(): string;
  8494. /**
  8495. * @hidden
  8496. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8497. */
  8498. _checkInputs(): void;
  8499. /**
  8500. * Reset the camera to its default orientation on the specified axis only.
  8501. * @param axis The axis to reset
  8502. */
  8503. resetToCurrentRotation(axis?: Axis): void;
  8504. }
  8505. }
  8506. declare module BABYLON {
  8507. /**
  8508. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8509. * such as in a 3D Space Shooter or a Flight Simulator.
  8510. */
  8511. class FlyCamera extends TargetCamera {
  8512. /**
  8513. * Define the collision ellipsoid of the camera.
  8514. * This is helpful for simulating a camera body, like a player's body.
  8515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8516. */
  8517. ellipsoid: Vector3;
  8518. /**
  8519. * Define an offset for the position of the ellipsoid around the camera.
  8520. * This can be helpful if the camera is attached away from the player's body center,
  8521. * such as at its head.
  8522. */
  8523. ellipsoidOffset: Vector3;
  8524. /**
  8525. * Enable or disable collisions of the camera with the rest of the scene objects.
  8526. */
  8527. checkCollisions: boolean;
  8528. /**
  8529. * Enable or disable gravity on the camera.
  8530. */
  8531. applyGravity: boolean;
  8532. /**
  8533. * Define the current direction the camera is moving to.
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8538. * This overrides and empties cameraRotation.
  8539. */
  8540. rotationQuaternion: BABYLON.Quaternion;
  8541. /**
  8542. * Track Roll to maintain the wanted Rolling when looking around.
  8543. */
  8544. _trackRoll: number;
  8545. /**
  8546. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8547. */
  8548. rollCorrect: number;
  8549. /**
  8550. * Mimic a banked turn, Rolling the camera when Yawing.
  8551. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8552. */
  8553. bankedTurn: boolean;
  8554. /**
  8555. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8556. */
  8557. bankedTurnLimit: number;
  8558. /**
  8559. * Value of 0 disables the banked Roll.
  8560. * Value of 1 is equal to the Yaw angle in radians.
  8561. */
  8562. bankedTurnMultiplier: number;
  8563. /**
  8564. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8565. */
  8566. inputs: FlyCameraInputsManager;
  8567. /**
  8568. * Gets the input sensibility for mouse input.
  8569. * Higher values reduce sensitivity.
  8570. */
  8571. /**
  8572. * Sets the input sensibility for a mouse input.
  8573. * Higher values reduce sensitivity.
  8574. */
  8575. angularSensibility: number;
  8576. /**
  8577. * Get the keys for camera movement forward.
  8578. */
  8579. /**
  8580. * Set the keys for camera movement forward.
  8581. */
  8582. keysForward: number[];
  8583. /**
  8584. * Get the keys for camera movement backward.
  8585. */
  8586. keysBackward: number[];
  8587. /**
  8588. * Get the keys for camera movement up.
  8589. */
  8590. /**
  8591. * Set the keys for camera movement up.
  8592. */
  8593. keysUp: number[];
  8594. /**
  8595. * Get the keys for camera movement down.
  8596. */
  8597. /**
  8598. * Set the keys for camera movement down.
  8599. */
  8600. keysDown: number[];
  8601. /**
  8602. * Get the keys for camera movement left.
  8603. */
  8604. /**
  8605. * Set the keys for camera movement left.
  8606. */
  8607. keysLeft: number[];
  8608. /**
  8609. * Set the keys for camera movement right.
  8610. */
  8611. /**
  8612. * Set the keys for camera movement right.
  8613. */
  8614. keysRight: number[];
  8615. /**
  8616. * Event raised when the camera collides with a mesh in the scene.
  8617. */
  8618. onCollide: (collidedMesh: AbstractMesh) => void;
  8619. private _collider;
  8620. private _needMoveForGravity;
  8621. private _oldPosition;
  8622. private _diffPosition;
  8623. private _newPosition;
  8624. /** @hidden */
  8625. _localDirection: Vector3;
  8626. /** @hidden */
  8627. _transformedDirection: Vector3;
  8628. /**
  8629. * Instantiates a FlyCamera.
  8630. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8631. * such as in a 3D Space Shooter or a Flight Simulator.
  8632. * @param name Define the name of the camera in the scene.
  8633. * @param position Define the starting position of the camera in the scene.
  8634. * @param scene Define the scene the camera belongs to.
  8635. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8636. */
  8637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8638. /**
  8639. * Attach a control to the HTML DOM element.
  8640. * @param element Defines the element that listens to the input events.
  8641. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8642. */
  8643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8644. /**
  8645. * Detach a control from the HTML DOM element.
  8646. * The camera will stop reacting to that input.
  8647. * @param element Defines the element that listens to the input events.
  8648. */
  8649. detachControl(element: HTMLElement): void;
  8650. private _collisionMask;
  8651. /**
  8652. * Get the mask that the camera ignores in collision events.
  8653. */
  8654. /**
  8655. * Set the mask that the camera ignores in collision events.
  8656. */
  8657. collisionMask: number;
  8658. /** @hidden */
  8659. _collideWithWorld(displacement: Vector3): void;
  8660. /** @hidden */
  8661. private _onCollisionPositionChange;
  8662. /** @hidden */
  8663. _checkInputs(): void;
  8664. /** @hidden */
  8665. _decideIfNeedsToMove(): boolean;
  8666. /** @hidden */
  8667. _updatePosition(): void;
  8668. /**
  8669. * Restore the Roll to its target value at the rate specified.
  8670. * @param rate - Higher means slower restoring.
  8671. * @hidden
  8672. */
  8673. restoreRoll(rate: number): void;
  8674. /**
  8675. * Destroy the camera and release the current resources held by it.
  8676. */
  8677. dispose(): void;
  8678. /**
  8679. * Get the current object class name.
  8680. * @returns the class name.
  8681. */
  8682. getClassName(): string;
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /**
  8687. * Default Inputs manager for the FlyCamera.
  8688. * It groups all the default supported inputs for ease of use.
  8689. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8690. */
  8691. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8692. /**
  8693. * Instantiates a new FlyCameraInputsManager.
  8694. * @param camera Defines the camera the inputs belong to.
  8695. */
  8696. constructor(camera: FlyCamera);
  8697. /**
  8698. * Add keyboard input support to the input manager.
  8699. * @returns the new FlyCameraKeyboardMoveInput().
  8700. */
  8701. addKeyboard(): FlyCameraInputsManager;
  8702. /**
  8703. * Add mouse input support to the input manager.
  8704. * @param touchEnabled Enable touch screen support.
  8705. * @returns the new FlyCameraMouseInput().
  8706. */
  8707. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8708. }
  8709. }
  8710. declare module BABYLON {
  8711. /**
  8712. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8713. * an arc rotate version arcFollowCamera are available.
  8714. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8715. */
  8716. class FollowCamera extends TargetCamera {
  8717. /**
  8718. * Distance the follow camera should follow an object at
  8719. */
  8720. radius: number;
  8721. /**
  8722. * Define a rotation offset between the camera and the object it follows
  8723. */
  8724. rotationOffset: number;
  8725. /**
  8726. * Define a height offset between the camera and the object it follows.
  8727. * It can help following an object from the top (like a car chaing a plane)
  8728. */
  8729. heightOffset: number;
  8730. /**
  8731. * Define how fast the camera can accelerate to follow it s target.
  8732. */
  8733. cameraAcceleration: number;
  8734. /**
  8735. * Define the speed limit of the camera following an object.
  8736. */
  8737. maxCameraSpeed: number;
  8738. /**
  8739. * Define the target of the camera.
  8740. */
  8741. lockedTarget: Nullable<AbstractMesh>;
  8742. /**
  8743. * Instantiates the follow camera.
  8744. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8745. * @param name Define the name of the camera in the scene
  8746. * @param position Define the position of the camera
  8747. * @param scene Define the scene the camera belong to
  8748. * @param lockedTarget Define the target of the camera
  8749. */
  8750. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8751. private _follow;
  8752. /** @hidden */
  8753. _checkInputs(): void;
  8754. /**
  8755. * Gets the camera class name.
  8756. * @returns the class name
  8757. */
  8758. getClassName(): string;
  8759. }
  8760. /**
  8761. * Arc Rotate version of the follow camera.
  8762. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8763. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8764. */
  8765. class ArcFollowCamera extends TargetCamera {
  8766. /** The longitudinal angle of the camera */
  8767. alpha: number;
  8768. /** The latitudinal angle of the camera */
  8769. beta: number;
  8770. /** The radius of the camera from its target */
  8771. radius: number;
  8772. /** Define the camera target (the messh it should follow) */
  8773. target: Nullable<AbstractMesh>;
  8774. private _cartesianCoordinates;
  8775. /**
  8776. * Instantiates a new ArcFollowCamera
  8777. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8778. * @param name Define the name of the camera
  8779. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8780. * @param beta Define the rotation angle of the camera around the elevation axis
  8781. * @param radius Define the radius of the camera from its target point
  8782. * @param target Define the target of the camera
  8783. * @param scene Define the scene the camera belongs to
  8784. */
  8785. constructor(name: string,
  8786. /** The longitudinal angle of the camera */
  8787. alpha: number,
  8788. /** The latitudinal angle of the camera */
  8789. beta: number,
  8790. /** The radius of the camera from its target */
  8791. radius: number,
  8792. /** Define the camera target (the messh it should follow) */
  8793. target: Nullable<AbstractMesh>, scene: Scene);
  8794. private _follow;
  8795. /** @hidden */
  8796. _checkInputs(): void;
  8797. /**
  8798. * Returns the class name of the object.
  8799. * It is mostly used internally for serialization purposes.
  8800. */
  8801. getClassName(): string;
  8802. }
  8803. }
  8804. declare module BABYLON {
  8805. /**
  8806. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8807. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8809. */
  8810. class FreeCamera extends TargetCamera {
  8811. /**
  8812. * Define the collision ellipsoid of the camera.
  8813. * This is helpful to simulate a camera body like the player body around the camera
  8814. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8815. */
  8816. ellipsoid: Vector3;
  8817. /**
  8818. * Define an offset for the position of the ellipsoid around the camera.
  8819. * This can be helpful to determine the center of the body near the gravity center of the body
  8820. * instead of its head.
  8821. */
  8822. ellipsoidOffset: Vector3;
  8823. /**
  8824. * Enable or disable collisions of the camera with the rest of the scene objects.
  8825. */
  8826. checkCollisions: boolean;
  8827. /**
  8828. * Enable or disable gravity on the camera.
  8829. */
  8830. applyGravity: boolean;
  8831. /**
  8832. * Define the input manager associated to the camera.
  8833. */
  8834. inputs: FreeCameraInputsManager;
  8835. /**
  8836. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8837. * Higher values reduce sensitivity.
  8838. */
  8839. /**
  8840. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8841. * Higher values reduce sensitivity.
  8842. */
  8843. angularSensibility: number;
  8844. /**
  8845. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8846. */
  8847. keysUp: number[];
  8848. /**
  8849. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8850. */
  8851. keysDown: number[];
  8852. /**
  8853. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8854. */
  8855. keysLeft: number[];
  8856. /**
  8857. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8858. */
  8859. keysRight: number[];
  8860. /**
  8861. * Event raised when the camera collide with a mesh in the scene.
  8862. */
  8863. onCollide: (collidedMesh: AbstractMesh) => void;
  8864. private _collider;
  8865. private _needMoveForGravity;
  8866. private _oldPosition;
  8867. private _diffPosition;
  8868. private _newPosition;
  8869. /** @hidden */
  8870. _localDirection: Vector3;
  8871. /** @hidden */
  8872. _transformedDirection: Vector3;
  8873. /**
  8874. * Instantiates a Free Camera.
  8875. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8876. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8878. * @param name Define the name of the camera in the scene
  8879. * @param position Define the start position of the camera in the scene
  8880. * @param scene Define the scene the camera belongs to
  8881. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8882. */
  8883. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8884. /**
  8885. * Attached controls to the current camera.
  8886. * @param element Defines the element the controls should be listened from
  8887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8888. */
  8889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8890. /**
  8891. * Detach the current controls from the camera.
  8892. * The camera will stop reacting to inputs.
  8893. * @param element Defines the element to stop listening the inputs from
  8894. */
  8895. detachControl(element: HTMLElement): void;
  8896. private _collisionMask;
  8897. /**
  8898. * Define a collision mask to limit the list of object the camera can collide with
  8899. */
  8900. collisionMask: number;
  8901. /** @hidden */
  8902. _collideWithWorld(displacement: Vector3): void;
  8903. private _onCollisionPositionChange;
  8904. /** @hidden */
  8905. _checkInputs(): void;
  8906. /** @hidden */
  8907. _decideIfNeedsToMove(): boolean;
  8908. /** @hidden */
  8909. _updatePosition(): void;
  8910. /**
  8911. * Destroy the camera and release the current resources hold by it.
  8912. */
  8913. dispose(): void;
  8914. /**
  8915. * Gets the current object class name.
  8916. * @return the class name
  8917. */
  8918. getClassName(): string;
  8919. }
  8920. }
  8921. declare module BABYLON {
  8922. /**
  8923. * Default Inputs manager for the FreeCamera.
  8924. * It groups all the default supported inputs for ease of use.
  8925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8926. */
  8927. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8928. /**
  8929. * Instantiates a new FreeCameraInputsManager.
  8930. * @param camera Defines the camera the inputs belong to
  8931. */
  8932. constructor(camera: FreeCamera);
  8933. /**
  8934. * Add keyboard input support to the input manager.
  8935. * @returns the current input manager
  8936. */
  8937. addKeyboard(): FreeCameraInputsManager;
  8938. /**
  8939. * Add mouse input support to the input manager.
  8940. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8941. * @returns the current input manager
  8942. */
  8943. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8944. /**
  8945. * Add orientation input support to the input manager.
  8946. * @returns the current input manager
  8947. */
  8948. addDeviceOrientation(): FreeCameraInputsManager;
  8949. /**
  8950. * Add touch input support to the input manager.
  8951. * @returns the current input manager
  8952. */
  8953. addTouch(): FreeCameraInputsManager;
  8954. /**
  8955. * Add virtual joystick input support to the input manager.
  8956. * @returns the current input manager
  8957. */
  8958. addVirtualJoystick(): FreeCameraInputsManager;
  8959. }
  8960. }
  8961. declare module BABYLON {
  8962. /**
  8963. * This represents a FPS type of camera. This is only here for back compat purpose.
  8964. * Please use the UniversalCamera instead as both are identical.
  8965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8966. */
  8967. class GamepadCamera extends UniversalCamera {
  8968. /**
  8969. * Instantiates a new Gamepad Camera
  8970. * This represents a FPS type of camera. This is only here for back compat purpose.
  8971. * Please use the UniversalCamera instead as both are identical.
  8972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8973. * @param name Define the name of the camera in the scene
  8974. * @param position Define the start position of the camera in the scene
  8975. * @param scene Define the scene the camera belongs to
  8976. */
  8977. constructor(name: string, position: Vector3, scene: Scene);
  8978. /**
  8979. * Gets the current object class name.
  8980. * @return the class name
  8981. */
  8982. getClassName(): string;
  8983. }
  8984. }
  8985. declare module BABYLON {
  8986. /**
  8987. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8988. * This is the base of the follow, arc rotate cameras and Free camera
  8989. * @see http://doc.babylonjs.com/features/cameras
  8990. */
  8991. class TargetCamera extends Camera {
  8992. /**
  8993. * Define the current direction the camera is moving to
  8994. */
  8995. cameraDirection: Vector3;
  8996. /**
  8997. * Define the current rotation the camera is rotating to
  8998. */
  8999. cameraRotation: Vector2;
  9000. /**
  9001. * Define the current rotation of the camera
  9002. */
  9003. rotation: Vector3;
  9004. /**
  9005. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9006. */
  9007. rotationQuaternion: Quaternion;
  9008. /**
  9009. * Define the current speed of the camera
  9010. */
  9011. speed: number;
  9012. /**
  9013. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9014. * around all axis.
  9015. */
  9016. noRotationConstraint: boolean;
  9017. /**
  9018. * Define the current target of the camera as an object or a position.
  9019. */
  9020. lockedTarget: any;
  9021. /** @hidden */
  9022. _currentTarget: Vector3;
  9023. /** @hidden */
  9024. _viewMatrix: Matrix;
  9025. /** @hidden */
  9026. _camMatrix: Matrix;
  9027. /** @hidden */
  9028. _cameraTransformMatrix: Matrix;
  9029. /** @hidden */
  9030. _cameraRotationMatrix: Matrix;
  9031. private _rigCamTransformMatrix;
  9032. /** @hidden */
  9033. _referencePoint: Vector3;
  9034. /** @hidden */
  9035. _transformedReferencePoint: Vector3;
  9036. protected _globalCurrentTarget: Vector3;
  9037. protected _globalCurrentUpVector: Vector3;
  9038. /** @hidden */
  9039. _reset: () => void;
  9040. private _defaultUp;
  9041. /**
  9042. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9043. * This is the base of the follow, arc rotate cameras and Free camera
  9044. * @see http://doc.babylonjs.com/features/cameras
  9045. * @param name Defines the name of the camera in the scene
  9046. * @param position Defines the start position of the camera in the scene
  9047. * @param scene Defines the scene the camera belongs to
  9048. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9049. */
  9050. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9051. /**
  9052. * Gets the position in front of the camera at a given distance.
  9053. * @param distance The distance from the camera we want the position to be
  9054. * @returns the position
  9055. */
  9056. getFrontPosition(distance: number): Vector3;
  9057. /** @hidden */
  9058. _getLockedTargetPosition(): Nullable<Vector3>;
  9059. private _storedPosition;
  9060. private _storedRotation;
  9061. private _storedRotationQuaternion;
  9062. /**
  9063. * Store current camera state of the camera (fov, position, rotation, etc..)
  9064. * @returns the camera
  9065. */
  9066. storeState(): Camera;
  9067. /**
  9068. * Restored camera state. You must call storeState() first
  9069. * @returns whether it was successful or not
  9070. * @hidden
  9071. */
  9072. _restoreStateValues(): boolean;
  9073. /** @hidden */
  9074. _initCache(): void;
  9075. /** @hidden */
  9076. _updateCache(ignoreParentClass?: boolean): void;
  9077. /** @hidden */
  9078. _isSynchronizedViewMatrix(): boolean;
  9079. /** @hidden */
  9080. _computeLocalCameraSpeed(): number;
  9081. /** @hidden */
  9082. setTarget(target: Vector3): void;
  9083. /**
  9084. * Return the current target position of the camera. This value is expressed in local space.
  9085. * @returns the target position
  9086. */
  9087. getTarget(): Vector3;
  9088. /** @hidden */
  9089. _decideIfNeedsToMove(): boolean;
  9090. /** @hidden */
  9091. _updatePosition(): void;
  9092. /** @hidden */
  9093. _checkInputs(): void;
  9094. protected _updateCameraRotationMatrix(): void;
  9095. /**
  9096. * 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)
  9097. * @returns the current camera
  9098. */
  9099. private _rotateUpVectorWithCameraRotationMatrix;
  9100. private _cachedRotationZ;
  9101. private _cachedQuaternionRotationZ;
  9102. /** @hidden */
  9103. _getViewMatrix(): Matrix;
  9104. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9105. /**
  9106. * @hidden
  9107. */
  9108. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9109. /**
  9110. * @hidden
  9111. */
  9112. _updateRigCameras(): void;
  9113. private _getRigCamPosition;
  9114. /**
  9115. * Gets the current object class name.
  9116. * @return the class name
  9117. */
  9118. getClassName(): string;
  9119. }
  9120. }
  9121. declare module BABYLON {
  9122. /**
  9123. * This represents a FPS type of camera controlled by touch.
  9124. * This is like a universal camera minus the Gamepad controls.
  9125. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9126. */
  9127. class TouchCamera extends FreeCamera {
  9128. /**
  9129. * Defines the touch sensibility for rotation.
  9130. * The higher the faster.
  9131. */
  9132. touchAngularSensibility: number;
  9133. /**
  9134. * Defines the touch sensibility for move.
  9135. * The higher the faster.
  9136. */
  9137. touchMoveSensibility: number;
  9138. /**
  9139. * Instantiates a new touch camera.
  9140. * This represents a FPS type of camera controlled by touch.
  9141. * This is like a universal camera minus the Gamepad controls.
  9142. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9143. * @param name Define the name of the camera in the scene
  9144. * @param position Define the start position of the camera in the scene
  9145. * @param scene Define the scene the camera belongs to
  9146. */
  9147. constructor(name: string, position: Vector3, scene: Scene);
  9148. /**
  9149. * Gets the current object class name.
  9150. * @return the class name
  9151. */
  9152. getClassName(): string;
  9153. /** @hidden */
  9154. _setupInputs(): void;
  9155. }
  9156. }
  9157. declare module BABYLON {
  9158. /**
  9159. * 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,
  9160. * which still works and will still be found in many Playgrounds.
  9161. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9162. */
  9163. class UniversalCamera extends TouchCamera {
  9164. /**
  9165. * Defines the gamepad rotation sensiblity.
  9166. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9167. */
  9168. gamepadAngularSensibility: number;
  9169. /**
  9170. * Defines the gamepad move sensiblity.
  9171. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9172. */
  9173. gamepadMoveSensibility: number;
  9174. /**
  9175. * 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,
  9176. * which still works and will still be found in many Playgrounds.
  9177. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9178. * @param name Define the name of the camera in the scene
  9179. * @param position Define the start position of the camera in the scene
  9180. * @param scene Define the scene the camera belongs to
  9181. */
  9182. constructor(name: string, position: Vector3, scene: Scene);
  9183. /**
  9184. * Gets the current object class name.
  9185. * @return the class name
  9186. */
  9187. getClassName(): string;
  9188. }
  9189. }
  9190. declare module BABYLON {
  9191. /**
  9192. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  9193. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9194. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9195. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9196. */
  9197. class VirtualJoysticksCamera extends FreeCamera {
  9198. /**
  9199. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  9200. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9201. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9202. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9203. * @param name Define the name of the camera in the scene
  9204. * @param position Define the start position of the camera in the scene
  9205. * @param scene Define the scene the camera belongs to
  9206. */
  9207. constructor(name: string, position: Vector3, scene: Scene);
  9208. /**
  9209. * Gets the current object class name.
  9210. * @return the class name
  9211. */
  9212. getClassName(): string;
  9213. }
  9214. }
  9215. interface VRDisplay extends EventTarget {
  9216. /**
  9217. * Dictionary of capabilities describing the VRDisplay.
  9218. */
  9219. readonly capabilities: VRDisplayCapabilities;
  9220. /**
  9221. * z-depth defining the far plane of the eye view frustum
  9222. * enables mapping of values in the render target depth
  9223. * attachment to scene coordinates. Initially set to 10000.0.
  9224. */
  9225. depthFar: number;
  9226. /**
  9227. * z-depth defining the near plane of the eye view frustum
  9228. * enables mapping of values in the render target depth
  9229. * attachment to scene coordinates. Initially set to 0.01.
  9230. */
  9231. depthNear: number;
  9232. /**
  9233. * An identifier for this distinct VRDisplay. Used as an
  9234. * association point in the Gamepad API.
  9235. */
  9236. readonly displayId: number;
  9237. /**
  9238. * A display name, a user-readable name identifying it.
  9239. */
  9240. readonly displayName: string;
  9241. readonly isConnected: boolean;
  9242. readonly isPresenting: boolean;
  9243. /**
  9244. * If this VRDisplay supports room-scale experiences, the optional
  9245. * stage attribute contains details on the room-scale parameters.
  9246. */
  9247. readonly stageParameters: VRStageParameters | null;
  9248. /**
  9249. * Passing the value returned by `requestAnimationFrame` to
  9250. * `cancelAnimationFrame` will unregister the callback.
  9251. * @param handle Define the hanle of the request to cancel
  9252. */
  9253. cancelAnimationFrame(handle: number): void;
  9254. /**
  9255. * Stops presenting to the VRDisplay.
  9256. * @returns a promise to know when it stopped
  9257. */
  9258. exitPresent(): Promise<void>;
  9259. /**
  9260. * Return the current VREyeParameters for the given eye.
  9261. * @param whichEye Define the eye we want the parameter for
  9262. * @returns the eye parameters
  9263. */
  9264. getEyeParameters(whichEye: string): VREyeParameters;
  9265. /**
  9266. * Populates the passed VRFrameData with the information required to render
  9267. * the current frame.
  9268. * @param frameData Define the data structure to populate
  9269. * @returns true if ok otherwise false
  9270. */
  9271. getFrameData(frameData: VRFrameData): boolean;
  9272. /**
  9273. * Get the layers currently being presented.
  9274. * @returns the list of VR layers
  9275. */
  9276. getLayers(): VRLayer[];
  9277. /**
  9278. * Return a VRPose containing the future predicted pose of the VRDisplay
  9279. * when the current frame will be presented. The value returned will not
  9280. * change until JavaScript has returned control to the browser.
  9281. *
  9282. * The VRPose will contain the position, orientation, velocity,
  9283. * and acceleration of each of these properties.
  9284. * @returns the pose object
  9285. */
  9286. getPose(): VRPose;
  9287. /**
  9288. * Return the current instantaneous pose of the VRDisplay, with no
  9289. * prediction applied.
  9290. * @returns the current instantaneous pose
  9291. */
  9292. getImmediatePose(): VRPose;
  9293. /**
  9294. * The callback passed to `requestAnimationFrame` will be called
  9295. * any time a new frame should be rendered. When the VRDisplay is
  9296. * presenting the callback will be called at the native refresh
  9297. * rate of the HMD. When not presenting this function acts
  9298. * identically to how window.requestAnimationFrame acts. Content should
  9299. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9300. * asynchronously from other displays and at differing refresh rates.
  9301. * @param callback Define the eaction to run next frame
  9302. * @returns the request handle it
  9303. */
  9304. requestAnimationFrame(callback: FrameRequestCallback): number;
  9305. /**
  9306. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9307. * Repeat calls while already presenting will update the VRLayers being displayed.
  9308. * @param layers Define the list of layer to present
  9309. * @returns a promise to know when the request has been fulfilled
  9310. */
  9311. requestPresent(layers: VRLayer[]): Promise<void>;
  9312. /**
  9313. * Reset the pose for this display, treating its current position and
  9314. * orientation as the "origin/zero" values. VRPose.position,
  9315. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9316. * updated when calling resetPose(). This should be called in only
  9317. * sitting-space experiences.
  9318. */
  9319. resetPose(): void;
  9320. /**
  9321. * The VRLayer provided to the VRDisplay will be captured and presented
  9322. * in the HMD. Calling this function has the same effect on the source
  9323. * canvas as any other operation that uses its source image, and canvases
  9324. * created without preserveDrawingBuffer set to true will be cleared.
  9325. * @param pose Define the pose to submit
  9326. */
  9327. submitFrame(pose?: VRPose): void;
  9328. }
  9329. declare var VRDisplay: {
  9330. prototype: VRDisplay;
  9331. new (): VRDisplay;
  9332. };
  9333. interface VRLayer {
  9334. leftBounds?: number[] | Float32Array | null;
  9335. rightBounds?: number[] | Float32Array | null;
  9336. source?: HTMLCanvasElement | null;
  9337. }
  9338. interface VRDisplayCapabilities {
  9339. readonly canPresent: boolean;
  9340. readonly hasExternalDisplay: boolean;
  9341. readonly hasOrientation: boolean;
  9342. readonly hasPosition: boolean;
  9343. readonly maxLayers: number;
  9344. }
  9345. interface VREyeParameters {
  9346. /** @deprecated */
  9347. readonly fieldOfView: VRFieldOfView;
  9348. readonly offset: Float32Array;
  9349. readonly renderHeight: number;
  9350. readonly renderWidth: number;
  9351. }
  9352. interface VRFieldOfView {
  9353. readonly downDegrees: number;
  9354. readonly leftDegrees: number;
  9355. readonly rightDegrees: number;
  9356. readonly upDegrees: number;
  9357. }
  9358. interface VRFrameData {
  9359. readonly leftProjectionMatrix: Float32Array;
  9360. readonly leftViewMatrix: Float32Array;
  9361. readonly pose: VRPose;
  9362. readonly rightProjectionMatrix: Float32Array;
  9363. readonly rightViewMatrix: Float32Array;
  9364. readonly timestamp: number;
  9365. }
  9366. interface VRPose {
  9367. readonly angularAcceleration: Float32Array | null;
  9368. readonly angularVelocity: Float32Array | null;
  9369. readonly linearAcceleration: Float32Array | null;
  9370. readonly linearVelocity: Float32Array | null;
  9371. readonly orientation: Float32Array | null;
  9372. readonly position: Float32Array | null;
  9373. readonly timestamp: number;
  9374. }
  9375. interface VRStageParameters {
  9376. sittingToStandingTransform?: Float32Array;
  9377. sizeX?: number;
  9378. sizeY?: number;
  9379. }
  9380. interface Navigator {
  9381. getVRDisplays(): Promise<VRDisplay[]>;
  9382. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9383. }
  9384. interface Window {
  9385. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9386. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9387. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9388. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9389. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9390. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9391. }
  9392. interface Gamepad {
  9393. readonly displayId: number;
  9394. }
  9395. declare module BABYLON {
  9396. /**
  9397. * Interface for attribute information associated with buffer instanciation
  9398. */
  9399. class InstancingAttributeInfo {
  9400. /**
  9401. * Index/offset of the attribute in the vertex shader
  9402. */
  9403. index: number;
  9404. /**
  9405. * size of the attribute, 1, 2, 3 or 4
  9406. */
  9407. attributeSize: number;
  9408. /**
  9409. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9410. * default is FLOAT
  9411. */
  9412. attribyteType: number;
  9413. /**
  9414. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9415. */
  9416. normalized: boolean;
  9417. /**
  9418. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9419. */
  9420. offset: number;
  9421. /**
  9422. * Name of the GLSL attribute, for debugging purpose only
  9423. */
  9424. attributeName: string;
  9425. }
  9426. /**
  9427. * Define options used to create a render target texture
  9428. */
  9429. class RenderTargetCreationOptions {
  9430. /**
  9431. * Specifies is mipmaps must be generated
  9432. */
  9433. generateMipMaps?: boolean;
  9434. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9435. generateDepthBuffer?: boolean;
  9436. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9437. generateStencilBuffer?: boolean;
  9438. /** Defines texture type (int by default) */
  9439. type?: number;
  9440. /** Defines sampling mode (trilinear by default) */
  9441. samplingMode?: number;
  9442. /** Defines format (RGBA by default) */
  9443. format?: number;
  9444. }
  9445. /**
  9446. * Define options used to create a depth texture
  9447. */
  9448. class DepthTextureCreationOptions {
  9449. /** Specifies whether or not a stencil should be allocated in the texture */
  9450. generateStencil?: boolean;
  9451. /** Specifies whether or not bilinear filtering is enable on the texture */
  9452. bilinearFiltering?: boolean;
  9453. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9454. comparisonFunction?: number;
  9455. /** Specifies if the created texture is a cube texture */
  9456. isCube?: boolean;
  9457. }
  9458. /**
  9459. * Class used to describe the capabilities of the engine relatively to the current browser
  9460. */
  9461. class EngineCapabilities {
  9462. /** Maximum textures units per fragment shader */
  9463. maxTexturesImageUnits: number;
  9464. /** Maximum texture units per vertex shader */
  9465. maxVertexTextureImageUnits: number;
  9466. /** Maximum textures units in the entire pipeline */
  9467. maxCombinedTexturesImageUnits: number;
  9468. /** Maximum texture size */
  9469. maxTextureSize: number;
  9470. /** Maximum cube texture size */
  9471. maxCubemapTextureSize: number;
  9472. /** Maximum render texture size */
  9473. maxRenderTextureSize: number;
  9474. /** Maximum number of vertex attributes */
  9475. maxVertexAttribs: number;
  9476. /** Maximum number of varyings */
  9477. maxVaryingVectors: number;
  9478. /** Maximum number of uniforms per vertex shader */
  9479. maxVertexUniformVectors: number;
  9480. /** Maximum number of uniforms per fragment shader */
  9481. maxFragmentUniformVectors: number;
  9482. /** Defines if standard derivates (dx/dy) are supported */
  9483. standardDerivatives: boolean;
  9484. /** Defines if s3tc texture compression is supported */
  9485. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9486. /** Defines if pvrtc texture compression is supported */
  9487. pvrtc: any;
  9488. /** Defines if etc1 texture compression is supported */
  9489. etc1: any;
  9490. /** Defines if etc2 texture compression is supported */
  9491. etc2: any;
  9492. /** Defines if astc texture compression is supported */
  9493. astc: any;
  9494. /** Defines if float textures are supported */
  9495. textureFloat: boolean;
  9496. /** Defines if vertex array objects are supported */
  9497. vertexArrayObject: boolean;
  9498. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9499. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9500. /** Gets the maximum level of anisotropy supported */
  9501. maxAnisotropy: number;
  9502. /** Defines if instancing is supported */
  9503. instancedArrays: boolean;
  9504. /** Defines if 32 bits indices are supported */
  9505. uintIndices: boolean;
  9506. /** Defines if high precision shaders are supported */
  9507. highPrecisionShaderSupported: boolean;
  9508. /** Defines if depth reading in the fragment shader is supported */
  9509. fragmentDepthSupported: boolean;
  9510. /** Defines if float texture linear filtering is supported*/
  9511. textureFloatLinearFiltering: boolean;
  9512. /** Defines if rendering to float textures is supported */
  9513. textureFloatRender: boolean;
  9514. /** Defines if half float textures are supported*/
  9515. textureHalfFloat: boolean;
  9516. /** Defines if half float texture linear filtering is supported*/
  9517. textureHalfFloatLinearFiltering: boolean;
  9518. /** Defines if rendering to half float textures is supported */
  9519. textureHalfFloatRender: boolean;
  9520. /** Defines if textureLOD shader command is supported */
  9521. textureLOD: boolean;
  9522. /** Defines if draw buffers extension is supported */
  9523. drawBuffersExtension: boolean;
  9524. /** Defines if depth textures are supported */
  9525. depthTextureExtension: boolean;
  9526. /** Defines if float color buffer are supported */
  9527. colorBufferFloat: boolean;
  9528. /** Gets disjoint timer query extension (null if not supported) */
  9529. timerQuery: EXT_disjoint_timer_query;
  9530. /** Defines if timestamp can be used with timer query */
  9531. canUseTimestampForTimerQuery: boolean;
  9532. /** Function used to let the system compiles shaders in background */
  9533. parallelShaderCompile: {
  9534. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9535. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9536. COMPLETION_STATUS_KHR: number;
  9537. };
  9538. }
  9539. /** Interface defining initialization parameters for Engine class */
  9540. interface EngineOptions extends WebGLContextAttributes {
  9541. /**
  9542. * Defines if the engine should no exceed a specified device ratio
  9543. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9544. */
  9545. limitDeviceRatio?: number;
  9546. /**
  9547. * Defines if webvr should be enabled automatically
  9548. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9549. */
  9550. autoEnableWebVR?: boolean;
  9551. /**
  9552. * Defines if webgl2 should be turned off even if supported
  9553. * @see http://doc.babylonjs.com/features/webgl2
  9554. */
  9555. disableWebGL2Support?: boolean;
  9556. /**
  9557. * Defines if webaudio should be initialized as well
  9558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9559. */
  9560. audioEngine?: boolean;
  9561. /**
  9562. * Defines if animations should run using a deterministic lock step
  9563. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9564. */
  9565. deterministicLockstep?: boolean;
  9566. /** Defines the maximum steps to use with deterministic lock step mode */
  9567. lockstepMaxSteps?: number;
  9568. /**
  9569. * Defines that engine should ignore context lost events
  9570. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9571. */
  9572. doNotHandleContextLost?: boolean;
  9573. }
  9574. /**
  9575. * Defines the interface used by display changed events
  9576. */
  9577. interface IDisplayChangedEventArgs {
  9578. /** Gets the vrDisplay object (if any) */
  9579. vrDisplay: Nullable<any>;
  9580. /** Gets a boolean indicating if webVR is supported */
  9581. vrSupported: boolean;
  9582. }
  9583. /**
  9584. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9585. */
  9586. class Engine {
  9587. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9588. static ExceptionList: ({
  9589. key: string;
  9590. capture: string;
  9591. captureConstraint: number;
  9592. targets: string[];
  9593. } | {
  9594. key: string;
  9595. capture: null;
  9596. captureConstraint: null;
  9597. targets: string[];
  9598. })[];
  9599. /** Gets the list of created engines */
  9600. static Instances: Engine[];
  9601. /**
  9602. * Gets the latest created engine
  9603. */
  9604. static readonly LastCreatedEngine: Nullable<Engine>;
  9605. /**
  9606. * Gets the latest created scene
  9607. */
  9608. static readonly LastCreatedScene: Nullable<Scene>;
  9609. /**
  9610. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9611. * @param flag defines which part of the materials must be marked as dirty
  9612. * @param predicate defines a predicate used to filter which materials should be affected
  9613. */
  9614. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9615. /**
  9616. * Hidden
  9617. */
  9618. static _TextureLoaders: IInternalTextureLoader[];
  9619. /** Defines that alpha blending is disabled */
  9620. static readonly ALPHA_DISABLE: number;
  9621. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9622. static readonly ALPHA_ADD: number;
  9623. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9624. static readonly ALPHA_COMBINE: number;
  9625. /** Defines that alpha blending to DEST - SRC * DEST */
  9626. static readonly ALPHA_SUBTRACT: number;
  9627. /** Defines that alpha blending to SRC * DEST */
  9628. static readonly ALPHA_MULTIPLY: number;
  9629. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9630. static readonly ALPHA_MAXIMIZED: number;
  9631. /** Defines that alpha blending to SRC + DEST */
  9632. static readonly ALPHA_ONEONE: number;
  9633. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9634. static readonly ALPHA_PREMULTIPLIED: number;
  9635. /**
  9636. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9637. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9638. */
  9639. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9640. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  9641. static readonly ALPHA_INTERPOLATE: number;
  9642. /**
  9643. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  9644. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  9645. */
  9646. static readonly ALPHA_SCREENMODE: number;
  9647. /** Defines that the ressource is not delayed*/
  9648. static readonly DELAYLOADSTATE_NONE: number;
  9649. /** Defines that the ressource was successfully delay loaded */
  9650. static readonly DELAYLOADSTATE_LOADED: number;
  9651. /** Defines that the ressource is currently delay loading */
  9652. static readonly DELAYLOADSTATE_LOADING: number;
  9653. /** Defines that the ressource is delayed and has not started loading */
  9654. static readonly DELAYLOADSTATE_NOTLOADED: number;
  9655. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  9656. static readonly NEVER: number;
  9657. /** 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 */
  9658. static readonly ALWAYS: number;
  9659. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  9660. static readonly LESS: number;
  9661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  9662. static readonly EQUAL: number;
  9663. /** 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 */
  9664. static readonly LEQUAL: number;
  9665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  9666. static readonly GREATER: number;
  9667. /** 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 */
  9668. static readonly GEQUAL: number;
  9669. /** 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 */
  9670. static readonly NOTEQUAL: number;
  9671. /** Passed to stencilOperation to specify that stencil value must be kept */
  9672. static readonly KEEP: number;
  9673. /** Passed to stencilOperation to specify that stencil value must be replaced */
  9674. static readonly REPLACE: number;
  9675. /** Passed to stencilOperation to specify that stencil value must be incremented */
  9676. static readonly INCR: number;
  9677. /** Passed to stencilOperation to specify that stencil value must be decremented */
  9678. static readonly DECR: number;
  9679. /** Passed to stencilOperation to specify that stencil value must be inverted */
  9680. static readonly INVERT: number;
  9681. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  9682. static readonly INCR_WRAP: number;
  9683. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  9684. static readonly DECR_WRAP: number;
  9685. /** Texture is not repeating outside of 0..1 UVs */
  9686. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  9687. /** Texture is repeating outside of 0..1 UVs */
  9688. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  9689. /** Texture is repeating and mirrored */
  9690. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  9691. /** ALPHA */
  9692. static readonly TEXTUREFORMAT_ALPHA: number;
  9693. /** LUMINANCE */
  9694. static readonly TEXTUREFORMAT_LUMINANCE: number;
  9695. /** LUMINANCE_ALPHA */
  9696. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  9697. /** RGB */
  9698. static readonly TEXTUREFORMAT_RGB: number;
  9699. /** RGBA */
  9700. static readonly TEXTUREFORMAT_RGBA: number;
  9701. /** RED */
  9702. static readonly TEXTUREFORMAT_RED: number;
  9703. /** RED (2nd reference) */
  9704. static readonly TEXTUREFORMAT_R: number;
  9705. /** RG */
  9706. static readonly TEXTUREFORMAT_RG: number;
  9707. /** RED_INTEGER */
  9708. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  9709. /** RED_INTEGER (2nd reference) */
  9710. static readonly TEXTUREFORMAT_R_INTEGER: number;
  9711. /** RG_INTEGER */
  9712. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  9713. /** RGB_INTEGER */
  9714. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  9715. /** RGBA_INTEGER */
  9716. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  9717. /** UNSIGNED_BYTE */
  9718. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  9719. /** UNSIGNED_BYTE (2nd reference) */
  9720. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  9721. /** FLOAT */
  9722. static readonly TEXTURETYPE_FLOAT: number;
  9723. /** HALF_FLOAT */
  9724. static readonly TEXTURETYPE_HALF_FLOAT: number;
  9725. /** BYTE */
  9726. static readonly TEXTURETYPE_BYTE: number;
  9727. /** SHORT */
  9728. static readonly TEXTURETYPE_SHORT: number;
  9729. /** UNSIGNED_SHORT */
  9730. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  9731. /** INT */
  9732. static readonly TEXTURETYPE_INT: number;
  9733. /** UNSIGNED_INT */
  9734. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  9735. /** UNSIGNED_SHORT_4_4_4_4 */
  9736. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  9737. /** UNSIGNED_SHORT_5_5_5_1 */
  9738. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  9739. /** UNSIGNED_SHORT_5_6_5 */
  9740. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  9741. /** UNSIGNED_INT_2_10_10_10_REV */
  9742. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  9743. /** UNSIGNED_INT_24_8 */
  9744. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  9745. /** UNSIGNED_INT_10F_11F_11F_REV */
  9746. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  9747. /** UNSIGNED_INT_5_9_9_9_REV */
  9748. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  9749. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  9750. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  9751. /** nearest is mag = nearest and min = nearest and mip = linear */
  9752. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  9753. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9754. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  9755. /** Trilinear is mag = linear and min = linear and mip = linear */
  9756. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  9757. /** nearest is mag = nearest and min = nearest and mip = linear */
  9758. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  9759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  9760. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  9761. /** Trilinear is mag = linear and min = linear and mip = linear */
  9762. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  9763. /** mag = nearest and min = nearest and mip = nearest */
  9764. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  9765. /** mag = nearest and min = linear and mip = nearest */
  9766. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  9767. /** mag = nearest and min = linear and mip = linear */
  9768. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  9769. /** mag = nearest and min = linear and mip = none */
  9770. static readonly TEXTURE_NEAREST_LINEAR: number;
  9771. /** mag = nearest and min = nearest and mip = none */
  9772. static readonly TEXTURE_NEAREST_NEAREST: number;
  9773. /** mag = linear and min = nearest and mip = nearest */
  9774. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  9775. /** mag = linear and min = nearest and mip = linear */
  9776. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  9777. /** mag = linear and min = linear and mip = none */
  9778. static readonly TEXTURE_LINEAR_LINEAR: number;
  9779. /** mag = linear and min = nearest and mip = none */
  9780. static readonly TEXTURE_LINEAR_NEAREST: number;
  9781. /** Explicit coordinates mode */
  9782. static readonly TEXTURE_EXPLICIT_MODE: number;
  9783. /** Spherical coordinates mode */
  9784. static readonly TEXTURE_SPHERICAL_MODE: number;
  9785. /** Planar coordinates mode */
  9786. static readonly TEXTURE_PLANAR_MODE: number;
  9787. /** Cubic coordinates mode */
  9788. static readonly TEXTURE_CUBIC_MODE: number;
  9789. /** Projection coordinates mode */
  9790. static readonly TEXTURE_PROJECTION_MODE: number;
  9791. /** Skybox coordinates mode */
  9792. static readonly TEXTURE_SKYBOX_MODE: number;
  9793. /** Inverse Cubic coordinates mode */
  9794. static readonly TEXTURE_INVCUBIC_MODE: number;
  9795. /** Equirectangular coordinates mode */
  9796. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  9797. /** Equirectangular Fixed coordinates mode */
  9798. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  9799. /** Equirectangular Fixed Mirrored coordinates mode */
  9800. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  9801. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  9802. static readonly SCALEMODE_FLOOR: number;
  9803. /** Defines that texture rescaling will look for the nearest power of 2 size */
  9804. static readonly SCALEMODE_NEAREST: number;
  9805. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  9806. static readonly SCALEMODE_CEILING: number;
  9807. /**
  9808. * Returns the current version of the framework
  9809. */
  9810. static readonly Version: string;
  9811. /**
  9812. * Gets or sets the epsilon value used by collision engine
  9813. */
  9814. static CollisionsEpsilon: number;
  9815. /**
  9816. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  9817. */
  9818. static CodeRepository: string;
  9819. /**
  9820. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  9821. */
  9822. static ShadersRepository: string;
  9823. /**
  9824. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  9825. */
  9826. forcePOTTextures: boolean;
  9827. /**
  9828. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  9829. */
  9830. isFullscreen: boolean;
  9831. /**
  9832. * Gets a boolean indicating if the pointer is currently locked
  9833. */
  9834. isPointerLock: boolean;
  9835. /**
  9836. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  9837. */
  9838. cullBackFaces: boolean;
  9839. /**
  9840. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  9841. */
  9842. renderEvenInBackground: boolean;
  9843. /**
  9844. * Gets or sets a boolean indicating that cache can be kept between frames
  9845. */
  9846. preventCacheWipeBetweenFrames: boolean;
  9847. /**
  9848. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  9849. **/
  9850. enableOfflineSupport: boolean;
  9851. /**
  9852. * 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)
  9853. **/
  9854. disableManifestCheck: boolean;
  9855. /**
  9856. * Gets the list of created scenes
  9857. */
  9858. scenes: Scene[];
  9859. /**
  9860. * Gets the list of created postprocesses
  9861. */
  9862. postProcesses: PostProcess[];
  9863. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  9864. validateShaderPrograms: boolean;
  9865. /**
  9866. * Observable event triggered each time the rendering canvas is resized
  9867. */
  9868. onResizeObservable: Observable<Engine>;
  9869. /**
  9870. * Observable event triggered each time the canvas loses focus
  9871. */
  9872. onCanvasBlurObservable: Observable<Engine>;
  9873. /**
  9874. * Observable event triggered each time the canvas gains focus
  9875. */
  9876. onCanvasFocusObservable: Observable<Engine>;
  9877. /**
  9878. * Observable event triggered each time the canvas receives pointerout event
  9879. */
  9880. onCanvasPointerOutObservable: Observable<PointerEvent>;
  9881. /**
  9882. * Observable event triggered before each texture is initialized
  9883. */
  9884. onBeforeTextureInitObservable: Observable<Texture>;
  9885. private _vrDisplay;
  9886. private _vrSupported;
  9887. private _oldSize;
  9888. private _oldHardwareScaleFactor;
  9889. private _vrExclusivePointerMode;
  9890. private _webVRInitPromise;
  9891. /**
  9892. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  9893. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  9894. */
  9895. readonly isInVRExclusivePointerMode: boolean;
  9896. /**
  9897. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  9898. */
  9899. disableUniformBuffers: boolean;
  9900. /** @hidden */
  9901. _uniformBuffers: UniformBuffer[];
  9902. /**
  9903. * Gets a boolean indicating that the engine supports uniform buffers
  9904. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  9905. */
  9906. readonly supportsUniformBuffers: boolean;
  9907. /**
  9908. * Observable raised when the engine begins a new frame
  9909. */
  9910. onBeginFrameObservable: Observable<Engine>;
  9911. /**
  9912. * If set, will be used to request the next animation frame for the render loop
  9913. */
  9914. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  9915. /**
  9916. * Observable raised when the engine ends the current frame
  9917. */
  9918. onEndFrameObservable: Observable<Engine>;
  9919. /**
  9920. * Observable raised when the engine is about to compile a shader
  9921. */
  9922. onBeforeShaderCompilationObservable: Observable<Engine>;
  9923. /**
  9924. * Observable raised when the engine has jsut compiled a shader
  9925. */
  9926. onAfterShaderCompilationObservable: Observable<Engine>;
  9927. /** @hidden */
  9928. _gl: WebGLRenderingContext;
  9929. private _renderingCanvas;
  9930. private _windowIsBackground;
  9931. private _webGLVersion;
  9932. /**
  9933. * Gets a boolean indicating that only power of 2 textures are supported
  9934. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  9935. */
  9936. readonly needPOTTextures: boolean;
  9937. /** @hidden */
  9938. _badOS: boolean;
  9939. /** @hidden */
  9940. _badDesktopOS: boolean;
  9941. /**
  9942. * Gets or sets a value indicating if we want to disable texture binding optimization.
  9943. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  9944. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  9945. */
  9946. disableTextureBindingOptimization: boolean;
  9947. /**
  9948. * Gets the audio engine
  9949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9950. * @ignorenaming
  9951. */
  9952. static audioEngine: IAudioEngine;
  9953. /**
  9954. * Default AudioEngine factory responsible of creating the Audio Engine.
  9955. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  9956. */
  9957. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  9958. /**
  9959. * Default offline support factory responsible of creating a tool used to store data locally.
  9960. * By default, this will create a Database object if the workload has been embedded.
  9961. */
  9962. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  9963. private _onFocus;
  9964. private _onBlur;
  9965. private _onCanvasPointerOut;
  9966. private _onCanvasBlur;
  9967. private _onCanvasFocus;
  9968. private _onFullscreenChange;
  9969. private _onPointerLockChange;
  9970. private _onVRDisplayPointerRestricted;
  9971. private _onVRDisplayPointerUnrestricted;
  9972. private _onVrDisplayConnect;
  9973. private _onVrDisplayDisconnect;
  9974. private _onVrDisplayPresentChange;
  9975. /**
  9976. * Observable signaled when VR display mode changes
  9977. */
  9978. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  9979. /**
  9980. * Observable signaled when VR request present is complete
  9981. */
  9982. onVRRequestPresentComplete: Observable<boolean>;
  9983. /**
  9984. * Observable signaled when VR request present starts
  9985. */
  9986. onVRRequestPresentStart: Observable<Engine>;
  9987. private _hardwareScalingLevel;
  9988. /** @hidden */
  9989. protected _caps: EngineCapabilities;
  9990. private _pointerLockRequested;
  9991. private _isStencilEnable;
  9992. private _colorWrite;
  9993. private _loadingScreen;
  9994. /** @hidden */
  9995. _drawCalls: PerfCounter;
  9996. /** @hidden */
  9997. _textureCollisions: PerfCounter;
  9998. private _glVersion;
  9999. private _glRenderer;
  10000. private _glVendor;
  10001. private _videoTextureSupported;
  10002. private _renderingQueueLaunched;
  10003. private _activeRenderLoops;
  10004. private _deterministicLockstep;
  10005. private _lockstepMaxSteps;
  10006. /**
  10007. * Observable signaled when a context lost event is raised
  10008. */
  10009. onContextLostObservable: Observable<Engine>;
  10010. /**
  10011. * Observable signaled when a context restored event is raised
  10012. */
  10013. onContextRestoredObservable: Observable<Engine>;
  10014. private _onContextLost;
  10015. private _onContextRestored;
  10016. private _contextWasLost;
  10017. private _doNotHandleContextLost;
  10018. /**
  10019. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10021. */
  10022. doNotHandleContextLost: boolean;
  10023. private _performanceMonitor;
  10024. private _fps;
  10025. private _deltaTime;
  10026. /**
  10027. * Turn this value on if you want to pause FPS computation when in background
  10028. */
  10029. disablePerformanceMonitorInBackground: boolean;
  10030. /**
  10031. * Gets the performance monitor attached to this engine
  10032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10033. */
  10034. readonly performanceMonitor: PerformanceMonitor;
  10035. /** @hidden */
  10036. protected _depthCullingState: _DepthCullingState;
  10037. /** @hidden */
  10038. protected _stencilState: _StencilState;
  10039. /** @hidden */
  10040. protected _alphaState: _AlphaState;
  10041. /** @hidden */
  10042. protected _alphaMode: number;
  10043. protected _internalTexturesCache: InternalTexture[];
  10044. /** @hidden */
  10045. protected _activeChannel: number;
  10046. private _currentTextureChannel;
  10047. /** @hidden */
  10048. protected _boundTexturesCache: {
  10049. [key: string]: Nullable<InternalTexture>;
  10050. };
  10051. /** @hidden */
  10052. protected _currentEffect: Nullable<Effect>;
  10053. /** @hidden */
  10054. protected _currentProgram: Nullable<WebGLProgram>;
  10055. private _compiledEffects;
  10056. private _vertexAttribArraysEnabled;
  10057. /** @hidden */
  10058. protected _cachedViewport: Nullable<Viewport>;
  10059. private _cachedVertexArrayObject;
  10060. /** @hidden */
  10061. protected _cachedVertexBuffers: any;
  10062. /** @hidden */
  10063. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10064. /** @hidden */
  10065. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10066. /** @hidden */
  10067. protected _currentRenderTarget: Nullable<InternalTexture>;
  10068. private _uintIndicesCurrentlySet;
  10069. private _currentBoundBuffer;
  10070. /** @hidden */
  10071. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10072. private _currentBufferPointers;
  10073. private _currentInstanceLocations;
  10074. private _currentInstanceBuffers;
  10075. private _textureUnits;
  10076. private _firstBoundInternalTextureTracker;
  10077. private _lastBoundInternalTextureTracker;
  10078. private _workingCanvas;
  10079. private _workingContext;
  10080. private _rescalePostProcess;
  10081. private _dummyFramebuffer;
  10082. private _externalData;
  10083. private _bindedRenderFunction;
  10084. private _vaoRecordInProgress;
  10085. private _mustWipeVertexAttributes;
  10086. private _emptyTexture;
  10087. private _emptyCubeTexture;
  10088. private _emptyTexture3D;
  10089. private _frameHandler;
  10090. private _nextFreeTextureSlots;
  10091. private _maxSimultaneousTextures;
  10092. private _activeRequests;
  10093. private _texturesSupported;
  10094. private _textureFormatInUse;
  10095. /**
  10096. * Gets the list of texture formats supported
  10097. */
  10098. readonly texturesSupported: Array<string>;
  10099. /**
  10100. * Gets the list of texture formats in use
  10101. */
  10102. readonly textureFormatInUse: Nullable<string>;
  10103. /**
  10104. * Gets the current viewport
  10105. */
  10106. readonly currentViewport: Nullable<Viewport>;
  10107. /**
  10108. * Gets the default empty texture
  10109. */
  10110. readonly emptyTexture: InternalTexture;
  10111. /**
  10112. * Gets the default empty 3D texture
  10113. */
  10114. readonly emptyTexture3D: InternalTexture;
  10115. /**
  10116. * Gets the default empty cube texture
  10117. */
  10118. readonly emptyCubeTexture: InternalTexture;
  10119. /**
  10120. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10121. */
  10122. readonly premultipliedAlpha: boolean;
  10123. /**
  10124. * Creates a new engine
  10125. * @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
  10126. * @param antialias defines enable antialiasing (default: false)
  10127. * @param options defines further options to be sent to the getContext() function
  10128. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10129. */
  10130. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10131. private _rebuildInternalTextures;
  10132. private _rebuildEffects;
  10133. /**
  10134. * Gets a boolean indicating if all created effects are ready
  10135. * @returns true if all effects are ready
  10136. */
  10137. areAllEffectsReady(): boolean;
  10138. private _rebuildBuffers;
  10139. private _initGLContext;
  10140. /**
  10141. * Gets version of the current webGL context
  10142. */
  10143. readonly webGLVersion: number;
  10144. /**
  10145. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10146. */
  10147. readonly isStencilEnable: boolean;
  10148. private _prepareWorkingCanvas;
  10149. /**
  10150. * Reset the texture cache to empty state
  10151. */
  10152. resetTextureCache(): void;
  10153. /**
  10154. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10156. * @returns true if engine is in deterministic lock step mode
  10157. */
  10158. isDeterministicLockStep(): boolean;
  10159. /**
  10160. * Gets the max steps when engine is running in deterministic lock step
  10161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10162. * @returns the max steps
  10163. */
  10164. getLockstepMaxSteps(): number;
  10165. /**
  10166. * Gets an object containing information about the current webGL context
  10167. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10168. */
  10169. getGlInfo(): {
  10170. vendor: string;
  10171. renderer: string;
  10172. version: string;
  10173. };
  10174. /**
  10175. * Gets current aspect ratio
  10176. * @param camera defines the camera to use to get the aspect ratio
  10177. * @param useScreen defines if screen size must be used (or the current render target if any)
  10178. * @returns a number defining the aspect ratio
  10179. */
  10180. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10181. /**
  10182. * Gets current screen aspect ratio
  10183. * @returns a number defining the aspect ratio
  10184. */
  10185. getScreenAspectRatio(): number;
  10186. /**
  10187. * Gets the current render width
  10188. * @param useScreen defines if screen size must be used (or the current render target if any)
  10189. * @returns a number defining the current render width
  10190. */
  10191. getRenderWidth(useScreen?: boolean): number;
  10192. /**
  10193. * Gets the current render height
  10194. * @param useScreen defines if screen size must be used (or the current render target if any)
  10195. * @returns a number defining the current render height
  10196. */
  10197. getRenderHeight(useScreen?: boolean): number;
  10198. /**
  10199. * Gets the HTML canvas attached with the current webGL context
  10200. * @returns a HTML canvas
  10201. */
  10202. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10203. /**
  10204. * Gets the client rect of the HTML canvas attached with the current webGL context
  10205. * @returns a client rectanglee
  10206. */
  10207. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10208. /**
  10209. * Defines the hardware scaling level.
  10210. * By default the hardware scaling level is computed from the window device ratio.
  10211. * 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.
  10212. * @param level defines the level to use
  10213. */
  10214. setHardwareScalingLevel(level: number): void;
  10215. /**
  10216. * Gets the current hardware scaling level.
  10217. * By default the hardware scaling level is computed from the window device ratio.
  10218. * 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.
  10219. * @returns a number indicating the current hardware scaling level
  10220. */
  10221. getHardwareScalingLevel(): number;
  10222. /**
  10223. * Gets the list of loaded textures
  10224. * @returns an array containing all loaded textures
  10225. */
  10226. getLoadedTexturesCache(): InternalTexture[];
  10227. /**
  10228. * Gets the object containing all engine capabilities
  10229. * @returns the EngineCapabilities object
  10230. */
  10231. getCaps(): EngineCapabilities;
  10232. /** @hidden */
  10233. readonly drawCalls: number;
  10234. /** @hidden */
  10235. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10236. /**
  10237. * Gets the current depth function
  10238. * @returns a number defining the depth function
  10239. */
  10240. getDepthFunction(): Nullable<number>;
  10241. /**
  10242. * Sets the current depth function
  10243. * @param depthFunc defines the function to use
  10244. */
  10245. setDepthFunction(depthFunc: number): void;
  10246. /**
  10247. * Sets the current depth function to GREATER
  10248. */
  10249. setDepthFunctionToGreater(): void;
  10250. /**
  10251. * Sets the current depth function to GEQUAL
  10252. */
  10253. setDepthFunctionToGreaterOrEqual(): void;
  10254. /**
  10255. * Sets the current depth function to LESS
  10256. */
  10257. setDepthFunctionToLess(): void;
  10258. /**
  10259. * Sets the current depth function to LEQUAL
  10260. */
  10261. setDepthFunctionToLessOrEqual(): void;
  10262. /**
  10263. * Gets a boolean indicating if stencil buffer is enabled
  10264. * @returns the current stencil buffer state
  10265. */
  10266. getStencilBuffer(): boolean;
  10267. /**
  10268. * Enable or disable the stencil buffer
  10269. * @param enable defines if the stencil buffer must be enabled or disabled
  10270. */
  10271. setStencilBuffer(enable: boolean): void;
  10272. /**
  10273. * Gets the current stencil mask
  10274. * @returns a number defining the new stencil mask to use
  10275. */
  10276. getStencilMask(): number;
  10277. /**
  10278. * Sets the current stencil mask
  10279. * @param mask defines the new stencil mask to use
  10280. */
  10281. setStencilMask(mask: number): void;
  10282. /**
  10283. * Gets the current stencil function
  10284. * @returns a number defining the stencil function to use
  10285. */
  10286. getStencilFunction(): number;
  10287. /**
  10288. * Gets the current stencil reference value
  10289. * @returns a number defining the stencil reference value to use
  10290. */
  10291. getStencilFunctionReference(): number;
  10292. /**
  10293. * Gets the current stencil mask
  10294. * @returns a number defining the stencil mask to use
  10295. */
  10296. getStencilFunctionMask(): number;
  10297. /**
  10298. * Sets the current stencil function
  10299. * @param stencilFunc defines the new stencil function to use
  10300. */
  10301. setStencilFunction(stencilFunc: number): void;
  10302. /**
  10303. * Sets the current stencil reference
  10304. * @param reference defines the new stencil reference to use
  10305. */
  10306. setStencilFunctionReference(reference: number): void;
  10307. /**
  10308. * Sets the current stencil mask
  10309. * @param mask defines the new stencil mask to use
  10310. */
  10311. setStencilFunctionMask(mask: number): void;
  10312. /**
  10313. * Gets the current stencil operation when stencil fails
  10314. * @returns a number defining stencil operation to use when stencil fails
  10315. */
  10316. getStencilOperationFail(): number;
  10317. /**
  10318. * Gets the current stencil operation when depth fails
  10319. * @returns a number defining stencil operation to use when depth fails
  10320. */
  10321. getStencilOperationDepthFail(): number;
  10322. /**
  10323. * Gets the current stencil operation when stencil passes
  10324. * @returns a number defining stencil operation to use when stencil passes
  10325. */
  10326. getStencilOperationPass(): number;
  10327. /**
  10328. * Sets the stencil operation to use when stencil fails
  10329. * @param operation defines the stencil operation to use when stencil fails
  10330. */
  10331. setStencilOperationFail(operation: number): void;
  10332. /**
  10333. * Sets the stencil operation to use when depth fails
  10334. * @param operation defines the stencil operation to use when depth fails
  10335. */
  10336. setStencilOperationDepthFail(operation: number): void;
  10337. /**
  10338. * Sets the stencil operation to use when stencil passes
  10339. * @param operation defines the stencil operation to use when stencil passes
  10340. */
  10341. setStencilOperationPass(operation: number): void;
  10342. /**
  10343. * Sets a boolean indicating if the dithering state is enabled or disabled
  10344. * @param value defines the dithering state
  10345. */
  10346. setDitheringState(value: boolean): void;
  10347. /**
  10348. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10349. * @param value defines the rasterizer state
  10350. */
  10351. setRasterizerState(value: boolean): void;
  10352. /**
  10353. * stop executing a render loop function and remove it from the execution array
  10354. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10355. */
  10356. stopRenderLoop(renderFunction?: () => void): void;
  10357. /** @hidden */
  10358. _renderLoop(): void;
  10359. /**
  10360. * Register and execute a render loop. The engine can have more than one render function
  10361. * @param renderFunction defines the function to continuously execute
  10362. */
  10363. runRenderLoop(renderFunction: () => void): void;
  10364. /**
  10365. * Toggle full screen mode
  10366. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10367. */
  10368. switchFullscreen(requestPointerLock: boolean): void;
  10369. /**
  10370. * Clear the current render buffer or the current render target (if any is set up)
  10371. * @param color defines the color to use
  10372. * @param backBuffer defines if the back buffer must be cleared
  10373. * @param depth defines if the depth buffer must be cleared
  10374. * @param stencil defines if the stencil buffer must be cleared
  10375. */
  10376. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10377. /**
  10378. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10379. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10380. * @param y defines the y-coordinate of the corner of the clear rectangle
  10381. * @param width defines the width of the clear rectangle
  10382. * @param height defines the height of the clear rectangle
  10383. * @param clearColor defines the clear color
  10384. */
  10385. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10386. private _viewportCached;
  10387. /** @hidden */
  10388. _viewport(x: number, y: number, width: number, height: number): void;
  10389. /**
  10390. * Set the WebGL's viewport
  10391. * @param viewport defines the viewport element to be used
  10392. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10393. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10394. */
  10395. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10396. /**
  10397. * Directly set the WebGL Viewport
  10398. * @param x defines the x coordinate of the viewport (in screen space)
  10399. * @param y defines the y coordinate of the viewport (in screen space)
  10400. * @param width defines the width of the viewport (in screen space)
  10401. * @param height defines the height of the viewport (in screen space)
  10402. * @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
  10403. */
  10404. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10405. /**
  10406. * Begin a new frame
  10407. */
  10408. beginFrame(): void;
  10409. /**
  10410. * Enf the current frame
  10411. */
  10412. endFrame(): void;
  10413. /**
  10414. * Resize the view according to the canvas' size
  10415. */
  10416. resize(): void;
  10417. /**
  10418. * Force a specific size of the canvas
  10419. * @param width defines the new canvas' width
  10420. * @param height defines the new canvas' height
  10421. */
  10422. setSize(width: number, height: number): void;
  10423. /**
  10424. * Gets a boolean indicating if a webVR device was detected
  10425. * @returns true if a webVR device was detected
  10426. */
  10427. isVRDevicePresent(): boolean;
  10428. /**
  10429. * Gets the current webVR device
  10430. * @returns the current webVR device (or null)
  10431. */
  10432. getVRDevice(): any;
  10433. /**
  10434. * Initializes a webVR display and starts listening to display change events
  10435. * The onVRDisplayChangedObservable will be notified upon these changes
  10436. * @returns The onVRDisplayChangedObservable
  10437. */
  10438. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10439. /**
  10440. * Initializes a webVR display and starts listening to display change events
  10441. * The onVRDisplayChangedObservable will be notified upon these changes
  10442. * @returns A promise containing a VRDisplay and if vr is supported
  10443. */
  10444. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10445. /**
  10446. * Call this function to switch to webVR mode
  10447. * Will do nothing if webVR is not supported or if there is no webVR device
  10448. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10449. */
  10450. enableVR(): void;
  10451. /**
  10452. * Call this function to leave webVR mode
  10453. * Will do nothing if webVR is not supported or if there is no webVR device
  10454. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10455. */
  10456. disableVR(): void;
  10457. private _onVRFullScreenTriggered;
  10458. private _getVRDisplaysAsync;
  10459. /**
  10460. * Binds the frame buffer to the specified texture.
  10461. * @param texture The texture to render to or null for the default canvas
  10462. * @param faceIndex The face of the texture to render to in case of cube texture
  10463. * @param requiredWidth The width of the target to render to
  10464. * @param requiredHeight The height of the target to render to
  10465. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10466. * @param depthStencilTexture The depth stencil texture to use to render
  10467. * @param lodLevel defines le lod level to bind to the frame buffer
  10468. */
  10469. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10470. private bindUnboundFramebuffer;
  10471. /**
  10472. * Unbind the current render target texture from the webGL context
  10473. * @param texture defines the render target texture to unbind
  10474. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10475. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10476. */
  10477. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10478. /**
  10479. * Unbind a list of render target textures from the webGL context
  10480. * This is used only when drawBuffer extension or webGL2 are active
  10481. * @param textures defines the render target textures to unbind
  10482. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10483. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10484. */
  10485. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10486. /**
  10487. * Force the mipmap generation for the given render target texture
  10488. * @param texture defines the render target texture to use
  10489. */
  10490. generateMipMapsForCubemap(texture: InternalTexture): void;
  10491. /**
  10492. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10493. */
  10494. flushFramebuffer(): void;
  10495. /**
  10496. * Unbind the current render target and bind the default framebuffer
  10497. */
  10498. restoreDefaultFramebuffer(): void;
  10499. /**
  10500. * Create an uniform buffer
  10501. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10502. * @param elements defines the content of the uniform buffer
  10503. * @returns the webGL uniform buffer
  10504. */
  10505. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10506. /**
  10507. * Create a dynamic uniform buffer
  10508. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10509. * @param elements defines the content of the uniform buffer
  10510. * @returns the webGL uniform buffer
  10511. */
  10512. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10513. /**
  10514. * Update an existing uniform buffer
  10515. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10516. * @param uniformBuffer defines the target uniform buffer
  10517. * @param elements defines the content to update
  10518. * @param offset defines the offset in the uniform buffer where update should start
  10519. * @param count defines the size of the data to update
  10520. */
  10521. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10522. private _resetVertexBufferBinding;
  10523. /**
  10524. * Creates a vertex buffer
  10525. * @param data the data for the vertex buffer
  10526. * @returns the new WebGL static buffer
  10527. */
  10528. createVertexBuffer(data: DataArray): WebGLBuffer;
  10529. /**
  10530. * Creates a dynamic vertex buffer
  10531. * @param data the data for the dynamic vertex buffer
  10532. * @returns the new WebGL dynamic buffer
  10533. */
  10534. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10535. /**
  10536. * Update a dynamic index buffer
  10537. * @param indexBuffer defines the target index buffer
  10538. * @param indices defines the data to update
  10539. * @param offset defines the offset in the target index buffer where update should start
  10540. */
  10541. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10542. /**
  10543. * Updates a dynamic vertex buffer.
  10544. * @param vertexBuffer the vertex buffer to update
  10545. * @param data the data used to update the vertex buffer
  10546. * @param byteOffset the byte offset of the data
  10547. * @param byteLength the byte length of the data
  10548. */
  10549. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10550. private _resetIndexBufferBinding;
  10551. /**
  10552. * Creates a new index buffer
  10553. * @param indices defines the content of the index buffer
  10554. * @param updatable defines if the index buffer must be updatable
  10555. * @returns a new webGL buffer
  10556. */
  10557. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10558. /**
  10559. * Bind a webGL buffer to the webGL context
  10560. * @param buffer defines the buffer to bind
  10561. */
  10562. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10563. /**
  10564. * Bind an uniform buffer to the current webGL context
  10565. * @param buffer defines the buffer to bind
  10566. */
  10567. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10568. /**
  10569. * Bind a buffer to the current webGL context at a given location
  10570. * @param buffer defines the buffer to bind
  10571. * @param location defines the index where to bind the buffer
  10572. */
  10573. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10574. /**
  10575. * Bind a specific block at a given index in a specific shader program
  10576. * @param shaderProgram defines the shader program
  10577. * @param blockName defines the block name
  10578. * @param index defines the index where to bind the block
  10579. */
  10580. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10581. private bindIndexBuffer;
  10582. private bindBuffer;
  10583. /**
  10584. * update the bound buffer with the given data
  10585. * @param data defines the data to update
  10586. */
  10587. updateArrayBuffer(data: Float32Array): void;
  10588. private _vertexAttribPointer;
  10589. private _bindIndexBufferWithCache;
  10590. private _bindVertexBuffersAttributes;
  10591. /**
  10592. * Records a vertex array object
  10593. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10594. * @param vertexBuffers defines the list of vertex buffers to store
  10595. * @param indexBuffer defines the index buffer to store
  10596. * @param effect defines the effect to store
  10597. * @returns the new vertex array object
  10598. */
  10599. recordVertexArrayObject(vertexBuffers: {
  10600. [key: string]: VertexBuffer;
  10601. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10602. /**
  10603. * Bind a specific vertex array object
  10604. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10605. * @param vertexArrayObject defines the vertex array object to bind
  10606. * @param indexBuffer defines the index buffer to bind
  10607. */
  10608. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10609. /**
  10610. * Bind webGl buffers directly to the webGL context
  10611. * @param vertexBuffer defines the vertex buffer to bind
  10612. * @param indexBuffer defines the index buffer to bind
  10613. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10614. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10615. * @param effect defines the effect associated with the vertex buffer
  10616. */
  10617. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10618. private _unbindVertexArrayObject;
  10619. /**
  10620. * Bind a list of vertex buffers to the webGL context
  10621. * @param vertexBuffers defines the list of vertex buffers to bind
  10622. * @param indexBuffer defines the index buffer to bind
  10623. * @param effect defines the effect associated with the vertex buffers
  10624. */
  10625. bindBuffers(vertexBuffers: {
  10626. [key: string]: Nullable<VertexBuffer>;
  10627. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10628. /**
  10629. * Unbind all instance attributes
  10630. */
  10631. unbindInstanceAttributes(): void;
  10632. /**
  10633. * Release and free the memory of a vertex array object
  10634. * @param vao defines the vertex array object to delete
  10635. */
  10636. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  10637. /** @hidden */
  10638. _releaseBuffer(buffer: WebGLBuffer): boolean;
  10639. /**
  10640. * Creates a webGL buffer to use with instanciation
  10641. * @param capacity defines the size of the buffer
  10642. * @returns the webGL buffer
  10643. */
  10644. createInstancesBuffer(capacity: number): WebGLBuffer;
  10645. /**
  10646. * Delete a webGL buffer used with instanciation
  10647. * @param buffer defines the webGL buffer to delete
  10648. */
  10649. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  10650. /**
  10651. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  10652. * @param instancesBuffer defines the webGL buffer to update and bind
  10653. * @param data defines the data to store in the buffer
  10654. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  10655. */
  10656. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  10657. /**
  10658. * Apply all cached states (depth, culling, stencil and alpha)
  10659. */
  10660. applyStates(): void;
  10661. /**
  10662. * Send a draw order
  10663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10664. * @param indexStart defines the starting index
  10665. * @param indexCount defines the number of index to draw
  10666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10667. */
  10668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  10669. /**
  10670. * Draw a list of points
  10671. * @param verticesStart defines the index of first vertex to draw
  10672. * @param verticesCount defines the count of vertices to draw
  10673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10674. */
  10675. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10676. /**
  10677. * Draw a list of unindexed primitives
  10678. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  10679. * @param verticesStart defines the index of first vertex to draw
  10680. * @param verticesCount defines the count of vertices to draw
  10681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10682. */
  10683. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10684. /**
  10685. * Draw a list of indexed primitives
  10686. * @param fillMode defines the primitive to use
  10687. * @param indexStart defines the starting index
  10688. * @param indexCount defines the number of index to draw
  10689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10690. */
  10691. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  10692. /**
  10693. * Draw a list of unindexed primitives
  10694. * @param fillMode defines the primitive to use
  10695. * @param verticesStart defines the index of first vertex to draw
  10696. * @param verticesCount defines the count of vertices to draw
  10697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  10698. */
  10699. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  10700. private _drawMode;
  10701. /** @hidden */
  10702. _releaseEffect(effect: Effect): void;
  10703. /** @hidden */
  10704. _deleteProgram(program: WebGLProgram): void;
  10705. /**
  10706. * Create a new effect (used to store vertex/fragment shaders)
  10707. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  10708. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  10709. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  10710. * @param samplers defines an array of string used to represent textures
  10711. * @param defines defines the string containing the defines to use to compile the shaders
  10712. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  10713. * @param onCompiled defines a function to call when the effect creation is successful
  10714. * @param onError defines a function to call when the effect creation has failed
  10715. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  10716. * @returns the new Effect
  10717. */
  10718. 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;
  10719. private _compileShader;
  10720. private _compileRawShader;
  10721. /**
  10722. * Directly creates a webGL program
  10723. * @param vertexCode defines the vertex shader code to use
  10724. * @param fragmentCode defines the fragment shader code to use
  10725. * @param context defines the webGL context to use (if not set, the current one will be used)
  10726. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10727. * @returns the new webGL program
  10728. */
  10729. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10730. /**
  10731. * Creates a webGL program
  10732. * @param vertexCode defines the vertex shader code to use
  10733. * @param fragmentCode defines the fragment shader code to use
  10734. * @param defines defines the string containing the defines to use to compile the shaders
  10735. * @param context defines the webGL context to use (if not set, the current one will be used)
  10736. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  10737. * @returns the new webGL program
  10738. */
  10739. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  10740. private _createShaderProgram;
  10741. private _finalizeProgram;
  10742. /** @hidden */
  10743. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  10744. /** @hidden */
  10745. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  10746. /**
  10747. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  10748. * @param shaderProgram defines the webGL program to use
  10749. * @param uniformsNames defines the list of uniform names
  10750. * @returns an array of webGL uniform locations
  10751. */
  10752. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  10753. /**
  10754. * Gets the lsit of active attributes for a given webGL program
  10755. * @param shaderProgram defines the webGL program to use
  10756. * @param attributesNames defines the list of attribute names to get
  10757. * @returns an array of indices indicating the offset of each attribute
  10758. */
  10759. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  10760. /**
  10761. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  10762. * @param effect defines the effect to activate
  10763. */
  10764. enableEffect(effect: Nullable<Effect>): void;
  10765. /**
  10766. * Set the value of an uniform to an array of int32
  10767. * @param uniform defines the webGL uniform location where to store the value
  10768. * @param array defines the array of int32 to store
  10769. */
  10770. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10771. /**
  10772. * Set the value of an uniform to an array of int32 (stored as vec2)
  10773. * @param uniform defines the webGL uniform location where to store the value
  10774. * @param array defines the array of int32 to store
  10775. */
  10776. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10777. /**
  10778. * Set the value of an uniform to an array of int32 (stored as vec3)
  10779. * @param uniform defines the webGL uniform location where to store the value
  10780. * @param array defines the array of int32 to store
  10781. */
  10782. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10783. /**
  10784. * Set the value of an uniform to an array of int32 (stored as vec4)
  10785. * @param uniform defines the webGL uniform location where to store the value
  10786. * @param array defines the array of int32 to store
  10787. */
  10788. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  10789. /**
  10790. * Set the value of an uniform to an array of float32
  10791. * @param uniform defines the webGL uniform location where to store the value
  10792. * @param array defines the array of float32 to store
  10793. */
  10794. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10795. /**
  10796. * Set the value of an uniform to an array of float32 (stored as vec2)
  10797. * @param uniform defines the webGL uniform location where to store the value
  10798. * @param array defines the array of float32 to store
  10799. */
  10800. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10801. /**
  10802. * Set the value of an uniform to an array of float32 (stored as vec3)
  10803. * @param uniform defines the webGL uniform location where to store the value
  10804. * @param array defines the array of float32 to store
  10805. */
  10806. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10807. /**
  10808. * Set the value of an uniform to an array of float32 (stored as vec4)
  10809. * @param uniform defines the webGL uniform location where to store the value
  10810. * @param array defines the array of float32 to store
  10811. */
  10812. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  10813. /**
  10814. * Set the value of an uniform to an array of number
  10815. * @param uniform defines the webGL uniform location where to store the value
  10816. * @param array defines the array of number to store
  10817. */
  10818. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10819. /**
  10820. * Set the value of an uniform to an array of number (stored as vec2)
  10821. * @param uniform defines the webGL uniform location where to store the value
  10822. * @param array defines the array of number to store
  10823. */
  10824. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10825. /**
  10826. * Set the value of an uniform to an array of number (stored as vec3)
  10827. * @param uniform defines the webGL uniform location where to store the value
  10828. * @param array defines the array of number to store
  10829. */
  10830. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10831. /**
  10832. * Set the value of an uniform to an array of number (stored as vec4)
  10833. * @param uniform defines the webGL uniform location where to store the value
  10834. * @param array defines the array of number to store
  10835. */
  10836. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  10837. /**
  10838. * Set the value of an uniform to an array of float32 (stored as matrices)
  10839. * @param uniform defines the webGL uniform location where to store the value
  10840. * @param matrices defines the array of float32 to store
  10841. */
  10842. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  10843. /**
  10844. * Set the value of an uniform to a matrix
  10845. * @param uniform defines the webGL uniform location where to store the value
  10846. * @param matrix defines the matrix to store
  10847. */
  10848. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  10849. /**
  10850. * Set the value of an uniform to a matrix (3x3)
  10851. * @param uniform defines the webGL uniform location where to store the value
  10852. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  10853. */
  10854. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10855. /**
  10856. * Set the value of an uniform to a matrix (2x2)
  10857. * @param uniform defines the webGL uniform location where to store the value
  10858. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  10859. */
  10860. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  10861. /**
  10862. * Set the value of an uniform to a number (int)
  10863. * @param uniform defines the webGL uniform location where to store the value
  10864. * @param value defines the int number to store
  10865. */
  10866. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10867. /**
  10868. * Set the value of an uniform to a number (float)
  10869. * @param uniform defines the webGL uniform location where to store the value
  10870. * @param value defines the float number to store
  10871. */
  10872. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  10873. /**
  10874. * Set the value of an uniform to a vec2
  10875. * @param uniform defines the webGL uniform location where to store the value
  10876. * @param x defines the 1st component of the value
  10877. * @param y defines the 2nd component of the value
  10878. */
  10879. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  10880. /**
  10881. * Set the value of an uniform to a vec3
  10882. * @param uniform defines the webGL uniform location where to store the value
  10883. * @param x defines the 1st component of the value
  10884. * @param y defines the 2nd component of the value
  10885. * @param z defines the 3rd component of the value
  10886. */
  10887. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  10888. /**
  10889. * Set the value of an uniform to a boolean
  10890. * @param uniform defines the webGL uniform location where to store the value
  10891. * @param bool defines the boolean to store
  10892. */
  10893. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  10894. /**
  10895. * Set the value of an uniform to a vec4
  10896. * @param uniform defines the webGL uniform location where to store the value
  10897. * @param x defines the 1st component of the value
  10898. * @param y defines the 2nd component of the value
  10899. * @param z defines the 3rd component of the value
  10900. * @param w defines the 4th component of the value
  10901. */
  10902. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  10903. /**
  10904. * Set the value of an uniform to a Color3
  10905. * @param uniform defines the webGL uniform location where to store the value
  10906. * @param color3 defines the color to store
  10907. */
  10908. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  10909. /**
  10910. * Set the value of an uniform to a Color3 and an alpha value
  10911. * @param uniform defines the webGL uniform location where to store the value
  10912. * @param color3 defines the color to store
  10913. * @param alpha defines the alpha component to store
  10914. */
  10915. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  10916. /**
  10917. * Sets a Color4 on a uniform variable
  10918. * @param uniform defines the uniform location
  10919. * @param color4 defines the value to be set
  10920. */
  10921. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  10922. /**
  10923. * Set various states to the webGL context
  10924. * @param culling defines backface culling state
  10925. * @param zOffset defines the value to apply to zOffset (0 by default)
  10926. * @param force defines if states must be applied even if cache is up to date
  10927. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  10928. */
  10929. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  10930. /**
  10931. * Set the z offset to apply to current rendering
  10932. * @param value defines the offset to apply
  10933. */
  10934. setZOffset(value: number): void;
  10935. /**
  10936. * Gets the current value of the zOffset
  10937. * @returns the current zOffset state
  10938. */
  10939. getZOffset(): number;
  10940. /**
  10941. * Enable or disable depth buffering
  10942. * @param enable defines the state to set
  10943. */
  10944. setDepthBuffer(enable: boolean): void;
  10945. /**
  10946. * Gets a boolean indicating if depth writing is enabled
  10947. * @returns the current depth writing state
  10948. */
  10949. getDepthWrite(): boolean;
  10950. /**
  10951. * Enable or disable depth writing
  10952. * @param enable defines the state to set
  10953. */
  10954. setDepthWrite(enable: boolean): void;
  10955. /**
  10956. * Enable or disable color writing
  10957. * @param enable defines the state to set
  10958. */
  10959. setColorWrite(enable: boolean): void;
  10960. /**
  10961. * Gets a boolean indicating if color writing is enabled
  10962. * @returns the current color writing state
  10963. */
  10964. getColorWrite(): boolean;
  10965. /**
  10966. * Sets alpha constants used by some alpha blending modes
  10967. * @param r defines the red component
  10968. * @param g defines the green component
  10969. * @param b defines the blue component
  10970. * @param a defines the alpha component
  10971. */
  10972. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  10973. /**
  10974. * Sets the current alpha mode
  10975. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  10976. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  10977. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10978. */
  10979. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  10980. /**
  10981. * Gets the current alpha mode
  10982. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  10983. * @returns the current alpha mode
  10984. */
  10985. getAlphaMode(): number;
  10986. /**
  10987. * Clears the list of texture accessible through engine.
  10988. * This can help preventing texture load conflict due to name collision.
  10989. */
  10990. clearInternalTexturesCache(): void;
  10991. /**
  10992. * Force the entire cache to be cleared
  10993. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  10994. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  10995. */
  10996. wipeCaches(bruteForce?: boolean): void;
  10997. /**
  10998. * Set the compressed texture format to use, based on the formats you have, and the formats
  10999. * supported by the hardware / browser.
  11000. *
  11001. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11002. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11003. * to API arguments needed to compressed textures. This puts the burden on the container
  11004. * generator to house the arcane code for determining these for current & future formats.
  11005. *
  11006. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11007. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11008. *
  11009. * Note: The result of this call is not taken into account when a texture is base64.
  11010. *
  11011. * @param formatsAvailable defines the list of those format families you have created
  11012. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11013. *
  11014. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11015. * @returns The extension selected.
  11016. */
  11017. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11018. private _getSamplingParameters;
  11019. private _partialLoadImg;
  11020. private _cascadeLoadImgs;
  11021. /** @hidden */
  11022. _createTexture(): WebGLTexture;
  11023. /**
  11024. * Usually called from BABYLON.Texture.ts.
  11025. * Passed information to create a WebGLTexture
  11026. * @param urlArg defines a value which contains one of the following:
  11027. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11028. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11029. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11030. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11031. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11032. * @param scene needed for loading to the correct scene
  11033. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11034. * @param onLoad optional callback to be called upon successful completion
  11035. * @param onError optional callback to be called upon failure
  11036. * @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
  11037. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11038. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11039. * @param forcedExtension defines the extension to use to pick the right loader
  11040. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11041. */
  11042. 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;
  11043. private _rescaleTexture;
  11044. /**
  11045. * Update a raw texture
  11046. * @param texture defines the texture to update
  11047. * @param data defines the data to store in the texture
  11048. * @param format defines the format of the data
  11049. * @param invertY defines if data must be stored with Y axis inverted
  11050. * @param compression defines the compression used (null by default)
  11051. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11052. */
  11053. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11054. /**
  11055. * Creates a raw texture
  11056. * @param data defines the data to store in the texture
  11057. * @param width defines the width of the texture
  11058. * @param height defines the height of the texture
  11059. * @param format defines the format of the data
  11060. * @param generateMipMaps defines if the engine should generate the mip levels
  11061. * @param invertY defines if data must be stored with Y axis inverted
  11062. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11063. * @param compression defines the compression used (null by default)
  11064. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11065. * @returns the raw texture inside an InternalTexture
  11066. */
  11067. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11068. private _unpackFlipYCached;
  11069. /**
  11070. * In case you are sharing the context with other applications, it might
  11071. * be interested to not cache the unpack flip y state to ensure a consistent
  11072. * value would be set.
  11073. */
  11074. enableUnpackFlipYCached: boolean;
  11075. /** @hidden */
  11076. _unpackFlipY(value: boolean): void;
  11077. /** @hidden */
  11078. _getUnpackAlignement(): number;
  11079. /**
  11080. * Creates a dynamic texture
  11081. * @param width defines the width of the texture
  11082. * @param height defines the height of the texture
  11083. * @param generateMipMaps defines if the engine should generate the mip levels
  11084. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11085. * @returns the dynamic texture inside an InternalTexture
  11086. */
  11087. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11088. /**
  11089. * Update the sampling mode of a given texture
  11090. * @param samplingMode defines the required sampling mode
  11091. * @param texture defines the texture to update
  11092. */
  11093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11094. /**
  11095. * Update the content of a dynamic texture
  11096. * @param texture defines the texture to update
  11097. * @param canvas defines the canvas containing the source
  11098. * @param invertY defines if data must be stored with Y axis inverted
  11099. * @param premulAlpha defines if alpha is stored as premultiplied
  11100. * @param format defines the format of the data
  11101. */
  11102. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11103. /**
  11104. * Update a video texture
  11105. * @param texture defines the texture to update
  11106. * @param video defines the video element to use
  11107. * @param invertY defines if data must be stored with Y axis inverted
  11108. */
  11109. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11110. /**
  11111. * Updates a depth texture Comparison Mode and Function.
  11112. * If the comparison Function is equal to 0, the mode will be set to none.
  11113. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11114. * @param texture The texture to set the comparison function for
  11115. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11116. */
  11117. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11118. private _setupDepthStencilTexture;
  11119. /**
  11120. * Creates a depth stencil texture.
  11121. * This is only available in WebGL 2 or with the depth texture extension available.
  11122. * @param size The size of face edge in the texture.
  11123. * @param options The options defining the texture.
  11124. * @returns The texture
  11125. */
  11126. createDepthStencilTexture(size: number | {
  11127. width: number;
  11128. height: number;
  11129. }, options: DepthTextureCreationOptions): InternalTexture;
  11130. /**
  11131. * Creates a depth stencil texture.
  11132. * This is only available in WebGL 2 or with the depth texture extension available.
  11133. * @param size The size of face edge in the texture.
  11134. * @param options The options defining the texture.
  11135. * @returns The texture
  11136. */
  11137. private _createDepthStencilTexture;
  11138. /**
  11139. * Creates a depth stencil cube texture.
  11140. * This is only available in WebGL 2.
  11141. * @param size The size of face edge in the cube texture.
  11142. * @param options The options defining the cube texture.
  11143. * @returns The cube texture
  11144. */
  11145. private _createDepthStencilCubeTexture;
  11146. /**
  11147. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11148. * @param renderTarget The render target to set the frame buffer for
  11149. */
  11150. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11151. /**
  11152. * Creates a new render target texture
  11153. * @param size defines the size of the texture
  11154. * @param options defines the options used to create the texture
  11155. * @returns a new render target texture stored in an InternalTexture
  11156. */
  11157. createRenderTargetTexture(size: number | {
  11158. width: number;
  11159. height: number;
  11160. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11161. /**
  11162. * Create a multi render target texture
  11163. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11164. * @param size defines the size of the texture
  11165. * @param options defines the creation options
  11166. * @returns the cube texture as an InternalTexture
  11167. */
  11168. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11169. private _setupFramebufferDepthAttachments;
  11170. /**
  11171. * Updates the sample count of a render target texture
  11172. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11173. * @param texture defines the texture to update
  11174. * @param samples defines the sample count to set
  11175. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11176. */
  11177. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11178. /**
  11179. * Update the sample count for a given multiple render target texture
  11180. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11181. * @param textures defines the textures to update
  11182. * @param samples defines the sample count to set
  11183. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11184. */
  11185. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11186. /** @hidden */
  11187. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11188. /** @hidden */
  11189. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11190. /** @hidden */
  11191. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11192. /** @hidden */
  11193. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11194. /**
  11195. * Creates a new render target cube texture
  11196. * @param size defines the size of the texture
  11197. * @param options defines the options used to create the texture
  11198. * @returns a new render target cube texture stored in an InternalTexture
  11199. */
  11200. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11201. /**
  11202. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11203. * @param rootUrl defines the url where the file to load is located
  11204. * @param scene defines the current scene
  11205. * @param lodScale defines scale to apply to the mip map selection
  11206. * @param lodOffset defines offset to apply to the mip map selection
  11207. * @param onLoad defines an optional callback raised when the texture is loaded
  11208. * @param onError defines an optional callback raised if there is an issue to load the texture
  11209. * @param format defines the format of the data
  11210. * @param forcedExtension defines the extension to use to pick the right loader
  11211. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11212. * @returns the cube texture as an InternalTexture
  11213. */
  11214. 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;
  11215. /**
  11216. * Creates a cube texture
  11217. * @param rootUrl defines the url where the files to load is located
  11218. * @param scene defines the current scene
  11219. * @param files defines the list of files to load (1 per face)
  11220. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11221. * @param onLoad defines an optional callback raised when the texture is loaded
  11222. * @param onError defines an optional callback raised if there is an issue to load the texture
  11223. * @param format defines the format of the data
  11224. * @param forcedExtension defines the extension to use to pick the right loader
  11225. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11226. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11227. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11228. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11229. * @returns the cube texture as an InternalTexture
  11230. */
  11231. 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;
  11232. /**
  11233. * @hidden
  11234. */
  11235. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11236. /**
  11237. * Update a raw cube texture
  11238. * @param texture defines the texture to udpdate
  11239. * @param data defines the data to store
  11240. * @param format defines the data format
  11241. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11242. * @param invertY defines if data must be stored with Y axis inverted
  11243. * @param compression defines the compression used (null by default)
  11244. * @param level defines which level of the texture to update
  11245. */
  11246. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11247. /**
  11248. * Creates a new raw cube texture
  11249. * @param data defines the array of data to use to create each face
  11250. * @param size defines the size of the textures
  11251. * @param format defines the format of the data
  11252. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11253. * @param generateMipMaps defines if the engine should generate the mip levels
  11254. * @param invertY defines if data must be stored with Y axis inverted
  11255. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11256. * @param compression defines the compression used (null by default)
  11257. * @returns the cube texture as an InternalTexture
  11258. */
  11259. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11260. /**
  11261. * Creates a new raw cube texture from a specified url
  11262. * @param url defines the url where the data is located
  11263. * @param scene defines the current scene
  11264. * @param size defines the size of the textures
  11265. * @param format defines the format of the data
  11266. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11267. * @param noMipmap defines if the engine should avoid generating the mip levels
  11268. * @param callback defines a callback used to extract texture data from loaded data
  11269. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11270. * @param onLoad defines a callback called when texture is loaded
  11271. * @param onError defines a callback called if there is an error
  11272. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11273. * @param invertY defines if data must be stored with Y axis inverted
  11274. * @returns the cube texture as an InternalTexture
  11275. */
  11276. 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;
  11277. /**
  11278. * Update a raw 3D texture
  11279. * @param texture defines the texture to update
  11280. * @param data defines the data to store
  11281. * @param format defines the data format
  11282. * @param invertY defines if data must be stored with Y axis inverted
  11283. * @param compression defines the used compression (can be null)
  11284. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11285. */
  11286. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11287. /**
  11288. * Creates a new raw 3D texture
  11289. * @param data defines the data used to create the texture
  11290. * @param width defines the width of the texture
  11291. * @param height defines the height of the texture
  11292. * @param depth defines the depth of the texture
  11293. * @param format defines the format of the texture
  11294. * @param generateMipMaps defines if the engine must generate mip levels
  11295. * @param invertY defines if data must be stored with Y axis inverted
  11296. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11297. * @param compression defines the compressed used (can be null)
  11298. * @param textureType defines the compressed used (can be null)
  11299. * @returns a new raw 3D texture (stored in an InternalTexture)
  11300. */
  11301. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11302. private _prepareWebGLTextureContinuation;
  11303. private _prepareWebGLTexture;
  11304. private _convertRGBtoRGBATextureData;
  11305. /** @hidden */
  11306. _releaseFramebufferObjects(texture: InternalTexture): void;
  11307. /** @hidden */
  11308. _releaseTexture(texture: InternalTexture): void;
  11309. private setProgram;
  11310. private _boundUniforms;
  11311. /**
  11312. * Binds an effect to the webGL context
  11313. * @param effect defines the effect to bind
  11314. */
  11315. bindSamplers(effect: Effect): void;
  11316. private _moveBoundTextureOnTop;
  11317. private _getCorrectTextureChannel;
  11318. private _linkTrackers;
  11319. private _removeDesignatedSlot;
  11320. private _activateCurrentTexture;
  11321. /** @hidden */
  11322. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11323. /** @hidden */
  11324. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11325. /**
  11326. * Sets a texture to the webGL context from a postprocess
  11327. * @param channel defines the channel to use
  11328. * @param postProcess defines the source postprocess
  11329. */
  11330. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11331. /**
  11332. * Binds the output of the passed in post process to the texture channel specified
  11333. * @param channel The channel the texture should be bound to
  11334. * @param postProcess The post process which's output should be bound
  11335. */
  11336. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11337. /**
  11338. * Unbind all textures from the webGL context
  11339. */
  11340. unbindAllTextures(): void;
  11341. /**
  11342. * Sets a texture to the according uniform.
  11343. * @param channel The texture channel
  11344. * @param uniform The uniform to set
  11345. * @param texture The texture to apply
  11346. */
  11347. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11348. /**
  11349. * Sets a depth stencil texture from a render target to the according uniform.
  11350. * @param channel The texture channel
  11351. * @param uniform The uniform to set
  11352. * @param texture The render target texture containing the depth stencil texture to apply
  11353. */
  11354. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11355. private _bindSamplerUniformToChannel;
  11356. private _getTextureWrapMode;
  11357. private _setTexture;
  11358. /**
  11359. * Sets an array of texture to the webGL context
  11360. * @param channel defines the channel where the texture array must be set
  11361. * @param uniform defines the associated uniform location
  11362. * @param textures defines the array of textures to bind
  11363. */
  11364. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11365. /** @hidden */
  11366. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11367. private _setTextureParameterFloat;
  11368. private _setTextureParameterInteger;
  11369. /**
  11370. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11371. * @param x defines the x coordinate of the rectangle where pixels must be read
  11372. * @param y defines the y coordinate of the rectangle where pixels must be read
  11373. * @param width defines the width of the rectangle where pixels must be read
  11374. * @param height defines the height of the rectangle where pixels must be read
  11375. * @returns a Uint8Array containing RGBA colors
  11376. */
  11377. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11378. /**
  11379. * Add an externaly attached data from its key.
  11380. * This method call will fail and return false, if such key already exists.
  11381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11382. * @param key the unique key that identifies the data
  11383. * @param data the data object to associate to the key for this Engine instance
  11384. * @return true if no such key were already present and the data was added successfully, false otherwise
  11385. */
  11386. addExternalData<T>(key: string, data: T): boolean;
  11387. /**
  11388. * Get an externaly attached data from its key
  11389. * @param key the unique key that identifies the data
  11390. * @return the associated data, if present (can be null), or undefined if not present
  11391. */
  11392. getExternalData<T>(key: string): T;
  11393. /**
  11394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11395. * @param key the unique key that identifies the data
  11396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11397. * @return the associated data, can be null if the factory returned null.
  11398. */
  11399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11400. /**
  11401. * Remove an externaly attached data from the Engine instance
  11402. * @param key the unique key that identifies the data
  11403. * @return true if the data was successfully removed, false if it doesn't exist
  11404. */
  11405. removeExternalData(key: string): boolean;
  11406. /**
  11407. * Unbind all vertex attributes from the webGL context
  11408. */
  11409. unbindAllAttributes(): void;
  11410. /**
  11411. * 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
  11412. */
  11413. releaseEffects(): void;
  11414. /**
  11415. * Dispose and release all associated resources
  11416. */
  11417. dispose(): void;
  11418. /**
  11419. * Display the loading screen
  11420. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11421. */
  11422. displayLoadingUI(): void;
  11423. /**
  11424. * Hide the loading screen
  11425. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11426. */
  11427. hideLoadingUI(): void;
  11428. /**
  11429. * Gets the current loading screen object
  11430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11431. */
  11432. /**
  11433. * Sets the current loading screen object
  11434. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11435. */
  11436. loadingScreen: ILoadingScreen;
  11437. /**
  11438. * Sets the current loading screen text
  11439. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11440. */
  11441. loadingUIText: string;
  11442. /**
  11443. * Sets the current loading screen background color
  11444. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11445. */
  11446. loadingUIBackgroundColor: string;
  11447. /**
  11448. * Attach a new callback raised when context lost event is fired
  11449. * @param callback defines the callback to call
  11450. */
  11451. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11452. /**
  11453. * Attach a new callback raised when context restored event is fired
  11454. * @param callback defines the callback to call
  11455. */
  11456. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11457. /**
  11458. * Gets the source code of the vertex shader associated with a specific webGL program
  11459. * @param program defines the program to use
  11460. * @returns a string containing the source code of the vertex shader associated with the program
  11461. */
  11462. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11463. /**
  11464. * Gets the source code of the fragment shader associated with a specific webGL program
  11465. * @param program defines the program to use
  11466. * @returns a string containing the source code of the fragment shader associated with the program
  11467. */
  11468. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11469. /**
  11470. * Get the current error code of the webGL context
  11471. * @returns the error code
  11472. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11473. */
  11474. getError(): number;
  11475. /**
  11476. * Gets the current framerate
  11477. * @returns a number representing the framerate
  11478. */
  11479. getFps(): number;
  11480. /**
  11481. * Gets the time spent between current and previous frame
  11482. * @returns a number representing the delta time in ms
  11483. */
  11484. getDeltaTime(): number;
  11485. private _measureFps;
  11486. /** @hidden */
  11487. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11488. private _canRenderToFloatFramebuffer;
  11489. private _canRenderToHalfFloatFramebuffer;
  11490. private _canRenderToFramebuffer;
  11491. /** @hidden */
  11492. _getWebGLTextureType(type: number): number;
  11493. private _getInternalFormat;
  11494. /** @hidden */
  11495. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11496. /** @hidden */
  11497. _getRGBAMultiSampleBufferFormat(type: number): number;
  11498. /** @hidden */
  11499. _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;
  11500. /** @hidden */
  11501. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11502. private _partialLoadFile;
  11503. private _cascadeLoadFiles;
  11504. /**
  11505. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11506. * @returns true if the engine can be created
  11507. * @ignorenaming
  11508. */
  11509. static isSupported(): boolean;
  11510. }
  11511. }
  11512. declare module BABYLON {
  11513. /**
  11514. * Options to create the null engine
  11515. */
  11516. class NullEngineOptions {
  11517. /**
  11518. * Render width (Default: 512)
  11519. */
  11520. renderWidth: number;
  11521. /**
  11522. * Render height (Default: 256)
  11523. */
  11524. renderHeight: number;
  11525. /**
  11526. * Texture size (Default: 512)
  11527. */
  11528. textureSize: number;
  11529. /**
  11530. * If delta time between frames should be constant
  11531. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11532. */
  11533. deterministicLockstep: boolean;
  11534. /**
  11535. * Maximum about of steps between frames (Default: 4)
  11536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11537. */
  11538. lockstepMaxSteps: number;
  11539. }
  11540. /**
  11541. * The null engine class provides support for headless version of babylon.js.
  11542. * This can be used in server side scenario or for testing purposes
  11543. */
  11544. class NullEngine extends Engine {
  11545. private _options;
  11546. /**
  11547. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11548. */
  11549. isDeterministicLockStep(): boolean;
  11550. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11551. getLockstepMaxSteps(): number;
  11552. /**
  11553. * Sets hardware scaling, used to save performance if needed
  11554. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11555. */
  11556. getHardwareScalingLevel(): number;
  11557. constructor(options?: NullEngineOptions);
  11558. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11559. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11560. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11561. getRenderWidth(useScreen?: boolean): number;
  11562. getRenderHeight(useScreen?: boolean): number;
  11563. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11564. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11565. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11566. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11567. bindSamplers(effect: Effect): void;
  11568. enableEffect(effect: Effect): void;
  11569. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11570. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11571. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11572. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11573. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11574. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11575. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11576. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11577. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11578. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11579. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11580. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11581. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11582. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11583. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11584. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11585. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11586. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11587. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11588. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11589. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11590. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11591. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11592. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11593. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11594. bindBuffers(vertexBuffers: {
  11595. [key: string]: VertexBuffer;
  11596. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11597. wipeCaches(bruteForce?: boolean): void;
  11598. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11599. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11600. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11601. /** @hidden */
  11602. _createTexture(): WebGLTexture;
  11603. /** @hidden */
  11604. _releaseTexture(texture: InternalTexture): void;
  11605. 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;
  11606. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11607. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11608. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11609. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11610. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11611. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11612. areAllEffectsReady(): boolean;
  11613. /**
  11614. * @hidden
  11615. * Get the current error code of the webGL context
  11616. * @returns the error code
  11617. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11618. */
  11619. getError(): number;
  11620. /** @hidden */
  11621. _getUnpackAlignement(): number;
  11622. /** @hidden */
  11623. _unpackFlipY(value: boolean): void;
  11624. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11625. /**
  11626. * Updates a dynamic vertex buffer.
  11627. * @param vertexBuffer the vertex buffer to update
  11628. * @param data the data used to update the vertex buffer
  11629. * @param byteOffset the byte offset of the data (optional)
  11630. * @param byteLength the byte length of the data (optional)
  11631. */
  11632. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11633. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11634. /** @hidden */
  11635. _bindTexture(channel: number, texture: InternalTexture): void;
  11636. /** @hidden */
  11637. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11638. releaseEffects(): void;
  11639. displayLoadingUI(): void;
  11640. hideLoadingUI(): void;
  11641. /** @hidden */
  11642. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11643. /** @hidden */
  11644. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11645. /** @hidden */
  11646. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11647. /** @hidden */
  11648. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11649. }
  11650. }
  11651. interface WebGLRenderingContext {
  11652. readonly RASTERIZER_DISCARD: number;
  11653. readonly DEPTH_COMPONENT24: number;
  11654. readonly TEXTURE_3D: number;
  11655. readonly TEXTURE_2D_ARRAY: number;
  11656. readonly TEXTURE_COMPARE_FUNC: number;
  11657. readonly TEXTURE_COMPARE_MODE: number;
  11658. readonly COMPARE_REF_TO_TEXTURE: number;
  11659. readonly TEXTURE_WRAP_R: number;
  11660. readonly HALF_FLOAT: number;
  11661. readonly RGB8: number;
  11662. readonly RED_INTEGER: number;
  11663. readonly RG_INTEGER: number;
  11664. readonly RGB_INTEGER: number;
  11665. readonly RGBA_INTEGER: number;
  11666. readonly R8_SNORM: number;
  11667. readonly RG8_SNORM: number;
  11668. readonly RGB8_SNORM: number;
  11669. readonly RGBA8_SNORM: number;
  11670. readonly R8I: number;
  11671. readonly RG8I: number;
  11672. readonly RGB8I: number;
  11673. readonly RGBA8I: number;
  11674. readonly R8UI: number;
  11675. readonly RG8UI: number;
  11676. readonly RGB8UI: number;
  11677. readonly RGBA8UI: number;
  11678. readonly R16I: number;
  11679. readonly RG16I: number;
  11680. readonly RGB16I: number;
  11681. readonly RGBA16I: number;
  11682. readonly R16UI: number;
  11683. readonly RG16UI: number;
  11684. readonly RGB16UI: number;
  11685. readonly RGBA16UI: number;
  11686. readonly R32I: number;
  11687. readonly RG32I: number;
  11688. readonly RGB32I: number;
  11689. readonly RGBA32I: number;
  11690. readonly R32UI: number;
  11691. readonly RG32UI: number;
  11692. readonly RGB32UI: number;
  11693. readonly RGBA32UI: number;
  11694. readonly RGB10_A2UI: number;
  11695. readonly R11F_G11F_B10F: number;
  11696. readonly RGB9_E5: number;
  11697. readonly RGB10_A2: number;
  11698. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  11699. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  11700. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  11701. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  11702. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  11703. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  11704. 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;
  11705. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  11706. readonly TRANSFORM_FEEDBACK: number;
  11707. readonly INTERLEAVED_ATTRIBS: number;
  11708. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  11709. createTransformFeedback(): WebGLTransformFeedback;
  11710. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  11711. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  11712. beginTransformFeedback(primitiveMode: number): void;
  11713. endTransformFeedback(): void;
  11714. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  11715. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11716. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11717. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  11718. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  11719. }
  11720. interface ImageBitmap {
  11721. readonly width: number;
  11722. readonly height: number;
  11723. close(): void;
  11724. }
  11725. interface WebGLQuery extends WebGLObject {
  11726. }
  11727. declare var WebGLQuery: {
  11728. prototype: WebGLQuery;
  11729. new (): WebGLQuery;
  11730. };
  11731. interface WebGLSampler extends WebGLObject {
  11732. }
  11733. declare var WebGLSampler: {
  11734. prototype: WebGLSampler;
  11735. new (): WebGLSampler;
  11736. };
  11737. interface WebGLSync extends WebGLObject {
  11738. }
  11739. declare var WebGLSync: {
  11740. prototype: WebGLSync;
  11741. new (): WebGLSync;
  11742. };
  11743. interface WebGLTransformFeedback extends WebGLObject {
  11744. }
  11745. declare var WebGLTransformFeedback: {
  11746. prototype: WebGLTransformFeedback;
  11747. new (): WebGLTransformFeedback;
  11748. };
  11749. interface WebGLVertexArrayObject extends WebGLObject {
  11750. }
  11751. declare var WebGLVertexArrayObject: {
  11752. prototype: WebGLVertexArrayObject;
  11753. new (): WebGLVertexArrayObject;
  11754. };
  11755. /**
  11756. * Module Debug contains the (visual) components to debug a scene correctly
  11757. */
  11758. declare module BABYLON.Debug {
  11759. /**
  11760. * The Axes viewer will show 3 axes in a specific point in space
  11761. */
  11762. class AxesViewer {
  11763. private _xline;
  11764. private _yline;
  11765. private _zline;
  11766. private _xmesh;
  11767. private _ymesh;
  11768. private _zmesh;
  11769. /**
  11770. * Gets the hosting scene
  11771. */
  11772. scene: Nullable<Scene>;
  11773. /**
  11774. * Gets or sets a number used to scale line length
  11775. */
  11776. scaleLines: number;
  11777. /**
  11778. * Creates a new AxesViewer
  11779. * @param scene defines the hosting scene
  11780. * @param scaleLines defines a number used to scale line length (1 by default)
  11781. */
  11782. constructor(scene: Scene, scaleLines?: number);
  11783. /**
  11784. * Force the viewer to update
  11785. * @param position defines the position of the viewer
  11786. * @param xaxis defines the x axis of the viewer
  11787. * @param yaxis defines the y axis of the viewer
  11788. * @param zaxis defines the z axis of the viewer
  11789. */
  11790. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  11791. /** Releases resources */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module BABYLON.Debug {
  11796. /**
  11797. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  11798. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  11799. */
  11800. class BoneAxesViewer extends AxesViewer {
  11801. /**
  11802. * Gets or sets the target mesh where to display the axes viewer
  11803. */
  11804. mesh: Nullable<Mesh>;
  11805. /**
  11806. * Gets or sets the target bone where to display the axes viewer
  11807. */
  11808. bone: Nullable<Bone>;
  11809. /** Gets current position */
  11810. pos: Vector3;
  11811. /** Gets direction of X axis */
  11812. xaxis: Vector3;
  11813. /** Gets direction of Y axis */
  11814. yaxis: Vector3;
  11815. /** Gets direction of Z axis */
  11816. zaxis: Vector3;
  11817. /**
  11818. * Creates a new BoneAxesViewer
  11819. * @param scene defines the hosting scene
  11820. * @param bone defines the target bone
  11821. * @param mesh defines the target mesh
  11822. * @param scaleLines defines a scaling factor for line length (1 by default)
  11823. */
  11824. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  11825. /**
  11826. * Force the viewer to update
  11827. */
  11828. update(): void;
  11829. /** Releases resources */
  11830. dispose(): void;
  11831. }
  11832. }
  11833. declare module BABYLON {
  11834. interface Scene {
  11835. /**
  11836. * @hidden
  11837. * Backing field
  11838. */
  11839. _debugLayer: DebugLayer;
  11840. /**
  11841. * Gets the debug layer (aka Inspector) associated with the scene
  11842. * @see http://doc.babylonjs.com/features/playground_debuglayer
  11843. */
  11844. debugLayer: DebugLayer;
  11845. }
  11846. /**
  11847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  11848. * what is happening in your scene
  11849. * @see http://doc.babylonjs.com/features/playground_debuglayer
  11850. */
  11851. class DebugLayer {
  11852. /**
  11853. * Define the url to get the inspector script from.
  11854. * By default it uses the babylonjs CDN.
  11855. * @ignoreNaming
  11856. */
  11857. static InspectorURL: string;
  11858. private _scene;
  11859. private _inspector;
  11860. private BJSINSPECTOR;
  11861. /**
  11862. * Observable triggered when a property is changed through the inspector.
  11863. */
  11864. onPropertyChangedObservable: Observable<{
  11865. object: any;
  11866. property: string;
  11867. value: any;
  11868. initialValue: any;
  11869. }>;
  11870. /**
  11871. * Instantiates a new debug layer.
  11872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  11873. * what is happening in your scene
  11874. * @see http://doc.babylonjs.com/features/playground_debuglayer
  11875. * @param scene Defines the scene to inspect
  11876. */
  11877. constructor(scene: Scene);
  11878. /** Creates the inspector window. */
  11879. private _createInspector;
  11880. /**
  11881. * Get if the inspector is visible or not.
  11882. * @returns true if visible otherwise, false
  11883. */
  11884. isVisible(): boolean;
  11885. /**
  11886. * Hide the inspector and close its window.
  11887. */
  11888. hide(): void;
  11889. /**
  11890. *
  11891. * Launch the debugLayer.
  11892. *
  11893. * initialTab:
  11894. * | Value | Tab Name |
  11895. * | --- | --- |
  11896. * | 0 | Scene |
  11897. * | 1 | Console |
  11898. * | 2 | Stats |
  11899. * | 3 | Textures |
  11900. * | 4 | Mesh |
  11901. * | 5 | Light |
  11902. * | 6 | Material |
  11903. * | 7 | GLTF |
  11904. * | 8 | GUI |
  11905. * | 9 | Physics |
  11906. * | 10 | Camera |
  11907. * | 11 | Audio |
  11908. *
  11909. * @param config Define the configuration of the inspector
  11910. */
  11911. show(config?: {
  11912. popup?: boolean;
  11913. initialTab?: number | string;
  11914. parentElement?: HTMLElement;
  11915. newColors?: {
  11916. backgroundColor?: string;
  11917. backgroundColorLighter?: string;
  11918. backgroundColorLighter2?: string;
  11919. backgroundColorLighter3?: string;
  11920. color?: string;
  11921. colorTop?: string;
  11922. colorBot?: string;
  11923. };
  11924. }): void;
  11925. /**
  11926. * Gets the active tab
  11927. * @return the index of the active tab or -1 if the inspector is hidden
  11928. */
  11929. getActiveTab(): number;
  11930. }
  11931. }
  11932. declare module BABYLON.Debug {
  11933. /**
  11934. * Used to show the physics impostor around the specific mesh
  11935. */
  11936. class PhysicsViewer {
  11937. /** @hidden */
  11938. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  11939. /** @hidden */
  11940. protected _meshes: Array<Nullable<AbstractMesh>>;
  11941. /** @hidden */
  11942. protected _scene: Nullable<Scene>;
  11943. /** @hidden */
  11944. protected _numMeshes: number;
  11945. /** @hidden */
  11946. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  11947. private _renderFunction;
  11948. private _debugBoxMesh;
  11949. private _debugSphereMesh;
  11950. private _debugMaterial;
  11951. /**
  11952. * Creates a new PhysicsViewer
  11953. * @param scene defines the hosting scene
  11954. */
  11955. constructor(scene: Scene);
  11956. /** @hidden */
  11957. protected _updateDebugMeshes(): void;
  11958. /**
  11959. * Renders a specified physic impostor
  11960. * @param impostor defines the impostor to render
  11961. */
  11962. showImpostor(impostor: PhysicsImpostor): void;
  11963. /**
  11964. * Hides a specified physic impostor
  11965. * @param impostor defines the impostor to hide
  11966. */
  11967. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  11968. private _getDebugMaterial;
  11969. private _getDebugBoxMesh;
  11970. private _getDebugSphereMesh;
  11971. private _getDebugMesh;
  11972. /** Releases all resources */
  11973. dispose(): void;
  11974. }
  11975. }
  11976. declare module BABYLON {
  11977. /**
  11978. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  11979. * in order to better appreciate the issue one might have.
  11980. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  11981. */
  11982. class RayHelper {
  11983. /**
  11984. * Defines the ray we are currently tryin to visualize.
  11985. */
  11986. ray: Nullable<Ray>;
  11987. private _renderPoints;
  11988. private _renderLine;
  11989. private _renderFunction;
  11990. private _scene;
  11991. private _updateToMeshFunction;
  11992. private _attachedToMesh;
  11993. private _meshSpaceDirection;
  11994. private _meshSpaceOrigin;
  11995. /**
  11996. * Helper function to create a colored helper in a scene in one line.
  11997. * @param ray Defines the ray we are currently tryin to visualize
  11998. * @param scene Defines the scene the ray is used in
  11999. * @param color Defines the color we want to see the ray in
  12000. * @returns The newly created ray helper.
  12001. */
  12002. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  12003. /**
  12004. * Instantiate a new ray helper.
  12005. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  12006. * in order to better appreciate the issue one might have.
  12007. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  12008. * @param ray Defines the ray we are currently tryin to visualize
  12009. */
  12010. constructor(ray: Ray);
  12011. /**
  12012. * Shows the ray we are willing to debug.
  12013. * @param scene Defines the scene the ray needs to be rendered in
  12014. * @param color Defines the color the ray needs to be rendered in
  12015. */
  12016. show(scene: Scene, color?: Color3): void;
  12017. /**
  12018. * Hides the ray we are debugging.
  12019. */
  12020. hide(): void;
  12021. private _render;
  12022. /**
  12023. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  12024. * @param mesh Defines the mesh we want the helper attached to
  12025. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  12026. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  12027. * @param length Defines the length of the ray
  12028. */
  12029. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  12030. /**
  12031. * Detach the ray helper from the mesh it has previously been attached to.
  12032. */
  12033. detachFromMesh(): void;
  12034. private _updateToMesh;
  12035. /**
  12036. * Dispose the helper and release its associated resources.
  12037. */
  12038. dispose(): void;
  12039. }
  12040. }
  12041. declare module BABYLON.Debug {
  12042. /**
  12043. * Class used to render a debug view of a given skeleton
  12044. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  12045. */
  12046. class SkeletonViewer {
  12047. /** defines the skeleton to render */
  12048. skeleton: Skeleton;
  12049. /** defines the mesh attached to the skeleton */
  12050. mesh: AbstractMesh;
  12051. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  12052. autoUpdateBonesMatrices: boolean;
  12053. /** defines the rendering group id to use with the viewer */
  12054. renderingGroupId: number;
  12055. /** Gets or sets the color used to render the skeleton */
  12056. color: Color3;
  12057. private _scene;
  12058. private _debugLines;
  12059. private _debugMesh;
  12060. private _isEnabled;
  12061. private _renderFunction;
  12062. /**
  12063. * Creates a new SkeletonViewer
  12064. * @param skeleton defines the skeleton to render
  12065. * @param mesh defines the mesh attached to the skeleton
  12066. * @param scene defines the hosting scene
  12067. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  12068. * @param renderingGroupId defines the rendering group id to use with the viewer
  12069. */
  12070. constructor(
  12071. /** defines the skeleton to render */
  12072. skeleton: Skeleton,
  12073. /** defines the mesh attached to the skeleton */
  12074. mesh: AbstractMesh, scene: Scene,
  12075. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  12076. autoUpdateBonesMatrices?: boolean,
  12077. /** defines the rendering group id to use with the viewer */
  12078. renderingGroupId?: number);
  12079. /** Gets or sets a boolean indicating if the viewer is enabled */
  12080. isEnabled: boolean;
  12081. private _getBonePosition;
  12082. private _getLinesForBonesWithLength;
  12083. private _getLinesForBonesNoLength;
  12084. /** Update the viewer to sync with current skeleton state */
  12085. update(): void;
  12086. /** Release associated resources */
  12087. dispose(): void;
  12088. }
  12089. }
  12090. declare module BABYLON {
  12091. /**
  12092. * Gather the list of keyboard event types as constants.
  12093. */
  12094. class KeyboardEventTypes {
  12095. /**
  12096. * The keydown event is fired when a key becomes active (pressed).
  12097. */
  12098. static readonly KEYDOWN: number;
  12099. /**
  12100. * The keyup event is fired when a key has been released.
  12101. */
  12102. static readonly KEYUP: number;
  12103. }
  12104. /**
  12105. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12106. */
  12107. class KeyboardInfo {
  12108. /**
  12109. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12110. */
  12111. type: number;
  12112. /**
  12113. * Defines the related dom event
  12114. */
  12115. event: KeyboardEvent;
  12116. /**
  12117. * Instantiates a new keyboard info.
  12118. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12119. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12120. * @param event Defines the related dom event
  12121. */
  12122. constructor(
  12123. /**
  12124. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12125. */
  12126. type: number,
  12127. /**
  12128. * Defines the related dom event
  12129. */
  12130. event: KeyboardEvent);
  12131. }
  12132. /**
  12133. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12134. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12135. */
  12136. class KeyboardInfoPre extends KeyboardInfo {
  12137. /**
  12138. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12139. */
  12140. type: number;
  12141. /**
  12142. * Defines the related dom event
  12143. */
  12144. event: KeyboardEvent;
  12145. /**
  12146. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12147. */
  12148. skipOnPointerObservable: boolean;
  12149. /**
  12150. * Instantiates a new keyboard pre info.
  12151. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12152. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12153. * @param event Defines the related dom event
  12154. */
  12155. constructor(
  12156. /**
  12157. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12158. */
  12159. type: number,
  12160. /**
  12161. * Defines the related dom event
  12162. */
  12163. event: KeyboardEvent);
  12164. }
  12165. }
  12166. declare module BABYLON {
  12167. /**
  12168. * Gather the list of pointer event types as constants.
  12169. */
  12170. class PointerEventTypes {
  12171. /**
  12172. * 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.
  12173. */
  12174. static readonly POINTERDOWN: number;
  12175. /**
  12176. * The pointerup event is fired when a pointer is no longer active.
  12177. */
  12178. static readonly POINTERUP: number;
  12179. /**
  12180. * The pointermove event is fired when a pointer changes coordinates.
  12181. */
  12182. static readonly POINTERMOVE: number;
  12183. /**
  12184. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12185. */
  12186. static readonly POINTERWHEEL: number;
  12187. /**
  12188. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12189. */
  12190. static readonly POINTERPICK: number;
  12191. /**
  12192. * The pointertap event is fired when a the object has been touched and released without drag.
  12193. */
  12194. static readonly POINTERTAP: number;
  12195. /**
  12196. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12197. */
  12198. static readonly POINTERDOUBLETAP: number;
  12199. }
  12200. /**
  12201. * Base class of pointer info types.
  12202. */
  12203. class PointerInfoBase {
  12204. /**
  12205. * Defines the type of event (BABYLON.PointerEventTypes)
  12206. */
  12207. type: number;
  12208. /**
  12209. * Defines the related dom event
  12210. */
  12211. event: PointerEvent | MouseWheelEvent;
  12212. /**
  12213. * Instantiates the base class of pointers info.
  12214. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12215. * @param event Defines the related dom event
  12216. */
  12217. constructor(
  12218. /**
  12219. * Defines the type of event (BABYLON.PointerEventTypes)
  12220. */
  12221. type: number,
  12222. /**
  12223. * Defines the related dom event
  12224. */
  12225. event: PointerEvent | MouseWheelEvent);
  12226. }
  12227. /**
  12228. * This class is used to store pointer related info for the onPrePointerObservable event.
  12229. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12230. */
  12231. class PointerInfoPre extends PointerInfoBase {
  12232. /**
  12233. * Ray from a pointer if availible (eg. 6dof controller)
  12234. */
  12235. ray: Nullable<Ray>;
  12236. /**
  12237. * Defines the local position of the pointer on the canvas.
  12238. */
  12239. localPosition: Vector2;
  12240. /**
  12241. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12242. */
  12243. skipOnPointerObservable: boolean;
  12244. /**
  12245. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12246. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12247. * @param event Defines the related dom event
  12248. * @param localX Defines the local x coordinates of the pointer when the event occured
  12249. * @param localY Defines the local y coordinates of the pointer when the event occured
  12250. */
  12251. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12252. }
  12253. /**
  12254. * This type contains all the data related to a pointer event in Babylon.js.
  12255. * 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.
  12256. */
  12257. class PointerInfo extends PointerInfoBase {
  12258. /**
  12259. * Defines the picking info associated to the info (if any)\
  12260. */
  12261. pickInfo: Nullable<PickingInfo>;
  12262. /**
  12263. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12264. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12265. * @param event Defines the related dom event
  12266. * @param pickInfo Defines the picking info associated to the info (if any)\
  12267. */
  12268. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12269. /**
  12270. * Defines the picking info associated to the info (if any)\
  12271. */
  12272. pickInfo: Nullable<PickingInfo>);
  12273. }
  12274. }
  12275. declare module BABYLON {
  12276. /**
  12277. * Represents a gamepad control stick position
  12278. */
  12279. class StickValues {
  12280. /**
  12281. * The x component of the control stick
  12282. */
  12283. x: number;
  12284. /**
  12285. * The y component of the control stick
  12286. */
  12287. y: number;
  12288. /**
  12289. * Initializes the gamepad x and y control stick values
  12290. * @param x The x component of the gamepad control stick value
  12291. * @param y The y component of the gamepad control stick value
  12292. */
  12293. constructor(
  12294. /**
  12295. * The x component of the control stick
  12296. */
  12297. x: number,
  12298. /**
  12299. * The y component of the control stick
  12300. */
  12301. y: number);
  12302. }
  12303. /**
  12304. * An interface which manages callbacks for gamepad button changes
  12305. */
  12306. interface GamepadButtonChanges {
  12307. /**
  12308. * Called when a gamepad has been changed
  12309. */
  12310. changed: boolean;
  12311. /**
  12312. * Called when a gamepad press event has been triggered
  12313. */
  12314. pressChanged: boolean;
  12315. /**
  12316. * Called when a touch event has been triggered
  12317. */
  12318. touchChanged: boolean;
  12319. /**
  12320. * Called when a value has changed
  12321. */
  12322. valueChanged: boolean;
  12323. }
  12324. /**
  12325. * Represents a gamepad
  12326. */
  12327. class Gamepad {
  12328. /**
  12329. * The id of the gamepad
  12330. */
  12331. id: string;
  12332. /**
  12333. * The index of the gamepad
  12334. */
  12335. index: number;
  12336. /**
  12337. * The browser gamepad
  12338. */
  12339. browserGamepad: any;
  12340. /**
  12341. * Specifies what type of gamepad this represents
  12342. */
  12343. type: number;
  12344. private _leftStick;
  12345. private _rightStick;
  12346. /** @hidden */
  12347. _isConnected: boolean;
  12348. private _leftStickAxisX;
  12349. private _leftStickAxisY;
  12350. private _rightStickAxisX;
  12351. private _rightStickAxisY;
  12352. /**
  12353. * Triggered when the left control stick has been changed
  12354. */
  12355. private _onleftstickchanged;
  12356. /**
  12357. * Triggered when the right control stick has been changed
  12358. */
  12359. private _onrightstickchanged;
  12360. /**
  12361. * Represents a gamepad controller
  12362. */
  12363. static GAMEPAD: number;
  12364. /**
  12365. * Represents a generic controller
  12366. */
  12367. static GENERIC: number;
  12368. /**
  12369. * Represents an XBox controller
  12370. */
  12371. static XBOX: number;
  12372. /**
  12373. * Represents a pose-enabled controller
  12374. */
  12375. static POSE_ENABLED: number;
  12376. /**
  12377. * Specifies whether the left control stick should be Y-inverted
  12378. */
  12379. protected _invertLeftStickY: boolean;
  12380. /**
  12381. * Specifies if the gamepad has been connected
  12382. */
  12383. readonly isConnected: boolean;
  12384. /**
  12385. * Initializes the gamepad
  12386. * @param id The id of the gamepad
  12387. * @param index The index of the gamepad
  12388. * @param browserGamepad The browser gamepad
  12389. * @param leftStickX The x component of the left joystick
  12390. * @param leftStickY The y component of the left joystick
  12391. * @param rightStickX The x component of the right joystick
  12392. * @param rightStickY The y component of the right joystick
  12393. */
  12394. constructor(
  12395. /**
  12396. * The id of the gamepad
  12397. */
  12398. id: string,
  12399. /**
  12400. * The index of the gamepad
  12401. */
  12402. index: number,
  12403. /**
  12404. * The browser gamepad
  12405. */
  12406. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12407. /**
  12408. * Callback triggered when the left joystick has changed
  12409. * @param callback
  12410. */
  12411. onleftstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Callback triggered when the right joystick has changed
  12414. * @param callback
  12415. */
  12416. onrightstickchanged(callback: (values: StickValues) => void): void;
  12417. /**
  12418. * Gets the left joystick
  12419. */
  12420. /**
  12421. * Sets the left joystick values
  12422. */
  12423. leftStick: StickValues;
  12424. /**
  12425. * Gets the right joystick
  12426. */
  12427. /**
  12428. * Sets the right joystick value
  12429. */
  12430. rightStick: StickValues;
  12431. /**
  12432. * Updates the gamepad joystick positions
  12433. */
  12434. update(): void;
  12435. /**
  12436. * Disposes the gamepad
  12437. */
  12438. dispose(): void;
  12439. }
  12440. /**
  12441. * Represents a generic gamepad
  12442. */
  12443. class GenericPad extends Gamepad {
  12444. private _buttons;
  12445. private _onbuttondown;
  12446. private _onbuttonup;
  12447. /**
  12448. * Observable triggered when a button has been pressed
  12449. */
  12450. onButtonDownObservable: Observable<number>;
  12451. /**
  12452. * Observable triggered when a button has been released
  12453. */
  12454. onButtonUpObservable: Observable<number>;
  12455. /**
  12456. * Callback triggered when a button has been pressed
  12457. * @param callback Called when a button has been pressed
  12458. */
  12459. onbuttondown(callback: (buttonPressed: number) => void): void;
  12460. /**
  12461. * Callback triggered when a button has been released
  12462. * @param callback Called when a button has been released
  12463. */
  12464. onbuttonup(callback: (buttonReleased: number) => void): void;
  12465. /**
  12466. * Initializes the generic gamepad
  12467. * @param id The id of the generic gamepad
  12468. * @param index The index of the generic gamepad
  12469. * @param browserGamepad The browser gamepad
  12470. */
  12471. constructor(id: string, index: number, browserGamepad: any);
  12472. private _setButtonValue;
  12473. /**
  12474. * Updates the generic gamepad
  12475. */
  12476. update(): void;
  12477. /**
  12478. * Disposes the generic gamepad
  12479. */
  12480. dispose(): void;
  12481. }
  12482. }
  12483. declare module BABYLON {
  12484. /**
  12485. * Manager for handling gamepads
  12486. */
  12487. class GamepadManager {
  12488. private _scene?;
  12489. private _babylonGamepads;
  12490. private _oneGamepadConnected;
  12491. /** @hidden */
  12492. _isMonitoring: boolean;
  12493. private _gamepadEventSupported;
  12494. private _gamepadSupport;
  12495. /**
  12496. * observable to be triggered when the gamepad controller has been connected
  12497. */
  12498. onGamepadConnectedObservable: Observable<Gamepad>;
  12499. /**
  12500. * observable to be triggered when the gamepad controller has been disconnected
  12501. */
  12502. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12503. private _onGamepadConnectedEvent;
  12504. private _onGamepadDisconnectedEvent;
  12505. /**
  12506. * Initializes the gamepad manager
  12507. * @param _scene BabylonJS scene
  12508. */
  12509. constructor(_scene?: Scene | undefined);
  12510. /**
  12511. * The gamepads in the game pad manager
  12512. */
  12513. readonly gamepads: Gamepad[];
  12514. /**
  12515. * Get the gamepad controllers based on type
  12516. * @param type The type of gamepad controller
  12517. * @returns Nullable gamepad
  12518. */
  12519. getGamepadByType(type?: number): Nullable<Gamepad>;
  12520. /**
  12521. * Disposes the gamepad manager
  12522. */
  12523. dispose(): void;
  12524. private _addNewGamepad;
  12525. private _startMonitoringGamepads;
  12526. private _stopMonitoringGamepads;
  12527. /** @hidden */
  12528. _checkGamepadsStatus(): void;
  12529. private _updateGamepadObjects;
  12530. }
  12531. }
  12532. declare module BABYLON {
  12533. interface Scene {
  12534. /** @hidden */
  12535. _gamepadManager: Nullable<GamepadManager>;
  12536. /**
  12537. * Gets the gamepad manager associated with the scene
  12538. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12539. */
  12540. gamepadManager: GamepadManager;
  12541. }
  12542. /**
  12543. * Interface representing a free camera inputs manager
  12544. */
  12545. interface FreeCameraInputsManager {
  12546. /**
  12547. * Adds gamepad input support to the FreeCameraInputsManager.
  12548. * @returns the FreeCameraInputsManager
  12549. */
  12550. addGamepad(): FreeCameraInputsManager;
  12551. }
  12552. /**
  12553. * Interface representing an arc rotate camera inputs manager
  12554. */
  12555. interface ArcRotateCameraInputsManager {
  12556. /**
  12557. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12558. * @returns the camera inputs manager
  12559. */
  12560. addGamepad(): ArcRotateCameraInputsManager;
  12561. }
  12562. /**
  12563. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12564. */
  12565. class GamepadSystemSceneComponent implements ISceneComponent {
  12566. /**
  12567. * The component name helpfull to identify the component in the list of scene components.
  12568. */
  12569. readonly name: string;
  12570. /**
  12571. * The scene the component belongs to.
  12572. */
  12573. scene: Scene;
  12574. /**
  12575. * Creates a new instance of the component for the given scene
  12576. * @param scene Defines the scene to register the component in
  12577. */
  12578. constructor(scene: Scene);
  12579. /**
  12580. * Registers the component in a given scene
  12581. */
  12582. register(): void;
  12583. /**
  12584. * Rebuilds the elements related to this component in case of
  12585. * context lost for instance.
  12586. */
  12587. rebuild(): void;
  12588. /**
  12589. * Disposes the component and the associated ressources
  12590. */
  12591. dispose(): void;
  12592. private _beforeCameraUpdate;
  12593. }
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Defines supported buttons for XBox360 compatible gamepads
  12598. */
  12599. enum Xbox360Button {
  12600. /** A */
  12601. A = 0,
  12602. /** B */
  12603. B = 1,
  12604. /** X */
  12605. X = 2,
  12606. /** Y */
  12607. Y = 3,
  12608. /** Start */
  12609. Start = 4,
  12610. /** Back */
  12611. Back = 5,
  12612. /** Left button */
  12613. LB = 6,
  12614. /** Right button */
  12615. RB = 7,
  12616. /** Left stick */
  12617. LeftStick = 8,
  12618. /** Right stick */
  12619. RightStick = 9
  12620. }
  12621. /** Defines values for XBox360 DPad */
  12622. enum Xbox360Dpad {
  12623. /** Up */
  12624. Up = 0,
  12625. /** Down */
  12626. Down = 1,
  12627. /** Left */
  12628. Left = 2,
  12629. /** Right */
  12630. Right = 3
  12631. }
  12632. /**
  12633. * Defines a XBox360 gamepad
  12634. */
  12635. class Xbox360Pad extends Gamepad {
  12636. private _leftTrigger;
  12637. private _rightTrigger;
  12638. private _onlefttriggerchanged;
  12639. private _onrighttriggerchanged;
  12640. private _onbuttondown;
  12641. private _onbuttonup;
  12642. private _ondpaddown;
  12643. private _ondpadup;
  12644. /** Observable raised when a button is pressed */
  12645. onButtonDownObservable: Observable<Xbox360Button>;
  12646. /** Observable raised when a button is released */
  12647. onButtonUpObservable: Observable<Xbox360Button>;
  12648. /** Observable raised when a pad is pressed */
  12649. onPadDownObservable: Observable<Xbox360Dpad>;
  12650. /** Observable raised when a pad is released */
  12651. onPadUpObservable: Observable<Xbox360Dpad>;
  12652. private _buttonA;
  12653. private _buttonB;
  12654. private _buttonX;
  12655. private _buttonY;
  12656. private _buttonBack;
  12657. private _buttonStart;
  12658. private _buttonLB;
  12659. private _buttonRB;
  12660. private _buttonLeftStick;
  12661. private _buttonRightStick;
  12662. private _dPadUp;
  12663. private _dPadDown;
  12664. private _dPadLeft;
  12665. private _dPadRight;
  12666. private _isXboxOnePad;
  12667. /**
  12668. * Creates a new XBox360 gamepad object
  12669. * @param id defines the id of this gamepad
  12670. * @param index defines its index
  12671. * @param gamepad defines the internal HTML gamepad object
  12672. * @param xboxOne defines if it is a XBox One gamepad
  12673. */
  12674. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12675. /**
  12676. * Defines the callback to call when left trigger is pressed
  12677. * @param callback defines the callback to use
  12678. */
  12679. onlefttriggerchanged(callback: (value: number) => void): void;
  12680. /**
  12681. * Defines the callback to call when right trigger is pressed
  12682. * @param callback defines the callback to use
  12683. */
  12684. onrighttriggerchanged(callback: (value: number) => void): void;
  12685. /**
  12686. * Gets the left trigger value
  12687. */
  12688. /**
  12689. * Sets the left trigger value
  12690. */
  12691. leftTrigger: number;
  12692. /**
  12693. * Gets the right trigger value
  12694. */
  12695. /**
  12696. * Sets the right trigger value
  12697. */
  12698. rightTrigger: number;
  12699. /**
  12700. * Defines the callback to call when a button is pressed
  12701. * @param callback defines the callback to use
  12702. */
  12703. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12704. /**
  12705. * Defines the callback to call when a button is released
  12706. * @param callback defines the callback to use
  12707. */
  12708. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12709. /**
  12710. * Defines the callback to call when a pad is pressed
  12711. * @param callback defines the callback to use
  12712. */
  12713. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12714. /**
  12715. * Defines the callback to call when a pad is released
  12716. * @param callback defines the callback to use
  12717. */
  12718. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12719. private _setButtonValue;
  12720. private _setDPadValue;
  12721. /**
  12722. * Gets the value of the `A` button
  12723. */
  12724. /**
  12725. * Sets the value of the `A` button
  12726. */
  12727. buttonA: number;
  12728. /**
  12729. * Gets the value of the `B` button
  12730. */
  12731. /**
  12732. * Sets the value of the `B` button
  12733. */
  12734. buttonB: number;
  12735. /**
  12736. * Gets the value of the `X` button
  12737. */
  12738. /**
  12739. * Sets the value of the `X` button
  12740. */
  12741. buttonX: number;
  12742. /**
  12743. * Gets the value of the `Y` button
  12744. */
  12745. /**
  12746. * Sets the value of the `Y` button
  12747. */
  12748. buttonY: number;
  12749. /**
  12750. * Gets the value of the `Start` button
  12751. */
  12752. /**
  12753. * Sets the value of the `Start` button
  12754. */
  12755. buttonStart: number;
  12756. /**
  12757. * Gets the value of the `Back` button
  12758. */
  12759. /**
  12760. * Sets the value of the `Back` button
  12761. */
  12762. buttonBack: number;
  12763. /**
  12764. * Gets the value of the `Left` button
  12765. */
  12766. /**
  12767. * Sets the value of the `Left` button
  12768. */
  12769. buttonLB: number;
  12770. /**
  12771. * Gets the value of the `Right` button
  12772. */
  12773. /**
  12774. * Sets the value of the `Right` button
  12775. */
  12776. buttonRB: number;
  12777. /**
  12778. * Gets the value of the Left joystick
  12779. */
  12780. /**
  12781. * Sets the value of the Left joystick
  12782. */
  12783. buttonLeftStick: number;
  12784. /**
  12785. * Gets the value of the Right joystick
  12786. */
  12787. /**
  12788. * Sets the value of the Right joystick
  12789. */
  12790. buttonRightStick: number;
  12791. /**
  12792. * Gets the value of D-pad up
  12793. */
  12794. /**
  12795. * Sets the value of D-pad up
  12796. */
  12797. dPadUp: number;
  12798. /**
  12799. * Gets the value of D-pad down
  12800. */
  12801. /**
  12802. * Sets the value of D-pad down
  12803. */
  12804. dPadDown: number;
  12805. /**
  12806. * Gets the value of D-pad left
  12807. */
  12808. /**
  12809. * Sets the value of D-pad left
  12810. */
  12811. dPadLeft: number;
  12812. /**
  12813. * Gets the value of D-pad right
  12814. */
  12815. /**
  12816. * Sets the value of D-pad right
  12817. */
  12818. dPadRight: number;
  12819. /**
  12820. * Force the gamepad to synchronize with device values
  12821. */
  12822. update(): void;
  12823. /**
  12824. * Disposes the gamepad
  12825. */
  12826. dispose(): void;
  12827. }
  12828. }
  12829. declare module BABYLON {
  12830. /**
  12831. * Single axis drag gizmo
  12832. */
  12833. class AxisDragGizmo extends Gizmo {
  12834. /**
  12835. * Drag behavior responsible for the gizmos dragging interactions
  12836. */
  12837. dragBehavior: PointerDragBehavior;
  12838. private _pointerObserver;
  12839. /**
  12840. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12841. */
  12842. snapDistance: number;
  12843. /**
  12844. * Event that fires each time the gizmo snaps to a new location.
  12845. * * snapDistance is the the change in distance
  12846. */
  12847. onSnapObservable: Observable<{
  12848. snapDistance: number;
  12849. }>;
  12850. /**
  12851. * Creates an AxisDragGizmo
  12852. * @param gizmoLayer The utility layer the gizmo will be added to
  12853. * @param dragAxis The axis which the gizmo will be able to drag on
  12854. * @param color The color of the gizmo
  12855. */
  12856. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12857. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12858. /**
  12859. * Disposes of the gizmo
  12860. */
  12861. dispose(): void;
  12862. }
  12863. }
  12864. declare module BABYLON {
  12865. /**
  12866. * Single axis scale gizmo
  12867. */
  12868. class AxisScaleGizmo extends Gizmo {
  12869. private _coloredMaterial;
  12870. /**
  12871. * Drag behavior responsible for the gizmos dragging interactions
  12872. */
  12873. dragBehavior: PointerDragBehavior;
  12874. private _pointerObserver;
  12875. /**
  12876. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  12877. */
  12878. snapDistance: number;
  12879. /**
  12880. * Event that fires each time the gizmo snaps to a new location.
  12881. * * snapDistance is the the change in distance
  12882. */
  12883. onSnapObservable: Observable<{
  12884. snapDistance: number;
  12885. }>;
  12886. /**
  12887. * If the scaling operation should be done on all axis (default: false)
  12888. */
  12889. uniformScaling: boolean;
  12890. /**
  12891. * Creates an AxisScaleGizmo
  12892. * @param gizmoLayer The utility layer the gizmo will be added to
  12893. * @param dragAxis The axis which the gizmo will be able to scale on
  12894. * @param color The color of the gizmo
  12895. */
  12896. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12897. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12898. /**
  12899. * Disposes of the gizmo
  12900. */
  12901. dispose(): void;
  12902. /**
  12903. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  12904. * @param mesh The mesh to replace the default mesh of the gizmo
  12905. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  12906. */
  12907. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  12908. }
  12909. }
  12910. declare module BABYLON {
  12911. /**
  12912. * Bounding box gizmo
  12913. */
  12914. class BoundingBoxGizmo extends Gizmo {
  12915. private _lineBoundingBox;
  12916. private _rotateSpheresParent;
  12917. private _scaleBoxesParent;
  12918. private _boundingDimensions;
  12919. private _renderObserver;
  12920. private _pointerObserver;
  12921. private _scaleDragSpeed;
  12922. private _tmpQuaternion;
  12923. private _tmpVector;
  12924. private _tmpRotationMatrix;
  12925. /**
  12926. * 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)
  12927. */
  12928. ignoreChildren: boolean;
  12929. /**
  12930. * 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)
  12931. */
  12932. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  12933. /**
  12934. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  12935. */
  12936. rotationSphereSize: number;
  12937. /**
  12938. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  12939. */
  12940. scaleBoxSize: number;
  12941. /**
  12942. * 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)
  12943. */
  12944. fixedDragMeshScreenSize: boolean;
  12945. /**
  12946. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  12947. */
  12948. fixedDragMeshScreenSizeDistanceFactor: number;
  12949. /**
  12950. * Fired when a rotation sphere or scale box is dragged
  12951. */
  12952. onDragStartObservable: Observable<{}>;
  12953. /**
  12954. * Fired when a scale box is dragged
  12955. */
  12956. onScaleBoxDragObservable: Observable<{}>;
  12957. /**
  12958. * Fired when a scale box drag is ended
  12959. */
  12960. onScaleBoxDragEndObservable: Observable<{}>;
  12961. /**
  12962. * Fired when a rotation sphere is dragged
  12963. */
  12964. onRotationSphereDragObservable: Observable<{}>;
  12965. /**
  12966. * Fired when a rotation sphere drag is ended
  12967. */
  12968. onRotationSphereDragEndObservable: Observable<{}>;
  12969. /**
  12970. * 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)
  12971. */
  12972. scalePivot: Nullable<Vector3>;
  12973. private _anchorMesh;
  12974. private _existingMeshScale;
  12975. private static _PivotCached;
  12976. private static _OldPivotPoint;
  12977. private static _PivotTranslation;
  12978. private static _PivotTmpVector;
  12979. /** @hidden */
  12980. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  12981. /** @hidden */
  12982. static _RestorePivotPoint(mesh: AbstractMesh): void;
  12983. /**
  12984. * Creates an BoundingBoxGizmo
  12985. * @param gizmoLayer The utility layer the gizmo will be added to
  12986. * @param color The color of the gizmo
  12987. */
  12988. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  12989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  12990. private _selectNode;
  12991. /**
  12992. * Updates the bounding box information for the Gizmo
  12993. */
  12994. updateBoundingBox(): void;
  12995. /**
  12996. * Enables rotation on the specified axis and disables rotation on the others
  12997. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  12998. */
  12999. setEnabledRotationAxis(axis: string): void;
  13000. /**
  13001. * Disposes of the gizmo
  13002. */
  13003. dispose(): void;
  13004. /**
  13005. * 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)
  13006. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13007. * @returns the bounding box mesh with the passed in mesh as a child
  13008. */
  13009. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13010. /**
  13011. * CustomMeshes are not supported by this gizmo
  13012. * @param mesh The mesh to replace the default mesh of the gizmo
  13013. */
  13014. setCustomMesh(mesh: Mesh): void;
  13015. }
  13016. }
  13017. declare module BABYLON {
  13018. /**
  13019. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13020. */
  13021. class Gizmo implements IDisposable {
  13022. /** The utility layer the gizmo will be added to */
  13023. gizmoLayer: UtilityLayerRenderer;
  13024. /**
  13025. * The root mesh of the gizmo
  13026. */
  13027. protected _rootMesh: Mesh;
  13028. private _attachedMesh;
  13029. /**
  13030. * Ratio for the scale of the gizmo (Default: 1)
  13031. */
  13032. scaleRatio: number;
  13033. private _tmpMatrix;
  13034. /**
  13035. * If a custom mesh has been set (Default: false)
  13036. */
  13037. protected _customMeshSet: boolean;
  13038. /**
  13039. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13040. * * When set, interactions will be enabled
  13041. */
  13042. attachedMesh: Nullable<AbstractMesh>;
  13043. /**
  13044. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13045. * @param mesh The mesh to replace the default mesh of the gizmo
  13046. */
  13047. setCustomMesh(mesh: Mesh): void;
  13048. /**
  13049. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13050. */
  13051. updateGizmoRotationToMatchAttachedMesh: boolean;
  13052. /**
  13053. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13054. */
  13055. updateGizmoPositionToMatchAttachedMesh: boolean;
  13056. /**
  13057. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13058. */
  13059. protected _updateScale: boolean;
  13060. protected _interactionsEnabled: boolean;
  13061. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13062. private _beforeRenderObserver;
  13063. /**
  13064. * Creates a gizmo
  13065. * @param gizmoLayer The utility layer the gizmo will be added to
  13066. */
  13067. constructor(
  13068. /** The utility layer the gizmo will be added to */
  13069. gizmoLayer?: UtilityLayerRenderer);
  13070. private _tempVector;
  13071. /**
  13072. * @hidden
  13073. * Updates the gizmo to match the attached mesh's position/rotation
  13074. */
  13075. protected _update(): void;
  13076. /**
  13077. * Disposes of the gizmo
  13078. */
  13079. dispose(): void;
  13080. }
  13081. }
  13082. declare module BABYLON {
  13083. /**
  13084. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13085. */
  13086. class GizmoManager implements IDisposable {
  13087. private scene;
  13088. /**
  13089. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13090. */
  13091. gizmos: {
  13092. positionGizmo: Nullable<PositionGizmo>;
  13093. rotationGizmo: Nullable<RotationGizmo>;
  13094. scaleGizmo: Nullable<ScaleGizmo>;
  13095. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13096. };
  13097. private _gizmosEnabled;
  13098. private _pointerObserver;
  13099. private _attachedMesh;
  13100. private _boundingBoxColor;
  13101. private _defaultUtilityLayer;
  13102. private _defaultKeepDepthUtilityLayer;
  13103. /**
  13104. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13105. */
  13106. boundingBoxDragBehavior: SixDofDragBehavior;
  13107. /**
  13108. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13109. */
  13110. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13111. /**
  13112. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13113. */
  13114. usePointerToAttachGizmos: boolean;
  13115. /**
  13116. * Instatiates a gizmo manager
  13117. * @param scene the scene to overlay the gizmos on top of
  13118. */
  13119. constructor(scene: Scene);
  13120. /**
  13121. * Attaches a set of gizmos to the specified mesh
  13122. * @param mesh The mesh the gizmo's should be attached to
  13123. */
  13124. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13125. /**
  13126. * If the position gizmo is enabled
  13127. */
  13128. positionGizmoEnabled: boolean;
  13129. /**
  13130. * If the rotation gizmo is enabled
  13131. */
  13132. rotationGizmoEnabled: boolean;
  13133. /**
  13134. * If the scale gizmo is enabled
  13135. */
  13136. scaleGizmoEnabled: boolean;
  13137. /**
  13138. * If the boundingBox gizmo is enabled
  13139. */
  13140. boundingBoxGizmoEnabled: boolean;
  13141. /**
  13142. * Disposes of the gizmo manager
  13143. */
  13144. dispose(): void;
  13145. }
  13146. }
  13147. declare module BABYLON {
  13148. /**
  13149. * Single plane rotation gizmo
  13150. */
  13151. class PlaneRotationGizmo extends Gizmo {
  13152. /**
  13153. * Drag behavior responsible for the gizmos dragging interactions
  13154. */
  13155. dragBehavior: PointerDragBehavior;
  13156. private _pointerObserver;
  13157. /**
  13158. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13159. */
  13160. snapDistance: number;
  13161. /**
  13162. * Event that fires each time the gizmo snaps to a new location.
  13163. * * snapDistance is the the change in distance
  13164. */
  13165. onSnapObservable: Observable<{
  13166. snapDistance: number;
  13167. }>;
  13168. /**
  13169. * Creates a PlaneRotationGizmo
  13170. * @param gizmoLayer The utility layer the gizmo will be added to
  13171. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13172. * @param color The color of the gizmo
  13173. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13174. */
  13175. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13177. /**
  13178. * Disposes of the gizmo
  13179. */
  13180. dispose(): void;
  13181. }
  13182. }
  13183. declare module BABYLON {
  13184. /**
  13185. * Gizmo that enables dragging a mesh along 3 axis
  13186. */
  13187. class PositionGizmo extends Gizmo {
  13188. /**
  13189. * Internal gizmo used for interactions on the x axis
  13190. */
  13191. xGizmo: AxisDragGizmo;
  13192. /**
  13193. * Internal gizmo used for interactions on the y axis
  13194. */
  13195. yGizmo: AxisDragGizmo;
  13196. /**
  13197. * Internal gizmo used for interactions on the z axis
  13198. */
  13199. zGizmo: AxisDragGizmo;
  13200. /** Fires an event when any of it's sub gizmos are dragged */
  13201. onDragStartObservable: Observable<{}>;
  13202. /** Fires an event when any of it's sub gizmos are released from dragging */
  13203. onDragEndObservable: Observable<{}>;
  13204. attachedMesh: Nullable<AbstractMesh>;
  13205. /**
  13206. * Creates a PositionGizmo
  13207. * @param gizmoLayer The utility layer the gizmo will be added to
  13208. */
  13209. constructor(gizmoLayer?: UtilityLayerRenderer);
  13210. updateGizmoRotationToMatchAttachedMesh: boolean;
  13211. /**
  13212. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13213. */
  13214. snapDistance: number;
  13215. /**
  13216. * Ratio for the scale of the gizmo (Default: 1)
  13217. */
  13218. scaleRatio: number;
  13219. /**
  13220. * Disposes of the gizmo
  13221. */
  13222. dispose(): void;
  13223. /**
  13224. * CustomMeshes are not supported by this gizmo
  13225. * @param mesh The mesh to replace the default mesh of the gizmo
  13226. */
  13227. setCustomMesh(mesh: Mesh): void;
  13228. }
  13229. }
  13230. declare module BABYLON {
  13231. /**
  13232. * Gizmo that enables rotating a mesh along 3 axis
  13233. */
  13234. class RotationGizmo extends Gizmo {
  13235. /**
  13236. * Internal gizmo used for interactions on the x axis
  13237. */
  13238. xGizmo: PlaneRotationGizmo;
  13239. /**
  13240. * Internal gizmo used for interactions on the y axis
  13241. */
  13242. yGizmo: PlaneRotationGizmo;
  13243. /**
  13244. * Internal gizmo used for interactions on the z axis
  13245. */
  13246. zGizmo: PlaneRotationGizmo;
  13247. /** Fires an event when any of it's sub gizmos are dragged */
  13248. onDragStartObservable: Observable<{}>;
  13249. /** Fires an event when any of it's sub gizmos are released from dragging */
  13250. onDragEndObservable: Observable<{}>;
  13251. attachedMesh: Nullable<AbstractMesh>;
  13252. /**
  13253. * Creates a RotationGizmo
  13254. * @param gizmoLayer The utility layer the gizmo will be added to
  13255. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13256. */
  13257. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13258. updateGizmoRotationToMatchAttachedMesh: boolean;
  13259. /**
  13260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13261. */
  13262. snapDistance: number;
  13263. /**
  13264. * Ratio for the scale of the gizmo (Default: 1)
  13265. */
  13266. scaleRatio: number;
  13267. /**
  13268. * Disposes of the gizmo
  13269. */
  13270. dispose(): void;
  13271. /**
  13272. * CustomMeshes are not supported by this gizmo
  13273. * @param mesh The mesh to replace the default mesh of the gizmo
  13274. */
  13275. setCustomMesh(mesh: Mesh): void;
  13276. }
  13277. }
  13278. declare module BABYLON {
  13279. /**
  13280. * Gizmo that enables scaling a mesh along 3 axis
  13281. */
  13282. class ScaleGizmo extends Gizmo {
  13283. /**
  13284. * Internal gizmo used for interactions on the x axis
  13285. */
  13286. xGizmo: AxisScaleGizmo;
  13287. /**
  13288. * Internal gizmo used for interactions on the y axis
  13289. */
  13290. yGizmo: AxisScaleGizmo;
  13291. /**
  13292. * Internal gizmo used for interactions on the z axis
  13293. */
  13294. zGizmo: AxisScaleGizmo;
  13295. /**
  13296. * Internal gizmo used to scale all axis equally
  13297. */
  13298. uniformScaleGizmo: AxisScaleGizmo;
  13299. /** Fires an event when any of it's sub gizmos are dragged */
  13300. onDragStartObservable: Observable<{}>;
  13301. /** Fires an event when any of it's sub gizmos are released from dragging */
  13302. onDragEndObservable: Observable<{}>;
  13303. attachedMesh: Nullable<AbstractMesh>;
  13304. /**
  13305. * Creates a ScaleGizmo
  13306. * @param gizmoLayer The utility layer the gizmo will be added to
  13307. */
  13308. constructor(gizmoLayer?: UtilityLayerRenderer);
  13309. updateGizmoRotationToMatchAttachedMesh: boolean;
  13310. /**
  13311. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13312. */
  13313. snapDistance: number;
  13314. /**
  13315. * Ratio for the scale of the gizmo (Default: 1)
  13316. */
  13317. scaleRatio: number;
  13318. /**
  13319. * Disposes of the gizmo
  13320. */
  13321. dispose(): void;
  13322. }
  13323. }
  13324. declare module BABYLON {
  13325. /**
  13326. * Represents the different options available during the creation of
  13327. * a Environment helper.
  13328. *
  13329. * This can control the default ground, skybox and image processing setup of your scene.
  13330. */
  13331. interface IEnvironmentHelperOptions {
  13332. /**
  13333. * Specifies wether or not to create a ground.
  13334. * True by default.
  13335. */
  13336. createGround: boolean;
  13337. /**
  13338. * Specifies the ground size.
  13339. * 15 by default.
  13340. */
  13341. groundSize: number;
  13342. /**
  13343. * The texture used on the ground for the main color.
  13344. * Comes from the BabylonJS CDN by default.
  13345. *
  13346. * Remarks: Can be either a texture or a url.
  13347. */
  13348. groundTexture: string | BaseTexture;
  13349. /**
  13350. * The color mixed in the ground texture by default.
  13351. * BabylonJS clearColor by default.
  13352. */
  13353. groundColor: Color3;
  13354. /**
  13355. * Specifies the ground opacity.
  13356. * 1 by default.
  13357. */
  13358. groundOpacity: number;
  13359. /**
  13360. * Enables the ground to receive shadows.
  13361. * True by default.
  13362. */
  13363. enableGroundShadow: boolean;
  13364. /**
  13365. * Helps preventing the shadow to be fully black on the ground.
  13366. * 0.5 by default.
  13367. */
  13368. groundShadowLevel: number;
  13369. /**
  13370. * Creates a mirror texture attach to the ground.
  13371. * false by default.
  13372. */
  13373. enableGroundMirror: boolean;
  13374. /**
  13375. * Specifies the ground mirror size ratio.
  13376. * 0.3 by default as the default kernel is 64.
  13377. */
  13378. groundMirrorSizeRatio: number;
  13379. /**
  13380. * Specifies the ground mirror blur kernel size.
  13381. * 64 by default.
  13382. */
  13383. groundMirrorBlurKernel: number;
  13384. /**
  13385. * Specifies the ground mirror visibility amount.
  13386. * 1 by default
  13387. */
  13388. groundMirrorAmount: number;
  13389. /**
  13390. * Specifies the ground mirror reflectance weight.
  13391. * This uses the standard weight of the background material to setup the fresnel effect
  13392. * of the mirror.
  13393. * 1 by default.
  13394. */
  13395. groundMirrorFresnelWeight: number;
  13396. /**
  13397. * Specifies the ground mirror Falloff distance.
  13398. * This can helps reducing the size of the reflection.
  13399. * 0 by Default.
  13400. */
  13401. groundMirrorFallOffDistance: number;
  13402. /**
  13403. * Specifies the ground mirror texture type.
  13404. * Unsigned Int by Default.
  13405. */
  13406. groundMirrorTextureType: number;
  13407. /**
  13408. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13409. * the shown objects.
  13410. */
  13411. groundYBias: number;
  13412. /**
  13413. * Specifies wether or not to create a skybox.
  13414. * True by default.
  13415. */
  13416. createSkybox: boolean;
  13417. /**
  13418. * Specifies the skybox size.
  13419. * 20 by default.
  13420. */
  13421. skyboxSize: number;
  13422. /**
  13423. * The texture used on the skybox for the main color.
  13424. * Comes from the BabylonJS CDN by default.
  13425. *
  13426. * Remarks: Can be either a texture or a url.
  13427. */
  13428. skyboxTexture: string | BaseTexture;
  13429. /**
  13430. * The color mixed in the skybox texture by default.
  13431. * BabylonJS clearColor by default.
  13432. */
  13433. skyboxColor: Color3;
  13434. /**
  13435. * The background rotation around the Y axis of the scene.
  13436. * This helps aligning the key lights of your scene with the background.
  13437. * 0 by default.
  13438. */
  13439. backgroundYRotation: number;
  13440. /**
  13441. * Compute automatically the size of the elements to best fit with the scene.
  13442. */
  13443. sizeAuto: boolean;
  13444. /**
  13445. * Default position of the rootMesh if autoSize is not true.
  13446. */
  13447. rootPosition: Vector3;
  13448. /**
  13449. * Sets up the image processing in the scene.
  13450. * true by default.
  13451. */
  13452. setupImageProcessing: boolean;
  13453. /**
  13454. * The texture used as your environment texture in the scene.
  13455. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13456. *
  13457. * Remarks: Can be either a texture or a url.
  13458. */
  13459. environmentTexture: string | BaseTexture;
  13460. /**
  13461. * The value of the exposure to apply to the scene.
  13462. * 0.6 by default if setupImageProcessing is true.
  13463. */
  13464. cameraExposure: number;
  13465. /**
  13466. * The value of the contrast to apply to the scene.
  13467. * 1.6 by default if setupImageProcessing is true.
  13468. */
  13469. cameraContrast: number;
  13470. /**
  13471. * Specifies wether or not tonemapping should be enabled in the scene.
  13472. * true by default if setupImageProcessing is true.
  13473. */
  13474. toneMappingEnabled: boolean;
  13475. }
  13476. /**
  13477. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13478. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13479. * It also helps with the default setup of your imageProcessing configuration.
  13480. */
  13481. class EnvironmentHelper {
  13482. /**
  13483. * Default ground texture URL.
  13484. */
  13485. private static _groundTextureCDNUrl;
  13486. /**
  13487. * Default skybox texture URL.
  13488. */
  13489. private static _skyboxTextureCDNUrl;
  13490. /**
  13491. * Default environment texture URL.
  13492. */
  13493. private static _environmentTextureCDNUrl;
  13494. /**
  13495. * Creates the default options for the helper.
  13496. */
  13497. private static _getDefaultOptions;
  13498. private _rootMesh;
  13499. /**
  13500. * Gets the root mesh created by the helper.
  13501. */
  13502. readonly rootMesh: Mesh;
  13503. private _skybox;
  13504. /**
  13505. * Gets the skybox created by the helper.
  13506. */
  13507. readonly skybox: Nullable<Mesh>;
  13508. private _skyboxTexture;
  13509. /**
  13510. * Gets the skybox texture created by the helper.
  13511. */
  13512. readonly skyboxTexture: Nullable<BaseTexture>;
  13513. private _skyboxMaterial;
  13514. /**
  13515. * Gets the skybox material created by the helper.
  13516. */
  13517. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13518. private _ground;
  13519. /**
  13520. * Gets the ground mesh created by the helper.
  13521. */
  13522. readonly ground: Nullable<Mesh>;
  13523. private _groundTexture;
  13524. /**
  13525. * Gets the ground texture created by the helper.
  13526. */
  13527. readonly groundTexture: Nullable<BaseTexture>;
  13528. private _groundMirror;
  13529. /**
  13530. * Gets the ground mirror created by the helper.
  13531. */
  13532. readonly groundMirror: Nullable<MirrorTexture>;
  13533. /**
  13534. * Gets the ground mirror render list to helps pushing the meshes
  13535. * you wish in the ground reflection.
  13536. */
  13537. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13538. private _groundMaterial;
  13539. /**
  13540. * Gets the ground material created by the helper.
  13541. */
  13542. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13543. /**
  13544. * Stores the creation options.
  13545. */
  13546. private readonly _scene;
  13547. private _options;
  13548. /**
  13549. * This observable will be notified with any error during the creation of the environment,
  13550. * mainly texture creation errors.
  13551. */
  13552. onErrorObservable: Observable<{
  13553. message?: string;
  13554. exception?: any;
  13555. }>;
  13556. /**
  13557. * constructor
  13558. * @param options
  13559. * @param scene The scene to add the material to
  13560. */
  13561. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13562. /**
  13563. * Updates the background according to the new options
  13564. * @param options
  13565. */
  13566. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13567. /**
  13568. * Sets the primary color of all the available elements.
  13569. * @param color the main color to affect to the ground and the background
  13570. */
  13571. setMainColor(color: Color3): void;
  13572. /**
  13573. * Setup the image processing according to the specified options.
  13574. */
  13575. private _setupImageProcessing;
  13576. /**
  13577. * Setup the environment texture according to the specified options.
  13578. */
  13579. private _setupEnvironmentTexture;
  13580. /**
  13581. * Setup the background according to the specified options.
  13582. */
  13583. private _setupBackground;
  13584. /**
  13585. * Get the scene sizes according to the setup.
  13586. */
  13587. private _getSceneSize;
  13588. /**
  13589. * Setup the ground according to the specified options.
  13590. */
  13591. private _setupGround;
  13592. /**
  13593. * Setup the ground material according to the specified options.
  13594. */
  13595. private _setupGroundMaterial;
  13596. /**
  13597. * Setup the ground diffuse texture according to the specified options.
  13598. */
  13599. private _setupGroundDiffuseTexture;
  13600. /**
  13601. * Setup the ground mirror texture according to the specified options.
  13602. */
  13603. private _setupGroundMirrorTexture;
  13604. /**
  13605. * Setup the ground to receive the mirror texture.
  13606. */
  13607. private _setupMirrorInGroundMaterial;
  13608. /**
  13609. * Setup the skybox according to the specified options.
  13610. */
  13611. private _setupSkybox;
  13612. /**
  13613. * Setup the skybox material according to the specified options.
  13614. */
  13615. private _setupSkyboxMaterial;
  13616. /**
  13617. * Setup the skybox reflection texture according to the specified options.
  13618. */
  13619. private _setupSkyboxReflectionTexture;
  13620. private _errorHandler;
  13621. /**
  13622. * Dispose all the elements created by the Helper.
  13623. */
  13624. dispose(): void;
  13625. }
  13626. }
  13627. declare module BABYLON {
  13628. /**
  13629. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13630. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13631. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13632. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13633. */
  13634. class PhotoDome extends TransformNode {
  13635. private _useDirectMapping;
  13636. /**
  13637. * The texture being displayed on the sphere
  13638. */
  13639. protected _photoTexture: Texture;
  13640. /**
  13641. * Gets or sets the texture being displayed on the sphere
  13642. */
  13643. photoTexture: Texture;
  13644. /**
  13645. * Observable raised when an error occured while loading the 360 image
  13646. */
  13647. onLoadErrorObservable: Observable<string>;
  13648. /**
  13649. * The skybox material
  13650. */
  13651. protected _material: BackgroundMaterial;
  13652. /**
  13653. * The surface used for the skybox
  13654. */
  13655. protected _mesh: Mesh;
  13656. /**
  13657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13658. * Also see the options.resolution property.
  13659. */
  13660. fovMultiplier: number;
  13661. /**
  13662. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13663. * @param name Element's name, child elements will append suffixes for their own names.
  13664. * @param urlsOfPhoto defines the url of the photo to display
  13665. * @param options defines an object containing optional or exposed sub element properties
  13666. * @param onError defines a callback called when an error occured while loading the texture
  13667. */
  13668. constructor(name: string, urlOfPhoto: string, options: {
  13669. resolution?: number;
  13670. size?: number;
  13671. useDirectMapping?: boolean;
  13672. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13673. /**
  13674. * Releases resources associated with this node.
  13675. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13676. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13677. */
  13678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13679. }
  13680. }
  13681. declare module BABYLON {
  13682. interface Scene {
  13683. /**
  13684. * Creates a default light for the scene.
  13685. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13686. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13687. */
  13688. createDefaultLight(replace?: boolean): void;
  13689. /**
  13690. * Creates a default camera for the scene.
  13691. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13692. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13693. * @param replace has default false, when true replaces the active camera in the scene
  13694. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13695. */
  13696. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13697. /**
  13698. * Creates a default camera and a default light.
  13699. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13700. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13701. * @param replace has the default false, when true replaces the active camera/light in the scene
  13702. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13703. */
  13704. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13705. /**
  13706. * Creates a new sky box
  13707. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13708. * @param environmentTexture defines the texture to use as environment texture
  13709. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13710. * @param scale defines the overall scale of the skybox
  13711. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13712. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13713. * @returns a new mesh holding the sky box
  13714. */
  13715. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13716. /**
  13717. * Creates a new environment
  13718. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13719. * @param options defines the options you can use to configure the environment
  13720. * @returns the new EnvironmentHelper
  13721. */
  13722. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13723. /**
  13724. * Creates a new VREXperienceHelper
  13725. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13726. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13727. * @returns a new VREXperienceHelper
  13728. */
  13729. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13730. }
  13731. }
  13732. declare module BABYLON {
  13733. /**
  13734. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13735. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13736. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13737. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13738. */
  13739. class VideoDome extends TransformNode {
  13740. private _useDirectMapping;
  13741. /**
  13742. * The video texture being displayed on the sphere
  13743. */
  13744. protected _videoTexture: VideoTexture;
  13745. /**
  13746. * Gets the video texture being displayed on the sphere
  13747. */
  13748. readonly videoTexture: VideoTexture;
  13749. /**
  13750. * The skybox material
  13751. */
  13752. protected _material: BackgroundMaterial;
  13753. /**
  13754. * The surface used for the skybox
  13755. */
  13756. protected _mesh: Mesh;
  13757. /**
  13758. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13759. * Also see the options.resolution property.
  13760. */
  13761. fovMultiplier: number;
  13762. /**
  13763. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13764. * @param name Element's name, child elements will append suffixes for their own names.
  13765. * @param urlsOrVideo defines the url(s) or the video element to use
  13766. * @param options An object containing optional or exposed sub element properties
  13767. */
  13768. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13769. resolution?: number;
  13770. clickToPlay?: boolean;
  13771. autoPlay?: boolean;
  13772. loop?: boolean;
  13773. size?: number;
  13774. poster?: string;
  13775. useDirectMapping?: boolean;
  13776. }, scene: Scene);
  13777. /**
  13778. * Releases resources associated with this node.
  13779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13781. */
  13782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13783. }
  13784. }
  13785. declare module BABYLON {
  13786. /**
  13787. * This class can be used to get instrumentation data from a Babylon engine
  13788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13789. */
  13790. class EngineInstrumentation implements IDisposable {
  13791. /**
  13792. * Define the instrumented engine.
  13793. */
  13794. engine: Engine;
  13795. private _captureGPUFrameTime;
  13796. private _gpuFrameTimeToken;
  13797. private _gpuFrameTime;
  13798. private _captureShaderCompilationTime;
  13799. private _shaderCompilationTime;
  13800. private _onBeginFrameObserver;
  13801. private _onEndFrameObserver;
  13802. private _onBeforeShaderCompilationObserver;
  13803. private _onAfterShaderCompilationObserver;
  13804. /**
  13805. * Gets the perf counter used for GPU frame time
  13806. */
  13807. readonly gpuFrameTimeCounter: PerfCounter;
  13808. /**
  13809. * Gets the GPU frame time capture status
  13810. */
  13811. /**
  13812. * Enable or disable the GPU frame time capture
  13813. */
  13814. captureGPUFrameTime: boolean;
  13815. /**
  13816. * Gets the perf counter used for shader compilation time
  13817. */
  13818. readonly shaderCompilationTimeCounter: PerfCounter;
  13819. /**
  13820. * Gets the shader compilation time capture status
  13821. */
  13822. /**
  13823. * Enable or disable the shader compilation time capture
  13824. */
  13825. captureShaderCompilationTime: boolean;
  13826. /**
  13827. * Instantiates a new engine instrumentation.
  13828. * This class can be used to get instrumentation data from a Babylon engine
  13829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13830. * @param engine Defines the engine to instrument
  13831. */
  13832. constructor(
  13833. /**
  13834. * Define the instrumented engine.
  13835. */
  13836. engine: Engine);
  13837. /**
  13838. * Dispose and release associated resources.
  13839. */
  13840. dispose(): void;
  13841. }
  13842. }
  13843. declare module BABYLON {
  13844. /**
  13845. * This class can be used to get instrumentation data from a Babylon engine
  13846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13847. */
  13848. class SceneInstrumentation implements IDisposable {
  13849. /**
  13850. * Defines the scene to instrument
  13851. */
  13852. scene: Scene;
  13853. private _captureActiveMeshesEvaluationTime;
  13854. private _activeMeshesEvaluationTime;
  13855. private _captureRenderTargetsRenderTime;
  13856. private _renderTargetsRenderTime;
  13857. private _captureFrameTime;
  13858. private _frameTime;
  13859. private _captureRenderTime;
  13860. private _renderTime;
  13861. private _captureInterFrameTime;
  13862. private _interFrameTime;
  13863. private _captureParticlesRenderTime;
  13864. private _particlesRenderTime;
  13865. private _captureSpritesRenderTime;
  13866. private _spritesRenderTime;
  13867. private _capturePhysicsTime;
  13868. private _physicsTime;
  13869. private _captureAnimationsTime;
  13870. private _animationsTime;
  13871. private _captureCameraRenderTime;
  13872. private _cameraRenderTime;
  13873. private _onBeforeActiveMeshesEvaluationObserver;
  13874. private _onAfterActiveMeshesEvaluationObserver;
  13875. private _onBeforeRenderTargetsRenderObserver;
  13876. private _onAfterRenderTargetsRenderObserver;
  13877. private _onAfterRenderObserver;
  13878. private _onBeforeDrawPhaseObserver;
  13879. private _onAfterDrawPhaseObserver;
  13880. private _onBeforeAnimationsObserver;
  13881. private _onBeforeParticlesRenderingObserver;
  13882. private _onAfterParticlesRenderingObserver;
  13883. private _onBeforeSpritesRenderingObserver;
  13884. private _onAfterSpritesRenderingObserver;
  13885. private _onBeforePhysicsObserver;
  13886. private _onAfterPhysicsObserver;
  13887. private _onAfterAnimationsObserver;
  13888. private _onBeforeCameraRenderObserver;
  13889. private _onAfterCameraRenderObserver;
  13890. /**
  13891. * Gets the perf counter used for active meshes evaluation time
  13892. */
  13893. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13894. /**
  13895. * Gets the active meshes evaluation time capture status
  13896. */
  13897. /**
  13898. * Enable or disable the active meshes evaluation time capture
  13899. */
  13900. captureActiveMeshesEvaluationTime: boolean;
  13901. /**
  13902. * Gets the perf counter used for render targets render time
  13903. */
  13904. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13905. /**
  13906. * Gets the render targets render time capture status
  13907. */
  13908. /**
  13909. * Enable or disable the render targets render time capture
  13910. */
  13911. captureRenderTargetsRenderTime: boolean;
  13912. /**
  13913. * Gets the perf counter used for particles render time
  13914. */
  13915. readonly particlesRenderTimeCounter: PerfCounter;
  13916. /**
  13917. * Gets the particles render time capture status
  13918. */
  13919. /**
  13920. * Enable or disable the particles render time capture
  13921. */
  13922. captureParticlesRenderTime: boolean;
  13923. /**
  13924. * Gets the perf counter used for sprites render time
  13925. */
  13926. readonly spritesRenderTimeCounter: PerfCounter;
  13927. /**
  13928. * Gets the sprites render time capture status
  13929. */
  13930. /**
  13931. * Enable or disable the sprites render time capture
  13932. */
  13933. captureSpritesRenderTime: boolean;
  13934. /**
  13935. * Gets the perf counter used for physics time
  13936. */
  13937. readonly physicsTimeCounter: PerfCounter;
  13938. /**
  13939. * Gets the physics time capture status
  13940. */
  13941. /**
  13942. * Enable or disable the physics time capture
  13943. */
  13944. capturePhysicsTime: boolean;
  13945. /**
  13946. * Gets the perf counter used for animations time
  13947. */
  13948. readonly animationsTimeCounter: PerfCounter;
  13949. /**
  13950. * Gets the animations time capture status
  13951. */
  13952. /**
  13953. * Enable or disable the animations time capture
  13954. */
  13955. captureAnimationsTime: boolean;
  13956. /**
  13957. * Gets the perf counter used for frame time capture
  13958. */
  13959. readonly frameTimeCounter: PerfCounter;
  13960. /**
  13961. * Gets the frame time capture status
  13962. */
  13963. /**
  13964. * Enable or disable the frame time capture
  13965. */
  13966. captureFrameTime: boolean;
  13967. /**
  13968. * Gets the perf counter used for inter-frames time capture
  13969. */
  13970. readonly interFrameTimeCounter: PerfCounter;
  13971. /**
  13972. * Gets the inter-frames time capture status
  13973. */
  13974. /**
  13975. * Enable or disable the inter-frames time capture
  13976. */
  13977. captureInterFrameTime: boolean;
  13978. /**
  13979. * Gets the perf counter used for render time capture
  13980. */
  13981. readonly renderTimeCounter: PerfCounter;
  13982. /**
  13983. * Gets the render time capture status
  13984. */
  13985. /**
  13986. * Enable or disable the render time capture
  13987. */
  13988. captureRenderTime: boolean;
  13989. /**
  13990. * Gets the perf counter used for camera render time capture
  13991. */
  13992. readonly cameraRenderTimeCounter: PerfCounter;
  13993. /**
  13994. * Gets the camera render time capture status
  13995. */
  13996. /**
  13997. * Enable or disable the camera render time capture
  13998. */
  13999. captureCameraRenderTime: boolean;
  14000. /**
  14001. * Gets the perf counter used for draw calls
  14002. */
  14003. readonly drawCallsCounter: PerfCounter;
  14004. /**
  14005. * Gets the perf counter used for texture collisions
  14006. */
  14007. readonly textureCollisionsCounter: PerfCounter;
  14008. /**
  14009. * Instantiates a new scene instrumentation.
  14010. * This class can be used to get instrumentation data from a Babylon engine
  14011. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14012. * @param scene Defines the scene to instrument
  14013. */
  14014. constructor(
  14015. /**
  14016. * Defines the scene to instrument
  14017. */
  14018. scene: Scene);
  14019. /**
  14020. * Dispose and release associated resources.
  14021. */
  14022. dispose(): void;
  14023. }
  14024. }
  14025. declare module BABYLON {
  14026. /**
  14027. * @hidden
  14028. **/
  14029. class _TimeToken {
  14030. _startTimeQuery: Nullable<WebGLQuery>;
  14031. _endTimeQuery: Nullable<WebGLQuery>;
  14032. _timeElapsedQuery: Nullable<WebGLQuery>;
  14033. _timeElapsedQueryEnded: boolean;
  14034. }
  14035. }
  14036. declare module BABYLON {
  14037. /**
  14038. * Effect layer options. This helps customizing the behaviour
  14039. * of the effect layer.
  14040. */
  14041. interface IEffectLayerOptions {
  14042. /**
  14043. * Multiplication factor apply to the canvas size to compute the render target size
  14044. * used to generated the objects (the smaller the faster).
  14045. */
  14046. mainTextureRatio: number;
  14047. /**
  14048. * Enforces a fixed size texture to ensure effect stability across devices.
  14049. */
  14050. mainTextureFixedSize?: number;
  14051. /**
  14052. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14053. */
  14054. alphaBlendingMode: number;
  14055. /**
  14056. * The camera attached to the layer.
  14057. */
  14058. camera: Nullable<Camera>;
  14059. /**
  14060. * The rendering group to draw the layer in.
  14061. */
  14062. renderingGroupId: number;
  14063. }
  14064. /**
  14065. * The effect layer Helps adding post process effect blended with the main pass.
  14066. *
  14067. * This can be for instance use to generate glow or higlight effects on the scene.
  14068. *
  14069. * The effect layer class can not be used directly and is intented to inherited from to be
  14070. * customized per effects.
  14071. */
  14072. abstract class EffectLayer {
  14073. private _vertexBuffers;
  14074. private _indexBuffer;
  14075. private _cachedDefines;
  14076. private _effectLayerMapGenerationEffect;
  14077. private _effectLayerOptions;
  14078. private _mergeEffect;
  14079. protected _scene: Scene;
  14080. protected _engine: Engine;
  14081. protected _maxSize: number;
  14082. protected _mainTextureDesiredSize: ISize;
  14083. protected _mainTexture: RenderTargetTexture;
  14084. protected _shouldRender: boolean;
  14085. protected _postProcesses: PostProcess[];
  14086. protected _textures: BaseTexture[];
  14087. protected _emissiveTextureAndColor: {
  14088. texture: Nullable<BaseTexture>;
  14089. color: Color4;
  14090. };
  14091. /**
  14092. * The name of the layer
  14093. */
  14094. name: string;
  14095. /**
  14096. * The clear color of the texture used to generate the glow map.
  14097. */
  14098. neutralColor: Color4;
  14099. /**
  14100. * Specifies wether the highlight layer is enabled or not.
  14101. */
  14102. isEnabled: boolean;
  14103. /**
  14104. * Gets the camera attached to the layer.
  14105. */
  14106. readonly camera: Nullable<Camera>;
  14107. /**
  14108. * Gets the rendering group id the layer should render in.
  14109. */
  14110. readonly renderingGroupId: number;
  14111. /**
  14112. * An event triggered when the effect layer has been disposed.
  14113. */
  14114. onDisposeObservable: Observable<EffectLayer>;
  14115. /**
  14116. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14117. */
  14118. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14119. /**
  14120. * An event triggered when the generated texture is being merged in the scene.
  14121. */
  14122. onBeforeComposeObservable: Observable<EffectLayer>;
  14123. /**
  14124. * An event triggered when the generated texture has been merged in the scene.
  14125. */
  14126. onAfterComposeObservable: Observable<EffectLayer>;
  14127. /**
  14128. * An event triggered when the efffect layer changes its size.
  14129. */
  14130. onSizeChangedObservable: Observable<EffectLayer>;
  14131. /**
  14132. * Instantiates a new effect Layer and references it in the scene.
  14133. * @param name The name of the layer
  14134. * @param scene The scene to use the layer in
  14135. */
  14136. constructor(
  14137. /** The Friendly of the effect in the scene */
  14138. name: string, scene: Scene);
  14139. /**
  14140. * Get the effect name of the layer.
  14141. * @return The effect name
  14142. */
  14143. abstract getEffectName(): string;
  14144. /**
  14145. * Checks for the readiness of the element composing the layer.
  14146. * @param subMesh the mesh to check for
  14147. * @param useInstances specify wether or not to use instances to render the mesh
  14148. * @return true if ready otherwise, false
  14149. */
  14150. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14151. /**
  14152. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14153. * @returns true if the effect requires stencil during the main canvas render pass.
  14154. */
  14155. abstract needStencil(): boolean;
  14156. /**
  14157. * Create the merge effect. This is the shader use to blit the information back
  14158. * to the main canvas at the end of the scene rendering.
  14159. * @returns The effect containing the shader used to merge the effect on the main canvas
  14160. */
  14161. protected abstract _createMergeEffect(): Effect;
  14162. /**
  14163. * Creates the render target textures and post processes used in the effect layer.
  14164. */
  14165. protected abstract _createTextureAndPostProcesses(): void;
  14166. /**
  14167. * Implementation specific of rendering the generating effect on the main canvas.
  14168. * @param effect The effect used to render through
  14169. */
  14170. protected abstract _internalRender(effect: Effect): void;
  14171. /**
  14172. * Sets the required values for both the emissive texture and and the main color.
  14173. */
  14174. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14175. /**
  14176. * Free any resources and references associated to a mesh.
  14177. * Internal use
  14178. * @param mesh The mesh to free.
  14179. */
  14180. abstract _disposeMesh(mesh: Mesh): void;
  14181. /**
  14182. * Serializes this layer (Glow or Highlight for example)
  14183. * @returns a serialized layer object
  14184. */
  14185. abstract serialize?(): any;
  14186. /**
  14187. * Initializes the effect layer with the required options.
  14188. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14189. */
  14190. protected _init(options: Partial<IEffectLayerOptions>): void;
  14191. /**
  14192. * Generates the index buffer of the full screen quad blending to the main canvas.
  14193. */
  14194. private _generateIndexBuffer;
  14195. /**
  14196. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14197. */
  14198. private _genrateVertexBuffer;
  14199. /**
  14200. * Sets the main texture desired size which is the closest power of two
  14201. * of the engine canvas size.
  14202. */
  14203. private _setMainTextureSize;
  14204. /**
  14205. * Creates the main texture for the effect layer.
  14206. */
  14207. protected _createMainTexture(): void;
  14208. /**
  14209. * Checks for the readiness of the element composing the layer.
  14210. * @param subMesh the mesh to check for
  14211. * @param useInstances specify wether or not to use instances to render the mesh
  14212. * @param emissiveTexture the associated emissive texture used to generate the glow
  14213. * @return true if ready otherwise, false
  14214. */
  14215. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14216. /**
  14217. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14218. */
  14219. render(): void;
  14220. /**
  14221. * Determine if a given mesh will be used in the current effect.
  14222. * @param mesh mesh to test
  14223. * @returns true if the mesh will be used
  14224. */
  14225. hasMesh(mesh: AbstractMesh): boolean;
  14226. /**
  14227. * Returns true if the layer contains information to display, otherwise false.
  14228. * @returns true if the glow layer should be rendered
  14229. */
  14230. shouldRender(): boolean;
  14231. /**
  14232. * Returns true if the mesh should render, otherwise false.
  14233. * @param mesh The mesh to render
  14234. * @returns true if it should render otherwise false
  14235. */
  14236. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14237. /**
  14238. * Returns true if the mesh should render, otherwise false.
  14239. * @param mesh The mesh to render
  14240. * @returns true if it should render otherwise false
  14241. */
  14242. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14243. /**
  14244. * Renders the submesh passed in parameter to the generation map.
  14245. */
  14246. protected _renderSubMesh(subMesh: SubMesh): void;
  14247. /**
  14248. * Rebuild the required buffers.
  14249. * @hidden Internal use only.
  14250. */
  14251. _rebuild(): void;
  14252. /**
  14253. * Dispose only the render target textures and post process.
  14254. */
  14255. private _disposeTextureAndPostProcesses;
  14256. /**
  14257. * Dispose the highlight layer and free resources.
  14258. */
  14259. dispose(): void;
  14260. /**
  14261. * Gets the class name of the effect layer
  14262. * @returns the string with the class name of the effect layer
  14263. */
  14264. getClassName(): string;
  14265. /**
  14266. * Creates an effect layer from parsed effect layer data
  14267. * @param parsedEffectLayer defines effect layer data
  14268. * @param scene defines the current scene
  14269. * @param rootUrl defines the root URL containing the effect layer information
  14270. * @returns a parsed effect Layer
  14271. */
  14272. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14273. }
  14274. }
  14275. declare module BABYLON {
  14276. interface AbstractScene {
  14277. /**
  14278. * The list of effect layers (highlights/glow) added to the scene
  14279. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14280. * @see http://doc.babylonjs.com/how_to/glow_layer
  14281. */
  14282. effectLayers: Array<EffectLayer>;
  14283. /**
  14284. * Removes the given effect layer from this scene.
  14285. * @param toRemove defines the effect layer to remove
  14286. * @returns the index of the removed effect layer
  14287. */
  14288. removeEffectLayer(toRemove: EffectLayer): number;
  14289. /**
  14290. * Adds the given effect layer to this scene
  14291. * @param newEffectLayer defines the effect layer to add
  14292. */
  14293. addEffectLayer(newEffectLayer: EffectLayer): void;
  14294. }
  14295. /**
  14296. * Defines the layer scene component responsible to manage any effect layers
  14297. * in a given scene.
  14298. */
  14299. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14300. /**
  14301. * The component name helpfull to identify the component in the list of scene components.
  14302. */
  14303. readonly name: string;
  14304. /**
  14305. * The scene the component belongs to.
  14306. */
  14307. scene: Scene;
  14308. private _engine;
  14309. private _renderEffects;
  14310. private _needStencil;
  14311. private _previousStencilState;
  14312. /**
  14313. * Creates a new instance of the component for the given scene
  14314. * @param scene Defines the scene to register the component in
  14315. */
  14316. constructor(scene: Scene);
  14317. /**
  14318. * Registers the component in a given scene
  14319. */
  14320. register(): void;
  14321. /**
  14322. * Rebuilds the elements related to this component in case of
  14323. * context lost for instance.
  14324. */
  14325. rebuild(): void;
  14326. /**
  14327. * Serializes the component data to the specified json object
  14328. * @param serializationObject The object to serialize to
  14329. */
  14330. serialize(serializationObject: any): void;
  14331. /**
  14332. * Adds all the element from the container to the scene
  14333. * @param container the container holding the elements
  14334. */
  14335. addFromContainer(container: AbstractScene): void;
  14336. /**
  14337. * Removes all the elements in the container from the scene
  14338. * @param container contains the elements to remove
  14339. */
  14340. removeFromContainer(container: AbstractScene): void;
  14341. /**
  14342. * Disposes the component and the associated ressources.
  14343. */
  14344. dispose(): void;
  14345. private _isReadyForMesh;
  14346. private _renderMainTexture;
  14347. private _setStencil;
  14348. private _setStencilBack;
  14349. private _draw;
  14350. private _drawCamera;
  14351. private _drawRenderingGroup;
  14352. }
  14353. }
  14354. declare module BABYLON {
  14355. interface AbstractScene {
  14356. /**
  14357. * Return a the first highlight layer of the scene with a given name.
  14358. * @param name The name of the highlight layer to look for.
  14359. * @return The highlight layer if found otherwise null.
  14360. */
  14361. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14362. }
  14363. /**
  14364. * Glow layer options. This helps customizing the behaviour
  14365. * of the glow layer.
  14366. */
  14367. interface IGlowLayerOptions {
  14368. /**
  14369. * Multiplication factor apply to the canvas size to compute the render target size
  14370. * used to generated the glowing objects (the smaller the faster).
  14371. */
  14372. mainTextureRatio: number;
  14373. /**
  14374. * Enforces a fixed size texture to ensure resize independant blur.
  14375. */
  14376. mainTextureFixedSize?: number;
  14377. /**
  14378. * How big is the kernel of the blur texture.
  14379. */
  14380. blurKernelSize: number;
  14381. /**
  14382. * The camera attached to the layer.
  14383. */
  14384. camera: Nullable<Camera>;
  14385. /**
  14386. * Enable MSAA by chosing the number of samples.
  14387. */
  14388. mainTextureSamples?: number;
  14389. /**
  14390. * The rendering group to draw the layer in.
  14391. */
  14392. renderingGroupId: number;
  14393. }
  14394. /**
  14395. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14396. *
  14397. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14398. * glowy meshes to your scene.
  14399. *
  14400. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14401. */
  14402. class GlowLayer extends EffectLayer {
  14403. /**
  14404. * Effect Name of the layer.
  14405. */
  14406. static readonly EffectName: string;
  14407. /**
  14408. * The default blur kernel size used for the glow.
  14409. */
  14410. static DefaultBlurKernelSize: number;
  14411. /**
  14412. * The default texture size ratio used for the glow.
  14413. */
  14414. static DefaultTextureRatio: number;
  14415. /**
  14416. * Sets the kernel size of the blur.
  14417. */
  14418. /**
  14419. * Gets the kernel size of the blur.
  14420. */
  14421. blurKernelSize: number;
  14422. /**
  14423. * Sets the glow intensity.
  14424. */
  14425. /**
  14426. * Gets the glow intensity.
  14427. */
  14428. intensity: number;
  14429. private _options;
  14430. private _intensity;
  14431. private _horizontalBlurPostprocess1;
  14432. private _verticalBlurPostprocess1;
  14433. private _horizontalBlurPostprocess2;
  14434. private _verticalBlurPostprocess2;
  14435. private _blurTexture1;
  14436. private _blurTexture2;
  14437. private _postProcesses1;
  14438. private _postProcesses2;
  14439. private _includedOnlyMeshes;
  14440. private _excludedMeshes;
  14441. /**
  14442. * Callback used to let the user override the color selection on a per mesh basis
  14443. */
  14444. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14445. /**
  14446. * Callback used to let the user override the texture selection on a per mesh basis
  14447. */
  14448. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14449. /**
  14450. * Instantiates a new glow Layer and references it to the scene.
  14451. * @param name The name of the layer
  14452. * @param scene The scene to use the layer in
  14453. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14454. */
  14455. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14456. /**
  14457. * Get the effect name of the layer.
  14458. * @return The effect name
  14459. */
  14460. getEffectName(): string;
  14461. /**
  14462. * Create the merge effect. This is the shader use to blit the information back
  14463. * to the main canvas at the end of the scene rendering.
  14464. */
  14465. protected _createMergeEffect(): Effect;
  14466. /**
  14467. * Creates the render target textures and post processes used in the glow layer.
  14468. */
  14469. protected _createTextureAndPostProcesses(): void;
  14470. /**
  14471. * Checks for the readiness of the element composing the layer.
  14472. * @param subMesh the mesh to check for
  14473. * @param useInstances specify wether or not to use instances to render the mesh
  14474. * @param emissiveTexture the associated emissive texture used to generate the glow
  14475. * @return true if ready otherwise, false
  14476. */
  14477. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14478. /**
  14479. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14480. */
  14481. needStencil(): boolean;
  14482. /**
  14483. * Implementation specific of rendering the generating effect on the main canvas.
  14484. * @param effect The effect used to render through
  14485. */
  14486. protected _internalRender(effect: Effect): void;
  14487. /**
  14488. * Sets the required values for both the emissive texture and and the main color.
  14489. */
  14490. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14491. /**
  14492. * Returns true if the mesh should render, otherwise false.
  14493. * @param mesh The mesh to render
  14494. * @returns true if it should render otherwise false
  14495. */
  14496. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14497. /**
  14498. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14499. * @param mesh The mesh to exclude from the glow layer
  14500. */
  14501. addExcludedMesh(mesh: Mesh): void;
  14502. /**
  14503. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14504. * @param mesh The mesh to remove
  14505. */
  14506. removeExcludedMesh(mesh: Mesh): void;
  14507. /**
  14508. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14509. * @param mesh The mesh to include in the glow layer
  14510. */
  14511. addIncludedOnlyMesh(mesh: Mesh): void;
  14512. /**
  14513. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14514. * @param mesh The mesh to remove
  14515. */
  14516. removeIncludedOnlyMesh(mesh: Mesh): void;
  14517. /**
  14518. * Determine if a given mesh will be used in the glow layer
  14519. * @param mesh The mesh to test
  14520. * @returns true if the mesh will be highlighted by the current glow layer
  14521. */
  14522. hasMesh(mesh: AbstractMesh): boolean;
  14523. /**
  14524. * Free any resources and references associated to a mesh.
  14525. * Internal use
  14526. * @param mesh The mesh to free.
  14527. * @hidden
  14528. */
  14529. _disposeMesh(mesh: Mesh): void;
  14530. /**
  14531. * Gets the class name of the effect layer
  14532. * @returns the string with the class name of the effect layer
  14533. */
  14534. getClassName(): string;
  14535. /**
  14536. * Serializes this glow layer
  14537. * @returns a serialized glow layer object
  14538. */
  14539. serialize(): any;
  14540. /**
  14541. * Creates a Glow Layer from parsed glow layer data
  14542. * @param parsedGlowLayer defines glow layer data
  14543. * @param scene defines the current scene
  14544. * @param rootUrl defines the root URL containing the glow layer information
  14545. * @returns a parsed Glow Layer
  14546. */
  14547. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14548. }
  14549. }
  14550. declare module BABYLON {
  14551. interface AbstractScene {
  14552. /**
  14553. * Return a the first highlight layer of the scene with a given name.
  14554. * @param name The name of the highlight layer to look for.
  14555. * @return The highlight layer if found otherwise null.
  14556. */
  14557. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14558. }
  14559. /**
  14560. * Highlight layer options. This helps customizing the behaviour
  14561. * of the highlight layer.
  14562. */
  14563. interface IHighlightLayerOptions {
  14564. /**
  14565. * Multiplication factor apply to the canvas size to compute the render target size
  14566. * used to generated the glowing objects (the smaller the faster).
  14567. */
  14568. mainTextureRatio: number;
  14569. /**
  14570. * Enforces a fixed size texture to ensure resize independant blur.
  14571. */
  14572. mainTextureFixedSize?: number;
  14573. /**
  14574. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14575. * of the picture to blur (the smaller the faster).
  14576. */
  14577. blurTextureSizeRatio: number;
  14578. /**
  14579. * How big in texel of the blur texture is the vertical blur.
  14580. */
  14581. blurVerticalSize: number;
  14582. /**
  14583. * How big in texel of the blur texture is the horizontal blur.
  14584. */
  14585. blurHorizontalSize: number;
  14586. /**
  14587. * Alpha blending mode used to apply the blur. Default is combine.
  14588. */
  14589. alphaBlendingMode: number;
  14590. /**
  14591. * The camera attached to the layer.
  14592. */
  14593. camera: Nullable<Camera>;
  14594. /**
  14595. * Should we display highlight as a solid stroke?
  14596. */
  14597. isStroke?: boolean;
  14598. /**
  14599. * The rendering group to draw the layer in.
  14600. */
  14601. renderingGroupId: number;
  14602. }
  14603. /**
  14604. * The highlight layer Helps adding a glow effect around a mesh.
  14605. *
  14606. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14607. * glowy meshes to your scene.
  14608. *
  14609. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14610. */
  14611. class HighlightLayer extends EffectLayer {
  14612. name: string;
  14613. /**
  14614. * Effect Name of the highlight layer.
  14615. */
  14616. static readonly EffectName: string;
  14617. /**
  14618. * The neutral color used during the preparation of the glow effect.
  14619. * This is black by default as the blend operation is a blend operation.
  14620. */
  14621. static NeutralColor: Color4;
  14622. /**
  14623. * Stencil value used for glowing meshes.
  14624. */
  14625. static GlowingMeshStencilReference: number;
  14626. /**
  14627. * Stencil value used for the other meshes in the scene.
  14628. */
  14629. static NormalMeshStencilReference: number;
  14630. /**
  14631. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14632. */
  14633. innerGlow: boolean;
  14634. /**
  14635. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14636. */
  14637. outerGlow: boolean;
  14638. /**
  14639. * Specifies the horizontal size of the blur.
  14640. */
  14641. /**
  14642. * Gets the horizontal size of the blur.
  14643. */
  14644. blurHorizontalSize: number;
  14645. /**
  14646. * Specifies the vertical size of the blur.
  14647. */
  14648. /**
  14649. * Gets the vertical size of the blur.
  14650. */
  14651. blurVerticalSize: number;
  14652. /**
  14653. * An event triggered when the highlight layer is being blurred.
  14654. */
  14655. onBeforeBlurObservable: Observable<HighlightLayer>;
  14656. /**
  14657. * An event triggered when the highlight layer has been blurred.
  14658. */
  14659. onAfterBlurObservable: Observable<HighlightLayer>;
  14660. private _instanceGlowingMeshStencilReference;
  14661. private _options;
  14662. private _downSamplePostprocess;
  14663. private _horizontalBlurPostprocess;
  14664. private _verticalBlurPostprocess;
  14665. private _blurTexture;
  14666. private _meshes;
  14667. private _excludedMeshes;
  14668. /**
  14669. * Instantiates a new highlight Layer and references it to the scene..
  14670. * @param name The name of the layer
  14671. * @param scene The scene to use the layer in
  14672. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14673. */
  14674. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14675. /**
  14676. * Get the effect name of the layer.
  14677. * @return The effect name
  14678. */
  14679. getEffectName(): string;
  14680. /**
  14681. * Create the merge effect. This is the shader use to blit the information back
  14682. * to the main canvas at the end of the scene rendering.
  14683. */
  14684. protected _createMergeEffect(): Effect;
  14685. /**
  14686. * Creates the render target textures and post processes used in the highlight layer.
  14687. */
  14688. protected _createTextureAndPostProcesses(): void;
  14689. /**
  14690. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14691. */
  14692. needStencil(): boolean;
  14693. /**
  14694. * Checks for the readiness of the element composing the layer.
  14695. * @param subMesh the mesh to check for
  14696. * @param useInstances specify wether or not to use instances to render the mesh
  14697. * @param emissiveTexture the associated emissive texture used to generate the glow
  14698. * @return true if ready otherwise, false
  14699. */
  14700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14701. /**
  14702. * Implementation specific of rendering the generating effect on the main canvas.
  14703. * @param effect The effect used to render through
  14704. */
  14705. protected _internalRender(effect: Effect): void;
  14706. /**
  14707. * Returns true if the layer contains information to display, otherwise false.
  14708. */
  14709. shouldRender(): boolean;
  14710. /**
  14711. * Returns true if the mesh should render, otherwise false.
  14712. * @param mesh The mesh to render
  14713. * @returns true if it should render otherwise false
  14714. */
  14715. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14716. /**
  14717. * Sets the required values for both the emissive texture and and the main color.
  14718. */
  14719. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14720. /**
  14721. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14722. * @param mesh The mesh to exclude from the highlight layer
  14723. */
  14724. addExcludedMesh(mesh: Mesh): void;
  14725. /**
  14726. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14727. * @param mesh The mesh to highlight
  14728. */
  14729. removeExcludedMesh(mesh: Mesh): void;
  14730. /**
  14731. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14732. * @param mesh mesh to test
  14733. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14734. */
  14735. hasMesh(mesh: AbstractMesh): boolean;
  14736. /**
  14737. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14738. * @param mesh The mesh to highlight
  14739. * @param color The color of the highlight
  14740. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14741. */
  14742. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14743. /**
  14744. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14745. * @param mesh The mesh to highlight
  14746. */
  14747. removeMesh(mesh: Mesh): void;
  14748. /**
  14749. * Force the stencil to the normal expected value for none glowing parts
  14750. */
  14751. private _defaultStencilReference;
  14752. /**
  14753. * Free any resources and references associated to a mesh.
  14754. * Internal use
  14755. * @param mesh The mesh to free.
  14756. * @hidden
  14757. */
  14758. _disposeMesh(mesh: Mesh): void;
  14759. /**
  14760. * Dispose the highlight layer and free resources.
  14761. */
  14762. dispose(): void;
  14763. /**
  14764. * Gets the class name of the effect layer
  14765. * @returns the string with the class name of the effect layer
  14766. */
  14767. getClassName(): string;
  14768. /**
  14769. * Serializes this Highlight layer
  14770. * @returns a serialized Highlight layer object
  14771. */
  14772. serialize(): any;
  14773. /**
  14774. * Creates a Highlight layer from parsed Highlight layer data
  14775. * @param parsedHightlightLayer defines the Highlight layer data
  14776. * @param scene defines the current scene
  14777. * @param rootUrl defines the root URL containing the Highlight layer information
  14778. * @returns a parsed Highlight layer
  14779. */
  14780. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14781. }
  14782. }
  14783. declare module BABYLON {
  14784. /**
  14785. * This represents a full screen 2d layer.
  14786. * This can be usefull to display a picture in the background of your scene for instance.
  14787. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14788. */
  14789. class Layer {
  14790. /**
  14791. * Define the name of the layer.
  14792. */
  14793. name: string;
  14794. /**
  14795. * Define the texture the layer should display.
  14796. */
  14797. texture: Nullable<Texture>;
  14798. /**
  14799. * Is the layer in background or foreground.
  14800. */
  14801. isBackground: boolean;
  14802. /**
  14803. * Define the color of the layer (instead of texture).
  14804. */
  14805. color: Color4;
  14806. /**
  14807. * Define the scale of the layer in order to zoom in out of the texture.
  14808. */
  14809. scale: Vector2;
  14810. /**
  14811. * Define an offset for the layer in order to shift the texture.
  14812. */
  14813. offset: Vector2;
  14814. /**
  14815. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14816. */
  14817. alphaBlendingMode: number;
  14818. /**
  14819. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14820. * Alpha test will not mix with the background color in case of transparency.
  14821. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14822. */
  14823. alphaTest: boolean;
  14824. /**
  14825. * Define a mask to restrict the layer to only some of the scene cameras.
  14826. */
  14827. layerMask: number;
  14828. private _scene;
  14829. private _vertexBuffers;
  14830. private _indexBuffer;
  14831. private _effect;
  14832. private _alphaTestEffect;
  14833. /**
  14834. * An event triggered when the layer is disposed.
  14835. */
  14836. onDisposeObservable: Observable<Layer>;
  14837. private _onDisposeObserver;
  14838. /**
  14839. * Back compatibility with callback before the onDisposeObservable existed.
  14840. * The set callback will be triggered when the layer has been disposed.
  14841. */
  14842. onDispose: () => void;
  14843. /**
  14844. * An event triggered before rendering the scene
  14845. */
  14846. onBeforeRenderObservable: Observable<Layer>;
  14847. private _onBeforeRenderObserver;
  14848. /**
  14849. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14850. * The set callback will be triggered just before rendering the layer.
  14851. */
  14852. onBeforeRender: () => void;
  14853. /**
  14854. * An event triggered after rendering the scene
  14855. */
  14856. onAfterRenderObservable: Observable<Layer>;
  14857. private _onAfterRenderObserver;
  14858. /**
  14859. * Back compatibility with callback before the onAfterRenderObservable existed.
  14860. * The set callback will be triggered just after rendering the layer.
  14861. */
  14862. onAfterRender: () => void;
  14863. /**
  14864. * Instantiates a new layer.
  14865. * This represents a full screen 2d layer.
  14866. * This can be usefull to display a picture in the background of your scene for instance.
  14867. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14868. * @param name Define the name of the layer in the scene
  14869. * @param imgUrl Define the url of the texture to display in the layer
  14870. * @param scene Define the scene the layer belongs to
  14871. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14872. * @param color Defines a color for the layer
  14873. */
  14874. constructor(
  14875. /**
  14876. * Define the name of the layer.
  14877. */
  14878. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14879. private _createIndexBuffer;
  14880. /** @hidden */
  14881. _rebuild(): void;
  14882. /**
  14883. * Renders the layer in the scene.
  14884. */
  14885. render(): void;
  14886. /**
  14887. * Disposes and releases the associated ressources.
  14888. */
  14889. dispose(): void;
  14890. }
  14891. }
  14892. declare module BABYLON {
  14893. interface AbstractScene {
  14894. /**
  14895. * The list of layers (background and foreground) of the scene
  14896. */
  14897. layers: Array<Layer>;
  14898. }
  14899. /**
  14900. * Defines the layer scene component responsible to manage any layers
  14901. * in a given scene.
  14902. */
  14903. class LayerSceneComponent implements ISceneComponent {
  14904. /**
  14905. * The component name helpfull to identify the component in the list of scene components.
  14906. */
  14907. readonly name: string;
  14908. /**
  14909. * The scene the component belongs to.
  14910. */
  14911. scene: Scene;
  14912. private _engine;
  14913. /**
  14914. * Creates a new instance of the component for the given scene
  14915. * @param scene Defines the scene to register the component in
  14916. */
  14917. constructor(scene: Scene);
  14918. /**
  14919. * Registers the component in a given scene
  14920. */
  14921. register(): void;
  14922. /**
  14923. * Rebuilds the elements related to this component in case of
  14924. * context lost for instance.
  14925. */
  14926. rebuild(): void;
  14927. /**
  14928. * Disposes the component and the associated ressources.
  14929. */
  14930. dispose(): void;
  14931. private _draw;
  14932. private _drawBackground;
  14933. private _drawForeground;
  14934. }
  14935. }
  14936. declare module BABYLON {
  14937. /**
  14938. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14939. * It controls one of the indiviual texture used in the effect.
  14940. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14941. */
  14942. class LensFlare {
  14943. /**
  14944. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14945. */
  14946. size: number;
  14947. /**
  14948. * 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.
  14949. */
  14950. position: number;
  14951. /**
  14952. * Define the lens color.
  14953. */
  14954. color: Color3;
  14955. /**
  14956. * Define the lens texture.
  14957. */
  14958. texture: Nullable<Texture>;
  14959. /**
  14960. * Define the alpha mode to render this particular lens.
  14961. */
  14962. alphaMode: number;
  14963. private _system;
  14964. /**
  14965. * Creates a new Lens Flare.
  14966. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14967. * It controls one of the indiviual texture used in the effect.
  14968. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14969. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14970. * @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.
  14971. * @param color Define the lens color
  14972. * @param imgUrl Define the lens texture url
  14973. * @param system Define the `lensFlareSystem` this flare is part of
  14974. * @returns The newly created Lens Flare
  14975. */
  14976. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14977. /**
  14978. * Instantiates a new Lens Flare.
  14979. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14980. * It controls one of the indiviual texture used in the effect.
  14981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14982. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14983. * @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.
  14984. * @param color Define the lens color
  14985. * @param imgUrl Define the lens texture url
  14986. * @param system Define the `lensFlareSystem` this flare is part of
  14987. */
  14988. constructor(
  14989. /**
  14990. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14991. */
  14992. size: number,
  14993. /**
  14994. * 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. */
  14996. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14997. /**
  14998. * Dispose and release the lens flare with its associated resources.
  14999. */
  15000. dispose(): void;
  15001. }
  15002. }
  15003. declare module BABYLON {
  15004. /**
  15005. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15006. * It is usually composed of several `BABYLON.lensFlare`.
  15007. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15008. */
  15009. class LensFlareSystem {
  15010. /**
  15011. * Define the name of the lens flare system
  15012. */
  15013. name: string;
  15014. /**
  15015. * List of lens flares used in this system.
  15016. */
  15017. lensFlares: LensFlare[];
  15018. /**
  15019. * Define a limit from the border the lens flare can be visible.
  15020. */
  15021. borderLimit: number;
  15022. /**
  15023. * Define a viewport border we do not want to see the lens flare in.
  15024. */
  15025. viewportBorder: number;
  15026. /**
  15027. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15028. */
  15029. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15030. /**
  15031. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15032. */
  15033. layerMask: number;
  15034. /**
  15035. * Define the id of the lens flare system in the scene.
  15036. * (equal to name by default)
  15037. */
  15038. id: string;
  15039. private _scene;
  15040. private _emitter;
  15041. private _vertexBuffers;
  15042. private _indexBuffer;
  15043. private _effect;
  15044. private _positionX;
  15045. private _positionY;
  15046. private _isEnabled;
  15047. /**
  15048. * Instantiates a lens flare system.
  15049. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15050. * It is usually composed of several `BABYLON.lensFlare`.
  15051. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15052. * @param name Define the name of the lens flare system in the scene
  15053. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15054. * @param scene Define the scene the lens flare system belongs to
  15055. */
  15056. constructor(
  15057. /**
  15058. * Define the name of the lens flare system
  15059. */
  15060. name: string, emitter: any, scene: Scene);
  15061. /**
  15062. * Define if the lens flare system is enabled.
  15063. */
  15064. isEnabled: boolean;
  15065. /**
  15066. * Get the scene the effects belongs to.
  15067. * @returns the scene holding the lens flare system
  15068. */
  15069. getScene(): Scene;
  15070. /**
  15071. * Get the emitter of the lens flare system.
  15072. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15073. * @returns the emitter of the lens flare system
  15074. */
  15075. getEmitter(): any;
  15076. /**
  15077. * Set the emitter of the lens flare system.
  15078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15079. * @param newEmitter Define the new emitter of the system
  15080. */
  15081. setEmitter(newEmitter: any): void;
  15082. /**
  15083. * Get the lens flare system emitter position.
  15084. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15085. * @returns the position
  15086. */
  15087. getEmitterPosition(): Vector3;
  15088. /**
  15089. * @hidden
  15090. */
  15091. computeEffectivePosition(globalViewport: Viewport): boolean;
  15092. /** @hidden */
  15093. _isVisible(): boolean;
  15094. /**
  15095. * @hidden
  15096. */
  15097. render(): boolean;
  15098. /**
  15099. * Dispose and release the lens flare with its associated resources.
  15100. */
  15101. dispose(): void;
  15102. /**
  15103. * Parse a lens flare system from a JSON repressentation
  15104. * @param parsedLensFlareSystem Define the JSON to parse
  15105. * @param scene Define the scene the parsed system should be instantiated in
  15106. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15107. * @returns the parsed system
  15108. */
  15109. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15110. /**
  15111. * Serialize the current Lens Flare System into a JSON representation.
  15112. * @returns the serialized JSON
  15113. */
  15114. serialize(): any;
  15115. }
  15116. }
  15117. declare module BABYLON {
  15118. interface AbstractScene {
  15119. /**
  15120. * The list of lens flare system added to the scene
  15121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15122. */
  15123. lensFlareSystems: Array<LensFlareSystem>;
  15124. /**
  15125. * Removes the given lens flare system from this scene.
  15126. * @param toRemove The lens flare system to remove
  15127. * @returns The index of the removed lens flare system
  15128. */
  15129. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15130. /**
  15131. * Adds the given lens flare system to this scene
  15132. * @param newLensFlareSystem The lens flare system to add
  15133. */
  15134. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15135. /**
  15136. * Gets a lens flare system using its name
  15137. * @param name defines the name to look for
  15138. * @returns the lens flare system or null if not found
  15139. */
  15140. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15141. /**
  15142. * Gets a lens flare system using its id
  15143. * @param id defines the id to look for
  15144. * @returns the lens flare system or null if not found
  15145. */
  15146. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15147. }
  15148. /**
  15149. * Defines the lens flare scene component responsible to manage any lens flares
  15150. * in a given scene.
  15151. */
  15152. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15153. /**
  15154. * The component name helpfull to identify the component in the list of scene components.
  15155. */
  15156. readonly name: string;
  15157. /**
  15158. * The scene the component belongs to.
  15159. */
  15160. scene: Scene;
  15161. /**
  15162. * Creates a new instance of the component for the given scene
  15163. * @param scene Defines the scene to register the component in
  15164. */
  15165. constructor(scene: Scene);
  15166. /**
  15167. * Registers the component in a given scene
  15168. */
  15169. register(): void;
  15170. /**
  15171. * Rebuilds the elements related to this component in case of
  15172. * context lost for instance.
  15173. */
  15174. rebuild(): void;
  15175. /**
  15176. * Adds all the element from the container to the scene
  15177. * @param container the container holding the elements
  15178. */
  15179. addFromContainer(container: AbstractScene): void;
  15180. /**
  15181. * Removes all the elements in the container from the scene
  15182. * @param container contains the elements to remove
  15183. */
  15184. removeFromContainer(container: AbstractScene): void;
  15185. /**
  15186. * Serializes the component data to the specified json object
  15187. * @param serializationObject The object to serialize to
  15188. */
  15189. serialize(serializationObject: any): void;
  15190. /**
  15191. * Disposes the component and the associated ressources.
  15192. */
  15193. dispose(): void;
  15194. private _draw;
  15195. }
  15196. }
  15197. declare module BABYLON {
  15198. /**
  15199. * A directional light is defined by a direction (what a surprise!).
  15200. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15201. * 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.
  15202. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15203. */
  15204. class DirectionalLight extends ShadowLight {
  15205. private _shadowFrustumSize;
  15206. /**
  15207. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15208. */
  15209. /**
  15210. * Specifies a fix frustum size for the shadow generation.
  15211. */
  15212. shadowFrustumSize: number;
  15213. private _shadowOrthoScale;
  15214. /**
  15215. * Gets the shadow projection scale against the optimal computed one.
  15216. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15217. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15218. */
  15219. /**
  15220. * Sets the shadow projection scale against the optimal computed one.
  15221. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15222. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15223. */
  15224. shadowOrthoScale: number;
  15225. /**
  15226. * Automatically compute the projection matrix to best fit (including all the casters)
  15227. * on each frame.
  15228. */
  15229. autoUpdateExtends: boolean;
  15230. private _orthoLeft;
  15231. private _orthoRight;
  15232. private _orthoTop;
  15233. private _orthoBottom;
  15234. /**
  15235. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15236. * The directional light is emitted from everywhere in the given direction.
  15237. * It can cast shadows.
  15238. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15239. * @param name The friendly name of the light
  15240. * @param direction The direction of the light
  15241. * @param scene The scene the light belongs to
  15242. */
  15243. constructor(name: string, direction: Vector3, scene: Scene);
  15244. /**
  15245. * Returns the string "DirectionalLight".
  15246. * @return The class name
  15247. */
  15248. getClassName(): string;
  15249. /**
  15250. * Returns the integer 1.
  15251. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15252. */
  15253. getTypeID(): number;
  15254. /**
  15255. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15256. * Returns the DirectionalLight Shadow projection matrix.
  15257. */
  15258. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15259. /**
  15260. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15261. * Returns the DirectionalLight Shadow projection matrix.
  15262. */
  15263. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15264. /**
  15265. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15266. * Returns the DirectionalLight Shadow projection matrix.
  15267. */
  15268. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15269. protected _buildUniformLayout(): void;
  15270. /**
  15271. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15272. * @param effect The effect to update
  15273. * @param lightIndex The index of the light in the effect to update
  15274. * @returns The directional light
  15275. */
  15276. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15277. /**
  15278. * Gets the minZ used for shadow according to both the scene and the light.
  15279. *
  15280. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15281. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15282. * @param activeCamera The camera we are returning the min for
  15283. * @returns the depth min z
  15284. */
  15285. getDepthMinZ(activeCamera: Camera): number;
  15286. /**
  15287. * Gets the maxZ used for shadow according to both the scene and the light.
  15288. *
  15289. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15290. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15291. * @param activeCamera The camera we are returning the max for
  15292. * @returns the depth max z
  15293. */
  15294. getDepthMaxZ(activeCamera: Camera): number;
  15295. /**
  15296. * Prepares the list of defines specific to the light type.
  15297. * @param defines the list of defines
  15298. * @param lightIndex defines the index of the light for the effect
  15299. */
  15300. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15301. }
  15302. }
  15303. declare module BABYLON {
  15304. /**
  15305. * The HemisphericLight simulates the ambient environment light,
  15306. * so the passed direction is the light reflection direction, not the incoming direction.
  15307. */
  15308. class HemisphericLight extends Light {
  15309. /**
  15310. * The groundColor is the light in the opposite direction to the one specified during creation.
  15311. * 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.
  15312. */
  15313. groundColor: Color3;
  15314. /**
  15315. * The light reflection direction, not the incoming direction.
  15316. */
  15317. direction: Vector3;
  15318. /**
  15319. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15320. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15321. * The HemisphericLight can't cast shadows.
  15322. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15323. * @param name The friendly name of the light
  15324. * @param direction The direction of the light reflection
  15325. * @param scene The scene the light belongs to
  15326. */
  15327. constructor(name: string, direction: Vector3, scene: Scene);
  15328. protected _buildUniformLayout(): void;
  15329. /**
  15330. * Returns the string "HemisphericLight".
  15331. * @return The class name
  15332. */
  15333. getClassName(): string;
  15334. /**
  15335. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15336. * Returns the updated direction.
  15337. * @param target The target the direction should point to
  15338. * @return The computed direction
  15339. */
  15340. setDirectionToTarget(target: Vector3): Vector3;
  15341. /**
  15342. * Returns the shadow generator associated to the light.
  15343. * @returns Always null for hemispheric lights because it does not support shadows.
  15344. */
  15345. getShadowGenerator(): Nullable<IShadowGenerator>;
  15346. /**
  15347. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15348. * @param effect The effect to update
  15349. * @param lightIndex The index of the light in the effect to update
  15350. * @returns The hemispheric light
  15351. */
  15352. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15353. /**
  15354. * Computes the world matrix of the node
  15355. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15356. * @param useWasUpdatedFlag defines a reserved property
  15357. * @returns the world matrix
  15358. */
  15359. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15360. /**
  15361. * Returns the integer 3.
  15362. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15363. */
  15364. getTypeID(): number;
  15365. /**
  15366. * Prepares the list of defines specific to the light type.
  15367. * @param defines the list of defines
  15368. * @param lightIndex defines the index of the light for the effect
  15369. */
  15370. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15371. }
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15376. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15377. * 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.
  15378. */
  15379. abstract class Light extends Node {
  15380. /**
  15381. * Falloff Default: light is falling off following the material specification:
  15382. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15383. */
  15384. static readonly FALLOFF_DEFAULT: number;
  15385. /**
  15386. * Falloff Physical: light is falling off following the inverse squared distance law.
  15387. */
  15388. static readonly FALLOFF_PHYSICAL: number;
  15389. /**
  15390. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15391. * to enhance interoperability with other engines.
  15392. */
  15393. static readonly FALLOFF_GLTF: number;
  15394. /**
  15395. * Falloff Standard: light is falling off like in the standard material
  15396. * to enhance interoperability with other materials.
  15397. */
  15398. static readonly FALLOFF_STANDARD: number;
  15399. /**
  15400. * If every light affecting the material is in this lightmapMode,
  15401. * material.lightmapTexture adds or multiplies
  15402. * (depends on material.useLightmapAsShadowmap)
  15403. * after every other light calculations.
  15404. */
  15405. static readonly LIGHTMAP_DEFAULT: number;
  15406. /**
  15407. * material.lightmapTexture as only diffuse lighting from this light
  15408. * adds only specular lighting from this light
  15409. * adds dynamic shadows
  15410. */
  15411. static readonly LIGHTMAP_SPECULAR: number;
  15412. /**
  15413. * material.lightmapTexture as only lighting
  15414. * no light calculation from this light
  15415. * only adds dynamic shadows from this light
  15416. */
  15417. static readonly LIGHTMAP_SHADOWSONLY: number;
  15418. /**
  15419. * Each light type uses the default quantity according to its type:
  15420. * point/spot lights use luminous intensity
  15421. * directional lights use illuminance
  15422. */
  15423. static readonly INTENSITYMODE_AUTOMATIC: number;
  15424. /**
  15425. * lumen (lm)
  15426. */
  15427. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15428. /**
  15429. * candela (lm/sr)
  15430. */
  15431. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15432. /**
  15433. * lux (lm/m^2)
  15434. */
  15435. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15436. /**
  15437. * nit (cd/m^2)
  15438. */
  15439. static readonly INTENSITYMODE_LUMINANCE: number;
  15440. /**
  15441. * Light type const id of the point light.
  15442. */
  15443. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15444. /**
  15445. * Light type const id of the directional light.
  15446. */
  15447. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15448. /**
  15449. * Light type const id of the spot light.
  15450. */
  15451. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15452. /**
  15453. * Light type const id of the hemispheric light.
  15454. */
  15455. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15456. /**
  15457. * Diffuse gives the basic color to an object.
  15458. */
  15459. diffuse: Color3;
  15460. /**
  15461. * Specular produces a highlight color on an object.
  15462. * Note: This is note affecting PBR materials.
  15463. */
  15464. specular: Color3;
  15465. /**
  15466. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15467. * falling off base on range or angle.
  15468. * This can be set to any values in Light.FALLOFF_x.
  15469. *
  15470. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15471. * other types of materials.
  15472. */
  15473. falloffType: number;
  15474. /**
  15475. * Strength of the light.
  15476. * Note: By default it is define in the framework own unit.
  15477. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15478. */
  15479. intensity: number;
  15480. private _range;
  15481. protected _inverseSquaredRange: number;
  15482. /**
  15483. * Defines how far from the source the light is impacting in scene units.
  15484. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15485. */
  15486. /**
  15487. * Defines how far from the source the light is impacting in scene units.
  15488. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15489. */
  15490. range: number;
  15491. /**
  15492. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15493. * of light.
  15494. */
  15495. private _photometricScale;
  15496. private _intensityMode;
  15497. /**
  15498. * Gets the photometric scale used to interpret the intensity.
  15499. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15500. */
  15501. /**
  15502. * Sets the photometric scale used to interpret the intensity.
  15503. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15504. */
  15505. intensityMode: number;
  15506. private _radius;
  15507. /**
  15508. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15509. */
  15510. /**
  15511. * sets the light radius used by PBR Materials to simulate soft area lights.
  15512. */
  15513. radius: number;
  15514. private _renderPriority;
  15515. /**
  15516. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15517. * exceeding the number allowed of the materials.
  15518. */
  15519. renderPriority: number;
  15520. private _shadowEnabled;
  15521. /**
  15522. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15523. * the current shadow generator.
  15524. */
  15525. /**
  15526. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15527. * the current shadow generator.
  15528. */
  15529. shadowEnabled: boolean;
  15530. private _includedOnlyMeshes;
  15531. /**
  15532. * Gets the only meshes impacted by this light.
  15533. */
  15534. /**
  15535. * Sets the only meshes impacted by this light.
  15536. */
  15537. includedOnlyMeshes: AbstractMesh[];
  15538. private _excludedMeshes;
  15539. /**
  15540. * Gets the meshes not impacted by this light.
  15541. */
  15542. /**
  15543. * Sets the meshes not impacted by this light.
  15544. */
  15545. excludedMeshes: AbstractMesh[];
  15546. private _excludeWithLayerMask;
  15547. /**
  15548. * Gets the layer id use to find what meshes are not impacted by the light.
  15549. * Inactive if 0
  15550. */
  15551. /**
  15552. * Sets the layer id use to find what meshes are not impacted by the light.
  15553. * Inactive if 0
  15554. */
  15555. excludeWithLayerMask: number;
  15556. private _includeOnlyWithLayerMask;
  15557. /**
  15558. * Gets the layer id use to find what meshes are impacted by the light.
  15559. * Inactive if 0
  15560. */
  15561. /**
  15562. * Sets the layer id use to find what meshes are impacted by the light.
  15563. * Inactive if 0
  15564. */
  15565. includeOnlyWithLayerMask: number;
  15566. private _lightmapMode;
  15567. /**
  15568. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15569. */
  15570. /**
  15571. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15572. */
  15573. lightmapMode: number;
  15574. /**
  15575. * Shadow generator associted to the light.
  15576. * @hidden Internal use only.
  15577. */
  15578. _shadowGenerator: Nullable<IShadowGenerator>;
  15579. /**
  15580. * @hidden Internal use only.
  15581. */
  15582. _excludedMeshesIds: string[];
  15583. /**
  15584. * @hidden Internal use only.
  15585. */
  15586. _includedOnlyMeshesIds: string[];
  15587. /**
  15588. * The current light unifom buffer.
  15589. * @hidden Internal use only.
  15590. */
  15591. _uniformBuffer: UniformBuffer;
  15592. /**
  15593. * Creates a Light object in the scene.
  15594. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15595. * @param name The firendly name of the light
  15596. * @param scene The scene the light belongs too
  15597. */
  15598. constructor(name: string, scene: Scene);
  15599. protected abstract _buildUniformLayout(): void;
  15600. /**
  15601. * Sets the passed Effect "effect" with the Light information.
  15602. * @param effect The effect to update
  15603. * @param lightIndex The index of the light in the effect to update
  15604. * @returns The light
  15605. */
  15606. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15607. /**
  15608. * Returns the string "Light".
  15609. * @returns the class name
  15610. */
  15611. getClassName(): string;
  15612. /**
  15613. * Converts the light information to a readable string for debug purpose.
  15614. * @param fullDetails Supports for multiple levels of logging within scene loading
  15615. * @returns the human readable light info
  15616. */
  15617. toString(fullDetails?: boolean): string;
  15618. /** @hidden */
  15619. protected _syncParentEnabledState(): void;
  15620. /**
  15621. * Set the enabled state of this node.
  15622. * @param value - the new enabled state
  15623. */
  15624. setEnabled(value: boolean): void;
  15625. /**
  15626. * Returns the Light associated shadow generator if any.
  15627. * @return the associated shadow generator.
  15628. */
  15629. getShadowGenerator(): Nullable<IShadowGenerator>;
  15630. /**
  15631. * Returns a Vector3, the absolute light position in the World.
  15632. * @returns the world space position of the light
  15633. */
  15634. getAbsolutePosition(): Vector3;
  15635. /**
  15636. * Specifies if the light will affect the passed mesh.
  15637. * @param mesh The mesh to test against the light
  15638. * @return true the mesh is affected otherwise, false.
  15639. */
  15640. canAffectMesh(mesh: AbstractMesh): boolean;
  15641. /**
  15642. * Sort function to order lights for rendering.
  15643. * @param a First Light object to compare to second.
  15644. * @param b Second Light object to compare first.
  15645. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15646. */
  15647. static CompareLightsPriority(a: Light, b: Light): number;
  15648. /**
  15649. * Releases resources associated with this node.
  15650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15652. */
  15653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15654. /**
  15655. * Returns the light type ID (integer).
  15656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15657. */
  15658. getTypeID(): number;
  15659. /**
  15660. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15661. * @returns the scaled intensity in intensity mode unit
  15662. */
  15663. getScaledIntensity(): number;
  15664. /**
  15665. * Returns a new Light object, named "name", from the current one.
  15666. * @param name The name of the cloned light
  15667. * @returns the new created light
  15668. */
  15669. clone(name: string): Nullable<Light>;
  15670. /**
  15671. * Serializes the current light into a Serialization object.
  15672. * @returns the serialized object.
  15673. */
  15674. serialize(): any;
  15675. /**
  15676. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15677. * This new light is named "name" and added to the passed scene.
  15678. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15679. * @param name The friendly name of the light
  15680. * @param scene The scene the new light will belong to
  15681. * @returns the constructor function
  15682. */
  15683. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15684. /**
  15685. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15686. * @param parsedLight The JSON representation of the light
  15687. * @param scene The scene to create the parsed light in
  15688. * @returns the created light after parsing
  15689. */
  15690. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15691. private _hookArrayForExcluded;
  15692. private _hookArrayForIncludedOnly;
  15693. private _resyncMeshes;
  15694. /**
  15695. * Forces the meshes to update their light related information in their rendering used effects
  15696. * @hidden Internal Use Only
  15697. */
  15698. _markMeshesAsLightDirty(): void;
  15699. /**
  15700. * Recomputes the cached photometric scale if needed.
  15701. */
  15702. private _computePhotometricScale;
  15703. /**
  15704. * Returns the Photometric Scale according to the light type and intensity mode.
  15705. */
  15706. private _getPhotometricScale;
  15707. /**
  15708. * Reorder the light in the scene according to their defined priority.
  15709. * @hidden Internal Use Only
  15710. */
  15711. _reorderLightsInScene(): void;
  15712. /**
  15713. * Prepares the list of defines specific to the light type.
  15714. * @param defines the list of defines
  15715. * @param lightIndex defines the index of the light for the effect
  15716. */
  15717. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15718. }
  15719. }
  15720. declare module BABYLON {
  15721. /**
  15722. * A point light is a light defined by an unique point in world space.
  15723. * The light is emitted in every direction from this point.
  15724. * A good example of a point light is a standard light bulb.
  15725. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15726. */
  15727. class PointLight extends ShadowLight {
  15728. private _shadowAngle;
  15729. /**
  15730. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15731. * This specifies what angle the shadow will use to be created.
  15732. *
  15733. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15734. */
  15735. /**
  15736. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15737. * This specifies what angle the shadow will use to be created.
  15738. *
  15739. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15740. */
  15741. shadowAngle: number;
  15742. /**
  15743. * Gets the direction if it has been set.
  15744. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15745. */
  15746. /**
  15747. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15748. */
  15749. direction: Vector3;
  15750. /**
  15751. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15752. * A PointLight emits the light in every direction.
  15753. * It can cast shadows.
  15754. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15755. * ```javascript
  15756. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15757. * ```
  15758. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15759. * @param name The light friendly name
  15760. * @param position The position of the point light in the scene
  15761. * @param scene The scene the lights belongs to
  15762. */
  15763. constructor(name: string, position: Vector3, scene: Scene);
  15764. /**
  15765. * Returns the string "PointLight"
  15766. * @returns the class name
  15767. */
  15768. getClassName(): string;
  15769. /**
  15770. * Returns the integer 0.
  15771. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15772. */
  15773. getTypeID(): number;
  15774. /**
  15775. * Specifies wether or not the shadowmap should be a cube texture.
  15776. * @returns true if the shadowmap needs to be a cube texture.
  15777. */
  15778. needCube(): boolean;
  15779. /**
  15780. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15781. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15782. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15783. */
  15784. getShadowDirection(faceIndex?: number): Vector3;
  15785. /**
  15786. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15787. * - fov = PI / 2
  15788. * - aspect ratio : 1.0
  15789. * - z-near and far equal to the active camera minZ and maxZ.
  15790. * Returns the PointLight.
  15791. */
  15792. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15793. protected _buildUniformLayout(): void;
  15794. /**
  15795. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15796. * @param effect The effect to update
  15797. * @param lightIndex The index of the light in the effect to update
  15798. * @returns The point light
  15799. */
  15800. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15801. /**
  15802. * Prepares the list of defines specific to the light type.
  15803. * @param defines the list of defines
  15804. * @param lightIndex defines the index of the light for the effect
  15805. */
  15806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15807. }
  15808. }
  15809. declare module BABYLON {
  15810. /**
  15811. * Interface describing all the common properties and methods a shadow light needs to implement.
  15812. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15813. * as well as binding the different shadow properties to the effects.
  15814. */
  15815. interface IShadowLight extends Light {
  15816. /**
  15817. * The light id in the scene (used in scene.findLighById for instance)
  15818. */
  15819. id: string;
  15820. /**
  15821. * The position the shdow will be casted from.
  15822. */
  15823. position: Vector3;
  15824. /**
  15825. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15826. */
  15827. direction: Vector3;
  15828. /**
  15829. * The transformed position. Position of the light in world space taking parenting in account.
  15830. */
  15831. transformedPosition: Vector3;
  15832. /**
  15833. * The transformed direction. Direction of the light in world space taking parenting in account.
  15834. */
  15835. transformedDirection: Vector3;
  15836. /**
  15837. * The friendly name of the light in the scene.
  15838. */
  15839. name: string;
  15840. /**
  15841. * Defines the shadow projection clipping minimum z value.
  15842. */
  15843. shadowMinZ: number;
  15844. /**
  15845. * Defines the shadow projection clipping maximum z value.
  15846. */
  15847. shadowMaxZ: number;
  15848. /**
  15849. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15850. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15851. */
  15852. computeTransformedInformation(): boolean;
  15853. /**
  15854. * Gets the scene the light belongs to.
  15855. * @returns The scene
  15856. */
  15857. getScene(): Scene;
  15858. /**
  15859. * Callback defining a custom Projection Matrix Builder.
  15860. * This can be used to override the default projection matrix computation.
  15861. */
  15862. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15863. /**
  15864. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15865. * @param matrix The materix to updated with the projection information
  15866. * @param viewMatrix The transform matrix of the light
  15867. * @param renderList The list of mesh to render in the map
  15868. * @returns The current light
  15869. */
  15870. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15871. /**
  15872. * Gets the current depth scale used in ESM.
  15873. * @returns The scale
  15874. */
  15875. getDepthScale(): number;
  15876. /**
  15877. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15878. * @returns true if a cube texture needs to be use
  15879. */
  15880. needCube(): boolean;
  15881. /**
  15882. * Detects if the projection matrix requires to be recomputed this frame.
  15883. * @returns true if it requires to be recomputed otherwise, false.
  15884. */
  15885. needProjectionMatrixCompute(): boolean;
  15886. /**
  15887. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15888. */
  15889. forceProjectionMatrixCompute(): void;
  15890. /**
  15891. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15892. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15893. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15894. */
  15895. getShadowDirection(faceIndex?: number): Vector3;
  15896. /**
  15897. * Gets the minZ used for shadow according to both the scene and the light.
  15898. * @param activeCamera The camera we are returning the min for
  15899. * @returns the depth min z
  15900. */
  15901. getDepthMinZ(activeCamera: Camera): number;
  15902. /**
  15903. * Gets the maxZ used for shadow according to both the scene and the light.
  15904. * @param activeCamera The camera we are returning the max for
  15905. * @returns the depth max z
  15906. */
  15907. getDepthMaxZ(activeCamera: Camera): number;
  15908. }
  15909. /**
  15910. * Base implementation IShadowLight
  15911. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15912. */
  15913. abstract class ShadowLight extends Light implements IShadowLight {
  15914. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15915. protected _position: Vector3;
  15916. protected _setPosition(value: Vector3): void;
  15917. /**
  15918. * Sets the position the shadow will be casted from. Also use as the light position for both
  15919. * point and spot lights.
  15920. */
  15921. /**
  15922. * Sets the position the shadow will be casted from. Also use as the light position for both
  15923. * point and spot lights.
  15924. */
  15925. position: Vector3;
  15926. protected _direction: Vector3;
  15927. protected _setDirection(value: Vector3): void;
  15928. /**
  15929. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15930. * Also use as the light direction on spot and directional lights.
  15931. */
  15932. /**
  15933. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15934. * Also use as the light direction on spot and directional lights.
  15935. */
  15936. direction: Vector3;
  15937. private _shadowMinZ;
  15938. /**
  15939. * Gets the shadow projection clipping minimum z value.
  15940. */
  15941. /**
  15942. * Sets the shadow projection clipping minimum z value.
  15943. */
  15944. shadowMinZ: number;
  15945. private _shadowMaxZ;
  15946. /**
  15947. * Sets the shadow projection clipping maximum z value.
  15948. */
  15949. /**
  15950. * Gets the shadow projection clipping maximum z value.
  15951. */
  15952. shadowMaxZ: number;
  15953. /**
  15954. * Callback defining a custom Projection Matrix Builder.
  15955. * This can be used to override the default projection matrix computation.
  15956. */
  15957. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15958. /**
  15959. * The transformed position. Position of the light in world space taking parenting in account.
  15960. */
  15961. transformedPosition: Vector3;
  15962. /**
  15963. * The transformed direction. Direction of the light in world space taking parenting in account.
  15964. */
  15965. transformedDirection: Vector3;
  15966. private _needProjectionMatrixCompute;
  15967. /**
  15968. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15969. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15970. */
  15971. computeTransformedInformation(): boolean;
  15972. /**
  15973. * Return the depth scale used for the shadow map.
  15974. * @returns the depth scale.
  15975. */
  15976. getDepthScale(): number;
  15977. /**
  15978. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15979. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15980. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15981. */
  15982. getShadowDirection(faceIndex?: number): Vector3;
  15983. /**
  15984. * Returns the ShadowLight absolute position in the World.
  15985. * @returns the position vector in world space
  15986. */
  15987. getAbsolutePosition(): Vector3;
  15988. /**
  15989. * Sets the ShadowLight direction toward the passed target.
  15990. * @param target The point tot target in local space
  15991. * @returns the updated ShadowLight direction
  15992. */
  15993. setDirectionToTarget(target: Vector3): Vector3;
  15994. /**
  15995. * Returns the light rotation in euler definition.
  15996. * @returns the x y z rotation in local space.
  15997. */
  15998. getRotation(): Vector3;
  15999. /**
  16000. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16001. * @returns true if a cube texture needs to be use
  16002. */
  16003. needCube(): boolean;
  16004. /**
  16005. * Detects if the projection matrix requires to be recomputed this frame.
  16006. * @returns true if it requires to be recomputed otherwise, false.
  16007. */
  16008. needProjectionMatrixCompute(): boolean;
  16009. /**
  16010. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16011. */
  16012. forceProjectionMatrixCompute(): void;
  16013. /** @hidden */
  16014. _initCache(): void;
  16015. /** @hidden */
  16016. _isSynchronized(): boolean;
  16017. /**
  16018. * Computes the world matrix of the node
  16019. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16020. * @returns the world matrix
  16021. */
  16022. computeWorldMatrix(force?: boolean): Matrix;
  16023. /**
  16024. * Gets the minZ used for shadow according to both the scene and the light.
  16025. * @param activeCamera The camera we are returning the min for
  16026. * @returns the depth min z
  16027. */
  16028. getDepthMinZ(activeCamera: Camera): number;
  16029. /**
  16030. * Gets the maxZ used for shadow according to both the scene and the light.
  16031. * @param activeCamera The camera we are returning the max for
  16032. * @returns the depth max z
  16033. */
  16034. getDepthMaxZ(activeCamera: Camera): number;
  16035. /**
  16036. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16037. * @param matrix The materix to updated with the projection information
  16038. * @param viewMatrix The transform matrix of the light
  16039. * @param renderList The list of mesh to render in the map
  16040. * @returns The current light
  16041. */
  16042. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16043. }
  16044. }
  16045. declare module BABYLON {
  16046. /**
  16047. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16048. * These values define a cone of light starting from the position, emitting toward the direction.
  16049. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16050. * and the exponent defines the speed of the decay of the light with distance (reach).
  16051. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16052. */
  16053. class SpotLight extends ShadowLight {
  16054. private _angle;
  16055. private _innerAngle;
  16056. private _cosHalfAngle;
  16057. private _lightAngleScale;
  16058. private _lightAngleOffset;
  16059. /**
  16060. * Gets the cone angle of the spot light in Radians.
  16061. */
  16062. /**
  16063. * Sets the cone angle of the spot light in Radians.
  16064. */
  16065. angle: number;
  16066. /**
  16067. * Only used in gltf falloff mode, this defines the angle where
  16068. * the directional falloff will start before cutting at angle which could be seen
  16069. * as outer angle.
  16070. */
  16071. /**
  16072. * Only used in gltf falloff mode, this defines the angle where
  16073. * the directional falloff will start before cutting at angle which could be seen
  16074. * as outer angle.
  16075. */
  16076. innerAngle: number;
  16077. private _shadowAngleScale;
  16078. /**
  16079. * Allows scaling the angle of the light for shadow generation only.
  16080. */
  16081. /**
  16082. * Allows scaling the angle of the light for shadow generation only.
  16083. */
  16084. shadowAngleScale: number;
  16085. /**
  16086. * The light decay speed with the distance from the emission spot.
  16087. */
  16088. exponent: number;
  16089. private _projectionTextureMatrix;
  16090. /**
  16091. * Allows reading the projecton texture
  16092. */
  16093. readonly projectionTextureMatrix: Matrix;
  16094. protected _projectionTextureLightNear: number;
  16095. /**
  16096. * Gets the near clip of the Spotlight for texture projection.
  16097. */
  16098. /**
  16099. * Sets the near clip of the Spotlight for texture projection.
  16100. */
  16101. projectionTextureLightNear: number;
  16102. protected _projectionTextureLightFar: number;
  16103. /**
  16104. * Gets the far clip of the Spotlight for texture projection.
  16105. */
  16106. /**
  16107. * Sets the far clip of the Spotlight for texture projection.
  16108. */
  16109. projectionTextureLightFar: number;
  16110. protected _projectionTextureUpDirection: Vector3;
  16111. /**
  16112. * Gets the Up vector of the Spotlight for texture projection.
  16113. */
  16114. /**
  16115. * Sets the Up vector of the Spotlight for texture projection.
  16116. */
  16117. projectionTextureUpDirection: Vector3;
  16118. private _projectionTexture;
  16119. /**
  16120. * Gets the projection texture of the light.
  16121. */
  16122. /**
  16123. * Sets the projection texture of the light.
  16124. */
  16125. projectionTexture: Nullable<BaseTexture>;
  16126. private _projectionTextureViewLightDirty;
  16127. private _projectionTextureProjectionLightDirty;
  16128. private _projectionTextureDirty;
  16129. private _projectionTextureViewTargetVector;
  16130. private _projectionTextureViewLightMatrix;
  16131. private _projectionTextureProjectionLightMatrix;
  16132. private _projectionTextureScalingMatrix;
  16133. /**
  16134. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16135. * It can cast shadows.
  16136. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16137. * @param name The light friendly name
  16138. * @param position The position of the spot light in the scene
  16139. * @param direction The direction of the light in the scene
  16140. * @param angle The cone angle of the light in Radians
  16141. * @param exponent The light decay speed with the distance from the emission spot
  16142. * @param scene The scene the lights belongs to
  16143. */
  16144. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16145. /**
  16146. * Returns the string "SpotLight".
  16147. * @returns the class name
  16148. */
  16149. getClassName(): string;
  16150. /**
  16151. * Returns the integer 2.
  16152. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16153. */
  16154. getTypeID(): number;
  16155. /**
  16156. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16157. */
  16158. protected _setDirection(value: Vector3): void;
  16159. /**
  16160. * Overrides the position setter to recompute the projection texture view light Matrix.
  16161. */
  16162. protected _setPosition(value: Vector3): void;
  16163. /**
  16164. * 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.
  16165. * Returns the SpotLight.
  16166. */
  16167. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16168. protected _computeProjectionTextureViewLightMatrix(): void;
  16169. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16170. /**
  16171. * Main function for light texture projection matrix computing.
  16172. */
  16173. protected _computeProjectionTextureMatrix(): void;
  16174. protected _buildUniformLayout(): void;
  16175. private _computeAngleValues;
  16176. /**
  16177. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16178. * @param effect The effect to update
  16179. * @param lightIndex The index of the light in the effect to update
  16180. * @returns The spot light
  16181. */
  16182. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16183. /**
  16184. * Disposes the light and the associated resources.
  16185. */
  16186. dispose(): void;
  16187. /**
  16188. * Prepares the list of defines specific to the light type.
  16189. * @param defines the list of defines
  16190. * @param lightIndex defines the index of the light for the effect
  16191. */
  16192. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16193. }
  16194. }
  16195. declare module BABYLON {
  16196. /**
  16197. * Interface used to present a loading screen while loading a scene
  16198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16199. */
  16200. interface ILoadingScreen {
  16201. /**
  16202. * Function called to display the loading screen
  16203. */
  16204. displayLoadingUI: () => void;
  16205. /**
  16206. * Function called to hide the loading screen
  16207. */
  16208. hideLoadingUI: () => void;
  16209. /**
  16210. * Gets or sets the color to use for the background
  16211. */
  16212. loadingUIBackgroundColor: string;
  16213. /**
  16214. * Gets or sets the text to display while loading
  16215. */
  16216. loadingUIText: string;
  16217. }
  16218. /**
  16219. * Class used for the default loading screen
  16220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16221. */
  16222. class DefaultLoadingScreen implements ILoadingScreen {
  16223. private _renderingCanvas;
  16224. private _loadingText;
  16225. private _loadingDivBackgroundColor;
  16226. private _loadingDiv;
  16227. private _loadingTextDiv;
  16228. /**
  16229. * Creates a new default loading screen
  16230. * @param _renderingCanvas defines the canvas used to render the scene
  16231. * @param _loadingText defines the default text to display
  16232. * @param _loadingDivBackgroundColor defines the default background color
  16233. */
  16234. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16235. /**
  16236. * Function called to display the loading screen
  16237. */
  16238. displayLoadingUI(): void;
  16239. /**
  16240. * Function called to hide the loading screen
  16241. */
  16242. hideLoadingUI(): void;
  16243. /**
  16244. * Gets or sets the text to display while loading
  16245. */
  16246. loadingUIText: string;
  16247. /**
  16248. * Gets or sets the color to use for the background
  16249. */
  16250. loadingUIBackgroundColor: string;
  16251. private _resizeLoadingUI;
  16252. }
  16253. }
  16254. declare module BABYLON {
  16255. /**
  16256. * Class used to represent data loading progression
  16257. */
  16258. class SceneLoaderProgressEvent {
  16259. /** defines if data length to load can be evaluated */
  16260. readonly lengthComputable: boolean;
  16261. /** defines the loaded data length */
  16262. readonly loaded: number;
  16263. /** defines the data length to load */
  16264. readonly total: number;
  16265. /**
  16266. * Create a new progress event
  16267. * @param lengthComputable defines if data length to load can be evaluated
  16268. * @param loaded defines the loaded data length
  16269. * @param total defines the data length to load
  16270. */
  16271. constructor(
  16272. /** defines if data length to load can be evaluated */
  16273. lengthComputable: boolean,
  16274. /** defines the loaded data length */
  16275. loaded: number,
  16276. /** defines the data length to load */
  16277. total: number);
  16278. /**
  16279. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16280. * @param event defines the source event
  16281. * @returns a new SceneLoaderProgressEvent
  16282. */
  16283. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16284. }
  16285. /**
  16286. * Interface used by SceneLoader plugins to define supported file extensions
  16287. */
  16288. interface ISceneLoaderPluginExtensions {
  16289. /**
  16290. * Defines the list of supported extensions
  16291. */
  16292. [extension: string]: {
  16293. isBinary: boolean;
  16294. };
  16295. }
  16296. /**
  16297. * Interface used by SceneLoader plugin factory
  16298. */
  16299. interface ISceneLoaderPluginFactory {
  16300. /**
  16301. * Defines the name of the factory
  16302. */
  16303. name: string;
  16304. /**
  16305. * Function called to create a new plugin
  16306. * @return the new plugin
  16307. */
  16308. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16309. /**
  16310. * Boolean indicating if the plugin can direct load specific data
  16311. */
  16312. canDirectLoad?: (data: string) => boolean;
  16313. }
  16314. /**
  16315. * Interface used to define a SceneLoader plugin
  16316. */
  16317. interface ISceneLoaderPlugin {
  16318. /**
  16319. * The friendly name of this plugin.
  16320. */
  16321. name: string;
  16322. /**
  16323. * The file extensions supported by this plugin.
  16324. */
  16325. extensions: string | ISceneLoaderPluginExtensions;
  16326. /**
  16327. * Import meshes into a scene.
  16328. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16329. * @param scene The scene to import into
  16330. * @param data The data to import
  16331. * @param rootUrl The root url for scene and resources
  16332. * @param meshes The meshes array to import into
  16333. * @param particleSystems The particle systems array to import into
  16334. * @param skeletons The skeletons array to import into
  16335. * @param onError The callback when import fails
  16336. * @returns True if successful or false otherwise
  16337. */
  16338. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16339. /**
  16340. * Load into a scene.
  16341. * @param scene The scene to load into
  16342. * @param data The data to import
  16343. * @param rootUrl The root url for scene and resources
  16344. * @param onError The callback when import fails
  16345. * @returns true if successful or false otherwise
  16346. */
  16347. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16348. /**
  16349. * The callback that returns true if the data can be directly loaded.
  16350. */
  16351. canDirectLoad?: (data: string) => boolean;
  16352. /**
  16353. * The callback that allows custom handling of the root url based on the response url.
  16354. */
  16355. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16356. /**
  16357. * Load into an asset container.
  16358. * @param scene The scene to load into
  16359. * @param data The data to import
  16360. * @param rootUrl The root url for scene and resources
  16361. * @param onError The callback when import fails
  16362. * @returns The loaded asset container
  16363. */
  16364. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16365. }
  16366. /**
  16367. * Interface used to define an async SceneLoader plugin
  16368. */
  16369. interface ISceneLoaderPluginAsync {
  16370. /**
  16371. * The friendly name of this plugin.
  16372. */
  16373. name: string;
  16374. /**
  16375. * The file extensions supported by this plugin.
  16376. */
  16377. extensions: string | ISceneLoaderPluginExtensions;
  16378. /**
  16379. * Import meshes into a scene.
  16380. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16381. * @param scene The scene to import into
  16382. * @param data The data to import
  16383. * @param rootUrl The root url for scene and resources
  16384. * @param onProgress The callback when the load progresses
  16385. * @param fileName Defines the name of the file to load
  16386. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16387. */
  16388. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16389. meshes: AbstractMesh[];
  16390. particleSystems: IParticleSystem[];
  16391. skeletons: Skeleton[];
  16392. animationGroups: AnimationGroup[];
  16393. }>;
  16394. /**
  16395. * Load into a scene.
  16396. * @param scene The scene to load into
  16397. * @param data The data to import
  16398. * @param rootUrl The root url for scene and resources
  16399. * @param onProgress The callback when the load progresses
  16400. * @param fileName Defines the name of the file to load
  16401. * @returns Nothing
  16402. */
  16403. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16404. /**
  16405. * The callback that returns true if the data can be directly loaded.
  16406. */
  16407. canDirectLoad?: (data: string) => boolean;
  16408. /**
  16409. * The callback that allows custom handling of the root url based on the response url.
  16410. */
  16411. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16412. /**
  16413. * Load into an asset container.
  16414. * @param scene The scene to load into
  16415. * @param data The data to import
  16416. * @param rootUrl The root url for scene and resources
  16417. * @param onProgress The callback when the load progresses
  16418. * @param fileName Defines the name of the file to load
  16419. * @returns The loaded asset container
  16420. */
  16421. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16422. }
  16423. /**
  16424. * Class used to load scene from various file formats using registered plugins
  16425. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16426. */
  16427. class SceneLoader {
  16428. private static _ForceFullSceneLoadingForIncremental;
  16429. private static _ShowLoadingScreen;
  16430. private static _CleanBoneMatrixWeights;
  16431. /**
  16432. * No logging while loading
  16433. */
  16434. static readonly NO_LOGGING: number;
  16435. /**
  16436. * Minimal logging while loading
  16437. */
  16438. static readonly MINIMAL_LOGGING: number;
  16439. /**
  16440. * Summary logging while loading
  16441. */
  16442. static readonly SUMMARY_LOGGING: number;
  16443. /**
  16444. * Detailled logging while loading
  16445. */
  16446. static readonly DETAILED_LOGGING: number;
  16447. private static _loggingLevel;
  16448. /**
  16449. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16450. */
  16451. static ForceFullSceneLoadingForIncremental: boolean;
  16452. /**
  16453. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16454. */
  16455. static ShowLoadingScreen: boolean;
  16456. /**
  16457. * Defines the current logging level (while loading the scene)
  16458. * @ignorenaming
  16459. */
  16460. static loggingLevel: number;
  16461. /**
  16462. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16463. */
  16464. static CleanBoneMatrixWeights: boolean;
  16465. /**
  16466. * Event raised when a plugin is used to load a scene
  16467. */
  16468. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16469. private static _registeredPlugins;
  16470. private static _getDefaultPlugin;
  16471. private static _getPluginForExtension;
  16472. private static _getPluginForDirectLoad;
  16473. private static _getPluginForFilename;
  16474. private static _getDirectLoad;
  16475. private static _loadData;
  16476. private static _getFileInfo;
  16477. /**
  16478. * Gets a plugin that can load the given extension
  16479. * @param extension defines the extension to load
  16480. * @returns a plugin or null if none works
  16481. */
  16482. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16483. /**
  16484. * Gets a boolean indicating that the given extension can be loaded
  16485. * @param extension defines the extension to load
  16486. * @returns true if the extension is supported
  16487. */
  16488. static IsPluginForExtensionAvailable(extension: string): boolean;
  16489. /**
  16490. * Adds a new plugin to the list of registered plugins
  16491. * @param plugin defines the plugin to add
  16492. */
  16493. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16494. /**
  16495. * Import meshes into a scene
  16496. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16497. * @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)
  16498. * @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)
  16499. * @param scene the instance of BABYLON.Scene to append to
  16500. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16501. * @param onProgress a callback with a progress event for each file being loaded
  16502. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16503. * @param pluginExtension the extension used to determine the plugin
  16504. * @returns The loaded plugin
  16505. */
  16506. 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>;
  16507. /**
  16508. * Import meshes into a scene
  16509. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16510. * @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)
  16511. * @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)
  16512. * @param scene the instance of BABYLON.Scene to append to
  16513. * @param onProgress a callback with a progress event for each file being loaded
  16514. * @param pluginExtension the extension used to determine the plugin
  16515. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16516. */
  16517. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16518. meshes: AbstractMesh[];
  16519. particleSystems: IParticleSystem[];
  16520. skeletons: Skeleton[];
  16521. animationGroups: AnimationGroup[];
  16522. }>;
  16523. /**
  16524. * Load a scene
  16525. * @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)
  16526. * @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)
  16527. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16528. * @param onSuccess a callback with the scene when import succeeds
  16529. * @param onProgress a callback with a progress event for each file being loaded
  16530. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16531. * @param pluginExtension the extension used to determine the plugin
  16532. * @returns The loaded plugin
  16533. */
  16534. 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>;
  16535. /**
  16536. * Load a scene
  16537. * @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)
  16538. * @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)
  16539. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16540. * @param onProgress a callback with a progress event for each file being loaded
  16541. * @param pluginExtension the extension used to determine the plugin
  16542. * @returns The loaded scene
  16543. */
  16544. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16545. /**
  16546. * Append a scene
  16547. * @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)
  16548. * @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)
  16549. * @param scene is the instance of BABYLON.Scene to append to
  16550. * @param onSuccess a callback with the scene when import succeeds
  16551. * @param onProgress a callback with a progress event for each file being loaded
  16552. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16553. * @param pluginExtension the extension used to determine the plugin
  16554. * @returns The loaded plugin
  16555. */
  16556. 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>;
  16557. /**
  16558. * Append a scene
  16559. * @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)
  16560. * @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)
  16561. * @param scene is the instance of BABYLON.Scene to append to
  16562. * @param onProgress a callback with a progress event for each file being loaded
  16563. * @param pluginExtension the extension used to determine the plugin
  16564. * @returns The given scene
  16565. */
  16566. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16567. /**
  16568. * Load a scene into an asset container
  16569. * @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)
  16570. * @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)
  16571. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16572. * @param onSuccess a callback with the scene when import succeeds
  16573. * @param onProgress a callback with a progress event for each file being loaded
  16574. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16575. * @param pluginExtension the extension used to determine the plugin
  16576. * @returns The loaded plugin
  16577. */
  16578. 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>;
  16579. /**
  16580. * Load a scene into an asset container
  16581. * @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)
  16582. * @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)
  16583. * @param scene is the instance of BABYLON.Scene to append to
  16584. * @param onProgress a callback with a progress event for each file being loaded
  16585. * @param pluginExtension the extension used to determine the plugin
  16586. * @returns The loaded asset container
  16587. */
  16588. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16589. }
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16594. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16595. * 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;
  16596. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16597. */
  16598. class ColorCurves {
  16599. private _dirty;
  16600. private _tempColor;
  16601. private _globalCurve;
  16602. private _highlightsCurve;
  16603. private _midtonesCurve;
  16604. private _shadowsCurve;
  16605. private _positiveCurve;
  16606. private _negativeCurve;
  16607. private _globalHue;
  16608. private _globalDensity;
  16609. private _globalSaturation;
  16610. private _globalExposure;
  16611. /**
  16612. * Gets the global Hue value.
  16613. * 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).
  16614. */
  16615. /**
  16616. * Sets the global Hue value.
  16617. * 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).
  16618. */
  16619. globalHue: number;
  16620. /**
  16621. * Gets the global Density value.
  16622. * 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.
  16623. * Values less than zero provide a filter of opposite hue.
  16624. */
  16625. /**
  16626. * Sets the global Density value.
  16627. * 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.
  16628. * Values less than zero provide a filter of opposite hue.
  16629. */
  16630. globalDensity: number;
  16631. /**
  16632. * Gets the global Saturation value.
  16633. * 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.
  16634. */
  16635. /**
  16636. * Sets the global Saturation value.
  16637. * 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.
  16638. */
  16639. globalSaturation: number;
  16640. /**
  16641. * Gets the global Exposure value.
  16642. * 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.
  16643. */
  16644. /**
  16645. * Sets the global Exposure value.
  16646. * 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.
  16647. */
  16648. globalExposure: number;
  16649. private _highlightsHue;
  16650. private _highlightsDensity;
  16651. private _highlightsSaturation;
  16652. private _highlightsExposure;
  16653. /**
  16654. * Gets the highlights Hue value.
  16655. * 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).
  16656. */
  16657. /**
  16658. * Sets the highlights Hue value.
  16659. * 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).
  16660. */
  16661. highlightsHue: number;
  16662. /**
  16663. * Gets the highlights Density value.
  16664. * 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.
  16665. * Values less than zero provide a filter of opposite hue.
  16666. */
  16667. /**
  16668. * Sets the highlights Density value.
  16669. * 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.
  16670. * Values less than zero provide a filter of opposite hue.
  16671. */
  16672. highlightsDensity: number;
  16673. /**
  16674. * Gets the highlights Saturation value.
  16675. * 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.
  16676. */
  16677. /**
  16678. * Sets the highlights Saturation value.
  16679. * 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.
  16680. */
  16681. highlightsSaturation: number;
  16682. /**
  16683. * Gets the highlights Exposure value.
  16684. * 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.
  16685. */
  16686. /**
  16687. * Sets the highlights Exposure value.
  16688. * 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.
  16689. */
  16690. highlightsExposure: number;
  16691. private _midtonesHue;
  16692. private _midtonesDensity;
  16693. private _midtonesSaturation;
  16694. private _midtonesExposure;
  16695. /**
  16696. * Gets the midtones Hue value.
  16697. * 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).
  16698. */
  16699. /**
  16700. * Sets the midtones Hue value.
  16701. * 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).
  16702. */
  16703. midtonesHue: number;
  16704. /**
  16705. * Gets the midtones Density value.
  16706. * 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.
  16707. * Values less than zero provide a filter of opposite hue.
  16708. */
  16709. /**
  16710. * Sets the midtones Density value.
  16711. * 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.
  16712. * Values less than zero provide a filter of opposite hue.
  16713. */
  16714. midtonesDensity: number;
  16715. /**
  16716. * Gets the midtones Saturation value.
  16717. * 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.
  16718. */
  16719. /**
  16720. * Sets the midtones Saturation value.
  16721. * 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.
  16722. */
  16723. midtonesSaturation: number;
  16724. /**
  16725. * Gets the midtones Exposure value.
  16726. * 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.
  16727. */
  16728. /**
  16729. * Sets the midtones Exposure value.
  16730. * 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.
  16731. */
  16732. midtonesExposure: number;
  16733. private _shadowsHue;
  16734. private _shadowsDensity;
  16735. private _shadowsSaturation;
  16736. private _shadowsExposure;
  16737. /**
  16738. * Gets the shadows Hue value.
  16739. * 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).
  16740. */
  16741. /**
  16742. * Sets the shadows Hue value.
  16743. * 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).
  16744. */
  16745. shadowsHue: number;
  16746. /**
  16747. * Gets the shadows Density value.
  16748. * 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.
  16749. * Values less than zero provide a filter of opposite hue.
  16750. */
  16751. /**
  16752. * Sets the shadows Density value.
  16753. * 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.
  16754. * Values less than zero provide a filter of opposite hue.
  16755. */
  16756. shadowsDensity: number;
  16757. /**
  16758. * Gets the shadows Saturation value.
  16759. * 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.
  16760. */
  16761. /**
  16762. * Sets the shadows Saturation value.
  16763. * 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.
  16764. */
  16765. shadowsSaturation: number;
  16766. /**
  16767. * Gets the shadows Exposure value.
  16768. * 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.
  16769. */
  16770. /**
  16771. * Sets the shadows Exposure value.
  16772. * 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.
  16773. */
  16774. shadowsExposure: number;
  16775. /**
  16776. * Returns the class name
  16777. * @returns The class name
  16778. */
  16779. getClassName(): string;
  16780. /**
  16781. * Binds the color curves to the shader.
  16782. * @param colorCurves The color curve to bind
  16783. * @param effect The effect to bind to
  16784. * @param positiveUniform The positive uniform shader parameter
  16785. * @param neutralUniform The neutral uniform shader parameter
  16786. * @param negativeUniform The negative uniform shader parameter
  16787. */
  16788. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16789. /**
  16790. * Prepare the list of uniforms associated with the ColorCurves effects.
  16791. * @param uniformsList The list of uniforms used in the effect
  16792. */
  16793. static PrepareUniforms(uniformsList: string[]): void;
  16794. /**
  16795. * Returns color grading data based on a hue, density, saturation and exposure value.
  16796. * @param filterHue The hue of the color filter.
  16797. * @param filterDensity The density of the color filter.
  16798. * @param saturation The saturation.
  16799. * @param exposure The exposure.
  16800. * @param result The result data container.
  16801. */
  16802. private getColorGradingDataToRef;
  16803. /**
  16804. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16805. * @param value The input slider value in range [-100,100].
  16806. * @returns Adjusted value.
  16807. */
  16808. private static applyColorGradingSliderNonlinear;
  16809. /**
  16810. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16811. * @param hue The hue (H) input.
  16812. * @param saturation The saturation (S) input.
  16813. * @param brightness The brightness (B) input.
  16814. * @result An RGBA color represented as Vector4.
  16815. */
  16816. private static fromHSBToRef;
  16817. /**
  16818. * Returns a value clamped between min and max
  16819. * @param value The value to clamp
  16820. * @param min The minimum of value
  16821. * @param max The maximum of value
  16822. * @returns The clamped value.
  16823. */
  16824. private static clamp;
  16825. /**
  16826. * Clones the current color curve instance.
  16827. * @return The cloned curves
  16828. */
  16829. clone(): ColorCurves;
  16830. /**
  16831. * Serializes the current color curve instance to a json representation.
  16832. * @return a JSON representation
  16833. */
  16834. serialize(): any;
  16835. /**
  16836. * Parses the color curve from a json representation.
  16837. * @param source the JSON source to parse
  16838. * @return The parsed curves
  16839. */
  16840. static Parse(source: any): ColorCurves;
  16841. }
  16842. }
  16843. declare module BABYLON {
  16844. /**
  16845. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16846. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16847. */
  16848. class EffectFallbacks {
  16849. private _defines;
  16850. private _currentRank;
  16851. private _maxRank;
  16852. private _mesh;
  16853. /**
  16854. * Removes the fallback from the bound mesh.
  16855. */
  16856. unBindMesh(): void;
  16857. /**
  16858. * Adds a fallback on the specified property.
  16859. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16860. * @param define The name of the define in the shader
  16861. */
  16862. addFallback(rank: number, define: string): void;
  16863. /**
  16864. * Sets the mesh to use CPU skinning when needing to fallback.
  16865. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16866. * @param mesh The mesh to use the fallbacks.
  16867. */
  16868. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16869. /**
  16870. * Checks to see if more fallbacks are still availible.
  16871. */
  16872. readonly isMoreFallbacks: boolean;
  16873. /**
  16874. * Removes the defines that shoould be removed when falling back.
  16875. * @param currentDefines defines the current define statements for the shader.
  16876. * @param effect defines the current effect we try to compile
  16877. * @returns The resulting defines with defines of the current rank removed.
  16878. */
  16879. reduce(currentDefines: string, effect: Effect): string;
  16880. }
  16881. /**
  16882. * Options to be used when creating an effect.
  16883. */
  16884. class EffectCreationOptions {
  16885. /**
  16886. * Atrributes that will be used in the shader.
  16887. */
  16888. attributes: string[];
  16889. /**
  16890. * Uniform varible names that will be set in the shader.
  16891. */
  16892. uniformsNames: string[];
  16893. /**
  16894. * Uniform buffer varible names that will be set in the shader.
  16895. */
  16896. uniformBuffersNames: string[];
  16897. /**
  16898. * Sampler texture variable names that will be set in the shader.
  16899. */
  16900. samplers: string[];
  16901. /**
  16902. * Define statements that will be set in the shader.
  16903. */
  16904. defines: any;
  16905. /**
  16906. * Possible fallbacks for this effect to improve performance when needed.
  16907. */
  16908. fallbacks: Nullable<EffectFallbacks>;
  16909. /**
  16910. * Callback that will be called when the shader is compiled.
  16911. */
  16912. onCompiled: Nullable<(effect: Effect) => void>;
  16913. /**
  16914. * Callback that will be called if an error occurs during shader compilation.
  16915. */
  16916. onError: Nullable<(effect: Effect, errors: string) => void>;
  16917. /**
  16918. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16919. */
  16920. indexParameters: any;
  16921. /**
  16922. * Max number of lights that can be used in the shader.
  16923. */
  16924. maxSimultaneousLights: number;
  16925. /**
  16926. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16927. */
  16928. transformFeedbackVaryings: Nullable<string[]>;
  16929. }
  16930. /**
  16931. * Effect containing vertex and fragment shader that can be executed on an object.
  16932. */
  16933. class Effect {
  16934. /**
  16935. * Name of the effect.
  16936. */
  16937. name: any;
  16938. /**
  16939. * String container all the define statements that should be set on the shader.
  16940. */
  16941. defines: string;
  16942. /**
  16943. * Callback that will be called when the shader is compiled.
  16944. */
  16945. onCompiled: Nullable<(effect: Effect) => void>;
  16946. /**
  16947. * Callback that will be called if an error occurs during shader compilation.
  16948. */
  16949. onError: Nullable<(effect: Effect, errors: string) => void>;
  16950. /**
  16951. * Callback that will be called when effect is bound.
  16952. */
  16953. onBind: Nullable<(effect: Effect) => void>;
  16954. /**
  16955. * Unique ID of the effect.
  16956. */
  16957. uniqueId: number;
  16958. /**
  16959. * Observable that will be called when the shader is compiled.
  16960. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  16961. */
  16962. onCompileObservable: Observable<Effect>;
  16963. /**
  16964. * Observable that will be called if an error occurs during shader compilation.
  16965. */
  16966. onErrorObservable: Observable<Effect>;
  16967. /** @hidden */
  16968. _onBindObservable: Nullable<Observable<Effect>>;
  16969. /**
  16970. * Observable that will be called when effect is bound.
  16971. */
  16972. readonly onBindObservable: Observable<Effect>;
  16973. /** @hidden */
  16974. _bonesComputationForcedToCPU: boolean;
  16975. private static _uniqueIdSeed;
  16976. private _engine;
  16977. private _uniformBuffersNames;
  16978. private _uniformsNames;
  16979. private _samplers;
  16980. private _isReady;
  16981. private _compilationError;
  16982. private _attributesNames;
  16983. private _attributes;
  16984. private _uniforms;
  16985. /**
  16986. * Key for the effect.
  16987. * @hidden
  16988. */
  16989. _key: string;
  16990. private _indexParameters;
  16991. private _fallbacks;
  16992. private _vertexSourceCode;
  16993. private _fragmentSourceCode;
  16994. private _vertexSourceCodeOverride;
  16995. private _fragmentSourceCodeOverride;
  16996. private _transformFeedbackVaryings;
  16997. /**
  16998. * Compiled shader to webGL program.
  16999. * @hidden
  17000. */
  17001. _program: WebGLProgram;
  17002. private _valueCache;
  17003. private static _baseCache;
  17004. /**
  17005. * Instantiates an effect.
  17006. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17007. * @param baseName Name of the effect.
  17008. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17009. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17010. * @param samplers List of sampler variables that will be passed to the shader.
  17011. * @param engine Engine to be used to render the effect
  17012. * @param defines Define statements to be added to the shader.
  17013. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17014. * @param onCompiled Callback that will be called when the shader is compiled.
  17015. * @param onError Callback that will be called if an error occurs during shader compilation.
  17016. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17017. */
  17018. 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);
  17019. /**
  17020. * Unique key for this effect
  17021. */
  17022. readonly key: string;
  17023. /**
  17024. * If the effect has been compiled and prepared.
  17025. * @returns if the effect is compiled and prepared.
  17026. */
  17027. isReady(): boolean;
  17028. /**
  17029. * The engine the effect was initialized with.
  17030. * @returns the engine.
  17031. */
  17032. getEngine(): Engine;
  17033. /**
  17034. * The compiled webGL program for the effect
  17035. * @returns the webGL program.
  17036. */
  17037. getProgram(): WebGLProgram;
  17038. /**
  17039. * The set of names of attribute variables for the shader.
  17040. * @returns An array of attribute names.
  17041. */
  17042. getAttributesNames(): string[];
  17043. /**
  17044. * Returns the attribute at the given index.
  17045. * @param index The index of the attribute.
  17046. * @returns The location of the attribute.
  17047. */
  17048. getAttributeLocation(index: number): number;
  17049. /**
  17050. * Returns the attribute based on the name of the variable.
  17051. * @param name of the attribute to look up.
  17052. * @returns the attribute location.
  17053. */
  17054. getAttributeLocationByName(name: string): number;
  17055. /**
  17056. * The number of attributes.
  17057. * @returns the numnber of attributes.
  17058. */
  17059. getAttributesCount(): number;
  17060. /**
  17061. * Gets the index of a uniform variable.
  17062. * @param uniformName of the uniform to look up.
  17063. * @returns the index.
  17064. */
  17065. getUniformIndex(uniformName: string): number;
  17066. /**
  17067. * Returns the attribute based on the name of the variable.
  17068. * @param uniformName of the uniform to look up.
  17069. * @returns the location of the uniform.
  17070. */
  17071. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17072. /**
  17073. * Returns an array of sampler variable names
  17074. * @returns The array of sampler variable neames.
  17075. */
  17076. getSamplers(): string[];
  17077. /**
  17078. * The error from the last compilation.
  17079. * @returns the error string.
  17080. */
  17081. getCompilationError(): string;
  17082. /**
  17083. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17084. * @param func The callback to be used.
  17085. */
  17086. executeWhenCompiled(func: (effect: Effect) => void): void;
  17087. private _checkIsReady;
  17088. /** @hidden */
  17089. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17090. /** @hidden */
  17091. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17092. /** @hidden */
  17093. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17094. private _processShaderConversion;
  17095. private _processIncludes;
  17096. private _processPrecision;
  17097. /**
  17098. * Recompiles the webGL program
  17099. * @param vertexSourceCode The source code for the vertex shader.
  17100. * @param fragmentSourceCode The source code for the fragment shader.
  17101. * @param onCompiled Callback called when completed.
  17102. * @param onError Callback called on error.
  17103. * @hidden
  17104. */
  17105. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17106. /**
  17107. * Gets the uniform locations of the the specified variable names
  17108. * @param names THe names of the variables to lookup.
  17109. * @returns Array of locations in the same order as variable names.
  17110. */
  17111. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17112. /**
  17113. * Prepares the effect
  17114. * @hidden
  17115. */
  17116. _prepareEffect(): void;
  17117. /**
  17118. * Checks if the effect is supported. (Must be called after compilation)
  17119. */
  17120. readonly isSupported: boolean;
  17121. /**
  17122. * Binds a texture to the engine to be used as output of the shader.
  17123. * @param channel Name of the output variable.
  17124. * @param texture Texture to bind.
  17125. * @hidden
  17126. */
  17127. _bindTexture(channel: string, texture: InternalTexture): void;
  17128. /**
  17129. * Sets a texture on the engine to be used in the shader.
  17130. * @param channel Name of the sampler variable.
  17131. * @param texture Texture to set.
  17132. */
  17133. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17134. /**
  17135. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17136. * @param channel Name of the sampler variable.
  17137. * @param texture Texture to set.
  17138. */
  17139. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17140. /**
  17141. * Sets an array of textures on the engine to be used in the shader.
  17142. * @param channel Name of the variable.
  17143. * @param textures Textures to set.
  17144. */
  17145. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17146. /**
  17147. * 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)
  17148. * @param channel Name of the sampler variable.
  17149. * @param postProcess Post process to get the input texture from.
  17150. */
  17151. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17152. /**
  17153. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17154. * 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)
  17155. * @param channel Name of the sampler variable.
  17156. * @param postProcess Post process to get the output texture from.
  17157. */
  17158. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17159. /** @hidden */
  17160. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17161. /** @hidden */
  17162. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17163. /** @hidden */
  17164. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17165. /** @hidden */
  17166. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17167. /**
  17168. * Binds a buffer to a uniform.
  17169. * @param buffer Buffer to bind.
  17170. * @param name Name of the uniform variable to bind to.
  17171. */
  17172. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17173. /**
  17174. * Binds block to a uniform.
  17175. * @param blockName Name of the block to bind.
  17176. * @param index Index to bind.
  17177. */
  17178. bindUniformBlock(blockName: string, index: number): void;
  17179. /**
  17180. * Sets an interger value on a uniform variable.
  17181. * @param uniformName Name of the variable.
  17182. * @param value Value to be set.
  17183. * @returns this effect.
  17184. */
  17185. setInt(uniformName: string, value: number): Effect;
  17186. /**
  17187. * Sets an int array on a uniform variable.
  17188. * @param uniformName Name of the variable.
  17189. * @param array array to be set.
  17190. * @returns this effect.
  17191. */
  17192. setIntArray(uniformName: string, array: Int32Array): Effect;
  17193. /**
  17194. * 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)
  17195. * @param uniformName Name of the variable.
  17196. * @param array array to be set.
  17197. * @returns this effect.
  17198. */
  17199. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17200. /**
  17201. * 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)
  17202. * @param uniformName Name of the variable.
  17203. * @param array array to be set.
  17204. * @returns this effect.
  17205. */
  17206. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17207. /**
  17208. * 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)
  17209. * @param uniformName Name of the variable.
  17210. * @param array array to be set.
  17211. * @returns this effect.
  17212. */
  17213. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17214. /**
  17215. * Sets an float array on a uniform variable.
  17216. * @param uniformName Name of the variable.
  17217. * @param array array to be set.
  17218. * @returns this effect.
  17219. */
  17220. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17221. /**
  17222. * 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)
  17223. * @param uniformName Name of the variable.
  17224. * @param array array to be set.
  17225. * @returns this effect.
  17226. */
  17227. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17228. /**
  17229. * 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)
  17230. * @param uniformName Name of the variable.
  17231. * @param array array to be set.
  17232. * @returns this effect.
  17233. */
  17234. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17235. /**
  17236. * 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)
  17237. * @param uniformName Name of the variable.
  17238. * @param array array to be set.
  17239. * @returns this effect.
  17240. */
  17241. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17242. /**
  17243. * Sets an array on a uniform variable.
  17244. * @param uniformName Name of the variable.
  17245. * @param array array to be set.
  17246. * @returns this effect.
  17247. */
  17248. setArray(uniformName: string, array: number[]): Effect;
  17249. /**
  17250. * 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)
  17251. * @param uniformName Name of the variable.
  17252. * @param array array to be set.
  17253. * @returns this effect.
  17254. */
  17255. setArray2(uniformName: string, array: number[]): Effect;
  17256. /**
  17257. * 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)
  17258. * @param uniformName Name of the variable.
  17259. * @param array array to be set.
  17260. * @returns this effect.
  17261. */
  17262. setArray3(uniformName: string, array: number[]): Effect;
  17263. /**
  17264. * 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)
  17265. * @param uniformName Name of the variable.
  17266. * @param array array to be set.
  17267. * @returns this effect.
  17268. */
  17269. setArray4(uniformName: string, array: number[]): Effect;
  17270. /**
  17271. * Sets matrices on a uniform variable.
  17272. * @param uniformName Name of the variable.
  17273. * @param matrices matrices to be set.
  17274. * @returns this effect.
  17275. */
  17276. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17277. /**
  17278. * Sets matrix on a uniform variable.
  17279. * @param uniformName Name of the variable.
  17280. * @param matrix matrix to be set.
  17281. * @returns this effect.
  17282. */
  17283. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17284. /**
  17285. * 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)
  17286. * @param uniformName Name of the variable.
  17287. * @param matrix matrix to be set.
  17288. * @returns this effect.
  17289. */
  17290. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17291. /**
  17292. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17293. * @param uniformName Name of the variable.
  17294. * @param matrix matrix to be set.
  17295. * @returns this effect.
  17296. */
  17297. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17298. /**
  17299. * Sets a float on a uniform variable.
  17300. * @param uniformName Name of the variable.
  17301. * @param value value to be set.
  17302. * @returns this effect.
  17303. */
  17304. setFloat(uniformName: string, value: number): Effect;
  17305. /**
  17306. * Sets a boolean on a uniform variable.
  17307. * @param uniformName Name of the variable.
  17308. * @param bool value to be set.
  17309. * @returns this effect.
  17310. */
  17311. setBool(uniformName: string, bool: boolean): Effect;
  17312. /**
  17313. * Sets a Vector2 on a uniform variable.
  17314. * @param uniformName Name of the variable.
  17315. * @param vector2 vector2 to be set.
  17316. * @returns this effect.
  17317. */
  17318. setVector2(uniformName: string, vector2: Vector2): Effect;
  17319. /**
  17320. * Sets a float2 on a uniform variable.
  17321. * @param uniformName Name of the variable.
  17322. * @param x First float in float2.
  17323. * @param y Second float in float2.
  17324. * @returns this effect.
  17325. */
  17326. setFloat2(uniformName: string, x: number, y: number): Effect;
  17327. /**
  17328. * Sets a Vector3 on a uniform variable.
  17329. * @param uniformName Name of the variable.
  17330. * @param vector3 Value to be set.
  17331. * @returns this effect.
  17332. */
  17333. setVector3(uniformName: string, vector3: Vector3): Effect;
  17334. /**
  17335. * Sets a float3 on a uniform variable.
  17336. * @param uniformName Name of the variable.
  17337. * @param x First float in float3.
  17338. * @param y Second float in float3.
  17339. * @param z Third float in float3.
  17340. * @returns this effect.
  17341. */
  17342. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17343. /**
  17344. * Sets a Vector4 on a uniform variable.
  17345. * @param uniformName Name of the variable.
  17346. * @param vector4 Value to be set.
  17347. * @returns this effect.
  17348. */
  17349. setVector4(uniformName: string, vector4: Vector4): Effect;
  17350. /**
  17351. * Sets a float4 on a uniform variable.
  17352. * @param uniformName Name of the variable.
  17353. * @param x First float in float4.
  17354. * @param y Second float in float4.
  17355. * @param z Third float in float4.
  17356. * @param w Fourth float in float4.
  17357. * @returns this effect.
  17358. */
  17359. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17360. /**
  17361. * Sets a Color3 on a uniform variable.
  17362. * @param uniformName Name of the variable.
  17363. * @param color3 Value to be set.
  17364. * @returns this effect.
  17365. */
  17366. setColor3(uniformName: string, color3: Color3): Effect;
  17367. /**
  17368. * Sets a Color4 on a uniform variable.
  17369. * @param uniformName Name of the variable.
  17370. * @param color3 Value to be set.
  17371. * @param alpha Alpha value to be set.
  17372. * @returns this effect.
  17373. */
  17374. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17375. /**
  17376. * Sets a Color4 on a uniform variable
  17377. * @param uniformName defines the name of the variable
  17378. * @param color4 defines the value to be set
  17379. * @returns this effect.
  17380. */
  17381. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17382. /**
  17383. * This function will add a new shader to the shader store
  17384. * @param name the name of the shader
  17385. * @param pixelShader optional pixel shader content
  17386. * @param vertexShader optional vertex shader content
  17387. */
  17388. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17389. /**
  17390. * Store of each shader (The can be looked up using effect.key)
  17391. */
  17392. static ShadersStore: {
  17393. [key: string]: string;
  17394. };
  17395. /**
  17396. * Store of each included file for a shader (The can be looked up using effect.key)
  17397. */
  17398. static IncludesShadersStore: {
  17399. [key: string]: string;
  17400. };
  17401. /**
  17402. * Resets the cache of effects.
  17403. */
  17404. static ResetCache(): void;
  17405. }
  17406. }
  17407. declare module BABYLON {
  17408. /**
  17409. * This represents all the required information to add a fresnel effect on a material:
  17410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17411. */
  17412. class FresnelParameters {
  17413. private _isEnabled;
  17414. /**
  17415. * Define if the fresnel effect is enable or not.
  17416. */
  17417. isEnabled: boolean;
  17418. /**
  17419. * Define the color used on edges (grazing angle)
  17420. */
  17421. leftColor: Color3;
  17422. /**
  17423. * Define the color used on center
  17424. */
  17425. rightColor: Color3;
  17426. /**
  17427. * Define bias applied to computed fresnel term
  17428. */
  17429. bias: number;
  17430. /**
  17431. * Defined the power exponent applied to fresnel term
  17432. */
  17433. power: number;
  17434. /**
  17435. * Clones the current fresnel and its valuues
  17436. * @returns a clone fresnel configuration
  17437. */
  17438. clone(): FresnelParameters;
  17439. /**
  17440. * Serializes the current fresnel parameters to a JSON representation.
  17441. * @return the JSON serialization
  17442. */
  17443. serialize(): any;
  17444. /**
  17445. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17446. * @param parsedFresnelParameters Define the JSON representation
  17447. * @returns the parsed parameters
  17448. */
  17449. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17450. }
  17451. }
  17452. declare module BABYLON {
  17453. /**
  17454. * Interface to follow in your material defines to integrate easily the
  17455. * Image proccessing functions.
  17456. * @hidden
  17457. */
  17458. interface IImageProcessingConfigurationDefines {
  17459. IMAGEPROCESSING: boolean;
  17460. VIGNETTE: boolean;
  17461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17462. VIGNETTEBLENDMODEOPAQUE: boolean;
  17463. TONEMAPPING: boolean;
  17464. TONEMAPPING_ACES: boolean;
  17465. CONTRAST: boolean;
  17466. EXPOSURE: boolean;
  17467. COLORCURVES: boolean;
  17468. COLORGRADING: boolean;
  17469. COLORGRADING3D: boolean;
  17470. SAMPLER3DGREENDEPTH: boolean;
  17471. SAMPLER3DBGRMAP: boolean;
  17472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17473. }
  17474. /**
  17475. * @hidden
  17476. */
  17477. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17478. IMAGEPROCESSING: boolean;
  17479. VIGNETTE: boolean;
  17480. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17481. VIGNETTEBLENDMODEOPAQUE: boolean;
  17482. TONEMAPPING: boolean;
  17483. TONEMAPPING_ACES: boolean;
  17484. CONTRAST: boolean;
  17485. COLORCURVES: boolean;
  17486. COLORGRADING: boolean;
  17487. COLORGRADING3D: boolean;
  17488. SAMPLER3DGREENDEPTH: boolean;
  17489. SAMPLER3DBGRMAP: boolean;
  17490. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17491. EXPOSURE: boolean;
  17492. constructor();
  17493. }
  17494. /**
  17495. * This groups together the common properties used for image processing either in direct forward pass
  17496. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17497. * or not.
  17498. */
  17499. class ImageProcessingConfiguration {
  17500. /**
  17501. * Default tone mapping applied in BabylonJS.
  17502. */
  17503. static readonly TONEMAPPING_STANDARD: number;
  17504. /**
  17505. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17506. * to other engines rendering to increase portability.
  17507. */
  17508. static readonly TONEMAPPING_ACES: number;
  17509. /**
  17510. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17511. */
  17512. colorCurves: Nullable<ColorCurves>;
  17513. private _colorCurvesEnabled;
  17514. /**
  17515. * Gets wether the color curves effect is enabled.
  17516. */
  17517. /**
  17518. * Sets wether the color curves effect is enabled.
  17519. */
  17520. colorCurvesEnabled: boolean;
  17521. private _colorGradingTexture;
  17522. /**
  17523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17524. */
  17525. /**
  17526. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17527. */
  17528. colorGradingTexture: Nullable<BaseTexture>;
  17529. private _colorGradingEnabled;
  17530. /**
  17531. * Gets wether the color grading effect is enabled.
  17532. */
  17533. /**
  17534. * Sets wether the color grading effect is enabled.
  17535. */
  17536. colorGradingEnabled: boolean;
  17537. private _colorGradingWithGreenDepth;
  17538. /**
  17539. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17540. */
  17541. /**
  17542. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17543. */
  17544. colorGradingWithGreenDepth: boolean;
  17545. private _colorGradingBGR;
  17546. /**
  17547. * Gets wether the color grading texture contains BGR values.
  17548. */
  17549. /**
  17550. * Sets wether the color grading texture contains BGR values.
  17551. */
  17552. colorGradingBGR: boolean;
  17553. /** @hidden */
  17554. _exposure: number;
  17555. /**
  17556. * Gets the Exposure used in the effect.
  17557. */
  17558. /**
  17559. * Sets the Exposure used in the effect.
  17560. */
  17561. exposure: number;
  17562. private _toneMappingEnabled;
  17563. /**
  17564. * Gets wether the tone mapping effect is enabled.
  17565. */
  17566. /**
  17567. * Sets wether the tone mapping effect is enabled.
  17568. */
  17569. toneMappingEnabled: boolean;
  17570. private _toneMappingType;
  17571. /**
  17572. * Gets the type of tone mapping effect.
  17573. */
  17574. /**
  17575. * Sets the type of tone mapping effect used in BabylonJS.
  17576. */
  17577. toneMappingType: number;
  17578. protected _contrast: number;
  17579. /**
  17580. * Gets the contrast used in the effect.
  17581. */
  17582. /**
  17583. * Sets the contrast used in the effect.
  17584. */
  17585. contrast: number;
  17586. /**
  17587. * Vignette stretch size.
  17588. */
  17589. vignetteStretch: number;
  17590. /**
  17591. * Vignette centre X Offset.
  17592. */
  17593. vignetteCentreX: number;
  17594. /**
  17595. * Vignette centre Y Offset.
  17596. */
  17597. vignetteCentreY: number;
  17598. /**
  17599. * Vignette weight or intensity of the vignette effect.
  17600. */
  17601. vignetteWeight: number;
  17602. /**
  17603. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17604. * if vignetteEnabled is set to true.
  17605. */
  17606. vignetteColor: Color4;
  17607. /**
  17608. * Camera field of view used by the Vignette effect.
  17609. */
  17610. vignetteCameraFov: number;
  17611. private _vignetteBlendMode;
  17612. /**
  17613. * Gets the vignette blend mode allowing different kind of effect.
  17614. */
  17615. /**
  17616. * Sets the vignette blend mode allowing different kind of effect.
  17617. */
  17618. vignetteBlendMode: number;
  17619. private _vignetteEnabled;
  17620. /**
  17621. * Gets wether the vignette effect is enabled.
  17622. */
  17623. /**
  17624. * Sets wether the vignette effect is enabled.
  17625. */
  17626. vignetteEnabled: boolean;
  17627. private _applyByPostProcess;
  17628. /**
  17629. * Gets wether the image processing is applied through a post process or not.
  17630. */
  17631. /**
  17632. * Sets wether the image processing is applied through a post process or not.
  17633. */
  17634. applyByPostProcess: boolean;
  17635. private _isEnabled;
  17636. /**
  17637. * Gets wether the image processing is enabled or not.
  17638. */
  17639. /**
  17640. * Sets wether the image processing is enabled or not.
  17641. */
  17642. isEnabled: boolean;
  17643. /**
  17644. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17645. */
  17646. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17647. /**
  17648. * Method called each time the image processing information changes requires to recompile the effect.
  17649. */
  17650. protected _updateParameters(): void;
  17651. /**
  17652. * Gets the current class name.
  17653. * @return "ImageProcessingConfiguration"
  17654. */
  17655. getClassName(): string;
  17656. /**
  17657. * Prepare the list of uniforms associated with the Image Processing effects.
  17658. * @param uniforms The list of uniforms used in the effect
  17659. * @param defines the list of defines currently in use
  17660. */
  17661. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17662. /**
  17663. * Prepare the list of samplers associated with the Image Processing effects.
  17664. * @param samplersList The list of uniforms used in the effect
  17665. * @param defines the list of defines currently in use
  17666. */
  17667. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17668. /**
  17669. * Prepare the list of defines associated to the shader.
  17670. * @param defines the list of defines to complete
  17671. * @param forPostProcess Define if we are currently in post process mode or not
  17672. */
  17673. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17674. /**
  17675. * Returns true if all the image processing information are ready.
  17676. * @returns True if ready, otherwise, false
  17677. */
  17678. isReady(): boolean;
  17679. /**
  17680. * Binds the image processing to the shader.
  17681. * @param effect The effect to bind to
  17682. * @param aspectRatio Define the current aspect ratio of the effect
  17683. */
  17684. bind(effect: Effect, aspectRatio?: number): void;
  17685. /**
  17686. * Clones the current image processing instance.
  17687. * @return The cloned image processing
  17688. */
  17689. clone(): ImageProcessingConfiguration;
  17690. /**
  17691. * Serializes the current image processing instance to a json representation.
  17692. * @return a JSON representation
  17693. */
  17694. serialize(): any;
  17695. /**
  17696. * Parses the image processing from a json representation.
  17697. * @param source the JSON source to parse
  17698. * @return The parsed image processing
  17699. */
  17700. static Parse(source: any): ImageProcessingConfiguration;
  17701. private static _VIGNETTEMODE_MULTIPLY;
  17702. private static _VIGNETTEMODE_OPAQUE;
  17703. /**
  17704. * Used to apply the vignette as a mix with the pixel color.
  17705. */
  17706. static readonly VIGNETTEMODE_MULTIPLY: number;
  17707. /**
  17708. * Used to apply the vignette as a replacement of the pixel color.
  17709. */
  17710. static readonly VIGNETTEMODE_OPAQUE: number;
  17711. }
  17712. }
  17713. declare module BABYLON {
  17714. /**
  17715. * Manages the defines for the Material
  17716. */
  17717. class MaterialDefines {
  17718. private _keys;
  17719. private _isDirty;
  17720. /** @hidden */
  17721. _renderId: number;
  17722. /** @hidden */
  17723. _areLightsDirty: boolean;
  17724. /** @hidden */
  17725. _areAttributesDirty: boolean;
  17726. /** @hidden */
  17727. _areTexturesDirty: boolean;
  17728. /** @hidden */
  17729. _areFresnelDirty: boolean;
  17730. /** @hidden */
  17731. _areMiscDirty: boolean;
  17732. /** @hidden */
  17733. _areImageProcessingDirty: boolean;
  17734. /** @hidden */
  17735. _normals: boolean;
  17736. /** @hidden */
  17737. _uvs: boolean;
  17738. /** @hidden */
  17739. _needNormals: boolean;
  17740. /** @hidden */
  17741. _needUVs: boolean;
  17742. /**
  17743. * Specifies if the material needs to be re-calculated
  17744. */
  17745. readonly isDirty: boolean;
  17746. /**
  17747. * Marks the material to indicate that it has been re-calculated
  17748. */
  17749. markAsProcessed(): void;
  17750. /**
  17751. * Marks the material to indicate that it needs to be re-calculated
  17752. */
  17753. markAsUnprocessed(): void;
  17754. /**
  17755. * Marks the material to indicate all of its defines need to be re-calculated
  17756. */
  17757. markAllAsDirty(): void;
  17758. /**
  17759. * Marks the material to indicate that image processing needs to be re-calculated
  17760. */
  17761. markAsImageProcessingDirty(): void;
  17762. /**
  17763. * Marks the material to indicate the lights need to be re-calculated
  17764. */
  17765. markAsLightDirty(): void;
  17766. /**
  17767. * Marks the attribute state as changed
  17768. */
  17769. markAsAttributesDirty(): void;
  17770. /**
  17771. * Marks the texture state as changed
  17772. */
  17773. markAsTexturesDirty(): void;
  17774. /**
  17775. * Marks the fresnel state as changed
  17776. */
  17777. markAsFresnelDirty(): void;
  17778. /**
  17779. * Marks the misc state as changed
  17780. */
  17781. markAsMiscDirty(): void;
  17782. /**
  17783. * Rebuilds the material defines
  17784. */
  17785. rebuild(): void;
  17786. /**
  17787. * Specifies if two material defines are equal
  17788. * @param other - A material define instance to compare to
  17789. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17790. */
  17791. isEqual(other: MaterialDefines): boolean;
  17792. /**
  17793. * Clones this instance's defines to another instance
  17794. * @param other - material defines to clone values to
  17795. */
  17796. cloneTo(other: MaterialDefines): void;
  17797. /**
  17798. * Resets the material define values
  17799. */
  17800. reset(): void;
  17801. /**
  17802. * Converts the material define values to a string
  17803. * @returns - String of material define information
  17804. */
  17805. toString(): string;
  17806. }
  17807. /**
  17808. * Base class for the main features of a material in Babylon.js
  17809. */
  17810. class Material implements IAnimatable {
  17811. private static _TriangleFillMode;
  17812. private static _WireFrameFillMode;
  17813. private static _PointFillMode;
  17814. private static _PointListDrawMode;
  17815. private static _LineListDrawMode;
  17816. private static _LineLoopDrawMode;
  17817. private static _LineStripDrawMode;
  17818. private static _TriangleStripDrawMode;
  17819. private static _TriangleFanDrawMode;
  17820. /**
  17821. * Returns the triangle fill mode
  17822. */
  17823. static readonly TriangleFillMode: number;
  17824. /**
  17825. * Returns the wireframe mode
  17826. */
  17827. static readonly WireFrameFillMode: number;
  17828. /**
  17829. * Returns the point fill mode
  17830. */
  17831. static readonly PointFillMode: number;
  17832. /**
  17833. * Returns the point list draw mode
  17834. */
  17835. static readonly PointListDrawMode: number;
  17836. /**
  17837. * Returns the line list draw mode
  17838. */
  17839. static readonly LineListDrawMode: number;
  17840. /**
  17841. * Returns the line loop draw mode
  17842. */
  17843. static readonly LineLoopDrawMode: number;
  17844. /**
  17845. * Returns the line strip draw mode
  17846. */
  17847. static readonly LineStripDrawMode: number;
  17848. /**
  17849. * Returns the triangle strip draw mode
  17850. */
  17851. static readonly TriangleStripDrawMode: number;
  17852. /**
  17853. * Returns the triangle fan draw mode
  17854. */
  17855. static readonly TriangleFanDrawMode: number;
  17856. /**
  17857. * Stores the clock-wise side orientation
  17858. */
  17859. private static _ClockWiseSideOrientation;
  17860. /**
  17861. * Stores the counter clock-wise side orientation
  17862. */
  17863. private static _CounterClockWiseSideOrientation;
  17864. /**
  17865. * Returns the clock-wise side orientation
  17866. */
  17867. static readonly ClockWiseSideOrientation: number;
  17868. /**
  17869. * Returns the counter clock-wise side orientation
  17870. */
  17871. static readonly CounterClockWiseSideOrientation: number;
  17872. /**
  17873. * The dirty texture flag value
  17874. */
  17875. static readonly TextureDirtyFlag: number;
  17876. /**
  17877. * The dirty light flag value
  17878. */
  17879. static readonly LightDirtyFlag: number;
  17880. /**
  17881. * The dirty fresnel flag value
  17882. */
  17883. static readonly FresnelDirtyFlag: number;
  17884. /**
  17885. * The dirty attribute flag value
  17886. */
  17887. static readonly AttributesDirtyFlag: number;
  17888. /**
  17889. * The dirty misc flag value
  17890. */
  17891. static readonly MiscDirtyFlag: number;
  17892. /**
  17893. * The all dirty flag value
  17894. */
  17895. static readonly AllDirtyFlag: number;
  17896. /**
  17897. * The ID of the material
  17898. */
  17899. id: string;
  17900. /**
  17901. * Gets or sets the unique id of the material
  17902. */
  17903. uniqueId: number;
  17904. /**
  17905. * The name of the material
  17906. */
  17907. name: string;
  17908. /**
  17909. * Specifies if the ready state should be checked on each call
  17910. */
  17911. checkReadyOnEveryCall: boolean;
  17912. /**
  17913. * Specifies if the ready state should be checked once
  17914. */
  17915. checkReadyOnlyOnce: boolean;
  17916. /**
  17917. * The state of the material
  17918. */
  17919. state: string;
  17920. /**
  17921. * The alpha value of the material
  17922. */
  17923. protected _alpha: number;
  17924. /**
  17925. * Sets the alpha value of the material
  17926. */
  17927. /**
  17928. * Gets the alpha value of the material
  17929. */
  17930. alpha: number;
  17931. /**
  17932. * Specifies if back face culling is enabled
  17933. */
  17934. protected _backFaceCulling: boolean;
  17935. /**
  17936. * Sets the back-face culling state
  17937. */
  17938. /**
  17939. * Gets the back-face culling state
  17940. */
  17941. backFaceCulling: boolean;
  17942. /**
  17943. * Stores the value for side orientation
  17944. */
  17945. sideOrientation: number;
  17946. /**
  17947. * Callback triggered when the material is compiled
  17948. */
  17949. onCompiled: (effect: Effect) => void;
  17950. /**
  17951. * Callback triggered when an error occurs
  17952. */
  17953. onError: (effect: Effect, errors: string) => void;
  17954. /**
  17955. * Callback triggered to get the render target textures
  17956. */
  17957. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17958. /**
  17959. * Gets a boolean indicating that current material needs to register RTT
  17960. */
  17961. readonly hasRenderTargetTextures: boolean;
  17962. /**
  17963. * Specifies if the material should be serialized
  17964. */
  17965. doNotSerialize: boolean;
  17966. /**
  17967. * @hidden
  17968. */
  17969. _storeEffectOnSubMeshes: boolean;
  17970. /**
  17971. * Stores the animations for the material
  17972. */
  17973. animations: Array<Animation>;
  17974. /**
  17975. * An event triggered when the material is disposed
  17976. */
  17977. onDisposeObservable: Observable<Material>;
  17978. /**
  17979. * An observer which watches for dispose events
  17980. */
  17981. private _onDisposeObserver;
  17982. private _onUnBindObservable;
  17983. /**
  17984. * Called during a dispose event
  17985. */
  17986. onDispose: () => void;
  17987. private _onBindObservable;
  17988. /**
  17989. * An event triggered when the material is bound
  17990. */
  17991. readonly onBindObservable: Observable<AbstractMesh>;
  17992. /**
  17993. * An observer which watches for bind events
  17994. */
  17995. private _onBindObserver;
  17996. /**
  17997. * Called during a bind event
  17998. */
  17999. onBind: (Mesh: AbstractMesh) => void;
  18000. /**
  18001. * An event triggered when the material is unbound
  18002. */
  18003. readonly onUnBindObservable: Observable<Material>;
  18004. /**
  18005. * Stores the value of the alpha mode
  18006. */
  18007. private _alphaMode;
  18008. /**
  18009. * Sets the value of the alpha mode.
  18010. *
  18011. * | Value | Type | Description |
  18012. * | --- | --- | --- |
  18013. * | 0 | ALPHA_DISABLE | |
  18014. * | 1 | ALPHA_ADD | |
  18015. * | 2 | ALPHA_COMBINE | |
  18016. * | 3 | ALPHA_SUBTRACT | |
  18017. * | 4 | ALPHA_MULTIPLY | |
  18018. * | 5 | ALPHA_MAXIMIZED | |
  18019. * | 6 | ALPHA_ONEONE | |
  18020. * | 7 | ALPHA_PREMULTIPLIED | |
  18021. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18022. * | 9 | ALPHA_INTERPOLATE | |
  18023. * | 10 | ALPHA_SCREENMODE | |
  18024. *
  18025. */
  18026. /**
  18027. * Gets the value of the alpha mode
  18028. */
  18029. alphaMode: number;
  18030. /**
  18031. * Stores the state of the need depth pre-pass value
  18032. */
  18033. private _needDepthPrePass;
  18034. /**
  18035. * Sets the need depth pre-pass value
  18036. */
  18037. /**
  18038. * Gets the depth pre-pass value
  18039. */
  18040. needDepthPrePass: boolean;
  18041. /**
  18042. * Specifies if depth writing should be disabled
  18043. */
  18044. disableDepthWrite: boolean;
  18045. /**
  18046. * Specifies if depth writing should be forced
  18047. */
  18048. forceDepthWrite: boolean;
  18049. /**
  18050. * Specifies if there should be a separate pass for culling
  18051. */
  18052. separateCullingPass: boolean;
  18053. /**
  18054. * Stores the state specifing if fog should be enabled
  18055. */
  18056. private _fogEnabled;
  18057. /**
  18058. * Sets the state for enabling fog
  18059. */
  18060. /**
  18061. * Gets the value of the fog enabled state
  18062. */
  18063. fogEnabled: boolean;
  18064. /**
  18065. * Stores the size of points
  18066. */
  18067. pointSize: number;
  18068. /**
  18069. * Stores the z offset value
  18070. */
  18071. zOffset: number;
  18072. /**
  18073. * Gets a value specifying if wireframe mode is enabled
  18074. */
  18075. /**
  18076. * Sets the state of wireframe mode
  18077. */
  18078. wireframe: boolean;
  18079. /**
  18080. * Gets the value specifying if point clouds are enabled
  18081. */
  18082. /**
  18083. * Sets the state of point cloud mode
  18084. */
  18085. pointsCloud: boolean;
  18086. /**
  18087. * Gets the material fill mode
  18088. */
  18089. /**
  18090. * Sets the material fill mode
  18091. */
  18092. fillMode: number;
  18093. /**
  18094. * @hidden
  18095. * Stores the effects for the material
  18096. */
  18097. _effect: Nullable<Effect>;
  18098. /**
  18099. * @hidden
  18100. * Specifies if the material was previously ready
  18101. */
  18102. _wasPreviouslyReady: boolean;
  18103. /**
  18104. * Specifies if uniform buffers should be used
  18105. */
  18106. private _useUBO;
  18107. /**
  18108. * Stores a reference to the scene
  18109. */
  18110. private _scene;
  18111. /**
  18112. * Stores the fill mode state
  18113. */
  18114. private _fillMode;
  18115. /**
  18116. * Specifies if the depth write state should be cached
  18117. */
  18118. private _cachedDepthWriteState;
  18119. /**
  18120. * Stores the uniform buffer
  18121. */
  18122. protected _uniformBuffer: UniformBuffer;
  18123. /**
  18124. * Creates a material instance
  18125. * @param name defines the name of the material
  18126. * @param scene defines the scene to reference
  18127. * @param doNotAdd specifies if the material should be added to the scene
  18128. */
  18129. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18130. /**
  18131. * Returns a string representation of the current material
  18132. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18133. * @returns a string with material information
  18134. */
  18135. toString(fullDetails?: boolean): string;
  18136. /**
  18137. * Gets the class name of the material
  18138. * @returns a string with the class name of the material
  18139. */
  18140. getClassName(): string;
  18141. /**
  18142. * Specifies if updates for the material been locked
  18143. */
  18144. readonly isFrozen: boolean;
  18145. /**
  18146. * Locks updates for the material
  18147. */
  18148. freeze(): void;
  18149. /**
  18150. * Unlocks updates for the material
  18151. */
  18152. unfreeze(): void;
  18153. /**
  18154. * Specifies if the material is ready to be used
  18155. * @param mesh defines the mesh to check
  18156. * @param useInstances specifies if instances should be used
  18157. * @returns a boolean indicating if the material is ready to be used
  18158. */
  18159. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18160. /**
  18161. * Specifies that the submesh is ready to be used
  18162. * @param mesh defines the mesh to check
  18163. * @param subMesh defines which submesh to check
  18164. * @param useInstances specifies that instances should be used
  18165. * @returns a boolean indicating that the submesh is ready or not
  18166. */
  18167. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18168. /**
  18169. * Returns the material effect
  18170. * @returns the effect associated with the material
  18171. */
  18172. getEffect(): Nullable<Effect>;
  18173. /**
  18174. * Returns the current scene
  18175. * @returns a Scene
  18176. */
  18177. getScene(): Scene;
  18178. /**
  18179. * Specifies if the material will require alpha blending
  18180. * @returns a boolean specifying if alpha blending is needed
  18181. */
  18182. needAlphaBlending(): boolean;
  18183. /**
  18184. * Specifies if the mesh will require alpha blending
  18185. * @param mesh defines the mesh to check
  18186. * @returns a boolean specifying if alpha blending is needed for the mesh
  18187. */
  18188. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18189. /**
  18190. * Specifies if this material should be rendered in alpha test mode
  18191. * @returns a boolean specifying if an alpha test is needed.
  18192. */
  18193. needAlphaTesting(): boolean;
  18194. /**
  18195. * Gets the texture used for the alpha test
  18196. * @returns the texture to use for alpha testing
  18197. */
  18198. getAlphaTestTexture(): Nullable<BaseTexture>;
  18199. /**
  18200. * Marks the material to indicate that it needs to be re-calculated
  18201. */
  18202. markDirty(): void;
  18203. /** @hidden */
  18204. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18205. /**
  18206. * Binds the material to the mesh
  18207. * @param world defines the world transformation matrix
  18208. * @param mesh defines the mesh to bind the material to
  18209. */
  18210. bind(world: Matrix, mesh?: Mesh): void;
  18211. /**
  18212. * Binds the submesh to the material
  18213. * @param world defines the world transformation matrix
  18214. * @param mesh defines the mesh containing the submesh
  18215. * @param subMesh defines the submesh to bind the material to
  18216. */
  18217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18218. /**
  18219. * Binds the world matrix to the material
  18220. * @param world defines the world transformation matrix
  18221. */
  18222. bindOnlyWorldMatrix(world: Matrix): void;
  18223. /**
  18224. * Binds the scene's uniform buffer to the effect.
  18225. * @param effect defines the effect to bind to the scene uniform buffer
  18226. * @param sceneUbo defines the uniform buffer storing scene data
  18227. */
  18228. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18229. /**
  18230. * Binds the view matrix to the effect
  18231. * @param effect defines the effect to bind the view matrix to
  18232. */
  18233. bindView(effect: Effect): void;
  18234. /**
  18235. * Binds the view projection matrix to the effect
  18236. * @param effect defines the effect to bind the view projection matrix to
  18237. */
  18238. bindViewProjection(effect: Effect): void;
  18239. /**
  18240. * Specifies if material alpha testing should be turned on for the mesh
  18241. * @param mesh defines the mesh to check
  18242. */
  18243. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18244. /**
  18245. * Processes to execute after binding the material to a mesh
  18246. * @param mesh defines the rendered mesh
  18247. */
  18248. protected _afterBind(mesh?: Mesh): void;
  18249. /**
  18250. * Unbinds the material from the mesh
  18251. */
  18252. unbind(): void;
  18253. /**
  18254. * Gets the active textures from the material
  18255. * @returns an array of textures
  18256. */
  18257. getActiveTextures(): BaseTexture[];
  18258. /**
  18259. * Specifies if the material uses a texture
  18260. * @param texture defines the texture to check against the material
  18261. * @returns a boolean specifying if the material uses the texture
  18262. */
  18263. hasTexture(texture: BaseTexture): boolean;
  18264. /**
  18265. * Makes a duplicate of the material, and gives it a new name
  18266. * @param name defines the new name for the duplicated material
  18267. * @returns the cloned material
  18268. */
  18269. clone(name: string): Nullable<Material>;
  18270. /**
  18271. * Gets the meshes bound to the material
  18272. * @returns an array of meshes bound to the material
  18273. */
  18274. getBindedMeshes(): AbstractMesh[];
  18275. /**
  18276. * Force shader compilation
  18277. * @param mesh defines the mesh associated with this material
  18278. * @param onCompiled defines a function to execute once the material is compiled
  18279. * @param options defines the options to configure the compilation
  18280. */
  18281. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18282. clipPlane: boolean;
  18283. }>): void;
  18284. /**
  18285. * Force shader compilation
  18286. * @param mesh defines the mesh that will use this material
  18287. * @param options defines additional options for compiling the shaders
  18288. * @returns a promise that resolves when the compilation completes
  18289. */
  18290. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18291. clipPlane: boolean;
  18292. }>): Promise<void>;
  18293. /**
  18294. * Marks a define in the material to indicate that it needs to be re-computed
  18295. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18296. */
  18297. markAsDirty(flag: number): void;
  18298. /**
  18299. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18300. * @param func defines a function which checks material defines against the submeshes
  18301. */
  18302. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18303. /**
  18304. * Indicates that image processing needs to be re-calculated for all submeshes
  18305. */
  18306. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18307. /**
  18308. * Indicates that textures need to be re-calculated for all submeshes
  18309. */
  18310. protected _markAllSubMeshesAsTexturesDirty(): void;
  18311. /**
  18312. * Indicates that fresnel needs to be re-calculated for all submeshes
  18313. */
  18314. protected _markAllSubMeshesAsFresnelDirty(): void;
  18315. /**
  18316. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18317. */
  18318. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18319. /**
  18320. * Indicates that lights need to be re-calculated for all submeshes
  18321. */
  18322. protected _markAllSubMeshesAsLightsDirty(): void;
  18323. /**
  18324. * Indicates that attributes need to be re-calculated for all submeshes
  18325. */
  18326. protected _markAllSubMeshesAsAttributesDirty(): void;
  18327. /**
  18328. * Indicates that misc needs to be re-calculated for all submeshes
  18329. */
  18330. protected _markAllSubMeshesAsMiscDirty(): void;
  18331. /**
  18332. * Indicates that textures and misc need to be re-calculated for all submeshes
  18333. */
  18334. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18335. /**
  18336. * Disposes the material
  18337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18339. */
  18340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18341. /**
  18342. * Serializes this material
  18343. * @returns the serialized material object
  18344. */
  18345. serialize(): any;
  18346. /**
  18347. * Creates a MultiMaterial from parsed MultiMaterial data.
  18348. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18349. * @param scene defines the hosting scene
  18350. * @returns a new MultiMaterial
  18351. */
  18352. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18353. /**
  18354. * Creates a material from parsed material data
  18355. * @param parsedMaterial defines parsed material data
  18356. * @param scene defines the hosting scene
  18357. * @param rootUrl defines the root URL to use to load textures
  18358. * @returns a new material
  18359. */
  18360. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18361. }
  18362. }
  18363. declare module BABYLON {
  18364. /**
  18365. * "Static Class" containing the most commonly used helper while dealing with material for
  18366. * rendering purpose.
  18367. *
  18368. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18369. *
  18370. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18371. */
  18372. class MaterialHelper {
  18373. /**
  18374. * Bind the current view position to an effect.
  18375. * @param effect The effect to be bound
  18376. * @param scene The scene the eyes position is used from
  18377. */
  18378. static BindEyePosition(effect: Effect, scene: Scene): void;
  18379. /**
  18380. * Helps preparing the defines values about the UVs in used in the effect.
  18381. * UVs are shared as much as we can accross channels in the shaders.
  18382. * @param texture The texture we are preparing the UVs for
  18383. * @param defines The defines to update
  18384. * @param key The channel key "diffuse", "specular"... used in the shader
  18385. */
  18386. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18387. /**
  18388. * Binds a texture matrix value to its corrsponding uniform
  18389. * @param texture The texture to bind the matrix for
  18390. * @param uniformBuffer The uniform buffer receivin the data
  18391. * @param key The channel key "diffuse", "specular"... used in the shader
  18392. */
  18393. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18394. /**
  18395. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18396. * @param mesh defines the current mesh
  18397. * @param scene defines the current scene
  18398. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18399. * @param pointsCloud defines if point cloud rendering has to be turned on
  18400. * @param fogEnabled defines if fog has to be turned on
  18401. * @param alphaTest defines if alpha testing has to be turned on
  18402. * @param defines defines the current list of defines
  18403. */
  18404. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18405. /**
  18406. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18407. * @param scene defines the current scene
  18408. * @param engine defines the current engine
  18409. * @param defines specifies the list of active defines
  18410. * @param useInstances defines if instances have to be turned on
  18411. * @param useClipPlane defines if clip plane have to be turned on
  18412. */
  18413. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18414. /**
  18415. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18416. * @param mesh The mesh containing the geometry data we will draw
  18417. * @param defines The defines to update
  18418. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18419. * @param useBones Precise whether bones should be used or not (override mesh info)
  18420. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18421. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18422. * @returns false if defines are considered not dirty and have not been checked
  18423. */
  18424. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18425. /**
  18426. * Prepares the defines related to the light information passed in parameter
  18427. * @param scene The scene we are intending to draw
  18428. * @param mesh The mesh the effect is compiling for
  18429. * @param defines The defines to update
  18430. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18431. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18432. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18433. * @returns true if normals will be required for the rest of the effect
  18434. */
  18435. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18436. /**
  18437. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18438. * that won t be acctive due to defines being turned off.
  18439. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18440. * @param samplersList The samplers list
  18441. * @param defines The defines helping in the list generation
  18442. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18443. */
  18444. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18445. /**
  18446. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18447. * @param defines The defines to update while falling back
  18448. * @param fallbacks The authorized effect fallbacks
  18449. * @param maxSimultaneousLights The maximum number of lights allowed
  18450. * @param rank the current rank of the Effect
  18451. * @returns The newly affected rank
  18452. */
  18453. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18454. /**
  18455. * Prepares the list of attributes required for morph targets according to the effect defines.
  18456. * @param attribs The current list of supported attribs
  18457. * @param mesh The mesh to prepare the morph targets attributes for
  18458. * @param defines The current Defines of the effect
  18459. */
  18460. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18461. /**
  18462. * Prepares the list of attributes required for bones according to the effect defines.
  18463. * @param attribs The current list of supported attribs
  18464. * @param mesh The mesh to prepare the bones attributes for
  18465. * @param defines The current Defines of the effect
  18466. * @param fallbacks The current efffect fallback strategy
  18467. */
  18468. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18469. /**
  18470. * Prepares the list of attributes required for instances according to the effect defines.
  18471. * @param attribs The current list of supported attribs
  18472. * @param defines The current Defines of the effect
  18473. */
  18474. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18475. /**
  18476. * Binds the light shadow information to the effect for the given mesh.
  18477. * @param light The light containing the generator
  18478. * @param scene The scene the lights belongs to
  18479. * @param mesh The mesh we are binding the information to render
  18480. * @param lightIndex The light index in the effect used to render the mesh
  18481. * @param effect The effect we are binding the data to
  18482. */
  18483. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18484. /**
  18485. * Binds the light information to the effect.
  18486. * @param light The light containing the generator
  18487. * @param effect The effect we are binding the data to
  18488. * @param lightIndex The light index in the effect used to render
  18489. */
  18490. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18491. /**
  18492. * Binds the lights information from the scene to the effect for the given mesh.
  18493. * @param scene The scene the lights belongs to
  18494. * @param mesh The mesh we are binding the information to render
  18495. * @param effect The effect we are binding the data to
  18496. * @param defines The generated defines for the effect
  18497. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18498. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18499. */
  18500. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18501. private static _tempFogColor;
  18502. /**
  18503. * Binds the fog information from the scene to the effect for the given mesh.
  18504. * @param scene The scene the lights belongs to
  18505. * @param mesh The mesh we are binding the information to render
  18506. * @param effect The effect we are binding the data to
  18507. * @param linearSpace Defines if the fog effect is applied in linear space
  18508. */
  18509. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18510. /**
  18511. * Binds the bones information from the mesh to the effect.
  18512. * @param mesh The mesh we are binding the information to render
  18513. * @param effect The effect we are binding the data to
  18514. */
  18515. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18516. /**
  18517. * Binds the morph targets information from the mesh to the effect.
  18518. * @param abstractMesh The mesh we are binding the information to render
  18519. * @param effect The effect we are binding the data to
  18520. */
  18521. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18522. /**
  18523. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18524. * @param defines The generated defines used in the effect
  18525. * @param effect The effect we are binding the data to
  18526. * @param scene The scene we are willing to render with logarithmic scale for
  18527. */
  18528. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18529. /**
  18530. * Binds the clip plane information from the scene to the effect.
  18531. * @param scene The scene the clip plane information are extracted from
  18532. * @param effect The effect we are binding the data to
  18533. */
  18534. static BindClipPlane(effect: Effect, scene: Scene): void;
  18535. }
  18536. }
  18537. declare module BABYLON {
  18538. /**
  18539. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18540. * separate meshes. This can be use to improve performances.
  18541. * @see http://doc.babylonjs.com/how_to/multi_materials
  18542. */
  18543. class MultiMaterial extends Material {
  18544. private _subMaterials;
  18545. /**
  18546. * Gets or Sets the list of Materials used within the multi material.
  18547. * They need to be ordered according to the submeshes order in the associated mesh
  18548. */
  18549. subMaterials: Nullable<Material>[];
  18550. /**
  18551. * Instantiates a new Multi Material
  18552. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18553. * separate meshes. This can be use to improve performances.
  18554. * @see http://doc.babylonjs.com/how_to/multi_materials
  18555. * @param name Define the name in the scene
  18556. * @param scene Define the scene the material belongs to
  18557. */
  18558. constructor(name: string, scene: Scene);
  18559. private _hookArray;
  18560. /**
  18561. * Get one of the submaterial by its index in the submaterials array
  18562. * @param index The index to look the sub material at
  18563. * @returns The Material if the index has been defined
  18564. */
  18565. getSubMaterial(index: number): Nullable<Material>;
  18566. /**
  18567. * Get the list of active textures for the whole sub materials list.
  18568. * @returns All the textures that will be used during the rendering
  18569. */
  18570. getActiveTextures(): BaseTexture[];
  18571. /**
  18572. * Gets the current class name of the material e.g. "MultiMaterial"
  18573. * Mainly use in serialization.
  18574. * @returns the class name
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Checks if the material is ready to render the requested sub mesh
  18579. * @param mesh Define the mesh the submesh belongs to
  18580. * @param subMesh Define the sub mesh to look readyness for
  18581. * @param useInstances Define whether or not the material is used with instances
  18582. * @returns true if ready, otherwise false
  18583. */
  18584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18585. /**
  18586. * Clones the current material and its related sub materials
  18587. * @param name Define the name of the newly cloned material
  18588. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18589. * @returns the cloned material
  18590. */
  18591. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18592. /**
  18593. * Serializes the materials into a JSON representation.
  18594. * @returns the JSON representation
  18595. */
  18596. serialize(): any;
  18597. /**
  18598. * Dispose the material and release its associated resources
  18599. * @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)
  18600. * @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)
  18601. */
  18602. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18603. }
  18604. }
  18605. declare module BABYLON {
  18606. /**
  18607. * Base class of materials working in push mode in babylon JS
  18608. * @hidden
  18609. */
  18610. class PushMaterial extends Material {
  18611. protected _activeEffect: Effect;
  18612. protected _normalMatrix: Matrix;
  18613. /**
  18614. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18615. * This means that the material can keep using a previous shader while a new one is being compiled.
  18616. * This is mostly used when shader parallel compilation is supported (true by default)
  18617. */
  18618. allowShaderHotSwapping: boolean;
  18619. constructor(name: string, scene: Scene);
  18620. getEffect(): Effect;
  18621. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18622. /**
  18623. * Binds the given world matrix to the active effect
  18624. *
  18625. * @param world the matrix to bind
  18626. */
  18627. bindOnlyWorldMatrix(world: Matrix): void;
  18628. /**
  18629. * Binds the given normal matrix to the active effect
  18630. *
  18631. * @param normalMatrix the matrix to bind
  18632. */
  18633. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18634. bind(world: Matrix, mesh?: Mesh): void;
  18635. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18636. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18637. }
  18638. }
  18639. declare module BABYLON {
  18640. /**
  18641. * Defines the options associated with the creation of a shader material.
  18642. */
  18643. interface IShaderMaterialOptions {
  18644. /**
  18645. * Does the material work in alpha blend mode
  18646. */
  18647. needAlphaBlending: boolean;
  18648. /**
  18649. * Does the material work in alpha test mode
  18650. */
  18651. needAlphaTesting: boolean;
  18652. /**
  18653. * The list of attribute names used in the shader
  18654. */
  18655. attributes: string[];
  18656. /**
  18657. * The list of unifrom names used in the shader
  18658. */
  18659. uniforms: string[];
  18660. /**
  18661. * The list of UBO names used in the shader
  18662. */
  18663. uniformBuffers: string[];
  18664. /**
  18665. * The list of sampler names used in the shader
  18666. */
  18667. samplers: string[];
  18668. /**
  18669. * The list of defines used in the shader
  18670. */
  18671. defines: string[];
  18672. }
  18673. /**
  18674. * 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.
  18675. *
  18676. * This returned material effects how the mesh will look based on the code in the shaders.
  18677. *
  18678. * @see http://doc.babylonjs.com/how_to/shader_material
  18679. */
  18680. class ShaderMaterial extends Material {
  18681. private _shaderPath;
  18682. private _options;
  18683. private _textures;
  18684. private _textureArrays;
  18685. private _floats;
  18686. private _ints;
  18687. private _floatsArrays;
  18688. private _colors3;
  18689. private _colors3Arrays;
  18690. private _colors4;
  18691. private _vectors2;
  18692. private _vectors3;
  18693. private _vectors4;
  18694. private _matrices;
  18695. private _matrices3x3;
  18696. private _matrices2x2;
  18697. private _vectors2Arrays;
  18698. private _vectors3Arrays;
  18699. private _cachedWorldViewMatrix;
  18700. private _renderId;
  18701. /**
  18702. * Instantiate a new shader material.
  18703. * 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.
  18704. * This returned material effects how the mesh will look based on the code in the shaders.
  18705. * @see http://doc.babylonjs.com/how_to/shader_material
  18706. * @param name Define the name of the material in the scene
  18707. * @param scene Define the scene the material belongs to
  18708. * @param shaderPath Defines the route to the shader code in one of three ways:
  18709. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18710. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18711. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18712. * @param options Define the options used to create the shader
  18713. */
  18714. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18715. /**
  18716. * Gets the current class name of the material e.g. "ShaderMaterial"
  18717. * Mainly use in serialization.
  18718. * @returns the class name
  18719. */
  18720. getClassName(): string;
  18721. /**
  18722. * Specifies if the material will require alpha blending
  18723. * @returns a boolean specifying if alpha blending is needed
  18724. */
  18725. needAlphaBlending(): boolean;
  18726. /**
  18727. * Specifies if this material should be rendered in alpha test mode
  18728. * @returns a boolean specifying if an alpha test is needed.
  18729. */
  18730. needAlphaTesting(): boolean;
  18731. private _checkUniform;
  18732. /**
  18733. * Set a texture in the shader.
  18734. * @param name Define the name of the uniform samplers as defined in the shader
  18735. * @param texture Define the texture to bind to this sampler
  18736. * @return the material itself allowing "fluent" like uniform updates
  18737. */
  18738. setTexture(name: string, texture: Texture): ShaderMaterial;
  18739. /**
  18740. * Set a texture array in the shader.
  18741. * @param name Define the name of the uniform sampler array as defined in the shader
  18742. * @param textures Define the list of textures to bind to this sampler
  18743. * @return the material itself allowing "fluent" like uniform updates
  18744. */
  18745. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18746. /**
  18747. * Set a float in the shader.
  18748. * @param name Define the name of the uniform as defined in the shader
  18749. * @param value Define the value to give to the uniform
  18750. * @return the material itself allowing "fluent" like uniform updates
  18751. */
  18752. setFloat(name: string, value: number): ShaderMaterial;
  18753. /**
  18754. * Set a int in the shader.
  18755. * @param name Define the name of the uniform as defined in the shader
  18756. * @param value Define the value to give to the uniform
  18757. * @return the material itself allowing "fluent" like uniform updates
  18758. */
  18759. setInt(name: string, value: number): ShaderMaterial;
  18760. /**
  18761. * Set an array of floats in the shader.
  18762. * @param name Define the name of the uniform as defined in the shader
  18763. * @param value Define the value to give to the uniform
  18764. * @return the material itself allowing "fluent" like uniform updates
  18765. */
  18766. setFloats(name: string, value: number[]): ShaderMaterial;
  18767. /**
  18768. * Set a vec3 in the shader from a Color3.
  18769. * @param name Define the name of the uniform as defined in the shader
  18770. * @param value Define the value to give to the uniform
  18771. * @return the material itself allowing "fluent" like uniform updates
  18772. */
  18773. setColor3(name: string, value: Color3): ShaderMaterial;
  18774. /**
  18775. * Set a vec3 array in the shader from a Color3 array.
  18776. * @param name Define the name of the uniform as defined in the shader
  18777. * @param value Define the value to give to the uniform
  18778. * @return the material itself allowing "fluent" like uniform updates
  18779. */
  18780. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18781. /**
  18782. * Set a vec4 in the shader from a Color4.
  18783. * @param name Define the name of the uniform as defined in the shader
  18784. * @param value Define the value to give to the uniform
  18785. * @return the material itself allowing "fluent" like uniform updates
  18786. */
  18787. setColor4(name: string, value: Color4): ShaderMaterial;
  18788. /**
  18789. * Set a vec2 in the shader from a Vector2.
  18790. * @param name Define the name of the uniform as defined in the shader
  18791. * @param value Define the value to give to the uniform
  18792. * @return the material itself allowing "fluent" like uniform updates
  18793. */
  18794. setVector2(name: string, value: Vector2): ShaderMaterial;
  18795. /**
  18796. * Set a vec3 in the shader from a Vector3.
  18797. * @param name Define the name of the uniform as defined in the shader
  18798. * @param value Define the value to give to the uniform
  18799. * @return the material itself allowing "fluent" like uniform updates
  18800. */
  18801. setVector3(name: string, value: Vector3): ShaderMaterial;
  18802. /**
  18803. * Set a vec4 in the shader from a Vector4.
  18804. * @param name Define the name of the uniform as defined in the shader
  18805. * @param value Define the value to give to the uniform
  18806. * @return the material itself allowing "fluent" like uniform updates
  18807. */
  18808. setVector4(name: string, value: Vector4): ShaderMaterial;
  18809. /**
  18810. * Set a mat4 in the shader from a Matrix.
  18811. * @param name Define the name of the uniform as defined in the shader
  18812. * @param value Define the value to give to the uniform
  18813. * @return the material itself allowing "fluent" like uniform updates
  18814. */
  18815. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18816. /**
  18817. * Set a mat3 in the shader from a Float32Array.
  18818. * @param name Define the name of the uniform as defined in the shader
  18819. * @param value Define the value to give to the uniform
  18820. * @return the material itself allowing "fluent" like uniform updates
  18821. */
  18822. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18823. /**
  18824. * Set a mat2 in the shader from a Float32Array.
  18825. * @param name Define the name of the uniform as defined in the shader
  18826. * @param value Define the value to give to the uniform
  18827. * @return the material itself allowing "fluent" like uniform updates
  18828. */
  18829. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18830. /**
  18831. * Set a vec2 array in the shader from a number array.
  18832. * @param name Define the name of the uniform as defined in the shader
  18833. * @param value Define the value to give to the uniform
  18834. * @return the material itself allowing "fluent" like uniform updates
  18835. */
  18836. setArray2(name: string, value: number[]): ShaderMaterial;
  18837. /**
  18838. * Set a vec3 array in the shader from a number array.
  18839. * @param name Define the name of the uniform as defined in the shader
  18840. * @param value Define the value to give to the uniform
  18841. * @return the material itself allowing "fluent" like uniform updates
  18842. */
  18843. setArray3(name: string, value: number[]): ShaderMaterial;
  18844. private _checkCache;
  18845. /**
  18846. * Checks if the material is ready to render the requested mesh
  18847. * @param mesh Define the mesh to render
  18848. * @param useInstances Define whether or not the material is used with instances
  18849. * @returns true if ready, otherwise false
  18850. */
  18851. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18852. /**
  18853. * Binds the world matrix to the material
  18854. * @param world defines the world transformation matrix
  18855. */
  18856. bindOnlyWorldMatrix(world: Matrix): void;
  18857. /**
  18858. * Binds the material to the mesh
  18859. * @param world defines the world transformation matrix
  18860. * @param mesh defines the mesh to bind the material to
  18861. */
  18862. bind(world: Matrix, mesh?: Mesh): void;
  18863. /**
  18864. * Gets the active textures from the material
  18865. * @returns an array of textures
  18866. */
  18867. getActiveTextures(): BaseTexture[];
  18868. /**
  18869. * Specifies if the material uses a texture
  18870. * @param texture defines the texture to check against the material
  18871. * @returns a boolean specifying if the material uses the texture
  18872. */
  18873. hasTexture(texture: BaseTexture): boolean;
  18874. /**
  18875. * Makes a duplicate of the material, and gives it a new name
  18876. * @param name defines the new name for the duplicated material
  18877. * @returns the cloned material
  18878. */
  18879. clone(name: string): ShaderMaterial;
  18880. /**
  18881. * Disposes the material
  18882. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18883. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18884. */
  18885. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18886. /**
  18887. * Serializes this material in a JSON representation
  18888. * @returns the serialized material object
  18889. */
  18890. serialize(): any;
  18891. /**
  18892. * Creates a shader material from parsed shader material data
  18893. * @param source defines the JSON represnetation of the material
  18894. * @param scene defines the hosting scene
  18895. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18896. * @returns a new material
  18897. */
  18898. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18899. }
  18900. }
  18901. declare module BABYLON {
  18902. /** @hidden */
  18903. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18904. MAINUV1: boolean;
  18905. MAINUV2: boolean;
  18906. DIFFUSE: boolean;
  18907. DIFFUSEDIRECTUV: number;
  18908. AMBIENT: boolean;
  18909. AMBIENTDIRECTUV: number;
  18910. OPACITY: boolean;
  18911. OPACITYDIRECTUV: number;
  18912. OPACITYRGB: boolean;
  18913. REFLECTION: boolean;
  18914. EMISSIVE: boolean;
  18915. EMISSIVEDIRECTUV: number;
  18916. SPECULAR: boolean;
  18917. SPECULARDIRECTUV: number;
  18918. BUMP: boolean;
  18919. BUMPDIRECTUV: number;
  18920. PARALLAX: boolean;
  18921. PARALLAXOCCLUSION: boolean;
  18922. SPECULAROVERALPHA: boolean;
  18923. CLIPPLANE: boolean;
  18924. CLIPPLANE2: boolean;
  18925. CLIPPLANE3: boolean;
  18926. CLIPPLANE4: boolean;
  18927. ALPHATEST: boolean;
  18928. DEPTHPREPASS: boolean;
  18929. ALPHAFROMDIFFUSE: boolean;
  18930. POINTSIZE: boolean;
  18931. FOG: boolean;
  18932. SPECULARTERM: boolean;
  18933. DIFFUSEFRESNEL: boolean;
  18934. OPACITYFRESNEL: boolean;
  18935. REFLECTIONFRESNEL: boolean;
  18936. REFRACTIONFRESNEL: boolean;
  18937. EMISSIVEFRESNEL: boolean;
  18938. FRESNEL: boolean;
  18939. NORMAL: boolean;
  18940. UV1: boolean;
  18941. UV2: boolean;
  18942. VERTEXCOLOR: boolean;
  18943. VERTEXALPHA: boolean;
  18944. NUM_BONE_INFLUENCERS: number;
  18945. BonesPerMesh: number;
  18946. INSTANCES: boolean;
  18947. GLOSSINESS: boolean;
  18948. ROUGHNESS: boolean;
  18949. EMISSIVEASILLUMINATION: boolean;
  18950. LINKEMISSIVEWITHDIFFUSE: boolean;
  18951. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18952. LIGHTMAP: boolean;
  18953. LIGHTMAPDIRECTUV: number;
  18954. OBJECTSPACE_NORMALMAP: boolean;
  18955. USELIGHTMAPASSHADOWMAP: boolean;
  18956. REFLECTIONMAP_3D: boolean;
  18957. REFLECTIONMAP_SPHERICAL: boolean;
  18958. REFLECTIONMAP_PLANAR: boolean;
  18959. REFLECTIONMAP_CUBIC: boolean;
  18960. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18961. REFLECTIONMAP_PROJECTION: boolean;
  18962. REFLECTIONMAP_SKYBOX: boolean;
  18963. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  18964. REFLECTIONMAP_EXPLICIT: boolean;
  18965. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18966. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18967. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18968. INVERTCUBICMAP: boolean;
  18969. LOGARITHMICDEPTH: boolean;
  18970. REFRACTION: boolean;
  18971. REFRACTIONMAP_3D: boolean;
  18972. REFLECTIONOVERALPHA: boolean;
  18973. TWOSIDEDLIGHTING: boolean;
  18974. SHADOWFLOAT: boolean;
  18975. MORPHTARGETS: boolean;
  18976. MORPHTARGETS_NORMAL: boolean;
  18977. MORPHTARGETS_TANGENT: boolean;
  18978. NUM_MORPH_INFLUENCERS: number;
  18979. NONUNIFORMSCALING: boolean;
  18980. PREMULTIPLYALPHA: boolean;
  18981. IMAGEPROCESSING: boolean;
  18982. VIGNETTE: boolean;
  18983. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18984. VIGNETTEBLENDMODEOPAQUE: boolean;
  18985. TONEMAPPING: boolean;
  18986. TONEMAPPING_ACES: boolean;
  18987. CONTRAST: boolean;
  18988. COLORCURVES: boolean;
  18989. COLORGRADING: boolean;
  18990. COLORGRADING3D: boolean;
  18991. SAMPLER3DGREENDEPTH: boolean;
  18992. SAMPLER3DBGRMAP: boolean;
  18993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18994. /**
  18995. * If the reflection texture on this material is in linear color space
  18996. * @hidden
  18997. */
  18998. IS_REFLECTION_LINEAR: boolean;
  18999. /**
  19000. * If the refraction texture on this material is in linear color space
  19001. * @hidden
  19002. */
  19003. IS_REFRACTION_LINEAR: boolean;
  19004. EXPOSURE: boolean;
  19005. constructor();
  19006. setReflectionMode(modeToEnable: string): void;
  19007. }
  19008. /**
  19009. * This is the default material used in Babylon. It is the best trade off between quality
  19010. * and performances.
  19011. * @see http://doc.babylonjs.com/babylon101/materials
  19012. */
  19013. class StandardMaterial extends PushMaterial {
  19014. private _diffuseTexture;
  19015. /**
  19016. * The basic texture of the material as viewed under a light.
  19017. */
  19018. diffuseTexture: Nullable<BaseTexture>;
  19019. private _ambientTexture;
  19020. /**
  19021. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19022. */
  19023. ambientTexture: Nullable<BaseTexture>;
  19024. private _opacityTexture;
  19025. /**
  19026. * Define the transparency of the material from a texture.
  19027. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19028. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19029. */
  19030. opacityTexture: Nullable<BaseTexture>;
  19031. private _reflectionTexture;
  19032. /**
  19033. * Define the texture used to display the reflection.
  19034. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19035. */
  19036. reflectionTexture: Nullable<BaseTexture>;
  19037. private _emissiveTexture;
  19038. /**
  19039. * Define texture of the material as if self lit.
  19040. * This will be mixed in the final result even in the absence of light.
  19041. */
  19042. emissiveTexture: Nullable<BaseTexture>;
  19043. private _specularTexture;
  19044. /**
  19045. * Define how the color and intensity of the highlight given by the light in the material.
  19046. */
  19047. specularTexture: Nullable<BaseTexture>;
  19048. private _bumpTexture;
  19049. /**
  19050. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19051. * 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.
  19052. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19053. */
  19054. bumpTexture: Nullable<BaseTexture>;
  19055. private _lightmapTexture;
  19056. /**
  19057. * Complex lighting can be computationally expensive to compute at runtime.
  19058. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19059. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19060. */
  19061. lightmapTexture: Nullable<BaseTexture>;
  19062. private _refractionTexture;
  19063. /**
  19064. * Define the texture used to display the refraction.
  19065. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19066. */
  19067. refractionTexture: Nullable<BaseTexture>;
  19068. /**
  19069. * The color of the material lit by the environmental background lighting.
  19070. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19071. */
  19072. ambientColor: Color3;
  19073. /**
  19074. * The basic color of the material as viewed under a light.
  19075. */
  19076. diffuseColor: Color3;
  19077. /**
  19078. * Define how the color and intensity of the highlight given by the light in the material.
  19079. */
  19080. specularColor: Color3;
  19081. /**
  19082. * Define the color of the material as if self lit.
  19083. * This will be mixed in the final result even in the absence of light.
  19084. */
  19085. emissiveColor: Color3;
  19086. /**
  19087. * Defines how sharp are the highlights in the material.
  19088. * The bigger the value the sharper giving a more glossy feeling to the result.
  19089. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19090. */
  19091. specularPower: number;
  19092. private _useAlphaFromDiffuseTexture;
  19093. /**
  19094. * Does the transparency come from the diffuse texture alpha channel.
  19095. */
  19096. useAlphaFromDiffuseTexture: boolean;
  19097. private _useEmissiveAsIllumination;
  19098. /**
  19099. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19100. */
  19101. useEmissiveAsIllumination: boolean;
  19102. private _linkEmissiveWithDiffuse;
  19103. /**
  19104. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19105. * the emissive level when the final color is close to one.
  19106. */
  19107. linkEmissiveWithDiffuse: boolean;
  19108. private _useSpecularOverAlpha;
  19109. /**
  19110. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19111. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19112. */
  19113. useSpecularOverAlpha: boolean;
  19114. private _useReflectionOverAlpha;
  19115. /**
  19116. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19117. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19118. */
  19119. useReflectionOverAlpha: boolean;
  19120. private _disableLighting;
  19121. /**
  19122. * Does lights from the scene impacts this material.
  19123. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19124. */
  19125. disableLighting: boolean;
  19126. private _useObjectSpaceNormalMap;
  19127. /**
  19128. * Allows using an object space normal map (instead of tangent space).
  19129. */
  19130. useObjectSpaceNormalMap: boolean;
  19131. private _useParallax;
  19132. /**
  19133. * Is parallax enabled or not.
  19134. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19135. */
  19136. useParallax: boolean;
  19137. private _useParallaxOcclusion;
  19138. /**
  19139. * Is parallax occlusion enabled or not.
  19140. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19141. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19142. */
  19143. useParallaxOcclusion: boolean;
  19144. /**
  19145. * 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.
  19146. */
  19147. parallaxScaleBias: number;
  19148. private _roughness;
  19149. /**
  19150. * Helps to define how blurry the reflections should appears in the material.
  19151. */
  19152. roughness: number;
  19153. /**
  19154. * In case of refraction, define the value of the indice of refraction.
  19155. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19156. */
  19157. indexOfRefraction: number;
  19158. /**
  19159. * Invert the refraction texture alongside the y axis.
  19160. * It can be usefull with procedural textures or probe for instance.
  19161. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19162. */
  19163. invertRefractionY: boolean;
  19164. /**
  19165. * Defines the alpha limits in alpha test mode.
  19166. */
  19167. alphaCutOff: number;
  19168. private _useLightmapAsShadowmap;
  19169. /**
  19170. * In case of light mapping, define whether the map contains light or shadow informations.
  19171. */
  19172. useLightmapAsShadowmap: boolean;
  19173. private _diffuseFresnelParameters;
  19174. /**
  19175. * Define the diffuse fresnel parameters of the material.
  19176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19177. */
  19178. diffuseFresnelParameters: FresnelParameters;
  19179. private _opacityFresnelParameters;
  19180. /**
  19181. * Define the opacity fresnel parameters of the material.
  19182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19183. */
  19184. opacityFresnelParameters: FresnelParameters;
  19185. private _reflectionFresnelParameters;
  19186. /**
  19187. * Define the reflection fresnel parameters of the material.
  19188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19189. */
  19190. reflectionFresnelParameters: FresnelParameters;
  19191. private _refractionFresnelParameters;
  19192. /**
  19193. * Define the refraction fresnel parameters of the material.
  19194. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19195. */
  19196. refractionFresnelParameters: FresnelParameters;
  19197. private _emissiveFresnelParameters;
  19198. /**
  19199. * Define the emissive fresnel parameters of the material.
  19200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19201. */
  19202. emissiveFresnelParameters: FresnelParameters;
  19203. private _useReflectionFresnelFromSpecular;
  19204. /**
  19205. * If true automatically deducts the fresnels values from the material specularity.
  19206. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19207. */
  19208. useReflectionFresnelFromSpecular: boolean;
  19209. private _useGlossinessFromSpecularMapAlpha;
  19210. /**
  19211. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19212. */
  19213. useGlossinessFromSpecularMapAlpha: boolean;
  19214. private _maxSimultaneousLights;
  19215. /**
  19216. * Defines the maximum number of lights that can be used in the material
  19217. */
  19218. maxSimultaneousLights: number;
  19219. private _invertNormalMapX;
  19220. /**
  19221. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19222. */
  19223. invertNormalMapX: boolean;
  19224. private _invertNormalMapY;
  19225. /**
  19226. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19227. */
  19228. invertNormalMapY: boolean;
  19229. private _twoSidedLighting;
  19230. /**
  19231. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19232. */
  19233. twoSidedLighting: boolean;
  19234. /**
  19235. * Default configuration related to image processing available in the standard Material.
  19236. */
  19237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19238. /**
  19239. * Gets the image processing configuration used either in this material.
  19240. */
  19241. /**
  19242. * Sets the Default image processing configuration used either in the this material.
  19243. *
  19244. * If sets to null, the scene one is in use.
  19245. */
  19246. imageProcessingConfiguration: ImageProcessingConfiguration;
  19247. /**
  19248. * Keep track of the image processing observer to allow dispose and replace.
  19249. */
  19250. private _imageProcessingObserver;
  19251. /**
  19252. * Attaches a new image processing configuration to the Standard Material.
  19253. * @param configuration
  19254. */
  19255. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19256. /**
  19257. * Gets wether the color curves effect is enabled.
  19258. */
  19259. /**
  19260. * Sets wether the color curves effect is enabled.
  19261. */
  19262. cameraColorCurvesEnabled: boolean;
  19263. /**
  19264. * Gets wether the color grading effect is enabled.
  19265. */
  19266. /**
  19267. * Gets wether the color grading effect is enabled.
  19268. */
  19269. cameraColorGradingEnabled: boolean;
  19270. /**
  19271. * Gets wether tonemapping is enabled or not.
  19272. */
  19273. /**
  19274. * Sets wether tonemapping is enabled or not
  19275. */
  19276. cameraToneMappingEnabled: boolean;
  19277. /**
  19278. * The camera exposure used on this material.
  19279. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19280. * This corresponds to a photographic exposure.
  19281. */
  19282. /**
  19283. * The camera exposure used on this material.
  19284. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19285. * This corresponds to a photographic exposure.
  19286. */
  19287. cameraExposure: number;
  19288. /**
  19289. * Gets The camera contrast used on this material.
  19290. */
  19291. /**
  19292. * Sets The camera contrast used on this material.
  19293. */
  19294. cameraContrast: number;
  19295. /**
  19296. * Gets the Color Grading 2D Lookup Texture.
  19297. */
  19298. /**
  19299. * Sets the Color Grading 2D Lookup Texture.
  19300. */
  19301. cameraColorGradingTexture: Nullable<BaseTexture>;
  19302. /**
  19303. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19304. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19305. * 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;
  19306. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19307. */
  19308. /**
  19309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19311. * 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;
  19312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19313. */
  19314. cameraColorCurves: Nullable<ColorCurves>;
  19315. /**
  19316. * Custom callback helping to override the default shader used in the material.
  19317. */
  19318. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19319. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19320. protected _worldViewProjectionMatrix: Matrix;
  19321. protected _globalAmbientColor: Color3;
  19322. protected _useLogarithmicDepth: boolean;
  19323. /**
  19324. * Instantiates a new standard material.
  19325. * This is the default material used in Babylon. It is the best trade off between quality
  19326. * and performances.
  19327. * @see http://doc.babylonjs.com/babylon101/materials
  19328. * @param name Define the name of the material in the scene
  19329. * @param scene Define the scene the material belong to
  19330. */
  19331. constructor(name: string, scene: Scene);
  19332. /**
  19333. * Gets a boolean indicating that current material needs to register RTT
  19334. */
  19335. readonly hasRenderTargetTextures: boolean;
  19336. /**
  19337. * Gets the current class name of the material e.g. "StandardMaterial"
  19338. * Mainly use in serialization.
  19339. * @returns the class name
  19340. */
  19341. getClassName(): string;
  19342. /**
  19343. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19344. * You can try switching to logarithmic depth.
  19345. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19346. */
  19347. useLogarithmicDepth: boolean;
  19348. /**
  19349. * Specifies if the material will require alpha blending
  19350. * @returns a boolean specifying if alpha blending is needed
  19351. */
  19352. needAlphaBlending(): boolean;
  19353. /**
  19354. * Specifies if this material should be rendered in alpha test mode
  19355. * @returns a boolean specifying if an alpha test is needed.
  19356. */
  19357. needAlphaTesting(): boolean;
  19358. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19359. /**
  19360. * Get the texture used for alpha test purpose.
  19361. * @returns the diffuse texture in case of the standard material.
  19362. */
  19363. getAlphaTestTexture(): Nullable<BaseTexture>;
  19364. /**
  19365. * Get if the submesh is ready to be used and all its information available.
  19366. * Child classes can use it to update shaders
  19367. * @param mesh defines the mesh to check
  19368. * @param subMesh defines which submesh to check
  19369. * @param useInstances specifies that instances should be used
  19370. * @returns a boolean indicating that the submesh is ready or not
  19371. */
  19372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19373. /**
  19374. * Builds the material UBO layouts.
  19375. * Used internally during the effect preparation.
  19376. */
  19377. buildUniformLayout(): void;
  19378. /**
  19379. * Unbinds the material from the mesh
  19380. */
  19381. unbind(): void;
  19382. /**
  19383. * Binds the submesh to this material by preparing the effect and shader to draw
  19384. * @param world defines the world transformation matrix
  19385. * @param mesh defines the mesh containing the submesh
  19386. * @param subMesh defines the submesh to bind the material to
  19387. */
  19388. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19389. /**
  19390. * Get the list of animatables in the material.
  19391. * @returns the list of animatables object used in the material
  19392. */
  19393. getAnimatables(): IAnimatable[];
  19394. /**
  19395. * Gets the active textures from the material
  19396. * @returns an array of textures
  19397. */
  19398. getActiveTextures(): BaseTexture[];
  19399. /**
  19400. * Specifies if the material uses a texture
  19401. * @param texture defines the texture to check against the material
  19402. * @returns a boolean specifying if the material uses the texture
  19403. */
  19404. hasTexture(texture: BaseTexture): boolean;
  19405. /**
  19406. * Disposes the material
  19407. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19408. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19409. */
  19410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19411. /**
  19412. * Makes a duplicate of the material, and gives it a new name
  19413. * @param name defines the new name for the duplicated material
  19414. * @returns the cloned material
  19415. */
  19416. clone(name: string): StandardMaterial;
  19417. /**
  19418. * Serializes this material in a JSON representation
  19419. * @returns the serialized material object
  19420. */
  19421. serialize(): any;
  19422. /**
  19423. * Creates a standard material from parsed material data
  19424. * @param source defines the JSON represnetation of the material
  19425. * @param scene defines the hosting scene
  19426. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19427. * @returns a new material
  19428. */
  19429. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19430. private static _DiffuseTextureEnabled;
  19431. /**
  19432. * Are diffuse textures enabled in the application.
  19433. */
  19434. static DiffuseTextureEnabled: boolean;
  19435. private static _AmbientTextureEnabled;
  19436. /**
  19437. * Are ambient textures enabled in the application.
  19438. */
  19439. static AmbientTextureEnabled: boolean;
  19440. private static _OpacityTextureEnabled;
  19441. /**
  19442. * Are opacity textures enabled in the application.
  19443. */
  19444. static OpacityTextureEnabled: boolean;
  19445. private static _ReflectionTextureEnabled;
  19446. /**
  19447. * Are reflection textures enabled in the application.
  19448. */
  19449. static ReflectionTextureEnabled: boolean;
  19450. private static _EmissiveTextureEnabled;
  19451. /**
  19452. * Are emissive textures enabled in the application.
  19453. */
  19454. static EmissiveTextureEnabled: boolean;
  19455. private static _SpecularTextureEnabled;
  19456. /**
  19457. * Are specular textures enabled in the application.
  19458. */
  19459. static SpecularTextureEnabled: boolean;
  19460. private static _BumpTextureEnabled;
  19461. /**
  19462. * Are bump textures enabled in the application.
  19463. */
  19464. static BumpTextureEnabled: boolean;
  19465. private static _LightmapTextureEnabled;
  19466. /**
  19467. * Are lightmap textures enabled in the application.
  19468. */
  19469. static LightmapTextureEnabled: boolean;
  19470. private static _RefractionTextureEnabled;
  19471. /**
  19472. * Are refraction textures enabled in the application.
  19473. */
  19474. static RefractionTextureEnabled: boolean;
  19475. private static _ColorGradingTextureEnabled;
  19476. /**
  19477. * Are color grading textures enabled in the application.
  19478. */
  19479. static ColorGradingTextureEnabled: boolean;
  19480. private static _FresnelEnabled;
  19481. /**
  19482. * Are fresnels enabled in the application.
  19483. */
  19484. static FresnelEnabled: boolean;
  19485. }
  19486. }
  19487. declare module BABYLON {
  19488. /**
  19489. * Uniform buffer objects.
  19490. *
  19491. * Handles blocks of uniform on the GPU.
  19492. *
  19493. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19494. *
  19495. * For more information, please refer to :
  19496. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19497. */
  19498. class UniformBuffer {
  19499. private _engine;
  19500. private _buffer;
  19501. private _data;
  19502. private _bufferData;
  19503. private _dynamic?;
  19504. private _uniformLocations;
  19505. private _uniformSizes;
  19506. private _uniformLocationPointer;
  19507. private _needSync;
  19508. private _noUBO;
  19509. private _currentEffect;
  19510. private static _MAX_UNIFORM_SIZE;
  19511. private static _tempBuffer;
  19512. /**
  19513. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19514. * This is dynamic to allow compat with webgl 1 and 2.
  19515. * You will need to pass the name of the uniform as well as the value.
  19516. */
  19517. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19518. /**
  19519. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19520. * This is dynamic to allow compat with webgl 1 and 2.
  19521. * You will need to pass the name of the uniform as well as the value.
  19522. */
  19523. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19524. /**
  19525. * Lambda to Update a single float in a uniform buffer.
  19526. * This is dynamic to allow compat with webgl 1 and 2.
  19527. * You will need to pass the name of the uniform as well as the value.
  19528. */
  19529. updateFloat: (name: string, x: number) => void;
  19530. /**
  19531. * Lambda to Update a vec2 of float in a uniform buffer.
  19532. * This is dynamic to allow compat with webgl 1 and 2.
  19533. * You will need to pass the name of the uniform as well as the value.
  19534. */
  19535. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19536. /**
  19537. * Lambda to Update a vec3 of float in a uniform buffer.
  19538. * This is dynamic to allow compat with webgl 1 and 2.
  19539. * You will need to pass the name of the uniform as well as the value.
  19540. */
  19541. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19542. /**
  19543. * Lambda to Update a vec4 of float in a uniform buffer.
  19544. * This is dynamic to allow compat with webgl 1 and 2.
  19545. * You will need to pass the name of the uniform as well as the value.
  19546. */
  19547. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19548. /**
  19549. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19550. * This is dynamic to allow compat with webgl 1 and 2.
  19551. * You will need to pass the name of the uniform as well as the value.
  19552. */
  19553. updateMatrix: (name: string, mat: Matrix) => void;
  19554. /**
  19555. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19556. * This is dynamic to allow compat with webgl 1 and 2.
  19557. * You will need to pass the name of the uniform as well as the value.
  19558. */
  19559. updateVector3: (name: string, vector: Vector3) => void;
  19560. /**
  19561. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19562. * This is dynamic to allow compat with webgl 1 and 2.
  19563. * You will need to pass the name of the uniform as well as the value.
  19564. */
  19565. updateVector4: (name: string, vector: Vector4) => void;
  19566. /**
  19567. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19568. * This is dynamic to allow compat with webgl 1 and 2.
  19569. * You will need to pass the name of the uniform as well as the value.
  19570. */
  19571. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19572. /**
  19573. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19574. * This is dynamic to allow compat with webgl 1 and 2.
  19575. * You will need to pass the name of the uniform as well as the value.
  19576. */
  19577. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19578. /**
  19579. * Instantiates a new Uniform buffer objects.
  19580. *
  19581. * Handles blocks of uniform on the GPU.
  19582. *
  19583. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19584. *
  19585. * For more information, please refer to :
  19586. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19587. * @param engine Define the engine the buffer is associated with
  19588. * @param data Define the data contained in the buffer
  19589. * @param dynamic Define if the buffer is updatable
  19590. */
  19591. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19592. /**
  19593. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19594. * or just falling back on setUniformXXX calls.
  19595. */
  19596. readonly useUbo: boolean;
  19597. /**
  19598. * Indicates if the WebGL underlying uniform buffer is in sync
  19599. * with the javascript cache data.
  19600. */
  19601. readonly isSync: boolean;
  19602. /**
  19603. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19604. * Also, a dynamic UniformBuffer will disable cache verification and always
  19605. * update the underlying WebGL uniform buffer to the GPU.
  19606. * @returns if Dynamic, otherwise false
  19607. */
  19608. isDynamic(): boolean;
  19609. /**
  19610. * The data cache on JS side.
  19611. * @returns the underlying data as a float array
  19612. */
  19613. getData(): Float32Array;
  19614. /**
  19615. * The underlying WebGL Uniform buffer.
  19616. * @returns the webgl buffer
  19617. */
  19618. getBuffer(): Nullable<WebGLBuffer>;
  19619. /**
  19620. * std140 layout specifies how to align data within an UBO structure.
  19621. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19622. * for specs.
  19623. */
  19624. private _fillAlignment;
  19625. /**
  19626. * Adds an uniform in the buffer.
  19627. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19628. * for the layout to be correct !
  19629. * @param name Name of the uniform, as used in the uniform block in the shader.
  19630. * @param size Data size, or data directly.
  19631. */
  19632. addUniform(name: string, size: number | number[]): void;
  19633. /**
  19634. * Adds a Matrix 4x4 to the uniform buffer.
  19635. * @param name Name of the uniform, as used in the uniform block in the shader.
  19636. * @param mat A 4x4 matrix.
  19637. */
  19638. addMatrix(name: string, mat: Matrix): void;
  19639. /**
  19640. * Adds a vec2 to the uniform buffer.
  19641. * @param name Name of the uniform, as used in the uniform block in the shader.
  19642. * @param x Define the x component value of the vec2
  19643. * @param y Define the y component value of the vec2
  19644. */
  19645. addFloat2(name: string, x: number, y: number): void;
  19646. /**
  19647. * Adds a vec3 to the uniform buffer.
  19648. * @param name Name of the uniform, as used in the uniform block in the shader.
  19649. * @param x Define the x component value of the vec3
  19650. * @param y Define the y component value of the vec3
  19651. * @param z Define the z component value of the vec3
  19652. */
  19653. addFloat3(name: string, x: number, y: number, z: number): void;
  19654. /**
  19655. * Adds a vec3 to the uniform buffer.
  19656. * @param name Name of the uniform, as used in the uniform block in the shader.
  19657. * @param color Define the vec3 from a Color
  19658. */
  19659. addColor3(name: string, color: Color3): void;
  19660. /**
  19661. * Adds a vec4 to the uniform buffer.
  19662. * @param name Name of the uniform, as used in the uniform block in the shader.
  19663. * @param color Define the rgb components from a Color
  19664. * @param alpha Define the a component of the vec4
  19665. */
  19666. addColor4(name: string, color: Color3, alpha: number): void;
  19667. /**
  19668. * Adds a vec3 to the uniform buffer.
  19669. * @param name Name of the uniform, as used in the uniform block in the shader.
  19670. * @param vector Define the vec3 components from a Vector
  19671. */
  19672. addVector3(name: string, vector: Vector3): void;
  19673. /**
  19674. * Adds a Matrix 3x3 to the uniform buffer.
  19675. * @param name Name of the uniform, as used in the uniform block in the shader.
  19676. */
  19677. addMatrix3x3(name: string): void;
  19678. /**
  19679. * Adds a Matrix 2x2 to the uniform buffer.
  19680. * @param name Name of the uniform, as used in the uniform block in the shader.
  19681. */
  19682. addMatrix2x2(name: string): void;
  19683. /**
  19684. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19685. */
  19686. create(): void;
  19687. /** @hidden */
  19688. _rebuild(): void;
  19689. /**
  19690. * Updates the WebGL Uniform Buffer on the GPU.
  19691. * If the `dynamic` flag is set to true, no cache comparison is done.
  19692. * Otherwise, the buffer will be updated only if the cache differs.
  19693. */
  19694. update(): void;
  19695. /**
  19696. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19697. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19698. * @param data Define the flattened data
  19699. * @param size Define the size of the data.
  19700. */
  19701. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19702. private _updateMatrix3x3ForUniform;
  19703. private _updateMatrix3x3ForEffect;
  19704. private _updateMatrix2x2ForEffect;
  19705. private _updateMatrix2x2ForUniform;
  19706. private _updateFloatForEffect;
  19707. private _updateFloatForUniform;
  19708. private _updateFloat2ForEffect;
  19709. private _updateFloat2ForUniform;
  19710. private _updateFloat3ForEffect;
  19711. private _updateFloat3ForUniform;
  19712. private _updateFloat4ForEffect;
  19713. private _updateFloat4ForUniform;
  19714. private _updateMatrixForEffect;
  19715. private _updateMatrixForUniform;
  19716. private _updateVector3ForEffect;
  19717. private _updateVector3ForUniform;
  19718. private _updateVector4ForEffect;
  19719. private _updateVector4ForUniform;
  19720. private _updateColor3ForEffect;
  19721. private _updateColor3ForUniform;
  19722. private _updateColor4ForEffect;
  19723. private _updateColor4ForUniform;
  19724. /**
  19725. * Sets a sampler uniform on the effect.
  19726. * @param name Define the name of the sampler.
  19727. * @param texture Define the texture to set in the sampler
  19728. */
  19729. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19730. /**
  19731. * Directly updates the value of the uniform in the cache AND on the GPU.
  19732. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19733. * @param data Define the flattened data
  19734. */
  19735. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19736. /**
  19737. * Binds this uniform buffer to an effect.
  19738. * @param effect Define the effect to bind the buffer to
  19739. * @param name Name of the uniform block in the shader.
  19740. */
  19741. bindToEffect(effect: Effect, name: string): void;
  19742. /**
  19743. * Disposes the uniform buffer.
  19744. */
  19745. dispose(): void;
  19746. }
  19747. }
  19748. declare module BABYLON {
  19749. /**
  19750. * Scalar computation library
  19751. */
  19752. class Scalar {
  19753. /**
  19754. * Two pi constants convenient for computation.
  19755. */
  19756. static TwoPi: number;
  19757. /**
  19758. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19759. * @param a number
  19760. * @param b number
  19761. * @param epsilon (default = 1.401298E-45)
  19762. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19763. */
  19764. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19765. /**
  19766. * Returns a string : the upper case translation of the number i to hexadecimal.
  19767. * @param i number
  19768. * @returns the upper case translation of the number i to hexadecimal.
  19769. */
  19770. static ToHex(i: number): string;
  19771. /**
  19772. * Returns -1 if value is negative and +1 is value is positive.
  19773. * @param value the value
  19774. * @returns the value itself if it's equal to zero.
  19775. */
  19776. static Sign(value: number): number;
  19777. /**
  19778. * Returns the value itself if it's between min and max.
  19779. * Returns min if the value is lower than min.
  19780. * Returns max if the value is greater than max.
  19781. * @param value the value to clmap
  19782. * @param min the min value to clamp to (default: 0)
  19783. * @param max the max value to clamp to (default: 1)
  19784. * @returns the clamped value
  19785. */
  19786. static Clamp(value: number, min?: number, max?: number): number;
  19787. /**
  19788. * the log2 of value.
  19789. * @param value the value to compute log2 of
  19790. * @returns the log2 of value.
  19791. */
  19792. static Log2(value: number): number;
  19793. /**
  19794. * Loops the value, so that it is never larger than length and never smaller than 0.
  19795. *
  19796. * This is similar to the modulo operator but it works with floating point numbers.
  19797. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19798. * With t = 5 and length = 2.5, the result would be 0.0.
  19799. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19800. * @param value the value
  19801. * @param length the length
  19802. * @returns the looped value
  19803. */
  19804. static Repeat(value: number, length: number): number;
  19805. /**
  19806. * Normalize the value between 0.0 and 1.0 using min and max values
  19807. * @param value value to normalize
  19808. * @param min max to normalize between
  19809. * @param max min to normalize between
  19810. * @returns the normalized value
  19811. */
  19812. static Normalize(value: number, min: number, max: number): number;
  19813. /**
  19814. * Denormalize the value from 0.0 and 1.0 using min and max values
  19815. * @param normalized value to denormalize
  19816. * @param min max to denormalize between
  19817. * @param max min to denormalize between
  19818. * @returns the denormalized value
  19819. */
  19820. static Denormalize(normalized: number, min: number, max: number): number;
  19821. /**
  19822. * Calculates the shortest difference between two given angles given in degrees.
  19823. * @param current current angle in degrees
  19824. * @param target target angle in degrees
  19825. * @returns the delta
  19826. */
  19827. static DeltaAngle(current: number, target: number): number;
  19828. /**
  19829. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19830. * @param tx value
  19831. * @param length length
  19832. * @returns The returned value will move back and forth between 0 and length
  19833. */
  19834. static PingPong(tx: number, length: number): number;
  19835. /**
  19836. * Interpolates between min and max with smoothing at the limits.
  19837. *
  19838. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19839. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19840. * @param from from
  19841. * @param to to
  19842. * @param tx value
  19843. * @returns the smooth stepped value
  19844. */
  19845. static SmoothStep(from: number, to: number, tx: number): number;
  19846. /**
  19847. * Moves a value current towards target.
  19848. *
  19849. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19850. * Negative values of maxDelta pushes the value away from target.
  19851. * @param current current value
  19852. * @param target target value
  19853. * @param maxDelta max distance to move
  19854. * @returns resulting value
  19855. */
  19856. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19857. /**
  19858. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19859. *
  19860. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19861. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19862. * @param current current value
  19863. * @param target target value
  19864. * @param maxDelta max distance to move
  19865. * @returns resulting angle
  19866. */
  19867. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19868. /**
  19869. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19870. * @param start start value
  19871. * @param end target value
  19872. * @param amount amount to lerp between
  19873. * @returns the lerped value
  19874. */
  19875. static Lerp(start: number, end: number, amount: number): number;
  19876. /**
  19877. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19878. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19879. * @param start start value
  19880. * @param end target value
  19881. * @param amount amount to lerp between
  19882. * @returns the lerped value
  19883. */
  19884. static LerpAngle(start: number, end: number, amount: number): number;
  19885. /**
  19886. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19887. * @param a start value
  19888. * @param b target value
  19889. * @param value value between a and b
  19890. * @returns the inverseLerp value
  19891. */
  19892. static InverseLerp(a: number, b: number, value: number): number;
  19893. /**
  19894. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19895. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19896. * @param value1 spline value
  19897. * @param tangent1 spline value
  19898. * @param value2 spline value
  19899. * @param tangent2 spline value
  19900. * @param amount input value
  19901. * @returns hermite result
  19902. */
  19903. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19904. /**
  19905. * Returns a random float number between and min and max values
  19906. * @param min min value of random
  19907. * @param max max value of random
  19908. * @returns random value
  19909. */
  19910. static RandomRange(min: number, max: number): number;
  19911. /**
  19912. * This function returns percentage of a number in a given range.
  19913. *
  19914. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19915. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19916. * @param number to convert to percentage
  19917. * @param min min range
  19918. * @param max max range
  19919. * @returns the percentage
  19920. */
  19921. static RangeToPercent(number: number, min: number, max: number): number;
  19922. /**
  19923. * This function returns number that corresponds to the percentage in a given range.
  19924. *
  19925. * PercentToRange(0.34,0,100) will return 34.
  19926. * @param percent to convert to number
  19927. * @param min min range
  19928. * @param max max range
  19929. * @returns the number
  19930. */
  19931. static PercentToRange(percent: number, min: number, max: number): number;
  19932. /**
  19933. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19934. * @param angle The angle to normalize in radian.
  19935. * @return The converted angle.
  19936. */
  19937. static NormalizeRadians(angle: number): number;
  19938. }
  19939. }
  19940. declare module BABYLON {
  19941. /**
  19942. * Constant used to convert a value to gamma space
  19943. * @ignorenaming
  19944. */
  19945. const ToGammaSpace: number;
  19946. /**
  19947. * Constant used to convert a value to linear space
  19948. * @ignorenaming
  19949. */
  19950. const ToLinearSpace = 2.2;
  19951. /**
  19952. * Constant used to define the minimal number value in Babylon.js
  19953. * @ignorenaming
  19954. */
  19955. const Epsilon = 0.001;
  19956. /**
  19957. * Class used to hold a RBG color
  19958. */
  19959. class Color3 {
  19960. /**
  19961. * Defines the red component (between 0 and 1, default is 0)
  19962. */
  19963. r: number;
  19964. /**
  19965. * Defines the green component (between 0 and 1, default is 0)
  19966. */
  19967. g: number;
  19968. /**
  19969. * Defines the blue component (between 0 and 1, default is 0)
  19970. */
  19971. b: number;
  19972. /**
  19973. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  19974. * @param r defines the red component (between 0 and 1, default is 0)
  19975. * @param g defines the green component (between 0 and 1, default is 0)
  19976. * @param b defines the blue component (between 0 and 1, default is 0)
  19977. */
  19978. constructor(
  19979. /**
  19980. * Defines the red component (between 0 and 1, default is 0)
  19981. */
  19982. r?: number,
  19983. /**
  19984. * Defines the green component (between 0 and 1, default is 0)
  19985. */
  19986. g?: number,
  19987. /**
  19988. * Defines the blue component (between 0 and 1, default is 0)
  19989. */
  19990. b?: number);
  19991. /**
  19992. * Creates a string with the Color3 current values
  19993. * @returns the string representation of the Color3 object
  19994. */
  19995. toString(): string;
  19996. /**
  19997. * Returns the string "Color3"
  19998. * @returns "Color3"
  19999. */
  20000. getClassName(): string;
  20001. /**
  20002. * Compute the Color3 hash code
  20003. * @returns an unique number that can be used to hash Color3 objects
  20004. */
  20005. getHashCode(): number;
  20006. /**
  20007. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20008. * @param array defines the array where to store the r,g,b components
  20009. * @param index defines an optional index in the target array to define where to start storing values
  20010. * @returns the current Color3 object
  20011. */
  20012. toArray(array: FloatArray, index?: number): Color3;
  20013. /**
  20014. * Returns a new Color4 object from the current Color3 and the given alpha
  20015. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20016. * @returns a new Color4 object
  20017. */
  20018. toColor4(alpha?: number): Color4;
  20019. /**
  20020. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20021. * @returns the new array
  20022. */
  20023. asArray(): number[];
  20024. /**
  20025. * Returns the luminance value
  20026. * @returns a float value
  20027. */
  20028. toLuminance(): number;
  20029. /**
  20030. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20031. * @param otherColor defines the second operand
  20032. * @returns the new Color3 object
  20033. */
  20034. multiply(otherColor: Color3): Color3;
  20035. /**
  20036. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20037. * @param otherColor defines the second operand
  20038. * @param result defines the Color3 object where to store the result
  20039. * @returns the current Color3
  20040. */
  20041. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20042. /**
  20043. * Determines equality between Color3 objects
  20044. * @param otherColor defines the second operand
  20045. * @returns true if the rgb values are equal to the given ones
  20046. */
  20047. equals(otherColor: Color3): boolean;
  20048. /**
  20049. * Determines equality between the current Color3 object and a set of r,b,g values
  20050. * @param r defines the red component to check
  20051. * @param g defines the green component to check
  20052. * @param b defines the blue component to check
  20053. * @returns true if the rgb values are equal to the given ones
  20054. */
  20055. equalsFloats(r: number, g: number, b: number): boolean;
  20056. /**
  20057. * Multiplies in place each rgb value by scale
  20058. * @param scale defines the scaling factor
  20059. * @returns the updated Color3
  20060. */
  20061. scale(scale: number): Color3;
  20062. /**
  20063. * Multiplies the rgb values by scale and stores the result into "result"
  20064. * @param scale defines the scaling factor
  20065. * @param result defines the Color3 object where to store the result
  20066. * @returns the unmodified current Color3
  20067. */
  20068. scaleToRef(scale: number, result: Color3): Color3;
  20069. /**
  20070. * Scale the current Color3 values by a factor and add the result to a given Color3
  20071. * @param scale defines the scale factor
  20072. * @param result defines color to store the result into
  20073. * @returns the unmodified current Color3
  20074. */
  20075. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20076. /**
  20077. * Clamps the rgb values by the min and max values and stores the result into "result"
  20078. * @param min defines minimum clamping value (default is 0)
  20079. * @param max defines maximum clamping value (default is 1)
  20080. * @param result defines color to store the result into
  20081. * @returns the original Color3
  20082. */
  20083. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20084. /**
  20085. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20086. * @param otherColor defines the second operand
  20087. * @returns the new Color3
  20088. */
  20089. add(otherColor: Color3): Color3;
  20090. /**
  20091. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20092. * @param otherColor defines the second operand
  20093. * @param result defines Color3 object to store the result into
  20094. * @returns the unmodified current Color3
  20095. */
  20096. addToRef(otherColor: Color3, result: Color3): Color3;
  20097. /**
  20098. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20099. * @param otherColor defines the second operand
  20100. * @returns the new Color3
  20101. */
  20102. subtract(otherColor: Color3): Color3;
  20103. /**
  20104. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20105. * @param otherColor defines the second operand
  20106. * @param result defines Color3 object to store the result into
  20107. * @returns the unmodified current Color3
  20108. */
  20109. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20110. /**
  20111. * Copy the current object
  20112. * @returns a new Color3 copied the current one
  20113. */
  20114. clone(): Color3;
  20115. /**
  20116. * Copies the rgb values from the source in the current Color3
  20117. * @param source defines the source Color3 object
  20118. * @returns the updated Color3 object
  20119. */
  20120. copyFrom(source: Color3): Color3;
  20121. /**
  20122. * Updates the Color3 rgb values from the given floats
  20123. * @param r defines the red component to read from
  20124. * @param g defines the green component to read from
  20125. * @param b defines the blue component to read from
  20126. * @returns the current Color3 object
  20127. */
  20128. copyFromFloats(r: number, g: number, b: number): Color3;
  20129. /**
  20130. * Updates the Color3 rgb values from the given floats
  20131. * @param r defines the red component to read from
  20132. * @param g defines the green component to read from
  20133. * @param b defines the blue component to read from
  20134. * @returns the current Color3 object
  20135. */
  20136. set(r: number, g: number, b: number): Color3;
  20137. /**
  20138. * Compute the Color3 hexadecimal code as a string
  20139. * @returns a string containing the hexadecimal representation of the Color3 object
  20140. */
  20141. toHexString(): string;
  20142. /**
  20143. * Computes a new Color3 converted from the current one to linear space
  20144. * @returns a new Color3 object
  20145. */
  20146. toLinearSpace(): Color3;
  20147. /**
  20148. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20149. * @param convertedColor defines the Color3 object where to store the linear space version
  20150. * @returns the unmodified Color3
  20151. */
  20152. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20153. /**
  20154. * Computes a new Color3 converted from the current one to gamma space
  20155. * @returns a new Color3 object
  20156. */
  20157. toGammaSpace(): Color3;
  20158. /**
  20159. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20160. * @param convertedColor defines the Color3 object where to store the gamma space version
  20161. * @returns the unmodified Color3
  20162. */
  20163. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20164. /**
  20165. * Creates a new Color3 from the string containing valid hexadecimal values
  20166. * @param hex defines a string containing valid hexadecimal values
  20167. * @returns a new Color3 object
  20168. */
  20169. static FromHexString(hex: string): Color3;
  20170. /**
  20171. * Creates a new Vector3 from the starting index of the given array
  20172. * @param array defines the source array
  20173. * @param offset defines an offset in the source array
  20174. * @returns a new Color3 object
  20175. */
  20176. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20177. /**
  20178. * Creates a new Color3 from integer values (< 256)
  20179. * @param r defines the red component to read from (value between 0 and 255)
  20180. * @param g defines the green component to read from (value between 0 and 255)
  20181. * @param b defines the blue component to read from (value between 0 and 255)
  20182. * @returns a new Color3 object
  20183. */
  20184. static FromInts(r: number, g: number, b: number): Color3;
  20185. /**
  20186. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20187. * @param start defines the start Color3 value
  20188. * @param end defines the end Color3 value
  20189. * @param amount defines the gradient value between start and end
  20190. * @returns a new Color3 object
  20191. */
  20192. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20193. /**
  20194. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20195. * @param left defines the start value
  20196. * @param right defines the end value
  20197. * @param amount defines the gradient factor
  20198. * @param result defines the Color3 object where to store the result
  20199. */
  20200. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20201. /**
  20202. * Returns a Color3 value containing a red color
  20203. * @returns a new Color3 object
  20204. */
  20205. static Red(): Color3;
  20206. /**
  20207. * Returns a Color3 value containing a green color
  20208. * @returns a new Color3 object
  20209. */
  20210. static Green(): Color3;
  20211. /**
  20212. * Returns a Color3 value containing a blue color
  20213. * @returns a new Color3 object
  20214. */
  20215. static Blue(): Color3;
  20216. /**
  20217. * Returns a Color3 value containing a black color
  20218. * @returns a new Color3 object
  20219. */
  20220. static Black(): Color3;
  20221. /**
  20222. * Returns a Color3 value containing a white color
  20223. * @returns a new Color3 object
  20224. */
  20225. static White(): Color3;
  20226. /**
  20227. * Returns a Color3 value containing a purple color
  20228. * @returns a new Color3 object
  20229. */
  20230. static Purple(): Color3;
  20231. /**
  20232. * Returns a Color3 value containing a magenta color
  20233. * @returns a new Color3 object
  20234. */
  20235. static Magenta(): Color3;
  20236. /**
  20237. * Returns a Color3 value containing a yellow color
  20238. * @returns a new Color3 object
  20239. */
  20240. static Yellow(): Color3;
  20241. /**
  20242. * Returns a Color3 value containing a gray color
  20243. * @returns a new Color3 object
  20244. */
  20245. static Gray(): Color3;
  20246. /**
  20247. * Returns a Color3 value containing a teal color
  20248. * @returns a new Color3 object
  20249. */
  20250. static Teal(): Color3;
  20251. /**
  20252. * Returns a Color3 value containing a random color
  20253. * @returns a new Color3 object
  20254. */
  20255. static Random(): Color3;
  20256. }
  20257. /**
  20258. * Class used to hold a RBGA color
  20259. */
  20260. class Color4 {
  20261. /**
  20262. * Defines the red component (between 0 and 1, default is 0)
  20263. */
  20264. r: number;
  20265. /**
  20266. * Defines the green component (between 0 and 1, default is 0)
  20267. */
  20268. g: number;
  20269. /**
  20270. * Defines the blue component (between 0 and 1, default is 0)
  20271. */
  20272. b: number;
  20273. /**
  20274. * Defines the alpha component (between 0 and 1, default is 1)
  20275. */
  20276. a: number;
  20277. /**
  20278. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20279. * @param r defines the red component (between 0 and 1, default is 0)
  20280. * @param g defines the green component (between 0 and 1, default is 0)
  20281. * @param b defines the blue component (between 0 and 1, default is 0)
  20282. * @param a defines the alpha component (between 0 and 1, default is 1)
  20283. */
  20284. constructor(
  20285. /**
  20286. * Defines the red component (between 0 and 1, default is 0)
  20287. */
  20288. r?: number,
  20289. /**
  20290. * Defines the green component (between 0 and 1, default is 0)
  20291. */
  20292. g?: number,
  20293. /**
  20294. * Defines the blue component (between 0 and 1, default is 0)
  20295. */
  20296. b?: number,
  20297. /**
  20298. * Defines the alpha component (between 0 and 1, default is 1)
  20299. */
  20300. a?: number);
  20301. /**
  20302. * Adds in place the given Color4 values to the current Color4 object
  20303. * @param right defines the second operand
  20304. * @returns the current updated Color4 object
  20305. */
  20306. addInPlace(right: Color4): Color4;
  20307. /**
  20308. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20309. * @returns the new array
  20310. */
  20311. asArray(): number[];
  20312. /**
  20313. * Stores from the starting index in the given array the Color4 successive values
  20314. * @param array defines the array where to store the r,g,b components
  20315. * @param index defines an optional index in the target array to define where to start storing values
  20316. * @returns the current Color4 object
  20317. */
  20318. toArray(array: number[], index?: number): Color4;
  20319. /**
  20320. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20321. * @param right defines the second operand
  20322. * @returns a new Color4 object
  20323. */
  20324. add(right: Color4): Color4;
  20325. /**
  20326. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20327. * @param right defines the second operand
  20328. * @returns a new Color4 object
  20329. */
  20330. subtract(right: Color4): Color4;
  20331. /**
  20332. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20333. * @param right defines the second operand
  20334. * @param result defines the Color4 object where to store the result
  20335. * @returns the current Color4 object
  20336. */
  20337. subtractToRef(right: Color4, result: Color4): Color4;
  20338. /**
  20339. * Creates a new Color4 with the current Color4 values multiplied by scale
  20340. * @param scale defines the scaling factor to apply
  20341. * @returns a new Color4 object
  20342. */
  20343. scale(scale: number): Color4;
  20344. /**
  20345. * Multiplies the current Color4 values by scale and stores the result in "result"
  20346. * @param scale defines the scaling factor to apply
  20347. * @param result defines the Color4 object where to store the result
  20348. * @returns the current unmodified Color4
  20349. */
  20350. scaleToRef(scale: number, result: Color4): Color4;
  20351. /**
  20352. * Scale the current Color4 values by a factor and add the result to a given Color4
  20353. * @param scale defines the scale factor
  20354. * @param result defines the Color4 object where to store the result
  20355. * @returns the unmodified current Color4
  20356. */
  20357. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20358. /**
  20359. * Clamps the rgb values by the min and max values and stores the result into "result"
  20360. * @param min defines minimum clamping value (default is 0)
  20361. * @param max defines maximum clamping value (default is 1)
  20362. * @param result defines color to store the result into.
  20363. * @returns the cuurent Color4
  20364. */
  20365. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20366. /**
  20367. * Multipy an Color4 value by another and return a new Color4 object
  20368. * @param color defines the Color4 value to multiply by
  20369. * @returns a new Color4 object
  20370. */
  20371. multiply(color: Color4): Color4;
  20372. /**
  20373. * Multipy a Color4 value by another and push the result in a reference value
  20374. * @param color defines the Color4 value to multiply by
  20375. * @param result defines the Color4 to fill the result in
  20376. * @returns the result Color4
  20377. */
  20378. multiplyToRef(color: Color4, result: Color4): Color4;
  20379. /**
  20380. * Creates a string with the Color4 current values
  20381. * @returns the string representation of the Color4 object
  20382. */
  20383. toString(): string;
  20384. /**
  20385. * Returns the string "Color4"
  20386. * @returns "Color4"
  20387. */
  20388. getClassName(): string;
  20389. /**
  20390. * Compute the Color4 hash code
  20391. * @returns an unique number that can be used to hash Color4 objects
  20392. */
  20393. getHashCode(): number;
  20394. /**
  20395. * Creates a new Color4 copied from the current one
  20396. * @returns a new Color4 object
  20397. */
  20398. clone(): Color4;
  20399. /**
  20400. * Copies the given Color4 values into the current one
  20401. * @param source defines the source Color4 object
  20402. * @returns the current updated Color4 object
  20403. */
  20404. copyFrom(source: Color4): Color4;
  20405. /**
  20406. * Copies the given float values into the current one
  20407. * @param r defines the red component to read from
  20408. * @param g defines the green component to read from
  20409. * @param b defines the blue component to read from
  20410. * @param a defines the alpha component to read from
  20411. * @returns the current updated Color4 object
  20412. */
  20413. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20414. /**
  20415. * Copies the given float values into the current one
  20416. * @param r defines the red component to read from
  20417. * @param g defines the green component to read from
  20418. * @param b defines the blue component to read from
  20419. * @param a defines the alpha component to read from
  20420. * @returns the current updated Color4 object
  20421. */
  20422. set(r: number, g: number, b: number, a: number): Color4;
  20423. /**
  20424. * Compute the Color4 hexadecimal code as a string
  20425. * @returns a string containing the hexadecimal representation of the Color4 object
  20426. */
  20427. toHexString(): string;
  20428. /**
  20429. * Computes a new Color4 converted from the current one to linear space
  20430. * @returns a new Color4 object
  20431. */
  20432. toLinearSpace(): Color4;
  20433. /**
  20434. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20435. * @param convertedColor defines the Color4 object where to store the linear space version
  20436. * @returns the unmodified Color4
  20437. */
  20438. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20439. /**
  20440. * Computes a new Color4 converted from the current one to gamma space
  20441. * @returns a new Color4 object
  20442. */
  20443. toGammaSpace(): Color4;
  20444. /**
  20445. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20446. * @param convertedColor defines the Color4 object where to store the gamma space version
  20447. * @returns the unmodified Color4
  20448. */
  20449. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20450. /**
  20451. * Creates a new Color4 from the string containing valid hexadecimal values
  20452. * @param hex defines a string containing valid hexadecimal values
  20453. * @returns a new Color4 object
  20454. */
  20455. static FromHexString(hex: string): Color4;
  20456. /**
  20457. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20458. * @param left defines the start value
  20459. * @param right defines the end value
  20460. * @param amount defines the gradient factor
  20461. * @returns a new Color4 object
  20462. */
  20463. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20464. /**
  20465. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20466. * @param left defines the start value
  20467. * @param right defines the end value
  20468. * @param amount defines the gradient factor
  20469. * @param result defines the Color4 object where to store data
  20470. */
  20471. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20472. /**
  20473. * Creates a new Color4 from a Color3 and an alpha value
  20474. * @param color3 defines the source Color3 to read from
  20475. * @param alpha defines the alpha component (1.0 by default)
  20476. * @returns a new Color4 object
  20477. */
  20478. static FromColor3(color3: Color3, alpha?: number): Color4;
  20479. /**
  20480. * Creates a new Color4 from the starting index element of the given array
  20481. * @param array defines the source array to read from
  20482. * @param offset defines the offset in the source array
  20483. * @returns a new Color4 object
  20484. */
  20485. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20486. /**
  20487. * Creates a new Color3 from integer values (< 256)
  20488. * @param r defines the red component to read from (value between 0 and 255)
  20489. * @param g defines the green component to read from (value between 0 and 255)
  20490. * @param b defines the blue component to read from (value between 0 and 255)
  20491. * @param a defines the alpha component to read from (value between 0 and 255)
  20492. * @returns a new Color3 object
  20493. */
  20494. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20495. /**
  20496. * Check the content of a given array and convert it to an array containing RGBA data
  20497. * If the original array was already containing count * 4 values then it is returned directly
  20498. * @param colors defines the array to check
  20499. * @param count defines the number of RGBA data to expect
  20500. * @returns an array containing count * 4 values (RGBA)
  20501. */
  20502. static CheckColors4(colors: number[], count: number): number[];
  20503. }
  20504. /**
  20505. * Class representing a vector containing 2 coordinates
  20506. */
  20507. class Vector2 {
  20508. /** defines the first coordinate */
  20509. x: number;
  20510. /** defines the second coordinate */
  20511. y: number;
  20512. /**
  20513. * Creates a new Vector2 from the given x and y coordinates
  20514. * @param x defines the first coordinate
  20515. * @param y defines the second coordinate
  20516. */
  20517. constructor(
  20518. /** defines the first coordinate */
  20519. x?: number,
  20520. /** defines the second coordinate */
  20521. y?: number);
  20522. /**
  20523. * Gets a string with the Vector2 coordinates
  20524. * @returns a string with the Vector2 coordinates
  20525. */
  20526. toString(): string;
  20527. /**
  20528. * Gets class name
  20529. * @returns the string "Vector2"
  20530. */
  20531. getClassName(): string;
  20532. /**
  20533. * Gets current vector hash code
  20534. * @returns the Vector2 hash code as a number
  20535. */
  20536. getHashCode(): number;
  20537. /**
  20538. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20539. * @param array defines the source array
  20540. * @param index defines the offset in source array
  20541. * @returns the current Vector2
  20542. */
  20543. toArray(array: FloatArray, index?: number): Vector2;
  20544. /**
  20545. * Copy the current vector to an array
  20546. * @returns a new array with 2 elements: the Vector2 coordinates.
  20547. */
  20548. asArray(): number[];
  20549. /**
  20550. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20551. * @param source defines the source Vector2
  20552. * @returns the current updated Vector2
  20553. */
  20554. copyFrom(source: Vector2): Vector2;
  20555. /**
  20556. * Sets the Vector2 coordinates with the given floats
  20557. * @param x defines the first coordinate
  20558. * @param y defines the second coordinate
  20559. * @returns the current updated Vector2
  20560. */
  20561. copyFromFloats(x: number, y: number): Vector2;
  20562. /**
  20563. * Sets the Vector2 coordinates with the given floats
  20564. * @param x defines the first coordinate
  20565. * @param y defines the second coordinate
  20566. * @returns the current updated Vector2
  20567. */
  20568. set(x: number, y: number): Vector2;
  20569. /**
  20570. * Add another vector with the current one
  20571. * @param otherVector defines the other vector
  20572. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20573. */
  20574. add(otherVector: Vector2): Vector2;
  20575. /**
  20576. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20577. * @param otherVector defines the other vector
  20578. * @param result defines the target vector
  20579. * @returns the unmodified current Vector2
  20580. */
  20581. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20582. /**
  20583. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20584. * @param otherVector defines the other vector
  20585. * @returns the current updated Vector2
  20586. */
  20587. addInPlace(otherVector: Vector2): Vector2;
  20588. /**
  20589. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20590. * @param otherVector defines the other vector
  20591. * @returns a new Vector2
  20592. */
  20593. addVector3(otherVector: Vector3): Vector2;
  20594. /**
  20595. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20596. * @param otherVector defines the other vector
  20597. * @returns a new Vector2
  20598. */
  20599. subtract(otherVector: Vector2): Vector2;
  20600. /**
  20601. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20602. * @param otherVector defines the other vector
  20603. * @param result defines the target vector
  20604. * @returns the unmodified current Vector2
  20605. */
  20606. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20607. /**
  20608. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20609. * @param otherVector defines the other vector
  20610. * @returns the current updated Vector2
  20611. */
  20612. subtractInPlace(otherVector: Vector2): Vector2;
  20613. /**
  20614. * Multiplies in place the current Vector2 coordinates by the given ones
  20615. * @param otherVector defines the other vector
  20616. * @returns the current updated Vector2
  20617. */
  20618. multiplyInPlace(otherVector: Vector2): Vector2;
  20619. /**
  20620. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20621. * @param otherVector defines the other vector
  20622. * @returns a new Vector2
  20623. */
  20624. multiply(otherVector: Vector2): Vector2;
  20625. /**
  20626. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20627. * @param otherVector defines the other vector
  20628. * @param result defines the target vector
  20629. * @returns the unmodified current Vector2
  20630. */
  20631. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20632. /**
  20633. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20634. * @param x defines the first coordinate
  20635. * @param y defines the second coordinate
  20636. * @returns a new Vector2
  20637. */
  20638. multiplyByFloats(x: number, y: number): Vector2;
  20639. /**
  20640. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20641. * @param otherVector defines the other vector
  20642. * @returns a new Vector2
  20643. */
  20644. divide(otherVector: Vector2): Vector2;
  20645. /**
  20646. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20647. * @param otherVector defines the other vector
  20648. * @param result defines the target vector
  20649. * @returns the unmodified current Vector2
  20650. */
  20651. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20652. /**
  20653. * Divides the current Vector2 coordinates by the given ones
  20654. * @param otherVector defines the other vector
  20655. * @returns the current updated Vector2
  20656. */
  20657. divideInPlace(otherVector: Vector2): Vector2;
  20658. /**
  20659. * Gets a new Vector2 with current Vector2 negated coordinates
  20660. * @returns a new Vector2
  20661. */
  20662. negate(): Vector2;
  20663. /**
  20664. * Multiply the Vector2 coordinates by scale
  20665. * @param scale defines the scaling factor
  20666. * @returns the current updated Vector2
  20667. */
  20668. scaleInPlace(scale: number): Vector2;
  20669. /**
  20670. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20671. * @param scale defines the scaling factor
  20672. * @returns a new Vector2
  20673. */
  20674. scale(scale: number): Vector2;
  20675. /**
  20676. * Scale the current Vector2 values by a factor to a given Vector2
  20677. * @param scale defines the scale factor
  20678. * @param result defines the Vector2 object where to store the result
  20679. * @returns the unmodified current Vector2
  20680. */
  20681. scaleToRef(scale: number, result: Vector2): Vector2;
  20682. /**
  20683. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20684. * @param scale defines the scale factor
  20685. * @param result defines the Vector2 object where to store the result
  20686. * @returns the unmodified current Vector2
  20687. */
  20688. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20689. /**
  20690. * Gets a boolean if two vectors are equals
  20691. * @param otherVector defines the other vector
  20692. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20693. */
  20694. equals(otherVector: Vector2): boolean;
  20695. /**
  20696. * Gets a boolean if two vectors are equals (using an epsilon value)
  20697. * @param otherVector defines the other vector
  20698. * @param epsilon defines the minimal distance to consider equality
  20699. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20700. */
  20701. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20702. /**
  20703. * Gets a new Vector2 from current Vector2 floored values
  20704. * @returns a new Vector2
  20705. */
  20706. floor(): Vector2;
  20707. /**
  20708. * Gets a new Vector2 from current Vector2 floored values
  20709. * @returns a new Vector2
  20710. */
  20711. fract(): Vector2;
  20712. /**
  20713. * Gets the length of the vector
  20714. * @returns the vector length (float)
  20715. */
  20716. length(): number;
  20717. /**
  20718. * Gets the vector squared length
  20719. * @returns the vector squared length (float)
  20720. */
  20721. lengthSquared(): number;
  20722. /**
  20723. * Normalize the vector
  20724. * @returns the current updated Vector2
  20725. */
  20726. normalize(): Vector2;
  20727. /**
  20728. * Gets a new Vector2 copied from the Vector2
  20729. * @returns a new Vector2
  20730. */
  20731. clone(): Vector2;
  20732. /**
  20733. * Gets a new Vector2(0, 0)
  20734. * @returns a new Vector2
  20735. */
  20736. static Zero(): Vector2;
  20737. /**
  20738. * Gets a new Vector2(1, 1)
  20739. * @returns a new Vector2
  20740. */
  20741. static One(): Vector2;
  20742. /**
  20743. * Gets a new Vector2 set from the given index element of the given array
  20744. * @param array defines the data source
  20745. * @param offset defines the offset in the data source
  20746. * @returns a new Vector2
  20747. */
  20748. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20749. /**
  20750. * Sets "result" from the given index element of the given array
  20751. * @param array defines the data source
  20752. * @param offset defines the offset in the data source
  20753. * @param result defines the target vector
  20754. */
  20755. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20756. /**
  20757. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20758. * @param value1 defines 1st point of control
  20759. * @param value2 defines 2nd point of control
  20760. * @param value3 defines 3rd point of control
  20761. * @param value4 defines 4th point of control
  20762. * @param amount defines the interpolation factor
  20763. * @returns a new Vector2
  20764. */
  20765. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20766. /**
  20767. * 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".
  20768. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20769. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20770. * @param value defines the value to clamp
  20771. * @param min defines the lower limit
  20772. * @param max defines the upper limit
  20773. * @returns a new Vector2
  20774. */
  20775. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20776. /**
  20777. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20778. * @param value1 defines the 1st control point
  20779. * @param tangent1 defines the outgoing tangent
  20780. * @param value2 defines the 2nd control point
  20781. * @param tangent2 defines the incoming tangent
  20782. * @param amount defines the interpolation factor
  20783. * @returns a new Vector2
  20784. */
  20785. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20786. /**
  20787. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20788. * @param start defines the start vector
  20789. * @param end defines the end vector
  20790. * @param amount defines the interpolation factor
  20791. * @returns a new Vector2
  20792. */
  20793. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20794. /**
  20795. * Gets the dot product of the vector "left" and the vector "right"
  20796. * @param left defines first vector
  20797. * @param right defines second vector
  20798. * @returns the dot product (float)
  20799. */
  20800. static Dot(left: Vector2, right: Vector2): number;
  20801. /**
  20802. * Returns a new Vector2 equal to the normalized given vector
  20803. * @param vector defines the vector to normalize
  20804. * @returns a new Vector2
  20805. */
  20806. static Normalize(vector: Vector2): Vector2;
  20807. /**
  20808. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20809. * @param left defines 1st vector
  20810. * @param right defines 2nd vector
  20811. * @returns a new Vector2
  20812. */
  20813. static Minimize(left: Vector2, right: Vector2): Vector2;
  20814. /**
  20815. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20816. * @param left defines 1st vector
  20817. * @param right defines 2nd vector
  20818. * @returns a new Vector2
  20819. */
  20820. static Maximize(left: Vector2, right: Vector2): Vector2;
  20821. /**
  20822. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20823. * @param vector defines the vector to transform
  20824. * @param transformation defines the matrix to apply
  20825. * @returns a new Vector2
  20826. */
  20827. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20828. /**
  20829. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20830. * @param vector defines the vector to transform
  20831. * @param transformation defines the matrix to apply
  20832. * @param result defines the target vector
  20833. */
  20834. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20835. /**
  20836. * Determines if a given vector is included in a triangle
  20837. * @param p defines the vector to test
  20838. * @param p0 defines 1st triangle point
  20839. * @param p1 defines 2nd triangle point
  20840. * @param p2 defines 3rd triangle point
  20841. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20842. */
  20843. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20844. /**
  20845. * Gets the distance between the vectors "value1" and "value2"
  20846. * @param value1 defines first vector
  20847. * @param value2 defines second vector
  20848. * @returns the distance between vectors
  20849. */
  20850. static Distance(value1: Vector2, value2: Vector2): number;
  20851. /**
  20852. * Returns the squared distance between the vectors "value1" and "value2"
  20853. * @param value1 defines first vector
  20854. * @param value2 defines second vector
  20855. * @returns the squared distance between vectors
  20856. */
  20857. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20858. /**
  20859. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20860. * @param value1 defines first vector
  20861. * @param value2 defines second vector
  20862. * @returns a new Vector2
  20863. */
  20864. static Center(value1: Vector2, value2: Vector2): Vector2;
  20865. /**
  20866. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20867. * @param p defines the middle point
  20868. * @param segA defines one point of the segment
  20869. * @param segB defines the other point of the segment
  20870. * @returns the shortest distance
  20871. */
  20872. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20873. }
  20874. /**
  20875. * Classed used to store (x,y,z) vector representation
  20876. * A Vector3 is the main object used in 3D geometry
  20877. * It can represent etiher the coordinates of a point the space, either a direction
  20878. * Reminder: Babylon.js uses a left handed forward facing system
  20879. */
  20880. class Vector3 {
  20881. /**
  20882. * Defines the first coordinates (on X axis)
  20883. */
  20884. x: number;
  20885. /**
  20886. * Defines the second coordinates (on Y axis)
  20887. */
  20888. y: number;
  20889. /**
  20890. * Defines the third coordinates (on Z axis)
  20891. */
  20892. z: number;
  20893. /**
  20894. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20895. * @param x defines the first coordinates (on X axis)
  20896. * @param y defines the second coordinates (on Y axis)
  20897. * @param z defines the third coordinates (on Z axis)
  20898. */
  20899. constructor(
  20900. /**
  20901. * Defines the first coordinates (on X axis)
  20902. */
  20903. x?: number,
  20904. /**
  20905. * Defines the second coordinates (on Y axis)
  20906. */
  20907. y?: number,
  20908. /**
  20909. * Defines the third coordinates (on Z axis)
  20910. */
  20911. z?: number);
  20912. /**
  20913. * Creates a string representation of the Vector3
  20914. * @returns a string with the Vector3 coordinates.
  20915. */
  20916. toString(): string;
  20917. /**
  20918. * Gets the class name
  20919. * @returns the string "Vector3"
  20920. */
  20921. getClassName(): string;
  20922. /**
  20923. * Creates the Vector3 hash code
  20924. * @returns a number which tends to be unique between Vector3 instances
  20925. */
  20926. getHashCode(): number;
  20927. /**
  20928. * Creates an array containing three elements : the coordinates of the Vector3
  20929. * @returns a new array of numbers
  20930. */
  20931. asArray(): number[];
  20932. /**
  20933. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20934. * @param array defines the destination array
  20935. * @param index defines the offset in the destination array
  20936. * @returns the current Vector3
  20937. */
  20938. toArray(array: FloatArray, index?: number): Vector3;
  20939. /**
  20940. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20941. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20942. */
  20943. toQuaternion(): Quaternion;
  20944. /**
  20945. * Adds the given vector to the current Vector3
  20946. * @param otherVector defines the second operand
  20947. * @returns the current updated Vector3
  20948. */
  20949. addInPlace(otherVector: Vector3): Vector3;
  20950. /**
  20951. * Adds the given coordinates to the current Vector3
  20952. * @param x defines the x coordinate of the operand
  20953. * @param y defines the y coordinate of the operand
  20954. * @param z defines the z coordinate of the operand
  20955. * @returns the current updated Vector3
  20956. */
  20957. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20958. /**
  20959. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20960. * @param otherVector defines the second operand
  20961. * @returns the resulting Vector3
  20962. */
  20963. add(otherVector: Vector3): Vector3;
  20964. /**
  20965. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  20966. * @param otherVector defines the second operand
  20967. * @param result defines the Vector3 object where to store the result
  20968. * @returns the current Vector3
  20969. */
  20970. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  20971. /**
  20972. * Subtract the given vector from the current Vector3
  20973. * @param otherVector defines the second operand
  20974. * @returns the current updated Vector3
  20975. */
  20976. subtractInPlace(otherVector: Vector3): Vector3;
  20977. /**
  20978. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  20979. * @param otherVector defines the second operand
  20980. * @returns the resulting Vector3
  20981. */
  20982. subtract(otherVector: Vector3): Vector3;
  20983. /**
  20984. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  20985. * @param otherVector defines the second operand
  20986. * @param result defines the Vector3 object where to store the result
  20987. * @returns the current Vector3
  20988. */
  20989. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  20990. /**
  20991. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  20992. * @param x defines the x coordinate of the operand
  20993. * @param y defines the y coordinate of the operand
  20994. * @param z defines the z coordinate of the operand
  20995. * @returns the resulting Vector3
  20996. */
  20997. subtractFromFloats(x: number, y: number, z: number): Vector3;
  20998. /**
  20999. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21000. * @param x defines the x coordinate of the operand
  21001. * @param y defines the y coordinate of the operand
  21002. * @param z defines the z coordinate of the operand
  21003. * @param result defines the Vector3 object where to store the result
  21004. * @returns the current Vector3
  21005. */
  21006. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21007. /**
  21008. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21009. * @returns a new Vector3
  21010. */
  21011. negate(): Vector3;
  21012. /**
  21013. * Multiplies the Vector3 coordinates by the float "scale"
  21014. * @param scale defines the multiplier factor
  21015. * @returns the current updated Vector3
  21016. */
  21017. scaleInPlace(scale: number): Vector3;
  21018. /**
  21019. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21020. * @param scale defines the multiplier factor
  21021. * @returns a new Vector3
  21022. */
  21023. scale(scale: number): Vector3;
  21024. /**
  21025. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21026. * @param scale defines the multiplier factor
  21027. * @param result defines the Vector3 object where to store the result
  21028. * @returns the current Vector3
  21029. */
  21030. scaleToRef(scale: number, result: Vector3): Vector3;
  21031. /**
  21032. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21033. * @param scale defines the scale factor
  21034. * @param result defines the Vector3 object where to store the result
  21035. * @returns the unmodified current Vector3
  21036. */
  21037. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21038. /**
  21039. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21040. * @param otherVector defines the second operand
  21041. * @returns true if both vectors are equals
  21042. */
  21043. equals(otherVector: Vector3): boolean;
  21044. /**
  21045. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21046. * @param otherVector defines the second operand
  21047. * @param epsilon defines the minimal distance to define values as equals
  21048. * @returns true if both vectors are distant less than epsilon
  21049. */
  21050. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21051. /**
  21052. * Returns true if the current Vector3 coordinates equals the given floats
  21053. * @param x defines the x coordinate of the operand
  21054. * @param y defines the y coordinate of the operand
  21055. * @param z defines the z coordinate of the operand
  21056. * @returns true if both vectors are equals
  21057. */
  21058. equalsToFloats(x: number, y: number, z: number): boolean;
  21059. /**
  21060. * Multiplies the current Vector3 coordinates by the given ones
  21061. * @param otherVector defines the second operand
  21062. * @returns the current updated Vector3
  21063. */
  21064. multiplyInPlace(otherVector: Vector3): Vector3;
  21065. /**
  21066. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21067. * @param otherVector defines the second operand
  21068. * @returns the new Vector3
  21069. */
  21070. multiply(otherVector: Vector3): Vector3;
  21071. /**
  21072. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21073. * @param otherVector defines the second operand
  21074. * @param result defines the Vector3 object where to store the result
  21075. * @returns the current Vector3
  21076. */
  21077. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21078. /**
  21079. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21080. * @param x defines the x coordinate of the operand
  21081. * @param y defines the y coordinate of the operand
  21082. * @param z defines the z coordinate of the operand
  21083. * @returns the new Vector3
  21084. */
  21085. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21086. /**
  21087. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21088. * @param otherVector defines the second operand
  21089. * @returns the new Vector3
  21090. */
  21091. divide(otherVector: Vector3): Vector3;
  21092. /**
  21093. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21094. * @param otherVector defines the second operand
  21095. * @param result defines the Vector3 object where to store the result
  21096. * @returns the current Vector3
  21097. */
  21098. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21099. /**
  21100. * Divides the current Vector3 coordinates by the given ones.
  21101. * @param otherVector defines the second operand
  21102. * @returns the current updated Vector3
  21103. */
  21104. divideInPlace(otherVector: Vector3): Vector3;
  21105. /**
  21106. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21107. * @param other defines the second operand
  21108. * @returns the current updated Vector3
  21109. */
  21110. minimizeInPlace(other: Vector3): Vector3;
  21111. /**
  21112. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21113. * @param other defines the second operand
  21114. * @returns the current updated Vector3
  21115. */
  21116. maximizeInPlace(other: Vector3): Vector3;
  21117. /**
  21118. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21119. * @param x defines the x coordinate of the operand
  21120. * @param y defines the y coordinate of the operand
  21121. * @param z defines the z coordinate of the operand
  21122. * @returns the current updated Vector3
  21123. */
  21124. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21125. /**
  21126. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21127. * @param x defines the x coordinate of the operand
  21128. * @param y defines the y coordinate of the operand
  21129. * @param z defines the z coordinate of the operand
  21130. * @returns the current updated Vector3
  21131. */
  21132. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21133. /**
  21134. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21135. */
  21136. readonly isNonUniform: boolean;
  21137. /**
  21138. * Gets a new Vector3 from current Vector3 floored values
  21139. * @returns a new Vector3
  21140. */
  21141. floor(): Vector3;
  21142. /**
  21143. * Gets a new Vector3 from current Vector3 floored values
  21144. * @returns a new Vector3
  21145. */
  21146. fract(): Vector3;
  21147. /**
  21148. * Gets the length of the Vector3
  21149. * @returns the length of the Vecto3
  21150. */
  21151. length(): number;
  21152. /**
  21153. * Gets the squared length of the Vector3
  21154. * @returns squared length of the Vector3
  21155. */
  21156. lengthSquared(): number;
  21157. /**
  21158. * Normalize the current Vector3.
  21159. * Please note that this is an in place operation.
  21160. * @returns the current updated Vector3
  21161. */
  21162. normalize(): Vector3;
  21163. /**
  21164. * Normalize the current Vector3 with the given input length.
  21165. * Please note that this is an in place operation.
  21166. * @param len the length of the vector
  21167. * @returns the current updated Vector3
  21168. */
  21169. normalizeFromLength(len: number): Vector3;
  21170. /**
  21171. * Normalize the current Vector3 to a new vector
  21172. * @returns the new Vector3
  21173. */
  21174. normalizeToNew(): Vector3;
  21175. /**
  21176. * Normalize the current Vector3 to the reference
  21177. * @param reference define the Vector3 to update
  21178. * @returns the updated Vector3
  21179. */
  21180. normalizeToRef(reference: Vector3): Vector3;
  21181. /**
  21182. * Creates a new Vector3 copied from the current Vector3
  21183. * @returns the new Vector3
  21184. */
  21185. clone(): Vector3;
  21186. /**
  21187. * Copies the given vector coordinates to the current Vector3 ones
  21188. * @param source defines the source Vector3
  21189. * @returns the current updated Vector3
  21190. */
  21191. copyFrom(source: Vector3): Vector3;
  21192. /**
  21193. * Copies the given floats to the current Vector3 coordinates
  21194. * @param x defines the x coordinate of the operand
  21195. * @param y defines the y coordinate of the operand
  21196. * @param z defines the z coordinate of the operand
  21197. * @returns the current updated Vector3
  21198. */
  21199. copyFromFloats(x: number, y: number, z: number): Vector3;
  21200. /**
  21201. * Copies the given floats to the current Vector3 coordinates
  21202. * @param x defines the x coordinate of the operand
  21203. * @param y defines the y coordinate of the operand
  21204. * @param z defines the z coordinate of the operand
  21205. * @returns the current updated Vector3
  21206. */
  21207. set(x: number, y: number, z: number): Vector3;
  21208. /**
  21209. * Copies the given float to the current Vector3 coordinates
  21210. * @param v defines the x, y and z coordinates of the operand
  21211. * @returns the current updated Vector3
  21212. */
  21213. setAll(v: number): Vector3;
  21214. /**
  21215. * Get the clip factor between two vectors
  21216. * @param vector0 defines the first operand
  21217. * @param vector1 defines the second operand
  21218. * @param axis defines the axis to use
  21219. * @param size defines the size along the axis
  21220. * @returns the clip factor
  21221. */
  21222. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21223. /**
  21224. * Get angle between two vectors
  21225. * @param vector0 angle between vector0 and vector1
  21226. * @param vector1 angle between vector0 and vector1
  21227. * @param normal direction of the normal
  21228. * @return the angle between vector0 and vector1
  21229. */
  21230. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21231. /**
  21232. * Returns a new Vector3 set from the index "offset" of the given array
  21233. * @param array defines the source array
  21234. * @param offset defines the offset in the source array
  21235. * @returns the new Vector3
  21236. */
  21237. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21238. /**
  21239. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21240. * This function is deprecated. Use FromArray instead
  21241. * @param array defines the source array
  21242. * @param offset defines the offset in the source array
  21243. * @returns the new Vector3
  21244. */
  21245. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21246. /**
  21247. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21248. * @param array defines the source array
  21249. * @param offset defines the offset in the source array
  21250. * @param result defines the Vector3 where to store the result
  21251. */
  21252. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21253. /**
  21254. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21255. * This function is deprecated. Use FromArrayToRef instead.
  21256. * @param array defines the source array
  21257. * @param offset defines the offset in the source array
  21258. * @param result defines the Vector3 where to store the result
  21259. */
  21260. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21261. /**
  21262. * Sets the given vector "result" with the given floats.
  21263. * @param x defines the x coordinate of the source
  21264. * @param y defines the y coordinate of the source
  21265. * @param z defines the z coordinate of the source
  21266. * @param result defines the Vector3 where to store the result
  21267. */
  21268. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21269. /**
  21270. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21271. * @returns a new empty Vector3
  21272. */
  21273. static Zero(): Vector3;
  21274. /**
  21275. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21276. * @returns a new unit Vector3
  21277. */
  21278. static One(): Vector3;
  21279. /**
  21280. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21281. * @returns a new up Vector3
  21282. */
  21283. static Up(): Vector3;
  21284. /**
  21285. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21286. * @returns a new down Vector3
  21287. */
  21288. static Down(): Vector3;
  21289. /**
  21290. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21291. * @returns a new forward Vector3
  21292. */
  21293. static Forward(): Vector3;
  21294. /**
  21295. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21296. * @returns a new forward Vector3
  21297. */
  21298. static Backward(): Vector3;
  21299. /**
  21300. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21301. * @returns a new right Vector3
  21302. */
  21303. static Right(): Vector3;
  21304. /**
  21305. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21306. * @returns a new left Vector3
  21307. */
  21308. static Left(): Vector3;
  21309. /**
  21310. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21311. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21312. * @param vector defines the Vector3 to transform
  21313. * @param transformation defines the transformation matrix
  21314. * @returns the transformed Vector3
  21315. */
  21316. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21317. /**
  21318. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21319. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21320. * @param vector defines the Vector3 to transform
  21321. * @param transformation defines the transformation matrix
  21322. * @param result defines the Vector3 where to store the result
  21323. */
  21324. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21325. /**
  21326. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21327. * This method computes tranformed coordinates only, not transformed direction vectors
  21328. * @param x define the x coordinate of the source vector
  21329. * @param y define the y coordinate of the source vector
  21330. * @param z define the z coordinate of the source vector
  21331. * @param transformation defines the transformation matrix
  21332. * @param result defines the Vector3 where to store the result
  21333. */
  21334. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21335. /**
  21336. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21337. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21338. * @param vector defines the Vector3 to transform
  21339. * @param transformation defines the transformation matrix
  21340. * @returns the new Vector3
  21341. */
  21342. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21343. /**
  21344. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21345. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21346. * @param vector defines the Vector3 to transform
  21347. * @param transformation defines the transformation matrix
  21348. * @param result defines the Vector3 where to store the result
  21349. */
  21350. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21351. /**
  21352. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21353. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21354. * @param x define the x coordinate of the source vector
  21355. * @param y define the y coordinate of the source vector
  21356. * @param z define the z coordinate of the source vector
  21357. * @param transformation defines the transformation matrix
  21358. * @param result defines the Vector3 where to store the result
  21359. */
  21360. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21361. /**
  21362. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21363. * @param value1 defines the first control point
  21364. * @param value2 defines the second control point
  21365. * @param value3 defines the third control point
  21366. * @param value4 defines the fourth control point
  21367. * @param amount defines the amount on the spline to use
  21368. * @returns the new Vector3
  21369. */
  21370. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21371. /**
  21372. * 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"
  21373. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21374. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21375. * @param value defines the current value
  21376. * @param min defines the lower range value
  21377. * @param max defines the upper range value
  21378. * @returns the new Vector3
  21379. */
  21380. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21381. /**
  21382. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21383. * @param value1 defines the first control point
  21384. * @param tangent1 defines the first tangent vector
  21385. * @param value2 defines the second control point
  21386. * @param tangent2 defines the second tangent vector
  21387. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21388. * @returns the new Vector3
  21389. */
  21390. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21391. /**
  21392. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21393. * @param start defines the start value
  21394. * @param end defines the end value
  21395. * @param amount max defines amount between both (between 0 and 1)
  21396. * @returns the new Vector3
  21397. */
  21398. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21399. /**
  21400. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21401. * @param start defines the start value
  21402. * @param end defines the end value
  21403. * @param amount max defines amount between both (between 0 and 1)
  21404. * @param result defines the Vector3 where to store the result
  21405. */
  21406. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21407. /**
  21408. * Returns the dot product (float) between the vectors "left" and "right"
  21409. * @param left defines the left operand
  21410. * @param right defines the right operand
  21411. * @returns the dot product
  21412. */
  21413. static Dot(left: Vector3, right: Vector3): number;
  21414. /**
  21415. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21416. * The cross product is then orthogonal to both "left" and "right"
  21417. * @param left defines the left operand
  21418. * @param right defines the right operand
  21419. * @returns the cross product
  21420. */
  21421. static Cross(left: Vector3, right: Vector3): Vector3;
  21422. /**
  21423. * Sets the given vector "result" with the cross product of "left" and "right"
  21424. * The cross product is then orthogonal to both "left" and "right"
  21425. * @param left defines the left operand
  21426. * @param right defines the right operand
  21427. * @param result defines the Vector3 where to store the result
  21428. */
  21429. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21430. /**
  21431. * Returns a new Vector3 as the normalization of the given vector
  21432. * @param vector defines the Vector3 to normalize
  21433. * @returns the new Vector3
  21434. */
  21435. static Normalize(vector: Vector3): Vector3;
  21436. /**
  21437. * Sets the given vector "result" with the normalization of the given first vector
  21438. * @param vector defines the Vector3 to normalize
  21439. * @param result defines the Vector3 where to store the result
  21440. */
  21441. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21442. private static _viewportMatrixCache;
  21443. /**
  21444. * Project a Vector3 onto screen space
  21445. * @param vector defines the Vector3 to project
  21446. * @param world defines the world matrix to use
  21447. * @param transform defines the transform (view x projection) matrix to use
  21448. * @param viewport defines the screen viewport to use
  21449. * @returns the new Vector3
  21450. */
  21451. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21452. /**
  21453. * Unproject from screen space to object space
  21454. * @param source defines the screen space Vector3 to use
  21455. * @param viewportWidth defines the current width of the viewport
  21456. * @param viewportHeight defines the current height of the viewport
  21457. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21458. * @param transform defines the transform (view x projection) matrix to use
  21459. * @returns the new Vector3
  21460. */
  21461. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21462. /**
  21463. * Unproject from screen space to object space
  21464. * @param source defines the screen space Vector3 to use
  21465. * @param viewportWidth defines the current width of the viewport
  21466. * @param viewportHeight defines the current height of the viewport
  21467. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21468. * @param view defines the view matrix to use
  21469. * @param projection defines the projection matrix to use
  21470. * @returns the new Vector3
  21471. */
  21472. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21473. /**
  21474. * Unproject from screen space to object space
  21475. * @param source defines the screen space Vector3 to use
  21476. * @param viewportWidth defines the current width of the viewport
  21477. * @param viewportHeight defines the current height of the viewport
  21478. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21479. * @param view defines the view matrix to use
  21480. * @param projection defines the projection matrix to use
  21481. * @param result defines the Vector3 where to store the result
  21482. */
  21483. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21484. /**
  21485. * Unproject from screen space to object space
  21486. * @param sourceX defines the screen space x coordinate to use
  21487. * @param sourceY defines the screen space y coordinate to use
  21488. * @param sourceZ defines the screen space z coordinate to use
  21489. * @param viewportWidth defines the current width of the viewport
  21490. * @param viewportHeight defines the current height of the viewport
  21491. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21492. * @param view defines the view matrix to use
  21493. * @param projection defines the projection matrix to use
  21494. * @param result defines the Vector3 where to store the result
  21495. */
  21496. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21497. /**
  21498. * Gets the minimal coordinate values between two Vector3
  21499. * @param left defines the first operand
  21500. * @param right defines the second operand
  21501. * @returns the new Vector3
  21502. */
  21503. static Minimize(left: Vector3, right: Vector3): Vector3;
  21504. /**
  21505. * Gets the maximal coordinate values between two Vector3
  21506. * @param left defines the first operand
  21507. * @param right defines the second operand
  21508. * @returns the new Vector3
  21509. */
  21510. static Maximize(left: Vector3, right: Vector3): Vector3;
  21511. /**
  21512. * Returns the distance between the vectors "value1" and "value2"
  21513. * @param value1 defines the first operand
  21514. * @param value2 defines the second operand
  21515. * @returns the distance
  21516. */
  21517. static Distance(value1: Vector3, value2: Vector3): number;
  21518. /**
  21519. * Returns the squared distance between the vectors "value1" and "value2"
  21520. * @param value1 defines the first operand
  21521. * @param value2 defines the second operand
  21522. * @returns the squared distance
  21523. */
  21524. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21525. /**
  21526. * Returns a new Vector3 located at the center between "value1" and "value2"
  21527. * @param value1 defines the first operand
  21528. * @param value2 defines the second operand
  21529. * @returns the new Vector3
  21530. */
  21531. static Center(value1: Vector3, value2: Vector3): Vector3;
  21532. /**
  21533. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21534. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21535. * to something in order to rotate it from its local system to the given target system
  21536. * Note: axis1, axis2 and axis3 are normalized during this operation
  21537. * @param axis1 defines the first axis
  21538. * @param axis2 defines the second axis
  21539. * @param axis3 defines the third axis
  21540. * @returns a new Vector3
  21541. */
  21542. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21543. /**
  21544. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21545. * @param axis1 defines the first axis
  21546. * @param axis2 defines the second axis
  21547. * @param axis3 defines the third axis
  21548. * @param ref defines the Vector3 where to store the result
  21549. */
  21550. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21551. }
  21552. /**
  21553. * Vector4 class created for EulerAngle class conversion to Quaternion
  21554. */
  21555. class Vector4 {
  21556. /** x value of the vector */
  21557. x: number;
  21558. /** y value of the vector */
  21559. y: number;
  21560. /** z value of the vector */
  21561. z: number;
  21562. /** w value of the vector */
  21563. w: number;
  21564. /**
  21565. * Creates a Vector4 object from the given floats.
  21566. * @param x x value of the vector
  21567. * @param y y value of the vector
  21568. * @param z z value of the vector
  21569. * @param w w value of the vector
  21570. */
  21571. constructor(
  21572. /** x value of the vector */
  21573. x: number,
  21574. /** y value of the vector */
  21575. y: number,
  21576. /** z value of the vector */
  21577. z: number,
  21578. /** w value of the vector */
  21579. w: number);
  21580. /**
  21581. * Returns the string with the Vector4 coordinates.
  21582. * @returns a string containing all the vector values
  21583. */
  21584. toString(): string;
  21585. /**
  21586. * Returns the string "Vector4".
  21587. * @returns "Vector4"
  21588. */
  21589. getClassName(): string;
  21590. /**
  21591. * Returns the Vector4 hash code.
  21592. * @returns a unique hash code
  21593. */
  21594. getHashCode(): number;
  21595. /**
  21596. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21597. * @returns the resulting array
  21598. */
  21599. asArray(): number[];
  21600. /**
  21601. * Populates the given array from the given index with the Vector4 coordinates.
  21602. * @param array array to populate
  21603. * @param index index of the array to start at (default: 0)
  21604. * @returns the Vector4.
  21605. */
  21606. toArray(array: FloatArray, index?: number): Vector4;
  21607. /**
  21608. * Adds the given vector to the current Vector4.
  21609. * @param otherVector the vector to add
  21610. * @returns the updated Vector4.
  21611. */
  21612. addInPlace(otherVector: Vector4): Vector4;
  21613. /**
  21614. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21615. * @param otherVector the vector to add
  21616. * @returns the resulting vector
  21617. */
  21618. add(otherVector: Vector4): Vector4;
  21619. /**
  21620. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21621. * @param otherVector the vector to add
  21622. * @param result the vector to store the result
  21623. * @returns the current Vector4.
  21624. */
  21625. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21626. /**
  21627. * Subtract in place the given vector from the current Vector4.
  21628. * @param otherVector the vector to subtract
  21629. * @returns the updated Vector4.
  21630. */
  21631. subtractInPlace(otherVector: Vector4): Vector4;
  21632. /**
  21633. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21634. * @param otherVector the vector to add
  21635. * @returns the new vector with the result
  21636. */
  21637. subtract(otherVector: Vector4): Vector4;
  21638. /**
  21639. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21640. * @param otherVector the vector to subtract
  21641. * @param result the vector to store the result
  21642. * @returns the current Vector4.
  21643. */
  21644. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21645. /**
  21646. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21647. */
  21648. /**
  21649. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21650. * @param x value to subtract
  21651. * @param y value to subtract
  21652. * @param z value to subtract
  21653. * @param w value to subtract
  21654. * @returns new vector containing the result
  21655. */
  21656. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21657. /**
  21658. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21659. * @param x value to subtract
  21660. * @param y value to subtract
  21661. * @param z value to subtract
  21662. * @param w value to subtract
  21663. * @param result the vector to store the result in
  21664. * @returns the current Vector4.
  21665. */
  21666. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21667. /**
  21668. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21669. * @returns a new vector with the negated values
  21670. */
  21671. negate(): Vector4;
  21672. /**
  21673. * Multiplies the current Vector4 coordinates by scale (float).
  21674. * @param scale the number to scale with
  21675. * @returns the updated Vector4.
  21676. */
  21677. scaleInPlace(scale: number): Vector4;
  21678. /**
  21679. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21680. * @param scale the number to scale with
  21681. * @returns a new vector with the result
  21682. */
  21683. scale(scale: number): Vector4;
  21684. /**
  21685. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21686. * @param scale the number to scale with
  21687. * @param result a vector to store the result in
  21688. * @returns the current Vector4.
  21689. */
  21690. scaleToRef(scale: number, result: Vector4): Vector4;
  21691. /**
  21692. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21693. * @param scale defines the scale factor
  21694. * @param result defines the Vector4 object where to store the result
  21695. * @returns the unmodified current Vector4
  21696. */
  21697. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21698. /**
  21699. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21700. * @param otherVector the vector to compare against
  21701. * @returns true if they are equal
  21702. */
  21703. equals(otherVector: Vector4): boolean;
  21704. /**
  21705. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21706. * @param otherVector vector to compare against
  21707. * @param epsilon (Default: very small number)
  21708. * @returns true if they are equal
  21709. */
  21710. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21711. /**
  21712. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21713. * @param x x value to compare against
  21714. * @param y y value to compare against
  21715. * @param z z value to compare against
  21716. * @param w w value to compare against
  21717. * @returns true if equal
  21718. */
  21719. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21720. /**
  21721. * Multiplies in place the current Vector4 by the given one.
  21722. * @param otherVector vector to multiple with
  21723. * @returns the updated Vector4.
  21724. */
  21725. multiplyInPlace(otherVector: Vector4): Vector4;
  21726. /**
  21727. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21728. * @param otherVector vector to multiple with
  21729. * @returns resulting new vector
  21730. */
  21731. multiply(otherVector: Vector4): Vector4;
  21732. /**
  21733. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21734. * @param otherVector vector to multiple with
  21735. * @param result vector to store the result
  21736. * @returns the current Vector4.
  21737. */
  21738. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21739. /**
  21740. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21741. * @param x x value multiply with
  21742. * @param y y value multiply with
  21743. * @param z z value multiply with
  21744. * @param w w value multiply with
  21745. * @returns resulting new vector
  21746. */
  21747. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21748. /**
  21749. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21750. * @param otherVector vector to devide with
  21751. * @returns resulting new vector
  21752. */
  21753. divide(otherVector: Vector4): Vector4;
  21754. /**
  21755. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21756. * @param otherVector vector to devide with
  21757. * @param result vector to store the result
  21758. * @returns the current Vector4.
  21759. */
  21760. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21761. /**
  21762. * Divides the current Vector3 coordinates by the given ones.
  21763. * @param otherVector vector to devide with
  21764. * @returns the updated Vector3.
  21765. */
  21766. divideInPlace(otherVector: Vector4): Vector4;
  21767. /**
  21768. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21769. * @param other defines the second operand
  21770. * @returns the current updated Vector4
  21771. */
  21772. minimizeInPlace(other: Vector4): Vector4;
  21773. /**
  21774. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21775. * @param other defines the second operand
  21776. * @returns the current updated Vector4
  21777. */
  21778. maximizeInPlace(other: Vector4): Vector4;
  21779. /**
  21780. * Gets a new Vector4 from current Vector4 floored values
  21781. * @returns a new Vector4
  21782. */
  21783. floor(): Vector4;
  21784. /**
  21785. * Gets a new Vector4 from current Vector3 floored values
  21786. * @returns a new Vector4
  21787. */
  21788. fract(): Vector4;
  21789. /**
  21790. * Returns the Vector4 length (float).
  21791. * @returns the length
  21792. */
  21793. length(): number;
  21794. /**
  21795. * Returns the Vector4 squared length (float).
  21796. * @returns the length squared
  21797. */
  21798. lengthSquared(): number;
  21799. /**
  21800. * Normalizes in place the Vector4.
  21801. * @returns the updated Vector4.
  21802. */
  21803. normalize(): Vector4;
  21804. /**
  21805. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21806. * @returns this converted to a new vector3
  21807. */
  21808. toVector3(): Vector3;
  21809. /**
  21810. * Returns a new Vector4 copied from the current one.
  21811. * @returns the new cloned vector
  21812. */
  21813. clone(): Vector4;
  21814. /**
  21815. * Updates the current Vector4 with the given one coordinates.
  21816. * @param source the source vector to copy from
  21817. * @returns the updated Vector4.
  21818. */
  21819. copyFrom(source: Vector4): Vector4;
  21820. /**
  21821. * Updates the current Vector4 coordinates with the given floats.
  21822. * @param x float to copy from
  21823. * @param y float to copy from
  21824. * @param z float to copy from
  21825. * @param w float to copy from
  21826. * @returns the updated Vector4.
  21827. */
  21828. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21829. /**
  21830. * Updates the current Vector4 coordinates with the given floats.
  21831. * @param x float to set from
  21832. * @param y float to set from
  21833. * @param z float to set from
  21834. * @param w float to set from
  21835. * @returns the updated Vector4.
  21836. */
  21837. set(x: number, y: number, z: number, w: number): Vector4;
  21838. /**
  21839. * Copies the given float to the current Vector3 coordinates
  21840. * @param v defines the x, y, z and w coordinates of the operand
  21841. * @returns the current updated Vector3
  21842. */
  21843. setAll(v: number): Vector4;
  21844. /**
  21845. * Returns a new Vector4 set from the starting index of the given array.
  21846. * @param array the array to pull values from
  21847. * @param offset the offset into the array to start at
  21848. * @returns the new vector
  21849. */
  21850. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21851. /**
  21852. * Updates the given vector "result" from the starting index of the given array.
  21853. * @param array the array to pull values from
  21854. * @param offset the offset into the array to start at
  21855. * @param result the vector to store the result in
  21856. */
  21857. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21858. /**
  21859. * Updates the given vector "result" from the starting index of the given Float32Array.
  21860. * @param array the array to pull values from
  21861. * @param offset the offset into the array to start at
  21862. * @param result the vector to store the result in
  21863. */
  21864. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21865. /**
  21866. * Updates the given vector "result" coordinates from the given floats.
  21867. * @param x float to set from
  21868. * @param y float to set from
  21869. * @param z float to set from
  21870. * @param w float to set from
  21871. * @param result the vector to the floats in
  21872. */
  21873. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21874. /**
  21875. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21876. * @returns the new vector
  21877. */
  21878. static Zero(): Vector4;
  21879. /**
  21880. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21881. * @returns the new vector
  21882. */
  21883. static One(): Vector4;
  21884. /**
  21885. * Returns a new normalized Vector4 from the given one.
  21886. * @param vector the vector to normalize
  21887. * @returns the vector
  21888. */
  21889. static Normalize(vector: Vector4): Vector4;
  21890. /**
  21891. * Updates the given vector "result" from the normalization of the given one.
  21892. * @param vector the vector to normalize
  21893. * @param result the vector to store the result in
  21894. */
  21895. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21896. /**
  21897. * Returns a vector with the minimum values from the left and right vectors
  21898. * @param left left vector to minimize
  21899. * @param right right vector to minimize
  21900. * @returns a new vector with the minimum of the left and right vector values
  21901. */
  21902. static Minimize(left: Vector4, right: Vector4): Vector4;
  21903. /**
  21904. * Returns a vector with the maximum values from the left and right vectors
  21905. * @param left left vector to maximize
  21906. * @param right right vector to maximize
  21907. * @returns a new vector with the maximum of the left and right vector values
  21908. */
  21909. static Maximize(left: Vector4, right: Vector4): Vector4;
  21910. /**
  21911. * Returns the distance (float) between the vectors "value1" and "value2".
  21912. * @param value1 value to calulate the distance between
  21913. * @param value2 value to calulate the distance between
  21914. * @return the distance between the two vectors
  21915. */
  21916. static Distance(value1: Vector4, value2: Vector4): number;
  21917. /**
  21918. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21919. * @param value1 value to calulate the distance between
  21920. * @param value2 value to calulate the distance between
  21921. * @return the distance between the two vectors squared
  21922. */
  21923. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21924. /**
  21925. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21926. * @param value1 value to calulate the center between
  21927. * @param value2 value to calulate the center between
  21928. * @return the center between the two vectors
  21929. */
  21930. static Center(value1: Vector4, value2: Vector4): Vector4;
  21931. /**
  21932. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21933. * This methods computes transformed normalized direction vectors only.
  21934. * @param vector the vector to transform
  21935. * @param transformation the transformation matrix to apply
  21936. * @returns the new vector
  21937. */
  21938. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21939. /**
  21940. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21941. * This methods computes transformed normalized direction vectors only.
  21942. * @param vector the vector to transform
  21943. * @param transformation the transformation matrix to apply
  21944. * @param result the vector to store the result in
  21945. */
  21946. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21947. /**
  21948. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21949. * This methods computes transformed normalized direction vectors only.
  21950. * @param x value to transform
  21951. * @param y value to transform
  21952. * @param z value to transform
  21953. * @param w value to transform
  21954. * @param transformation the transformation matrix to apply
  21955. * @param result the vector to store the results in
  21956. */
  21957. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21958. }
  21959. /**
  21960. * Interface for the size containing width and height
  21961. */
  21962. interface ISize {
  21963. /**
  21964. * Width
  21965. */
  21966. width: number;
  21967. /**
  21968. * Heighht
  21969. */
  21970. height: number;
  21971. }
  21972. /**
  21973. * Size containing widht and height
  21974. */
  21975. class Size implements ISize {
  21976. /**
  21977. * Width
  21978. */
  21979. width: number;
  21980. /**
  21981. * Height
  21982. */
  21983. height: number;
  21984. /**
  21985. * Creates a Size object from the given width and height (floats).
  21986. * @param width width of the new size
  21987. * @param height height of the new size
  21988. */
  21989. constructor(width: number, height: number);
  21990. /**
  21991. * Returns a string with the Size width and height
  21992. * @returns a string with the Size width and height
  21993. */
  21994. toString(): string;
  21995. /**
  21996. * "Size"
  21997. * @returns the string "Size"
  21998. */
  21999. getClassName(): string;
  22000. /**
  22001. * Returns the Size hash code.
  22002. * @returns a hash code for a unique width and height
  22003. */
  22004. getHashCode(): number;
  22005. /**
  22006. * Updates the current size from the given one.
  22007. * @param src the given size
  22008. */
  22009. copyFrom(src: Size): void;
  22010. /**
  22011. * Updates in place the current Size from the given floats.
  22012. * @param width width of the new size
  22013. * @param height height of the new size
  22014. * @returns the updated Size.
  22015. */
  22016. copyFromFloats(width: number, height: number): Size;
  22017. /**
  22018. * Updates in place the current Size from the given floats.
  22019. * @param width width to set
  22020. * @param height height to set
  22021. * @returns the updated Size.
  22022. */
  22023. set(width: number, height: number): Size;
  22024. /**
  22025. * Multiplies the width and height by numbers
  22026. * @param w factor to multiple the width by
  22027. * @param h factor to multiple the height by
  22028. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22029. */
  22030. multiplyByFloats(w: number, h: number): Size;
  22031. /**
  22032. * Clones the size
  22033. * @returns a new Size copied from the given one.
  22034. */
  22035. clone(): Size;
  22036. /**
  22037. * True if the current Size and the given one width and height are strictly equal.
  22038. * @param other the other size to compare against
  22039. * @returns True if the current Size and the given one width and height are strictly equal.
  22040. */
  22041. equals(other: Size): boolean;
  22042. /**
  22043. * The surface of the Size : width * height (float).
  22044. */
  22045. readonly surface: number;
  22046. /**
  22047. * Create a new size of zero
  22048. * @returns a new Size set to (0.0, 0.0)
  22049. */
  22050. static Zero(): Size;
  22051. /**
  22052. * Sums the width and height of two sizes
  22053. * @param otherSize size to add to this size
  22054. * @returns a new Size set as the addition result of the current Size and the given one.
  22055. */
  22056. add(otherSize: Size): Size;
  22057. /**
  22058. * Subtracts the width and height of two
  22059. * @param otherSize size to subtract to this size
  22060. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22061. */
  22062. subtract(otherSize: Size): Size;
  22063. /**
  22064. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22065. * @param start starting size to lerp between
  22066. * @param end end size to lerp between
  22067. * @param amount amount to lerp between the start and end values
  22068. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22069. */
  22070. static Lerp(start: Size, end: Size, amount: number): Size;
  22071. }
  22072. /**
  22073. * Class used to store quaternion data
  22074. * @see https://en.wikipedia.org/wiki/Quaternion
  22075. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22076. */
  22077. class Quaternion {
  22078. /** defines the first component (0 by default) */
  22079. x: number;
  22080. /** defines the second component (0 by default) */
  22081. y: number;
  22082. /** defines the third component (0 by default) */
  22083. z: number;
  22084. /** defines the fourth component (1.0 by default) */
  22085. w: number;
  22086. /**
  22087. * Creates a new Quaternion from the given floats
  22088. * @param x defines the first component (0 by default)
  22089. * @param y defines the second component (0 by default)
  22090. * @param z defines the third component (0 by default)
  22091. * @param w defines the fourth component (1.0 by default)
  22092. */
  22093. constructor(
  22094. /** defines the first component (0 by default) */
  22095. x?: number,
  22096. /** defines the second component (0 by default) */
  22097. y?: number,
  22098. /** defines the third component (0 by default) */
  22099. z?: number,
  22100. /** defines the fourth component (1.0 by default) */
  22101. w?: number);
  22102. /**
  22103. * Gets a string representation for the current quaternion
  22104. * @returns a string with the Quaternion coordinates
  22105. */
  22106. toString(): string;
  22107. /**
  22108. * Gets the class name of the quaternion
  22109. * @returns the string "Quaternion"
  22110. */
  22111. getClassName(): string;
  22112. /**
  22113. * Gets a hash code for this quaternion
  22114. * @returns the quaternion hash code
  22115. */
  22116. getHashCode(): number;
  22117. /**
  22118. * Copy the quaternion to an array
  22119. * @returns a new array populated with 4 elements from the quaternion coordinates
  22120. */
  22121. asArray(): number[];
  22122. /**
  22123. * Check if two quaternions are equals
  22124. * @param otherQuaternion defines the second operand
  22125. * @return true if the current quaternion and the given one coordinates are strictly equals
  22126. */
  22127. equals(otherQuaternion: Quaternion): boolean;
  22128. /**
  22129. * Clone the current quaternion
  22130. * @returns a new quaternion copied from the current one
  22131. */
  22132. clone(): Quaternion;
  22133. /**
  22134. * Copy a quaternion to the current one
  22135. * @param other defines the other quaternion
  22136. * @returns the updated current quaternion
  22137. */
  22138. copyFrom(other: Quaternion): Quaternion;
  22139. /**
  22140. * Updates the current quaternion with the given float coordinates
  22141. * @param x defines the x coordinate
  22142. * @param y defines the y coordinate
  22143. * @param z defines the z coordinate
  22144. * @param w defines the w coordinate
  22145. * @returns the updated current quaternion
  22146. */
  22147. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22148. /**
  22149. * Updates the current quaternion from the given float coordinates
  22150. * @param x defines the x coordinate
  22151. * @param y defines the y coordinate
  22152. * @param z defines the z coordinate
  22153. * @param w defines the w coordinate
  22154. * @returns the updated current quaternion
  22155. */
  22156. set(x: number, y: number, z: number, w: number): Quaternion;
  22157. /**
  22158. * Adds two quaternions
  22159. * @param other defines the second operand
  22160. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22161. */
  22162. add(other: Quaternion): Quaternion;
  22163. /**
  22164. * Add a quaternion to the current one
  22165. * @param other defines the quaternion to add
  22166. * @returns the current quaternion
  22167. */
  22168. addInPlace(other: Quaternion): Quaternion;
  22169. /**
  22170. * Subtract two quaternions
  22171. * @param other defines the second operand
  22172. * @returns a new quaternion as the subtraction result of the given one from the current one
  22173. */
  22174. subtract(other: Quaternion): Quaternion;
  22175. /**
  22176. * Multiplies the current quaternion by a scale factor
  22177. * @param value defines the scale factor
  22178. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22179. */
  22180. scale(value: number): Quaternion;
  22181. /**
  22182. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22183. * @param scale defines the scale factor
  22184. * @param result defines the Quaternion object where to store the result
  22185. * @returns the unmodified current quaternion
  22186. */
  22187. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22188. /**
  22189. * Multiplies in place the current quaternion by a scale factor
  22190. * @param value defines the scale factor
  22191. * @returns the current modified quaternion
  22192. */
  22193. scaleInPlace(value: number): Quaternion;
  22194. /**
  22195. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22196. * @param scale defines the scale factor
  22197. * @param result defines the Quaternion object where to store the result
  22198. * @returns the unmodified current quaternion
  22199. */
  22200. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22201. /**
  22202. * Multiplies two quaternions
  22203. * @param q1 defines the second operand
  22204. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22205. */
  22206. multiply(q1: Quaternion): Quaternion;
  22207. /**
  22208. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22209. * @param q1 defines the second operand
  22210. * @param result defines the target quaternion
  22211. * @returns the current quaternion
  22212. */
  22213. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22214. /**
  22215. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22216. * @param q1 defines the second operand
  22217. * @returns the currentupdated quaternion
  22218. */
  22219. multiplyInPlace(q1: Quaternion): Quaternion;
  22220. /**
  22221. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22222. * @param ref defines the target quaternion
  22223. * @returns the current quaternion
  22224. */
  22225. conjugateToRef(ref: Quaternion): Quaternion;
  22226. /**
  22227. * Conjugates in place (1-q) the current quaternion
  22228. * @returns the current updated quaternion
  22229. */
  22230. conjugateInPlace(): Quaternion;
  22231. /**
  22232. * Conjugates in place (1-q) the current quaternion
  22233. * @returns a new quaternion
  22234. */
  22235. conjugate(): Quaternion;
  22236. /**
  22237. * Gets length of current quaternion
  22238. * @returns the quaternion length (float)
  22239. */
  22240. length(): number;
  22241. /**
  22242. * Normalize in place the current quaternion
  22243. * @returns the current updated quaternion
  22244. */
  22245. normalize(): Quaternion;
  22246. /**
  22247. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22248. * @param order is a reserved parameter and is ignore for now
  22249. * @returns a new Vector3 containing the Euler angles
  22250. */
  22251. toEulerAngles(order?: string): Vector3;
  22252. /**
  22253. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22254. * @param result defines the vector which will be filled with the Euler angles
  22255. * @param order is a reserved parameter and is ignore for now
  22256. * @returns the current unchanged quaternion
  22257. */
  22258. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22259. /**
  22260. * Updates the given rotation matrix with the current quaternion values
  22261. * @param result defines the target matrix
  22262. * @returns the current unchanged quaternion
  22263. */
  22264. toRotationMatrix(result: Matrix): Quaternion;
  22265. /**
  22266. * Updates the current quaternion from the given rotation matrix values
  22267. * @param matrix defines the source matrix
  22268. * @returns the current updated quaternion
  22269. */
  22270. fromRotationMatrix(matrix: Matrix): Quaternion;
  22271. /**
  22272. * Creates a new quaternion from a rotation matrix
  22273. * @param matrix defines the source matrix
  22274. * @returns a new quaternion created from the given rotation matrix values
  22275. */
  22276. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22277. /**
  22278. * Updates the given quaternion with the given rotation matrix values
  22279. * @param matrix defines the source matrix
  22280. * @param result defines the target quaternion
  22281. */
  22282. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22283. /**
  22284. * Returns the dot product (float) between the quaternions "left" and "right"
  22285. * @param left defines the left operand
  22286. * @param right defines the right operand
  22287. * @returns the dot product
  22288. */
  22289. static Dot(left: Quaternion, right: Quaternion): number;
  22290. /**
  22291. * Checks if the two quaternions are close to each other
  22292. * @param quat0 defines the first quaternion to check
  22293. * @param quat1 defines the second quaternion to check
  22294. * @returns true if the two quaternions are close to each other
  22295. */
  22296. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22297. /**
  22298. * Creates an empty quaternion
  22299. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22300. */
  22301. static Zero(): Quaternion;
  22302. /**
  22303. * Inverse a given quaternion
  22304. * @param q defines the source quaternion
  22305. * @returns a new quaternion as the inverted current quaternion
  22306. */
  22307. static Inverse(q: Quaternion): Quaternion;
  22308. /**
  22309. * Creates an identity quaternion
  22310. * @returns the identity quaternion
  22311. */
  22312. static Identity(): Quaternion;
  22313. /**
  22314. * Gets a boolean indicating if the given quaternion is identity
  22315. * @param quaternion defines the quaternion to check
  22316. * @returns true if the quaternion is identity
  22317. */
  22318. static IsIdentity(quaternion: Quaternion): boolean;
  22319. /**
  22320. * Creates a quaternion from a rotation around an axis
  22321. * @param axis defines the axis to use
  22322. * @param angle defines the angle to use
  22323. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22324. */
  22325. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22326. /**
  22327. * Creates a rotation around an axis and stores it into the given quaternion
  22328. * @param axis defines the axis to use
  22329. * @param angle defines the angle to use
  22330. * @param result defines the target quaternion
  22331. * @returns the target quaternion
  22332. */
  22333. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22334. /**
  22335. * Creates a new quaternion from data stored into an array
  22336. * @param array defines the data source
  22337. * @param offset defines the offset in the source array where the data starts
  22338. * @returns a new quaternion
  22339. */
  22340. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22341. /**
  22342. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22343. * @param yaw defines the rotation around Y axis
  22344. * @param pitch defines the rotation around X axis
  22345. * @param roll defines the rotation around Z axis
  22346. * @returns the new quaternion
  22347. */
  22348. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22349. /**
  22350. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22351. * @param yaw defines the rotation around Y axis
  22352. * @param pitch defines the rotation around X axis
  22353. * @param roll defines the rotation around Z axis
  22354. * @param result defines the target quaternion
  22355. */
  22356. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22357. /**
  22358. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22359. * @param alpha defines the rotation around first axis
  22360. * @param beta defines the rotation around second axis
  22361. * @param gamma defines the rotation around third axis
  22362. * @returns the new quaternion
  22363. */
  22364. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22365. /**
  22366. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22367. * @param alpha defines the rotation around first axis
  22368. * @param beta defines the rotation around second axis
  22369. * @param gamma defines the rotation around third axis
  22370. * @param result defines the target quaternion
  22371. */
  22372. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22373. /**
  22374. * 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)
  22375. * @param axis1 defines the first axis
  22376. * @param axis2 defines the second axis
  22377. * @param axis3 defines the third axis
  22378. * @returns the new quaternion
  22379. */
  22380. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22381. /**
  22382. * 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
  22383. * @param axis1 defines the first axis
  22384. * @param axis2 defines the second axis
  22385. * @param axis3 defines the third axis
  22386. * @param ref defines the target quaternion
  22387. */
  22388. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22389. /**
  22390. * Interpolates between two quaternions
  22391. * @param left defines first quaternion
  22392. * @param right defines second quaternion
  22393. * @param amount defines the gradient to use
  22394. * @returns the new interpolated quaternion
  22395. */
  22396. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22397. /**
  22398. * Interpolates between two quaternions and stores it into a target quaternion
  22399. * @param left defines first quaternion
  22400. * @param right defines second quaternion
  22401. * @param amount defines the gradient to use
  22402. * @param result defines the target quaternion
  22403. */
  22404. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22405. /**
  22406. * Interpolate between two quaternions using Hermite interpolation
  22407. * @param value1 defines first quaternion
  22408. * @param tangent1 defines the incoming tangent
  22409. * @param value2 defines second quaternion
  22410. * @param tangent2 defines the outgoing tangent
  22411. * @param amount defines the target quaternion
  22412. * @returns the new interpolated quaternion
  22413. */
  22414. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22415. }
  22416. /**
  22417. * Class used to store matrix data (4x4)
  22418. */
  22419. class Matrix {
  22420. private static _tempQuaternion;
  22421. private static _xAxis;
  22422. private static _yAxis;
  22423. private static _zAxis;
  22424. private static _updateFlagSeed;
  22425. private static _identityReadOnly;
  22426. private _isIdentity;
  22427. private _isIdentityDirty;
  22428. /**
  22429. * Gets the update flag of the matrix which is an unique number for the matrix.
  22430. * It will be incremented every time the matrix data change.
  22431. * You can use it to speed the comparison between two versions of the same matrix.
  22432. */
  22433. updateFlag: number;
  22434. /**
  22435. * Gets or sets the internal data of the matrix
  22436. */
  22437. m: Float32Array;
  22438. /** @hidden */
  22439. _markAsUpdated(): void;
  22440. /**
  22441. * Creates an empty matrix (filled with zeros)
  22442. */
  22443. constructor();
  22444. /**
  22445. * Check if the current matrix is indentity
  22446. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  22447. * @returns true is the matrix is the identity matrix
  22448. */
  22449. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  22450. /**
  22451. * Gets the determinant of the matrix
  22452. * @returns the matrix determinant
  22453. */
  22454. determinant(): number;
  22455. /**
  22456. * Returns the matrix as a Float32Array
  22457. * @returns the matrix underlying array
  22458. */
  22459. toArray(): Float32Array;
  22460. /**
  22461. * Returns the matrix as a Float32Array
  22462. * @returns the matrix underlying array.
  22463. */
  22464. asArray(): Float32Array;
  22465. /**
  22466. * Inverts the current matrix in place
  22467. * @returns the current inverted matrix
  22468. */
  22469. invert(): Matrix;
  22470. /**
  22471. * Sets all the matrix elements to zero
  22472. * @returns the current matrix
  22473. */
  22474. reset(): Matrix;
  22475. /**
  22476. * Adds the current matrix with a second one
  22477. * @param other defines the matrix to add
  22478. * @returns a new matrix as the addition of the current matrix and the given one
  22479. */
  22480. add(other: Matrix): Matrix;
  22481. /**
  22482. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22483. * @param other defines the matrix to add
  22484. * @param result defines the target matrix
  22485. * @returns the current matrix
  22486. */
  22487. addToRef(other: Matrix, result: Matrix): Matrix;
  22488. /**
  22489. * Adds in place the given matrix to the current matrix
  22490. * @param other defines the second operand
  22491. * @returns the current updated matrix
  22492. */
  22493. addToSelf(other: Matrix): Matrix;
  22494. /**
  22495. * Sets the given matrix to the current inverted Matrix
  22496. * @param other defines the target matrix
  22497. * @returns the unmodified current matrix
  22498. */
  22499. invertToRef(other: Matrix): Matrix;
  22500. /**
  22501. * Inserts the translation vector (using 3 floats) in the current matrix
  22502. * @param x defines the 1st component of the translation
  22503. * @param y defines the 2nd component of the translation
  22504. * @param z defines the 3rd component of the translation
  22505. * @returns the current updated matrix
  22506. */
  22507. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22508. /**
  22509. * Inserts the translation vector in the current matrix
  22510. * @param vector3 defines the translation to insert
  22511. * @returns the current updated matrix
  22512. */
  22513. setTranslation(vector3: Vector3): Matrix;
  22514. /**
  22515. * Gets the translation value of the current matrix
  22516. * @returns a new Vector3 as the extracted translation from the matrix
  22517. */
  22518. getTranslation(): Vector3;
  22519. /**
  22520. * Fill a Vector3 with the extracted translation from the matrix
  22521. * @param result defines the Vector3 where to store the translation
  22522. * @returns the current matrix
  22523. */
  22524. getTranslationToRef(result: Vector3): Matrix;
  22525. /**
  22526. * Remove rotation and scaling part from the matrix
  22527. * @returns the updated matrix
  22528. */
  22529. removeRotationAndScaling(): Matrix;
  22530. /**
  22531. * Multiply two matrices
  22532. * @param other defines the second operand
  22533. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22534. */
  22535. multiply(other: Matrix): Matrix;
  22536. /**
  22537. * Copy the current matrix from the given one
  22538. * @param other defines the source matrix
  22539. * @returns the current updated matrix
  22540. */
  22541. copyFrom(other: Matrix): Matrix;
  22542. /**
  22543. * Populates the given array from the starting index with the current matrix values
  22544. * @param array defines the target array
  22545. * @param offset defines the offset in the target array where to start storing values
  22546. * @returns the current matrix
  22547. */
  22548. copyToArray(array: Float32Array, offset?: number): Matrix;
  22549. /**
  22550. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22551. * @param other defines the second operand
  22552. * @param result defines the matrix where to store the multiplication
  22553. * @returns the current matrix
  22554. */
  22555. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  22556. /**
  22557. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22558. * @param other defines the second operand
  22559. * @param result defines the array where to store the multiplication
  22560. * @param offset defines the offset in the target array where to start storing values
  22561. * @returns the current matrix
  22562. */
  22563. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  22564. /**
  22565. * Check equality between this matrix and a second one
  22566. * @param value defines the second matrix to compare
  22567. * @returns true is the current matrix and the given one values are strictly equal
  22568. */
  22569. equals(value: Matrix): boolean;
  22570. /**
  22571. * Clone the current matrix
  22572. * @returns a new matrix from the current matrix
  22573. */
  22574. clone(): Matrix;
  22575. /**
  22576. * Returns the name of the current matrix class
  22577. * @returns the string "Matrix"
  22578. */
  22579. getClassName(): string;
  22580. /**
  22581. * Gets the hash code of the current matrix
  22582. * @returns the hash code
  22583. */
  22584. getHashCode(): number;
  22585. /**
  22586. * Decomposes the current Matrix into a translation, rotation and scaling components
  22587. * @param scale defines the scale vector3 given as a reference to update
  22588. * @param rotation defines the rotation quaternion given as a reference to update
  22589. * @param translation defines the translation vector3 given as a reference to update
  22590. * @returns true if operation was successful
  22591. */
  22592. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22593. /**
  22594. * Gets specific row of the matrix
  22595. * @param index defines the number of the row to get
  22596. * @returns the index-th row of the current matrix as a new Vector4
  22597. */
  22598. getRow(index: number): Nullable<Vector4>;
  22599. /**
  22600. * Sets the index-th row of the current matrix to the vector4 values
  22601. * @param index defines the number of the row to set
  22602. * @param row defines the target vector4
  22603. * @returns the updated current matrix
  22604. */
  22605. setRow(index: number, row: Vector4): Matrix;
  22606. /**
  22607. * Compute the transpose of the matrix
  22608. * @returns the new transposed matrix
  22609. */
  22610. transpose(): Matrix;
  22611. /**
  22612. * Compute the transpose of the matrix and store it in a given matrix
  22613. * @param result defines the target matrix
  22614. * @returns the current matrix
  22615. */
  22616. transposeToRef(result: Matrix): Matrix;
  22617. /**
  22618. * Sets the index-th row of the current matrix with the given 4 x float values
  22619. * @param index defines the row index
  22620. * @param x defines the x component to set
  22621. * @param y defines the y component to set
  22622. * @param z defines the z component to set
  22623. * @param w defines the w component to set
  22624. * @returns the updated current matrix
  22625. */
  22626. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22627. /**
  22628. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22629. * @param scale defines the scale factor
  22630. * @returns a new matrix
  22631. */
  22632. scale(scale: number): Matrix;
  22633. /**
  22634. * Scale the current matrix values by a factor to a given result matrix
  22635. * @param scale defines the scale factor
  22636. * @param result defines the matrix to store the result
  22637. * @returns the current matrix
  22638. */
  22639. scaleToRef(scale: number, result: Matrix): Matrix;
  22640. /**
  22641. * Scale the current matrix values by a factor and add the result to a given matrix
  22642. * @param scale defines the scale factor
  22643. * @param result defines the Matrix to store the result
  22644. * @returns the current matrix
  22645. */
  22646. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22647. /**
  22648. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22649. * @param ref matrix to store the result
  22650. */
  22651. toNormalMatrix(ref: Matrix): void;
  22652. /**
  22653. * Gets only rotation part of the current matrix
  22654. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22655. */
  22656. getRotationMatrix(): Matrix;
  22657. /**
  22658. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22659. * @param result defines the target matrix to store data to
  22660. * @returns the current matrix
  22661. */
  22662. getRotationMatrixToRef(result: Matrix): Matrix;
  22663. /**
  22664. * Creates a matrix from an array
  22665. * @param array defines the source array
  22666. * @param offset defines an offset in the source array
  22667. * @returns a new Matrix set from the starting index of the given array
  22668. */
  22669. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22670. /**
  22671. * Copy the content of an array into a given matrix
  22672. * @param array defines the source array
  22673. * @param offset defines an offset in the source array
  22674. * @param result defines the target matrix
  22675. */
  22676. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22677. /**
  22678. * Stores an array into a matrix after having multiplied each component by a given factor
  22679. * @param array defines the source array
  22680. * @param offset defines the offset in the source array
  22681. * @param scale defines the scaling factor
  22682. * @param result defines the target matrix
  22683. */
  22684. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22685. /**
  22686. * Stores a list of values (16) inside a given matrix
  22687. * @param initialM11 defines 1st value of 1st row
  22688. * @param initialM12 defines 2nd value of 1st row
  22689. * @param initialM13 defines 3rd value of 1st row
  22690. * @param initialM14 defines 4th value of 1st row
  22691. * @param initialM21 defines 1st value of 2nd row
  22692. * @param initialM22 defines 2nd value of 2nd row
  22693. * @param initialM23 defines 3rd value of 2nd row
  22694. * @param initialM24 defines 4th value of 2nd row
  22695. * @param initialM31 defines 1st value of 3rd row
  22696. * @param initialM32 defines 2nd value of 3rd row
  22697. * @param initialM33 defines 3rd value of 3rd row
  22698. * @param initialM34 defines 4th value of 3rd row
  22699. * @param initialM41 defines 1st value of 4th row
  22700. * @param initialM42 defines 2nd value of 4th row
  22701. * @param initialM43 defines 3rd value of 4th row
  22702. * @param initialM44 defines 4th value of 4th row
  22703. * @param result defines the target matrix
  22704. */
  22705. 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;
  22706. /**
  22707. * Gets an identity matrix that must not be updated
  22708. */
  22709. static readonly IdentityReadOnly: Matrix;
  22710. /**
  22711. * Creates new matrix from a list of values (16)
  22712. * @param initialM11 defines 1st value of 1st row
  22713. * @param initialM12 defines 2nd value of 1st row
  22714. * @param initialM13 defines 3rd value of 1st row
  22715. * @param initialM14 defines 4th value of 1st row
  22716. * @param initialM21 defines 1st value of 2nd row
  22717. * @param initialM22 defines 2nd value of 2nd row
  22718. * @param initialM23 defines 3rd value of 2nd row
  22719. * @param initialM24 defines 4th value of 2nd row
  22720. * @param initialM31 defines 1st value of 3rd row
  22721. * @param initialM32 defines 2nd value of 3rd row
  22722. * @param initialM33 defines 3rd value of 3rd row
  22723. * @param initialM34 defines 4th value of 3rd row
  22724. * @param initialM41 defines 1st value of 4th row
  22725. * @param initialM42 defines 2nd value of 4th row
  22726. * @param initialM43 defines 3rd value of 4th row
  22727. * @param initialM44 defines 4th value of 4th row
  22728. * @returns the new matrix
  22729. */
  22730. 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;
  22731. /**
  22732. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22733. * @param scale defines the scale vector3
  22734. * @param rotation defines the rotation quaternion
  22735. * @param translation defines the translation vector3
  22736. * @returns a new matrix
  22737. */
  22738. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22739. /**
  22740. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22741. * @param scale defines the scale vector3
  22742. * @param rotation defines the rotation quaternion
  22743. * @param translation defines the translation vector3
  22744. * @param result defines the target matrix
  22745. */
  22746. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22747. /**
  22748. * Creates a new identity matrix
  22749. * @returns a new identity matrix
  22750. */
  22751. static Identity(): Matrix;
  22752. /**
  22753. * Creates a new identity matrix and stores the result in a given matrix
  22754. * @param result defines the target matrix
  22755. */
  22756. static IdentityToRef(result: Matrix): void;
  22757. /**
  22758. * Creates a new zero matrix
  22759. * @returns a new zero matrix
  22760. */
  22761. static Zero(): Matrix;
  22762. /**
  22763. * Creates a new rotation matrix for "angle" radians around the X axis
  22764. * @param angle defines the angle (in radians) to use
  22765. * @return the new matrix
  22766. */
  22767. static RotationX(angle: number): Matrix;
  22768. /**
  22769. * Creates a new matrix as the invert of a given matrix
  22770. * @param source defines the source matrix
  22771. * @returns the new matrix
  22772. */
  22773. static Invert(source: Matrix): Matrix;
  22774. /**
  22775. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22776. * @param angle defines the angle (in radians) to use
  22777. * @param result defines the target matrix
  22778. */
  22779. static RotationXToRef(angle: number, result: Matrix): void;
  22780. /**
  22781. * Creates a new rotation matrix for "angle" radians around the Y axis
  22782. * @param angle defines the angle (in radians) to use
  22783. * @return the new matrix
  22784. */
  22785. static RotationY(angle: number): Matrix;
  22786. /**
  22787. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22788. * @param angle defines the angle (in radians) to use
  22789. * @param result defines the target matrix
  22790. */
  22791. static RotationYToRef(angle: number, result: Matrix): void;
  22792. /**
  22793. * Creates a new rotation matrix for "angle" radians around the Z axis
  22794. * @param angle defines the angle (in radians) to use
  22795. * @return the new matrix
  22796. */
  22797. static RotationZ(angle: number): Matrix;
  22798. /**
  22799. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22800. * @param angle defines the angle (in radians) to use
  22801. * @param result defines the target matrix
  22802. */
  22803. static RotationZToRef(angle: number, result: Matrix): void;
  22804. /**
  22805. * Creates a new rotation matrix for "angle" radians around the given axis
  22806. * @param axis defines the axis to use
  22807. * @param angle defines the angle (in radians) to use
  22808. * @return the new matrix
  22809. */
  22810. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22811. /**
  22812. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22813. * @param axis defines the axis to use
  22814. * @param angle defines the angle (in radians) to use
  22815. * @param result defines the target matrix
  22816. */
  22817. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22818. /**
  22819. * Creates a rotation matrix
  22820. * @param yaw defines the yaw angle in radians (Y axis)
  22821. * @param pitch defines the pitch angle in radians (X axis)
  22822. * @param roll defines the roll angle in radians (X axis)
  22823. * @returns the new rotation matrix
  22824. */
  22825. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22826. /**
  22827. * Creates a rotation matrix and stores it in a given matrix
  22828. * @param yaw defines the yaw angle in radians (Y axis)
  22829. * @param pitch defines the pitch angle in radians (X axis)
  22830. * @param roll defines the roll angle in radians (X axis)
  22831. * @param result defines the target matrix
  22832. */
  22833. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22834. /**
  22835. * Creates a scaling matrix
  22836. * @param x defines the scale factor on X axis
  22837. * @param y defines the scale factor on Y axis
  22838. * @param z defines the scale factor on Z axis
  22839. * @returns the new matrix
  22840. */
  22841. static Scaling(x: number, y: number, z: number): Matrix;
  22842. /**
  22843. * Creates a scaling matrix and stores it in a given matrix
  22844. * @param x defines the scale factor on X axis
  22845. * @param y defines the scale factor on Y axis
  22846. * @param z defines the scale factor on Z axis
  22847. * @param result defines the target matrix
  22848. */
  22849. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22850. /**
  22851. * Creates a translation matrix
  22852. * @param x defines the translation on X axis
  22853. * @param y defines the translation on Y axis
  22854. * @param z defines the translationon Z axis
  22855. * @returns the new matrix
  22856. */
  22857. static Translation(x: number, y: number, z: number): Matrix;
  22858. /**
  22859. * Creates a translation matrix and stores it in a given matrix
  22860. * @param x defines the translation on X axis
  22861. * @param y defines the translation on Y axis
  22862. * @param z defines the translationon Z axis
  22863. * @param result defines the target matrix
  22864. */
  22865. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22866. /**
  22867. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22868. * @param startValue defines the start value
  22869. * @param endValue defines the end value
  22870. * @param gradient defines the gradient factor
  22871. * @returns the new matrix
  22872. */
  22873. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22874. /**
  22875. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22876. * @param startValue defines the start value
  22877. * @param endValue defines the end value
  22878. * @param gradient defines the gradient factor
  22879. * @param result defines the Matrix object where to store data
  22880. */
  22881. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22882. /**
  22883. * Builds a new matrix whose values are computed by:
  22884. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22885. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22886. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22887. * @param startValue defines the first matrix
  22888. * @param endValue defines the second matrix
  22889. * @param gradient defines the gradient between the two matrices
  22890. * @returns the new matrix
  22891. */
  22892. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22893. /**
  22894. * Update a matrix to values which are computed by:
  22895. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22896. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22897. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22898. * @param startValue defines the first matrix
  22899. * @param endValue defines the second matrix
  22900. * @param gradient defines the gradient between the two matrices
  22901. * @param result defines the target matrix
  22902. */
  22903. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22904. /**
  22905. * 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"
  22906. * This function works in left handed mode
  22907. * @param eye defines the final position of the entity
  22908. * @param target defines where the entity should look at
  22909. * @param up defines the up vector for the entity
  22910. * @returns the new matrix
  22911. */
  22912. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22913. /**
  22914. * 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".
  22915. * This function works in left handed mode
  22916. * @param eye defines the final position of the entity
  22917. * @param target defines where the entity should look at
  22918. * @param up defines the up vector for the entity
  22919. * @param result defines the target matrix
  22920. */
  22921. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22922. /**
  22923. * 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"
  22924. * This function works in right handed mode
  22925. * @param eye defines the final position of the entity
  22926. * @param target defines where the entity should look at
  22927. * @param up defines the up vector for the entity
  22928. * @returns the new matrix
  22929. */
  22930. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22931. /**
  22932. * 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".
  22933. * This function works in right handed mode
  22934. * @param eye defines the final position of the entity
  22935. * @param target defines where the entity should look at
  22936. * @param up defines the up vector for the entity
  22937. * @param result defines the target matrix
  22938. */
  22939. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22940. /**
  22941. * Create a left-handed orthographic projection matrix
  22942. * @param width defines the viewport width
  22943. * @param height defines the viewport height
  22944. * @param znear defines the near clip plane
  22945. * @param zfar defines the far clip plane
  22946. * @returns a new matrix as a left-handed orthographic projection matrix
  22947. */
  22948. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22949. /**
  22950. * Store a left-handed orthographic projection to a given matrix
  22951. * @param width defines the viewport width
  22952. * @param height defines the viewport height
  22953. * @param znear defines the near clip plane
  22954. * @param zfar defines the far clip plane
  22955. * @param result defines the target matrix
  22956. */
  22957. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22958. /**
  22959. * Create a left-handed orthographic projection matrix
  22960. * @param left defines the viewport left coordinate
  22961. * @param right defines the viewport right coordinate
  22962. * @param bottom defines the viewport bottom coordinate
  22963. * @param top defines the viewport top coordinate
  22964. * @param znear defines the near clip plane
  22965. * @param zfar defines the far clip plane
  22966. * @returns a new matrix as a left-handed orthographic projection matrix
  22967. */
  22968. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22969. /**
  22970. * Stores a left-handed orthographic projection into a given matrix
  22971. * @param left defines the viewport left coordinate
  22972. * @param right defines the viewport right coordinate
  22973. * @param bottom defines the viewport bottom coordinate
  22974. * @param top defines the viewport top coordinate
  22975. * @param znear defines the near clip plane
  22976. * @param zfar defines the far clip plane
  22977. * @param result defines the target matrix
  22978. */
  22979. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  22980. /**
  22981. * Creates a right-handed orthographic projection matrix
  22982. * @param left defines the viewport left coordinate
  22983. * @param right defines the viewport right coordinate
  22984. * @param bottom defines the viewport bottom coordinate
  22985. * @param top defines the viewport top coordinate
  22986. * @param znear defines the near clip plane
  22987. * @param zfar defines the far clip plane
  22988. * @returns a new matrix as a right-handed orthographic projection matrix
  22989. */
  22990. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  22991. /**
  22992. * Stores a right-handed orthographic projection into a given matrix
  22993. * @param left defines the viewport left coordinate
  22994. * @param right defines the viewport right coordinate
  22995. * @param bottom defines the viewport bottom coordinate
  22996. * @param top defines the viewport top coordinate
  22997. * @param znear defines the near clip plane
  22998. * @param zfar defines the far clip plane
  22999. * @param result defines the target matrix
  23000. */
  23001. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23002. /**
  23003. * Creates a left-handed perspective projection matrix
  23004. * @param width defines the viewport width
  23005. * @param height defines the viewport height
  23006. * @param znear defines the near clip plane
  23007. * @param zfar defines the far clip plane
  23008. * @returns a new matrix as a left-handed perspective projection matrix
  23009. */
  23010. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23011. /**
  23012. * Creates a left-handed perspective projection matrix
  23013. * @param fov defines the horizontal field of view
  23014. * @param aspect defines the aspect ratio
  23015. * @param znear defines the near clip plane
  23016. * @param zfar defines the far clip plane
  23017. * @returns a new matrix as a left-handed perspective projection matrix
  23018. */
  23019. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23020. /**
  23021. * Stores a left-handed perspective projection into a given matrix
  23022. * @param fov defines the horizontal field of view
  23023. * @param aspect defines the aspect ratio
  23024. * @param znear defines the near clip plane
  23025. * @param zfar defines the far clip plane
  23026. * @param result defines the target matrix
  23027. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23028. */
  23029. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23030. /**
  23031. * Creates a right-handed perspective projection matrix
  23032. * @param fov defines the horizontal field of view
  23033. * @param aspect defines the aspect ratio
  23034. * @param znear defines the near clip plane
  23035. * @param zfar defines the far clip plane
  23036. * @returns a new matrix as a right-handed perspective projection matrix
  23037. */
  23038. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23039. /**
  23040. * Stores a right-handed perspective projection into a given matrix
  23041. * @param fov defines the horizontal field of view
  23042. * @param aspect defines the aspect ratio
  23043. * @param znear defines the near clip plane
  23044. * @param zfar defines the far clip plane
  23045. * @param result defines the target matrix
  23046. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23047. */
  23048. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23049. /**
  23050. * Stores a perspective projection for WebVR info a given matrix
  23051. * @param fov defines the field of view
  23052. * @param znear defines the near clip plane
  23053. * @param zfar defines the far clip plane
  23054. * @param result defines the target matrix
  23055. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23056. */
  23057. static PerspectiveFovWebVRToRef(fov: {
  23058. upDegrees: number;
  23059. downDegrees: number;
  23060. leftDegrees: number;
  23061. rightDegrees: number;
  23062. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23063. /**
  23064. * Computes a complete transformation matrix
  23065. * @param viewport defines the viewport to use
  23066. * @param world defines the world matrix
  23067. * @param view defines the view matrix
  23068. * @param projection defines the projection matrix
  23069. * @param zmin defines the near clip plane
  23070. * @param zmax defines the far clip plane
  23071. * @returns the transformation matrix
  23072. */
  23073. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23074. /**
  23075. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23076. * @param matrix defines the matrix to use
  23077. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23078. */
  23079. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23080. /**
  23081. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23082. * @param matrix defines the matrix to use
  23083. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23084. */
  23085. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23086. /**
  23087. * Compute the transpose of a given matrix
  23088. * @param matrix defines the matrix to transpose
  23089. * @returns the new matrix
  23090. */
  23091. static Transpose(matrix: Matrix): Matrix;
  23092. /**
  23093. * Compute the transpose of a matrix and store it in a target matrix
  23094. * @param matrix defines the matrix to transpose
  23095. * @param result defines the target matrix
  23096. */
  23097. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23098. /**
  23099. * Computes a reflection matrix from a plane
  23100. * @param plane defines the reflection plane
  23101. * @returns a new matrix
  23102. */
  23103. static Reflection(plane: Plane): Matrix;
  23104. /**
  23105. * Computes a reflection matrix from a plane
  23106. * @param plane defines the reflection plane
  23107. * @param result defines the target matrix
  23108. */
  23109. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23110. /**
  23111. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23112. * @param xaxis defines the value of the 1st axis
  23113. * @param yaxis defines the value of the 2nd axis
  23114. * @param zaxis defines the value of the 3rd axis
  23115. * @param result defines the target matrix
  23116. */
  23117. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23118. /**
  23119. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23120. * @param quat defines the quaternion to use
  23121. * @param result defines the target matrix
  23122. */
  23123. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23124. }
  23125. /**
  23126. * Represens a plane by the equation ax + by + cz + d = 0
  23127. */
  23128. class Plane {
  23129. /**
  23130. * Normal of the plane (a,b,c)
  23131. */
  23132. normal: Vector3;
  23133. /**
  23134. * d component of the plane
  23135. */
  23136. d: number;
  23137. /**
  23138. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23139. * @param a a component of the plane
  23140. * @param b b component of the plane
  23141. * @param c c component of the plane
  23142. * @param d d component of the plane
  23143. */
  23144. constructor(a: number, b: number, c: number, d: number);
  23145. /**
  23146. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23147. */
  23148. asArray(): number[];
  23149. /**
  23150. * @returns a new plane copied from the current Plane.
  23151. */
  23152. clone(): Plane;
  23153. /**
  23154. * @returns the string "Plane".
  23155. */
  23156. getClassName(): string;
  23157. /**
  23158. * @returns the Plane hash code.
  23159. */
  23160. getHashCode(): number;
  23161. /**
  23162. * Normalize the current Plane in place.
  23163. * @returns the updated Plane.
  23164. */
  23165. normalize(): Plane;
  23166. /**
  23167. * Applies a transformation the plane and returns the result
  23168. * @param transformation the transformation matrix to be applied to the plane
  23169. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23170. */
  23171. transform(transformation: Matrix): Plane;
  23172. /**
  23173. * Calcualtte the dot product between the point and the plane normal
  23174. * @param point point to calculate the dot product with
  23175. * @returns the dot product (float) of the point coordinates and the plane normal.
  23176. */
  23177. dotCoordinate(point: Vector3): number;
  23178. /**
  23179. * Updates the current Plane from the plane defined by the three given points.
  23180. * @param point1 one of the points used to contruct the plane
  23181. * @param point2 one of the points used to contruct the plane
  23182. * @param point3 one of the points used to contruct the plane
  23183. * @returns the updated Plane.
  23184. */
  23185. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23186. /**
  23187. * Checks if the plane is facing a given direction
  23188. * @param direction the direction to check if the plane is facing
  23189. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23190. * @returns True is the vector "direction" is the same side than the plane normal.
  23191. */
  23192. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23193. /**
  23194. * Calculates the distance to a point
  23195. * @param point point to calculate distance to
  23196. * @returns the signed distance (float) from the given point to the Plane.
  23197. */
  23198. signedDistanceTo(point: Vector3): number;
  23199. /**
  23200. * Creates a plane from an array
  23201. * @param array the array to create a plane from
  23202. * @returns a new Plane from the given array.
  23203. */
  23204. static FromArray(array: ArrayLike<number>): Plane;
  23205. /**
  23206. * Creates a plane from three points
  23207. * @param point1 point used to create the plane
  23208. * @param point2 point used to create the plane
  23209. * @param point3 point used to create the plane
  23210. * @returns a new Plane defined by the three given points.
  23211. */
  23212. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23213. /**
  23214. * Creates a plane from an origin point and a normal
  23215. * @param origin origin of the plane to be constructed
  23216. * @param normal normal of the plane to be constructed
  23217. * @returns a new Plane the normal vector to this plane at the given origin point.
  23218. * Note : the vector "normal" is updated because normalized.
  23219. */
  23220. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23221. /**
  23222. * Calculates the distance from a plane and a point
  23223. * @param origin origin of the plane to be constructed
  23224. * @param normal normal of the plane to be constructed
  23225. * @param point point to calculate distance to
  23226. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23227. */
  23228. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23229. }
  23230. /**
  23231. * Class used to represent a viewport on screen
  23232. */
  23233. class Viewport {
  23234. /** viewport left coordinate */
  23235. x: number;
  23236. /** viewport top coordinate */
  23237. y: number;
  23238. /**viewport width */
  23239. width: number;
  23240. /** viewport height */
  23241. height: number;
  23242. /**
  23243. * Creates a Viewport object located at (x, y) and sized (width, height)
  23244. * @param x defines viewport left coordinate
  23245. * @param y defines viewport top coordinate
  23246. * @param width defines the viewport width
  23247. * @param height defines the viewport height
  23248. */
  23249. constructor(
  23250. /** viewport left coordinate */
  23251. x: number,
  23252. /** viewport top coordinate */
  23253. y: number,
  23254. /**viewport width */
  23255. width: number,
  23256. /** viewport height */
  23257. height: number);
  23258. /**
  23259. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23260. * @param renderWidthOrEngine defines either an engine or the rendering width
  23261. * @param renderHeight defines the rendering height
  23262. * @returns a new Viewport
  23263. */
  23264. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23265. /**
  23266. * Returns a new Viewport copied from the current one
  23267. * @returns a new Viewport
  23268. */
  23269. clone(): Viewport;
  23270. }
  23271. /**
  23272. * Reprasents a camera frustum
  23273. */
  23274. class Frustum {
  23275. /**
  23276. * Gets the planes representing the frustum
  23277. * @param transform matrix to be applied to the returned planes
  23278. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23279. */
  23280. static GetPlanes(transform: Matrix): Plane[];
  23281. /**
  23282. * Gets the near frustum plane transformed by the transform matrix
  23283. * @param transform transformation matrix to be applied to the resulting frustum plane
  23284. * @param frustumPlane the resuling frustum plane
  23285. */
  23286. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23287. /**
  23288. * Gets the far frustum plane transformed by the transform matrix
  23289. * @param transform transformation matrix to be applied to the resulting frustum plane
  23290. * @param frustumPlane the resuling frustum plane
  23291. */
  23292. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23293. /**
  23294. * Gets the left frustum plane transformed by the transform matrix
  23295. * @param transform transformation matrix to be applied to the resulting frustum plane
  23296. * @param frustumPlane the resuling frustum plane
  23297. */
  23298. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23299. /**
  23300. * Gets the right frustum plane transformed by the transform matrix
  23301. * @param transform transformation matrix to be applied to the resulting frustum plane
  23302. * @param frustumPlane the resuling frustum plane
  23303. */
  23304. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23305. /**
  23306. * Gets the top frustum plane transformed by the transform matrix
  23307. * @param transform transformation matrix to be applied to the resulting frustum plane
  23308. * @param frustumPlane the resuling frustum plane
  23309. */
  23310. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23311. /**
  23312. * Gets the bottom frustum plane transformed by the transform matrix
  23313. * @param transform transformation matrix to be applied to the resulting frustum plane
  23314. * @param frustumPlane the resuling frustum plane
  23315. */
  23316. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23317. /**
  23318. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23319. * @param transform transformation matrix to be applied to the resulting frustum planes
  23320. * @param frustumPlanes the resuling frustum planes
  23321. */
  23322. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23323. }
  23324. /** Defines supported spaces */
  23325. enum Space {
  23326. /** Local (object) space */
  23327. LOCAL = 0,
  23328. /** World space */
  23329. WORLD = 1,
  23330. /** Bone space */
  23331. BONE = 2
  23332. }
  23333. /** Defines the 3 main axes */
  23334. class Axis {
  23335. /** X axis */
  23336. static X: Vector3;
  23337. /** Y axis */
  23338. static Y: Vector3;
  23339. /** Z axis */
  23340. static Z: Vector3;
  23341. }
  23342. /** Class used to represent a Bezier curve */
  23343. class BezierCurve {
  23344. /**
  23345. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23346. * @param t defines the time
  23347. * @param x1 defines the left coordinate on X axis
  23348. * @param y1 defines the left coordinate on Y axis
  23349. * @param x2 defines the right coordinate on X axis
  23350. * @param y2 defines the right coordinate on Y axis
  23351. * @returns the interpolated value
  23352. */
  23353. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23354. }
  23355. /**
  23356. * Defines potential orientation for back face culling
  23357. */
  23358. enum Orientation {
  23359. /**
  23360. * Clockwise
  23361. */
  23362. CW = 0,
  23363. /** Counter clockwise */
  23364. CCW = 1
  23365. }
  23366. /**
  23367. * Defines angle representation
  23368. */
  23369. class Angle {
  23370. private _radians;
  23371. /**
  23372. * Creates an Angle object of "radians" radians (float).
  23373. */
  23374. constructor(radians: number);
  23375. /**
  23376. * Get value in degrees
  23377. * @returns the Angle value in degrees (float)
  23378. */
  23379. degrees(): number;
  23380. /**
  23381. * Get value in radians
  23382. * @returns the Angle value in radians (float)
  23383. */
  23384. radians(): number;
  23385. /**
  23386. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23387. * @param a defines first vector
  23388. * @param b defines second vector
  23389. * @returns a new Angle
  23390. */
  23391. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23392. /**
  23393. * Gets a new Angle object from the given float in radians
  23394. * @param radians defines the angle value in radians
  23395. * @returns a new Angle
  23396. */
  23397. static FromRadians(radians: number): Angle;
  23398. /**
  23399. * Gets a new Angle object from the given float in degrees
  23400. * @param degrees defines the angle value in degrees
  23401. * @returns a new Angle
  23402. */
  23403. static FromDegrees(degrees: number): Angle;
  23404. }
  23405. /**
  23406. * This represents an arc in a 2d space.
  23407. */
  23408. class Arc2 {
  23409. /** Defines the start point of the arc */
  23410. startPoint: Vector2;
  23411. /** Defines the mid point of the arc */
  23412. midPoint: Vector2;
  23413. /** Defines the end point of the arc */
  23414. endPoint: Vector2;
  23415. /**
  23416. * Defines the center point of the arc.
  23417. */
  23418. centerPoint: Vector2;
  23419. /**
  23420. * Defines the radius of the arc.
  23421. */
  23422. radius: number;
  23423. /**
  23424. * Defines the angle of the arc (from mid point to end point).
  23425. */
  23426. angle: Angle;
  23427. /**
  23428. * Defines the start angle of the arc (from start point to middle point).
  23429. */
  23430. startAngle: Angle;
  23431. /**
  23432. * Defines the orientation of the arc (clock wise/counter clock wise).
  23433. */
  23434. orientation: Orientation;
  23435. /**
  23436. * Creates an Arc object from the three given points : start, middle and end.
  23437. * @param startPoint Defines the start point of the arc
  23438. * @param midPoint Defines the midlle point of the arc
  23439. * @param endPoint Defines the end point of the arc
  23440. */
  23441. constructor(
  23442. /** Defines the start point of the arc */
  23443. startPoint: Vector2,
  23444. /** Defines the mid point of the arc */
  23445. midPoint: Vector2,
  23446. /** Defines the end point of the arc */
  23447. endPoint: Vector2);
  23448. }
  23449. /**
  23450. * Represents a 2D path made up of multiple 2D points
  23451. */
  23452. class Path2 {
  23453. private _points;
  23454. private _length;
  23455. /**
  23456. * If the path start and end point are the same
  23457. */
  23458. closed: boolean;
  23459. /**
  23460. * Creates a Path2 object from the starting 2D coordinates x and y.
  23461. * @param x the starting points x value
  23462. * @param y the starting points y value
  23463. */
  23464. constructor(x: number, y: number);
  23465. /**
  23466. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23467. * @param x the added points x value
  23468. * @param y the added points y value
  23469. * @returns the updated Path2.
  23470. */
  23471. addLineTo(x: number, y: number): Path2;
  23472. /**
  23473. * 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.
  23474. * @param midX middle point x value
  23475. * @param midY middle point y value
  23476. * @param endX end point x value
  23477. * @param endY end point y value
  23478. * @param numberOfSegments (default: 36)
  23479. * @returns the updated Path2.
  23480. */
  23481. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23482. /**
  23483. * Closes the Path2.
  23484. * @returns the Path2.
  23485. */
  23486. close(): Path2;
  23487. /**
  23488. * Gets the sum of the distance between each sequential point in the path
  23489. * @returns the Path2 total length (float).
  23490. */
  23491. length(): number;
  23492. /**
  23493. * Gets the points which construct the path
  23494. * @returns the Path2 internal array of points.
  23495. */
  23496. getPoints(): Vector2[];
  23497. /**
  23498. * Retreives the point at the distance aways from the starting point
  23499. * @param normalizedLengthPosition the length along the path to retreive the point from
  23500. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23501. */
  23502. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23503. /**
  23504. * Creates a new path starting from an x and y position
  23505. * @param x starting x value
  23506. * @param y starting y value
  23507. * @returns a new Path2 starting at the coordinates (x, y).
  23508. */
  23509. static StartingAt(x: number, y: number): Path2;
  23510. }
  23511. /**
  23512. * Represents a 3D path made up of multiple 3D points
  23513. */
  23514. class Path3D {
  23515. /**
  23516. * an array of Vector3, the curve axis of the Path3D
  23517. */
  23518. path: Vector3[];
  23519. private _curve;
  23520. private _distances;
  23521. private _tangents;
  23522. private _normals;
  23523. private _binormals;
  23524. private _raw;
  23525. /**
  23526. * new Path3D(path, normal, raw)
  23527. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23528. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23529. * @param path an array of Vector3, the curve axis of the Path3D
  23530. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23531. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23532. */
  23533. constructor(
  23534. /**
  23535. * an array of Vector3, the curve axis of the Path3D
  23536. */
  23537. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23538. /**
  23539. * Returns the Path3D array of successive Vector3 designing its curve.
  23540. * @returns the Path3D array of successive Vector3 designing its curve.
  23541. */
  23542. getCurve(): Vector3[];
  23543. /**
  23544. * Returns an array populated with tangent vectors on each Path3D curve point.
  23545. * @returns an array populated with tangent vectors on each Path3D curve point.
  23546. */
  23547. getTangents(): Vector3[];
  23548. /**
  23549. * Returns an array populated with normal vectors on each Path3D curve point.
  23550. * @returns an array populated with normal vectors on each Path3D curve point.
  23551. */
  23552. getNormals(): Vector3[];
  23553. /**
  23554. * Returns an array populated with binormal vectors on each Path3D curve point.
  23555. * @returns an array populated with binormal vectors on each Path3D curve point.
  23556. */
  23557. getBinormals(): Vector3[];
  23558. /**
  23559. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23560. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23561. */
  23562. getDistances(): number[];
  23563. /**
  23564. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23565. * @param path path which all values are copied into the curves points
  23566. * @param firstNormal which should be projected onto the curve
  23567. * @returns the same object updated.
  23568. */
  23569. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23570. private _compute;
  23571. private _getFirstNonNullVector;
  23572. private _getLastNonNullVector;
  23573. private _normalVector;
  23574. }
  23575. /**
  23576. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23577. * A Curve3 is designed from a series of successive Vector3.
  23578. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23579. */
  23580. class Curve3 {
  23581. private _points;
  23582. private _length;
  23583. /**
  23584. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23585. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23586. * @param v1 (Vector3) the control point
  23587. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23588. * @param nbPoints (integer) the wanted number of points in the curve
  23589. * @returns the created Curve3
  23590. */
  23591. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23592. /**
  23593. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23594. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23595. * @param v1 (Vector3) the first control point
  23596. * @param v2 (Vector3) the second control point
  23597. * @param v3 (Vector3) the end point of the Cubic Bezier
  23598. * @param nbPoints (integer) the wanted number of points in the curve
  23599. * @returns the created Curve3
  23600. */
  23601. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23602. /**
  23603. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23604. * @param p1 (Vector3) the origin point of the Hermite Spline
  23605. * @param t1 (Vector3) the tangent vector at the origin point
  23606. * @param p2 (Vector3) the end point of the Hermite Spline
  23607. * @param t2 (Vector3) the tangent vector at the end point
  23608. * @param nbPoints (integer) the wanted number of points in the curve
  23609. * @returns the created Curve3
  23610. */
  23611. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23612. /**
  23613. * Returns a Curve3 object along a CatmullRom Spline curve :
  23614. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23615. * @param nbPoints (integer) the wanted number of points between each curve control points
  23616. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23617. * @returns the created Curve3
  23618. */
  23619. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23620. /**
  23621. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23622. * A Curve3 is designed from a series of successive Vector3.
  23623. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23624. * @param points points which make up the curve
  23625. */
  23626. constructor(points: Vector3[]);
  23627. /**
  23628. * @returns the Curve3 stored array of successive Vector3
  23629. */
  23630. getPoints(): Vector3[];
  23631. /**
  23632. * @returns the computed length (float) of the curve.
  23633. */
  23634. length(): number;
  23635. /**
  23636. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23637. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23638. * curveA and curveB keep unchanged.
  23639. * @param curve the curve to continue from this curve
  23640. * @returns the newly constructed curve
  23641. */
  23642. continue(curve: Curve3): Curve3;
  23643. private _computeLength;
  23644. }
  23645. /**
  23646. * Contains position and normal vectors for a vertex
  23647. */
  23648. class PositionNormalVertex {
  23649. /** the position of the vertex (defaut: 0,0,0) */
  23650. position: Vector3;
  23651. /** the normal of the vertex (defaut: 0,1,0) */
  23652. normal: Vector3;
  23653. /**
  23654. * Creates a PositionNormalVertex
  23655. * @param position the position of the vertex (defaut: 0,0,0)
  23656. * @param normal the normal of the vertex (defaut: 0,1,0)
  23657. */
  23658. constructor(
  23659. /** the position of the vertex (defaut: 0,0,0) */
  23660. position?: Vector3,
  23661. /** the normal of the vertex (defaut: 0,1,0) */
  23662. normal?: Vector3);
  23663. /**
  23664. * Clones the PositionNormalVertex
  23665. * @returns the cloned PositionNormalVertex
  23666. */
  23667. clone(): PositionNormalVertex;
  23668. }
  23669. /**
  23670. * Contains position, normal and uv vectors for a vertex
  23671. */
  23672. class PositionNormalTextureVertex {
  23673. /** the position of the vertex (defaut: 0,0,0) */
  23674. position: Vector3;
  23675. /** the normal of the vertex (defaut: 0,1,0) */
  23676. normal: Vector3;
  23677. /** the uv of the vertex (default: 0,0) */
  23678. uv: Vector2;
  23679. /**
  23680. * Creates a PositionNormalTextureVertex
  23681. * @param position the position of the vertex (defaut: 0,0,0)
  23682. * @param normal the normal of the vertex (defaut: 0,1,0)
  23683. * @param uv the uv of the vertex (default: 0,0)
  23684. */
  23685. constructor(
  23686. /** the position of the vertex (defaut: 0,0,0) */
  23687. position?: Vector3,
  23688. /** the normal of the vertex (defaut: 0,1,0) */
  23689. normal?: Vector3,
  23690. /** the uv of the vertex (default: 0,0) */
  23691. uv?: Vector2);
  23692. /**
  23693. * Clones the PositionNormalTextureVertex
  23694. * @returns the cloned PositionNormalTextureVertex
  23695. */
  23696. clone(): PositionNormalTextureVertex;
  23697. }
  23698. /**
  23699. * @hidden
  23700. */
  23701. class Tmp {
  23702. static Color3: Color3[];
  23703. static Color4: Color4[];
  23704. static Vector2: Vector2[];
  23705. static Vector3: Vector3[];
  23706. static Vector4: Vector4[];
  23707. static Quaternion: Quaternion[];
  23708. static Matrix: Matrix[];
  23709. }
  23710. }
  23711. declare module BABYLON {
  23712. /**
  23713. * Class representing spherical polynomial coefficients to the 3rd degree
  23714. */
  23715. class SphericalPolynomial {
  23716. /**
  23717. * The x coefficients of the spherical polynomial
  23718. */
  23719. x: Vector3;
  23720. /**
  23721. * The y coefficients of the spherical polynomial
  23722. */
  23723. y: Vector3;
  23724. /**
  23725. * The z coefficients of the spherical polynomial
  23726. */
  23727. z: Vector3;
  23728. /**
  23729. * The xx coefficients of the spherical polynomial
  23730. */
  23731. xx: Vector3;
  23732. /**
  23733. * The yy coefficients of the spherical polynomial
  23734. */
  23735. yy: Vector3;
  23736. /**
  23737. * The zz coefficients of the spherical polynomial
  23738. */
  23739. zz: Vector3;
  23740. /**
  23741. * The xy coefficients of the spherical polynomial
  23742. */
  23743. xy: Vector3;
  23744. /**
  23745. * The yz coefficients of the spherical polynomial
  23746. */
  23747. yz: Vector3;
  23748. /**
  23749. * The zx coefficients of the spherical polynomial
  23750. */
  23751. zx: Vector3;
  23752. /**
  23753. * Adds an ambient color to the spherical polynomial
  23754. * @param color the color to add
  23755. */
  23756. addAmbient(color: Color3): void;
  23757. /**
  23758. * Scales the spherical polynomial by the given amount
  23759. * @param scale the amount to scale
  23760. */
  23761. scale(scale: number): void;
  23762. /**
  23763. * Gets the spherical polynomial from harmonics
  23764. * @param harmonics the spherical harmonics
  23765. * @returns the spherical polynomial
  23766. */
  23767. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23768. /**
  23769. * Constructs a spherical polynomial from an array.
  23770. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23771. * @returns the spherical polynomial
  23772. */
  23773. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23774. }
  23775. /**
  23776. * Class representing spherical harmonics coefficients to the 3rd degree
  23777. */
  23778. class SphericalHarmonics {
  23779. /**
  23780. * The l0,0 coefficients of the spherical harmonics
  23781. */
  23782. l00: Vector3;
  23783. /**
  23784. * The l1,-1 coefficients of the spherical harmonics
  23785. */
  23786. l1_1: Vector3;
  23787. /**
  23788. * The l1,0 coefficients of the spherical harmonics
  23789. */
  23790. l10: Vector3;
  23791. /**
  23792. * The l1,1 coefficients of the spherical harmonics
  23793. */
  23794. l11: Vector3;
  23795. /**
  23796. * The l2,-2 coefficients of the spherical harmonics
  23797. */
  23798. l2_2: Vector3;
  23799. /**
  23800. * The l2,-1 coefficients of the spherical harmonics
  23801. */
  23802. l2_1: Vector3;
  23803. /**
  23804. * The l2,0 coefficients of the spherical harmonics
  23805. */
  23806. l20: Vector3;
  23807. /**
  23808. * The l2,1 coefficients of the spherical harmonics
  23809. */
  23810. l21: Vector3;
  23811. /**
  23812. * The l2,2 coefficients of the spherical harmonics
  23813. */
  23814. lL22: Vector3;
  23815. /**
  23816. * Adds a light to the spherical harmonics
  23817. * @param direction the direction of the light
  23818. * @param color the color of the light
  23819. * @param deltaSolidAngle the delta solid angle of the light
  23820. */
  23821. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23822. /**
  23823. * Scales the spherical harmonics by the given amount
  23824. * @param scale the amount to scale
  23825. */
  23826. scale(scale: number): void;
  23827. /**
  23828. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23829. *
  23830. * ```
  23831. * E_lm = A_l * L_lm
  23832. * ```
  23833. *
  23834. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23835. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23836. * the scaling factors are given in equation 9.
  23837. */
  23838. convertIncidentRadianceToIrradiance(): void;
  23839. /**
  23840. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23841. *
  23842. * ```
  23843. * L = (1/pi) * E * rho
  23844. * ```
  23845. *
  23846. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23847. */
  23848. convertIrradianceToLambertianRadiance(): void;
  23849. /**
  23850. * Gets the spherical harmonics from polynomial
  23851. * @param polynomial the spherical polynomial
  23852. * @returns the spherical harmonics
  23853. */
  23854. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23855. /**
  23856. * Constructs a spherical harmonics from an array.
  23857. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23858. * @returns the spherical harmonics
  23859. */
  23860. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23861. }
  23862. }
  23863. declare module BABYLON {
  23864. /**
  23865. * Defines a target to use with MorphTargetManager
  23866. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23867. */
  23868. class MorphTarget implements IAnimatable {
  23869. /** defines the name of the target */
  23870. name: string;
  23871. /**
  23872. * Gets or sets the list of animations
  23873. */
  23874. animations: Animation[];
  23875. private _scene;
  23876. private _positions;
  23877. private _normals;
  23878. private _tangents;
  23879. private _influence;
  23880. /**
  23881. * Observable raised when the influence changes
  23882. */
  23883. onInfluenceChanged: Observable<boolean>;
  23884. /** @hidden */
  23885. _onDataLayoutChanged: Observable<void>;
  23886. /**
  23887. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23888. */
  23889. influence: number;
  23890. private _animationPropertiesOverride;
  23891. /**
  23892. * Gets or sets the animation properties override
  23893. */
  23894. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23895. /**
  23896. * Creates a new MorphTarget
  23897. * @param name defines the name of the target
  23898. * @param influence defines the influence to use
  23899. */
  23900. constructor(
  23901. /** defines the name of the target */
  23902. name: string, influence?: number, scene?: Nullable<Scene>);
  23903. /**
  23904. * Gets a boolean defining if the target contains position data
  23905. */
  23906. readonly hasPositions: boolean;
  23907. /**
  23908. * Gets a boolean defining if the target contains normal data
  23909. */
  23910. readonly hasNormals: boolean;
  23911. /**
  23912. * Gets a boolean defining if the target contains tangent data
  23913. */
  23914. readonly hasTangents: boolean;
  23915. /**
  23916. * Affects position data to this target
  23917. * @param data defines the position data to use
  23918. */
  23919. setPositions(data: Nullable<FloatArray>): void;
  23920. /**
  23921. * Gets the position data stored in this target
  23922. * @returns a FloatArray containing the position data (or null if not present)
  23923. */
  23924. getPositions(): Nullable<FloatArray>;
  23925. /**
  23926. * Affects normal data to this target
  23927. * @param data defines the normal data to use
  23928. */
  23929. setNormals(data: Nullable<FloatArray>): void;
  23930. /**
  23931. * Gets the normal data stored in this target
  23932. * @returns a FloatArray containing the normal data (or null if not present)
  23933. */
  23934. getNormals(): Nullable<FloatArray>;
  23935. /**
  23936. * Affects tangent data to this target
  23937. * @param data defines the tangent data to use
  23938. */
  23939. setTangents(data: Nullable<FloatArray>): void;
  23940. /**
  23941. * Gets the tangent data stored in this target
  23942. * @returns a FloatArray containing the tangent data (or null if not present)
  23943. */
  23944. getTangents(): Nullable<FloatArray>;
  23945. /**
  23946. * Serializes the current target into a Serialization object
  23947. * @returns the serialized object
  23948. */
  23949. serialize(): any;
  23950. /**
  23951. * Creates a new target from serialized data
  23952. * @param serializationObject defines the serialized data to use
  23953. * @returns a new MorphTarget
  23954. */
  23955. static Parse(serializationObject: any): MorphTarget;
  23956. /**
  23957. * Creates a MorphTarget from mesh data
  23958. * @param mesh defines the source mesh
  23959. * @param name defines the name to use for the new target
  23960. * @param influence defines the influence to attach to the target
  23961. * @returns a new MorphTarget
  23962. */
  23963. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23964. }
  23965. }
  23966. declare module BABYLON {
  23967. /**
  23968. * This class is used to deform meshes using morphing between different targets
  23969. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23970. */
  23971. class MorphTargetManager {
  23972. private _targets;
  23973. private _targetInfluenceChangedObservers;
  23974. private _targetDataLayoutChangedObservers;
  23975. private _activeTargets;
  23976. private _scene;
  23977. private _influences;
  23978. private _supportsNormals;
  23979. private _supportsTangents;
  23980. private _vertexCount;
  23981. private _uniqueId;
  23982. private _tempInfluences;
  23983. /**
  23984. * Creates a new MorphTargetManager
  23985. * @param scene defines the current scene
  23986. */
  23987. constructor(scene?: Nullable<Scene>);
  23988. /**
  23989. * Gets the unique ID of this manager
  23990. */
  23991. readonly uniqueId: number;
  23992. /**
  23993. * Gets the number of vertices handled by this manager
  23994. */
  23995. readonly vertexCount: number;
  23996. /**
  23997. * Gets a boolean indicating if this manager supports morphing of normals
  23998. */
  23999. readonly supportsNormals: boolean;
  24000. /**
  24001. * Gets a boolean indicating if this manager supports morphing of tangents
  24002. */
  24003. readonly supportsTangents: boolean;
  24004. /**
  24005. * Gets the number of targets stored in this manager
  24006. */
  24007. readonly numTargets: number;
  24008. /**
  24009. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24010. */
  24011. readonly numInfluencers: number;
  24012. /**
  24013. * Gets the list of influences (one per target)
  24014. */
  24015. readonly influences: Float32Array;
  24016. /**
  24017. * Gets the active target at specified index. An active target is a target with an influence > 0
  24018. * @param index defines the index to check
  24019. * @returns the requested target
  24020. */
  24021. getActiveTarget(index: number): MorphTarget;
  24022. /**
  24023. * Gets the target at specified index
  24024. * @param index defines the index to check
  24025. * @returns the requested target
  24026. */
  24027. getTarget(index: number): MorphTarget;
  24028. /**
  24029. * Add a new target to this manager
  24030. * @param target defines the target to add
  24031. */
  24032. addTarget(target: MorphTarget): void;
  24033. /**
  24034. * Removes a target from the manager
  24035. * @param target defines the target to remove
  24036. */
  24037. removeTarget(target: MorphTarget): void;
  24038. /**
  24039. * Serializes the current manager into a Serialization object
  24040. * @returns the serialized object
  24041. */
  24042. serialize(): any;
  24043. private _syncActiveTargets;
  24044. /**
  24045. * Syncrhonize the targets with all the meshes using this morph target manager
  24046. */
  24047. synchronize(): void;
  24048. /**
  24049. * Creates a new MorphTargetManager from serialized data
  24050. * @param serializationObject defines the serialized data
  24051. * @param scene defines the hosting scene
  24052. * @returns the new MorphTargetManager
  24053. */
  24054. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24055. }
  24056. }
  24057. declare module BABYLON {
  24058. /**
  24059. * Class used to enable access to IndexedDB
  24060. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  24061. */
  24062. class Database implements IOfflineProvider {
  24063. private _callbackManifestChecked;
  24064. private _currentSceneUrl;
  24065. private _db;
  24066. private _enableSceneOffline;
  24067. private _enableTexturesOffline;
  24068. private _manifestVersionFound;
  24069. private _mustUpdateRessources;
  24070. private _hasReachedQuota;
  24071. private _isSupported;
  24072. private _idbFactory;
  24073. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  24074. private static IsUASupportingBlobStorage;
  24075. /**
  24076. * Gets a boolean indicating if Database storate is enabled (off by default)
  24077. */
  24078. static IDBStorageEnabled: boolean;
  24079. /**
  24080. * Gets a boolean indicating if scene must be saved in the database
  24081. */
  24082. readonly enableSceneOffline: boolean;
  24083. /**
  24084. * Gets a boolean indicating if textures must be saved in the database
  24085. */
  24086. readonly enableTexturesOffline: boolean;
  24087. /**
  24088. * Creates a new Database
  24089. * @param urlToScene defines the url to load the scene
  24090. * @param callbackManifestChecked defines the callback to use when manifest is checked
  24091. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  24092. */
  24093. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  24094. private static _ParseURL;
  24095. private static _ReturnFullUrlLocation;
  24096. private _checkManifestFile;
  24097. /**
  24098. * Open the database and make it available
  24099. * @param successCallback defines the callback to call on success
  24100. * @param errorCallback defines the callback to call on error
  24101. */
  24102. open(successCallback: () => void, errorCallback: () => void): void;
  24103. /**
  24104. * Loads an image from the database
  24105. * @param url defines the url to load from
  24106. * @param image defines the target DOM image
  24107. */
  24108. loadImage(url: string, image: HTMLImageElement): void;
  24109. private _loadImageFromDBAsync;
  24110. private _saveImageIntoDBAsync;
  24111. private _checkVersionFromDB;
  24112. private _loadVersionFromDBAsync;
  24113. private _saveVersionIntoDBAsync;
  24114. /**
  24115. * Loads a file from database
  24116. * @param url defines the URL to load from
  24117. * @param sceneLoaded defines a callback to call on success
  24118. * @param progressCallBack defines a callback to call when progress changed
  24119. * @param errorCallback defines a callback to call on error
  24120. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  24121. */
  24122. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  24123. private _loadFileAsync;
  24124. private _saveFileAsync;
  24125. }
  24126. }
  24127. declare module BABYLON {
  24128. /**
  24129. * Class used to enable access to offline support
  24130. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  24131. */
  24132. interface IOfflineProvider {
  24133. /**
  24134. * Gets a boolean indicating if scene must be saved in the database
  24135. */
  24136. enableSceneOffline: boolean;
  24137. /**
  24138. * Gets a boolean indicating if textures must be saved in the database
  24139. */
  24140. enableTexturesOffline: boolean;
  24141. /**
  24142. * Open the offline support and make it available
  24143. * @param successCallback defines the callback to call on success
  24144. * @param errorCallback defines the callback to call on error
  24145. */
  24146. open(successCallback: () => void, errorCallback: () => void): void;
  24147. /**
  24148. * Loads an image from the offline support
  24149. * @param url defines the url to load from
  24150. * @param image defines the target DOM image
  24151. */
  24152. loadImage(url: string, image: HTMLImageElement): void;
  24153. /**
  24154. * Loads a file from offline support
  24155. * @param url defines the URL to load from
  24156. * @param sceneLoaded defines a callback to call on success
  24157. * @param progressCallBack defines a callback to call when progress changed
  24158. * @param errorCallback defines a callback to call on error
  24159. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  24160. */
  24161. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  24162. }
  24163. }
  24164. declare module BABYLON {
  24165. /**
  24166. * Class used to store all common mesh properties
  24167. */
  24168. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24169. /** No occlusion */
  24170. static OCCLUSION_TYPE_NONE: number;
  24171. /** Occlusion set to optimisitic */
  24172. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24173. /** Occlusion set to strict */
  24174. static OCCLUSION_TYPE_STRICT: number;
  24175. /** Use an accurante occlusion algorithm */
  24176. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24177. /** Use a conservative occlusion algorithm */
  24178. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24179. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24180. static readonly CULLINGSTRATEGY_STANDARD: number;
  24181. /** Culling strategy with bounding sphere only and then frustum culling */
  24182. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24183. /**
  24184. * No billboard
  24185. */
  24186. static readonly BILLBOARDMODE_NONE: number;
  24187. /** Billboard on X axis */
  24188. static readonly BILLBOARDMODE_X: number;
  24189. /** Billboard on Y axis */
  24190. static readonly BILLBOARDMODE_Y: number;
  24191. /** Billboard on Z axis */
  24192. static readonly BILLBOARDMODE_Z: number;
  24193. /** Billboard on all axes */
  24194. static readonly BILLBOARDMODE_ALL: number;
  24195. private _facetData;
  24196. /** Gets ot sets the culling strategy to use to find visible meshes */
  24197. cullingStrategy: number;
  24198. /**
  24199. * Gets the number of facets in the mesh
  24200. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24201. */
  24202. readonly facetNb: number;
  24203. /**
  24204. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24205. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24206. */
  24207. partitioningSubdivisions: number;
  24208. /**
  24209. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24210. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24211. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24212. */
  24213. partitioningBBoxRatio: number;
  24214. /**
  24215. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24216. * Works only for updatable meshes.
  24217. * Doesn't work with multi-materials
  24218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24219. */
  24220. mustDepthSortFacets: boolean;
  24221. /**
  24222. * The location (Vector3) where the facet depth sort must be computed from.
  24223. * By default, the active camera position.
  24224. * Used only when facet depth sort is enabled
  24225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24226. */
  24227. facetDepthSortFrom: Vector3;
  24228. /**
  24229. * gets a boolean indicating if facetData is enabled
  24230. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24231. */
  24232. readonly isFacetDataEnabled: boolean;
  24233. /** @hidden */
  24234. _updateNonUniformScalingState(value: boolean): boolean;
  24235. /**
  24236. * An event triggered when this mesh collides with another one
  24237. */
  24238. onCollideObservable: Observable<AbstractMesh>;
  24239. private _onCollideObserver;
  24240. /** Set a function to call when this mesh collides with another one */
  24241. onCollide: () => void;
  24242. /**
  24243. * An event triggered when the collision's position changes
  24244. */
  24245. onCollisionPositionChangeObservable: Observable<Vector3>;
  24246. private _onCollisionPositionChangeObserver;
  24247. /** Set a function to call when the collision's position changes */
  24248. onCollisionPositionChange: () => void;
  24249. /**
  24250. * An event triggered when material is changed
  24251. */
  24252. onMaterialChangedObservable: Observable<AbstractMesh>;
  24253. /**
  24254. * Gets or sets the orientation for POV movement & rotation
  24255. */
  24256. definedFacingForward: boolean;
  24257. /** @hidden */
  24258. _occlusionQuery: Nullable<WebGLQuery>;
  24259. private _visibility;
  24260. /**
  24261. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24262. */
  24263. /**
  24264. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24265. */
  24266. visibility: number;
  24267. /** Gets or sets the alpha index used to sort transparent meshes
  24268. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24269. */
  24270. alphaIndex: number;
  24271. /**
  24272. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24273. */
  24274. isVisible: boolean;
  24275. /**
  24276. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24277. */
  24278. isPickable: boolean;
  24279. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24280. showSubMeshesBoundingBox: boolean;
  24281. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24283. */
  24284. isBlocker: boolean;
  24285. /**
  24286. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24287. */
  24288. enablePointerMoveEvents: boolean;
  24289. /**
  24290. * Specifies the rendering group id for this mesh (0 by default)
  24291. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24292. */
  24293. renderingGroupId: number;
  24294. private _material;
  24295. /** Gets or sets current material */
  24296. material: Nullable<Material>;
  24297. private _receiveShadows;
  24298. /**
  24299. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24300. * @see http://doc.babylonjs.com/babylon101/shadows
  24301. */
  24302. receiveShadows: boolean;
  24303. /** Defines color to use when rendering outline */
  24304. outlineColor: Color3;
  24305. /** Define width to use when rendering outline */
  24306. outlineWidth: number;
  24307. /** Defines color to use when rendering overlay */
  24308. overlayColor: Color3;
  24309. /** Defines alpha to use when rendering overlay */
  24310. overlayAlpha: number;
  24311. private _hasVertexAlpha;
  24312. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24313. hasVertexAlpha: boolean;
  24314. private _useVertexColors;
  24315. /** 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) */
  24316. useVertexColors: boolean;
  24317. private _computeBonesUsingShaders;
  24318. /**
  24319. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24320. */
  24321. computeBonesUsingShaders: boolean;
  24322. private _numBoneInfluencers;
  24323. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24324. numBoneInfluencers: number;
  24325. private _applyFog;
  24326. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24327. applyFog: boolean;
  24328. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24329. useOctreeForRenderingSelection: boolean;
  24330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24331. useOctreeForPicking: boolean;
  24332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24333. useOctreeForCollisions: boolean;
  24334. private _layerMask;
  24335. /**
  24336. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24337. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24338. */
  24339. layerMask: number;
  24340. /**
  24341. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24342. */
  24343. alwaysSelectAsActiveMesh: boolean;
  24344. /**
  24345. * Gets or sets the current action manager
  24346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24347. */
  24348. actionManager: Nullable<ActionManager>;
  24349. private _checkCollisions;
  24350. private _collisionMask;
  24351. private _collisionGroup;
  24352. /**
  24353. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24355. */
  24356. ellipsoid: Vector3;
  24357. /**
  24358. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24359. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24360. */
  24361. ellipsoidOffset: Vector3;
  24362. private _collider;
  24363. private _oldPositionForCollisions;
  24364. private _diffPositionForCollisions;
  24365. /**
  24366. * Gets or sets a collision mask used to mask collisions (default is -1).
  24367. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24368. */
  24369. collisionMask: number;
  24370. /**
  24371. * Gets or sets the current collision group mask (-1 by default).
  24372. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24373. */
  24374. collisionGroup: number;
  24375. /**
  24376. * Defines edge width used when edgesRenderer is enabled
  24377. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24378. */
  24379. edgesWidth: number;
  24380. /**
  24381. * Defines edge color used when edgesRenderer is enabled
  24382. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24383. */
  24384. edgesColor: Color4;
  24385. /** @hidden */
  24386. _edgesRenderer: Nullable<IEdgesRenderer>;
  24387. /** @hidden */
  24388. _masterMesh: Nullable<AbstractMesh>;
  24389. /** @hidden */
  24390. _boundingInfo: Nullable<BoundingInfo>;
  24391. /** @hidden */
  24392. _renderId: number;
  24393. /**
  24394. * Gets or sets the list of subMeshes
  24395. * @see http://doc.babylonjs.com/how_to/multi_materials
  24396. */
  24397. subMeshes: SubMesh[];
  24398. /** @hidden */
  24399. _intersectionsInProgress: AbstractMesh[];
  24400. /** @hidden */
  24401. _unIndexed: boolean;
  24402. /** @hidden */
  24403. _lightSources: Light[];
  24404. /** @hidden */
  24405. readonly _positions: Nullable<Vector3[]>;
  24406. /** @hidden */
  24407. _waitingActions: any;
  24408. /** @hidden */
  24409. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24410. private _skeleton;
  24411. /** @hidden */
  24412. _bonesTransformMatrices: Nullable<Float32Array>;
  24413. /**
  24414. * Gets or sets a skeleton to apply skining transformations
  24415. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24416. */
  24417. skeleton: Nullable<Skeleton>;
  24418. /**
  24419. * An event triggered when the mesh is rebuilt.
  24420. */
  24421. onRebuildObservable: Observable<AbstractMesh>;
  24422. /**
  24423. * Creates a new AbstractMesh
  24424. * @param name defines the name of the mesh
  24425. * @param scene defines the hosting scene
  24426. */
  24427. constructor(name: string, scene?: Nullable<Scene>);
  24428. /**
  24429. * Returns the string "AbstractMesh"
  24430. * @returns "AbstractMesh"
  24431. */
  24432. getClassName(): string;
  24433. /**
  24434. * Gets a string representation of the current mesh
  24435. * @param fullDetails defines a boolean indicating if full details must be included
  24436. * @returns a string representation of the current mesh
  24437. */
  24438. toString(fullDetails?: boolean): string;
  24439. /** @hidden */
  24440. _rebuild(): void;
  24441. /** @hidden */
  24442. _resyncLightSources(): void;
  24443. /** @hidden */
  24444. _resyncLighSource(light: Light): void;
  24445. /** @hidden */
  24446. _unBindEffect(): void;
  24447. /** @hidden */
  24448. _removeLightSource(light: Light): void;
  24449. private _markSubMeshesAsDirty;
  24450. /** @hidden */
  24451. _markSubMeshesAsLightDirty(): void;
  24452. /** @hidden */
  24453. _markSubMeshesAsAttributesDirty(): void;
  24454. /** @hidden */
  24455. _markSubMeshesAsMiscDirty(): void;
  24456. /**
  24457. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24458. */
  24459. scaling: Vector3;
  24460. /**
  24461. * Returns true if the mesh is blocked. Implemented by child classes
  24462. */
  24463. readonly isBlocked: boolean;
  24464. /**
  24465. * Returns the mesh itself by default. Implemented by child classes
  24466. * @param camera defines the camera to use to pick the right LOD level
  24467. * @returns the currentAbstractMesh
  24468. */
  24469. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24470. /**
  24471. * Returns 0 by default. Implemented by child classes
  24472. * @returns an integer
  24473. */
  24474. getTotalVertices(): number;
  24475. /**
  24476. * Returns null by default. Implemented by child classes
  24477. * @returns null
  24478. */
  24479. getIndices(): Nullable<IndicesArray>;
  24480. /**
  24481. * Returns the array of the requested vertex data kind. Implemented by child classes
  24482. * @param kind defines the vertex data kind to use
  24483. * @returns null
  24484. */
  24485. getVerticesData(kind: string): Nullable<FloatArray>;
  24486. /**
  24487. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24488. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24489. * Note that a new underlying VertexBuffer object is created each call.
  24490. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24491. * @param kind defines vertex data kind:
  24492. * * BABYLON.VertexBuffer.PositionKind
  24493. * * BABYLON.VertexBuffer.UVKind
  24494. * * BABYLON.VertexBuffer.UV2Kind
  24495. * * BABYLON.VertexBuffer.UV3Kind
  24496. * * BABYLON.VertexBuffer.UV4Kind
  24497. * * BABYLON.VertexBuffer.UV5Kind
  24498. * * BABYLON.VertexBuffer.UV6Kind
  24499. * * BABYLON.VertexBuffer.ColorKind
  24500. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24501. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24502. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24503. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the data must be flagged as updatable (or static)
  24506. * @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
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24512. * If the mesh has no geometry, it is simply returned as it is.
  24513. * @param kind defines vertex data kind:
  24514. * * BABYLON.VertexBuffer.PositionKind
  24515. * * BABYLON.VertexBuffer.UVKind
  24516. * * BABYLON.VertexBuffer.UV2Kind
  24517. * * BABYLON.VertexBuffer.UV3Kind
  24518. * * BABYLON.VertexBuffer.UV4Kind
  24519. * * BABYLON.VertexBuffer.UV5Kind
  24520. * * BABYLON.VertexBuffer.UV6Kind
  24521. * * BABYLON.VertexBuffer.ColorKind
  24522. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24523. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24524. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24525. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24526. * @param data defines the data source
  24527. * @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
  24528. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24529. * @returns the current mesh
  24530. */
  24531. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24532. /**
  24533. * Sets the mesh indices,
  24534. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24535. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24536. * @param totalVertices Defines the total number of vertices
  24537. * @returns the current mesh
  24538. */
  24539. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24540. /**
  24541. * Gets a boolean indicating if specific vertex data is present
  24542. * @param kind defines the vertex data kind to use
  24543. * @returns true is data kind is present
  24544. */
  24545. isVerticesDataPresent(kind: string): boolean;
  24546. /**
  24547. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24548. * @returns a BoundingInfo
  24549. */
  24550. getBoundingInfo(): BoundingInfo;
  24551. /**
  24552. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24553. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24554. * @returns the current mesh
  24555. */
  24556. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24557. /**
  24558. * Overwrite the current bounding info
  24559. * @param boundingInfo defines the new bounding info
  24560. * @returns the current mesh
  24561. */
  24562. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24563. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24564. readonly useBones: boolean;
  24565. /** @hidden */
  24566. _preActivate(): void;
  24567. /** @hidden */
  24568. _preActivateForIntermediateRendering(renderId: number): void;
  24569. /** @hidden */
  24570. _activate(renderId: number): void;
  24571. /**
  24572. * Gets the current world matrix
  24573. * @returns a Matrix
  24574. */
  24575. getWorldMatrix(): Matrix;
  24576. /** @hidden */
  24577. _getWorldMatrixDeterminant(): number;
  24578. /**
  24579. * Perform relative position change from the point of view of behind the front of the mesh.
  24580. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24581. * Supports definition of mesh facing forward or backward
  24582. * @param amountRight defines the distance on the right axis
  24583. * @param amountUp defines the distance on the up axis
  24584. * @param amountForward defines the distance on the forward axis
  24585. * @returns the current mesh
  24586. */
  24587. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24588. /**
  24589. * Calculate relative position change from the point of view of behind the front of the mesh.
  24590. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24591. * Supports definition of mesh facing forward or backward
  24592. * @param amountRight defines the distance on the right axis
  24593. * @param amountUp defines the distance on the up axis
  24594. * @param amountForward defines the distance on the forward axis
  24595. * @returns the new displacement vector
  24596. */
  24597. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24598. /**
  24599. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24600. * Supports definition of mesh facing forward or backward
  24601. * @param flipBack defines the flip
  24602. * @param twirlClockwise defines the twirl
  24603. * @param tiltRight defines the tilt
  24604. * @returns the current mesh
  24605. */
  24606. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24607. /**
  24608. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24609. * Supports definition of mesh facing forward or backward.
  24610. * @param flipBack defines the flip
  24611. * @param twirlClockwise defines the twirl
  24612. * @param tiltRight defines the tilt
  24613. * @returns the new rotation vector
  24614. */
  24615. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24616. /**
  24617. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24618. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24619. * @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
  24620. * @returns the new bounding vectors
  24621. */
  24622. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24623. min: Vector3;
  24624. max: Vector3;
  24625. };
  24626. /** @hidden */
  24627. _updateBoundingInfo(): AbstractMesh;
  24628. /** @hidden */
  24629. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24630. /** @hidden */
  24631. protected _afterComputeWorldMatrix(): void;
  24632. /**
  24633. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24634. * A mesh is in the frustum if its bounding box intersects the frustum
  24635. * @param frustumPlanes defines the frustum to test
  24636. * @returns true if the mesh is in the frustum planes
  24637. */
  24638. isInFrustum(frustumPlanes: Plane[]): boolean;
  24639. /**
  24640. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24641. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24642. * @param frustumPlanes defines the frustum to test
  24643. * @returns true if the mesh is completely in the frustum planes
  24644. */
  24645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24646. /**
  24647. * True if the mesh intersects another mesh or a SolidParticle object
  24648. * @param mesh defines a target mesh or SolidParticle to test
  24649. * @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)
  24650. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24651. * @returns true if there is an intersection
  24652. */
  24653. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24654. /**
  24655. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24656. * @param point defines the point to test
  24657. * @returns true if there is an intersection
  24658. */
  24659. intersectsPoint(point: Vector3): boolean;
  24660. /**
  24661. * Gets the position of the current mesh in camera space
  24662. * @param camera defines the camera to use
  24663. * @returns a position
  24664. */
  24665. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24666. /**
  24667. * Returns the distance from the mesh to the active camera
  24668. * @param camera defines the camera to use
  24669. * @returns the distance
  24670. */
  24671. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24672. /**
  24673. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24675. */
  24676. checkCollisions: boolean;
  24677. /**
  24678. * Gets Collider object used to compute collisions (not physics)
  24679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24680. */
  24681. readonly collider: Collider;
  24682. /**
  24683. * Move the mesh using collision engine
  24684. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24685. * @param displacement defines the requested displacement vector
  24686. * @returns the current mesh
  24687. */
  24688. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24689. private _onCollisionPositionChange;
  24690. /** @hidden */
  24691. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24692. /** @hidden */
  24693. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24694. /** @hidden */
  24695. _checkCollision(collider: Collider): AbstractMesh;
  24696. /** @hidden */
  24697. _generatePointsArray(): boolean;
  24698. /**
  24699. * Checks if the passed Ray intersects with the mesh
  24700. * @param ray defines the ray to use
  24701. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24702. * @returns the picking info
  24703. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24704. */
  24705. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24706. /**
  24707. * Clones the current mesh
  24708. * @param name defines the mesh name
  24709. * @param newParent defines the new mesh parent
  24710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24711. * @returns the new mesh
  24712. */
  24713. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24714. /**
  24715. * Disposes all the submeshes of the current meshnp
  24716. * @returns the current mesh
  24717. */
  24718. releaseSubMeshes(): AbstractMesh;
  24719. /**
  24720. * Releases resources associated with this abstract mesh.
  24721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24723. */
  24724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24725. /**
  24726. * Adds the passed mesh as a child to the current mesh
  24727. * @param mesh defines the child mesh
  24728. * @returns the current mesh
  24729. */
  24730. addChild(mesh: AbstractMesh): AbstractMesh;
  24731. /**
  24732. * Removes the passed mesh from the current mesh children list
  24733. * @param mesh defines the child mesh
  24734. * @returns the current mesh
  24735. */
  24736. removeChild(mesh: AbstractMesh): AbstractMesh;
  24737. /** @hidden */
  24738. private _initFacetData;
  24739. /**
  24740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24741. * This method can be called within the render loop.
  24742. * 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
  24743. * @returns the current mesh
  24744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24745. */
  24746. updateFacetData(): AbstractMesh;
  24747. /**
  24748. * Returns the facetLocalNormals array.
  24749. * The normals are expressed in the mesh local spac
  24750. * @returns an array of Vector3
  24751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24752. */
  24753. getFacetLocalNormals(): Vector3[];
  24754. /**
  24755. * Returns the facetLocalPositions array.
  24756. * The facet positions are expressed in the mesh local space
  24757. * @returns an array of Vector3
  24758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24759. */
  24760. getFacetLocalPositions(): Vector3[];
  24761. /**
  24762. * Returns the facetLocalPartioning array
  24763. * @returns an array of array of numbers
  24764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24765. */
  24766. getFacetLocalPartitioning(): number[][];
  24767. /**
  24768. * Returns the i-th facet position in the world system.
  24769. * This method allocates a new Vector3 per call
  24770. * @param i defines the facet index
  24771. * @returns a new Vector3
  24772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24773. */
  24774. getFacetPosition(i: number): Vector3;
  24775. /**
  24776. * Sets the reference Vector3 with the i-th facet position in the world system
  24777. * @param i defines the facet index
  24778. * @param ref defines the target vector
  24779. * @returns the current mesh
  24780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24781. */
  24782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24783. /**
  24784. * Returns the i-th facet normal in the world system.
  24785. * This method allocates a new Vector3 per call
  24786. * @param i defines the facet index
  24787. * @returns a new Vector3
  24788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24789. */
  24790. getFacetNormal(i: number): Vector3;
  24791. /**
  24792. * Sets the reference Vector3 with the i-th facet normal in the world system
  24793. * @param i defines the facet index
  24794. * @param ref defines the target vector
  24795. * @returns the current mesh
  24796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24797. */
  24798. getFacetNormalToRef(i: number, ref: Vector3): this;
  24799. /**
  24800. * 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)
  24801. * @param x defines x coordinate
  24802. * @param y defines y coordinate
  24803. * @param z defines z coordinate
  24804. * @returns the array of facet indexes
  24805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24806. */
  24807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24808. /**
  24809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24810. * @param projected sets as the (x,y,z) world projection on the facet
  24811. * @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
  24812. * @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
  24813. * @param x defines x coordinate
  24814. * @param y defines y coordinate
  24815. * @param z defines z coordinate
  24816. * @returns the face index if found (or null instead)
  24817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24818. */
  24819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24820. /**
  24821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24822. * @param projected sets as the (x,y,z) local projection on the facet
  24823. * @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
  24824. * @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
  24825. * @param x defines x coordinate
  24826. * @param y defines y coordinate
  24827. * @param z defines z coordinate
  24828. * @returns the face index if found (or null instead)
  24829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24830. */
  24831. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24832. /**
  24833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24834. * @returns the parameters
  24835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24836. */
  24837. getFacetDataParameters(): any;
  24838. /**
  24839. * Disables the feature FacetData and frees the related memory
  24840. * @returns the current mesh
  24841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24842. */
  24843. disableFacetData(): AbstractMesh;
  24844. /**
  24845. * Updates the AbstractMesh indices array
  24846. * @param indices defines the data source
  24847. * @returns the current mesh
  24848. */
  24849. updateIndices(indices: IndicesArray): AbstractMesh;
  24850. /**
  24851. * Creates new normals data for the mesh
  24852. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24853. * @returns the current mesh
  24854. */
  24855. createNormals(updatable: boolean): AbstractMesh;
  24856. /**
  24857. * Align the mesh with a normal
  24858. * @param normal defines the normal to use
  24859. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24860. * @returns the current mesh
  24861. */
  24862. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24863. /** @hidden */
  24864. _checkOcclusionQuery(): boolean;
  24865. }
  24866. }
  24867. declare module BABYLON {
  24868. /**
  24869. * Class used to store data that will be store in GPU memory
  24870. */
  24871. class Buffer {
  24872. private _engine;
  24873. private _buffer;
  24874. /** @hidden */
  24875. _data: Nullable<DataArray>;
  24876. private _updatable;
  24877. private _instanced;
  24878. /**
  24879. * Gets the byte stride.
  24880. */
  24881. readonly byteStride: number;
  24882. /**
  24883. * Constructor
  24884. * @param engine the engine
  24885. * @param data the data to use for this buffer
  24886. * @param updatable whether the data is updatable
  24887. * @param stride the stride (optional)
  24888. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24889. * @param instanced whether the buffer is instanced (optional)
  24890. * @param useBytes set to true if the stride in in bytes (optional)
  24891. */
  24892. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24893. /**
  24894. * Create a new VertexBuffer based on the current buffer
  24895. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24896. * @param offset defines offset in the buffer (0 by default)
  24897. * @param size defines the size in floats of attributes (position is 3 for instance)
  24898. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24899. * @param instanced defines if the vertex buffer contains indexed data
  24900. * @param useBytes defines if the offset and stride are in bytes
  24901. * @returns the new vertex buffer
  24902. */
  24903. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24904. /**
  24905. * Gets a boolean indicating if the Buffer is updatable?
  24906. * @returns true if the buffer is updatable
  24907. */
  24908. isUpdatable(): boolean;
  24909. /**
  24910. * Gets current buffer's data
  24911. * @returns a DataArray or null
  24912. */
  24913. getData(): Nullable<DataArray>;
  24914. /**
  24915. * Gets underlying native buffer
  24916. * @returns underlying native buffer
  24917. */
  24918. getBuffer(): Nullable<WebGLBuffer>;
  24919. /**
  24920. * Gets the stride in float32 units (i.e. byte stride / 4).
  24921. * May not be an integer if the byte stride is not divisible by 4.
  24922. * DEPRECATED. Use byteStride instead.
  24923. * @returns the stride in float32 units
  24924. */
  24925. getStrideSize(): number;
  24926. /**
  24927. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24928. * @param data defines the data to store
  24929. */
  24930. create(data?: Nullable<DataArray>): void;
  24931. /** @hidden */
  24932. _rebuild(): void;
  24933. /**
  24934. * Update current buffer data
  24935. * @param data defines the data to store
  24936. */
  24937. update(data: DataArray): void;
  24938. /**
  24939. * Updates the data directly.
  24940. * @param data the new data
  24941. * @param offset the new offset
  24942. * @param vertexCount the vertex count (optional)
  24943. * @param useBytes set to true if the offset is in bytes
  24944. */
  24945. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24946. /**
  24947. * Release all resources
  24948. */
  24949. dispose(): void;
  24950. }
  24951. }
  24952. declare module BABYLON {
  24953. /**
  24954. * Class for building Constructive Solid Geometry
  24955. */
  24956. class CSG {
  24957. private polygons;
  24958. /**
  24959. * The world matrix
  24960. */
  24961. matrix: Matrix;
  24962. /**
  24963. * Stores the position
  24964. */
  24965. position: Vector3;
  24966. /**
  24967. * Stores the rotation
  24968. */
  24969. rotation: Vector3;
  24970. /**
  24971. * Stores the rotation quaternion
  24972. */
  24973. rotationQuaternion: Nullable<Quaternion>;
  24974. /**
  24975. * Stores the scaling vector
  24976. */
  24977. scaling: Vector3;
  24978. /**
  24979. * Convert the BABYLON.Mesh to BABYLON.CSG
  24980. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24981. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24982. */
  24983. static FromMesh(mesh: Mesh): CSG;
  24984. /**
  24985. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24986. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24987. */
  24988. private static FromPolygons;
  24989. /**
  24990. * Clones, or makes a deep copy, of the BABYLON.CSG
  24991. * @returns A new BABYLON.CSG
  24992. */
  24993. clone(): CSG;
  24994. /**
  24995. * Unions this CSG with another CSG
  24996. * @param csg The CSG to union against this CSG
  24997. * @returns The unioned CSG
  24998. */
  24999. union(csg: CSG): CSG;
  25000. /**
  25001. * Unions this CSG with another CSG in place
  25002. * @param csg The CSG to union against this CSG
  25003. */
  25004. unionInPlace(csg: CSG): void;
  25005. /**
  25006. * Subtracts this CSG with another CSG
  25007. * @param csg The CSG to subtract against this CSG
  25008. * @returns A new BABYLON.CSG
  25009. */
  25010. subtract(csg: CSG): CSG;
  25011. /**
  25012. * Subtracts this CSG with another CSG in place
  25013. * @param csg The CSG to subtact against this CSG
  25014. */
  25015. subtractInPlace(csg: CSG): void;
  25016. /**
  25017. * Intersect this CSG with another CSG
  25018. * @param csg The CSG to intersect against this CSG
  25019. * @returns A new BABYLON.CSG
  25020. */
  25021. intersect(csg: CSG): CSG;
  25022. /**
  25023. * Intersects this CSG with another CSG in place
  25024. * @param csg The CSG to intersect against this CSG
  25025. */
  25026. intersectInPlace(csg: CSG): void;
  25027. /**
  25028. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25029. * not modified.
  25030. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25031. */
  25032. inverse(): CSG;
  25033. /**
  25034. * Inverses the BABYLON.CSG in place
  25035. */
  25036. inverseInPlace(): void;
  25037. /**
  25038. * This is used to keep meshes transformations so they can be restored
  25039. * when we build back a Babylon Mesh
  25040. * NB : All CSG operations are performed in world coordinates
  25041. * @param csg The BABYLON.CSG to copy the transform attributes from
  25042. * @returns This BABYLON.CSG
  25043. */
  25044. copyTransformAttributes(csg: CSG): CSG;
  25045. /**
  25046. * Build Raw mesh from CSG
  25047. * Coordinates here are in world space
  25048. * @param name The name of the mesh geometry
  25049. * @param scene The BABYLON.Scene
  25050. * @param keepSubMeshes Specifies if the submeshes should be kept
  25051. * @returns A new BABYLON.Mesh
  25052. */
  25053. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25054. /**
  25055. * Build Mesh from CSG taking material and transforms into account
  25056. * @param name The name of the BABYLON.Mesh
  25057. * @param material The material of the BABYLON.Mesh
  25058. * @param scene The BABYLON.Scene
  25059. * @param keepSubMeshes Specifies if submeshes should be kept
  25060. * @returns The new BABYLON.Mesh
  25061. */
  25062. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25063. }
  25064. }
  25065. declare module BABYLON {
  25066. /**
  25067. * Class used to store geometry data (vertex buffers + index buffer)
  25068. */
  25069. class Geometry implements IGetSetVerticesData {
  25070. /**
  25071. * Gets or sets the unique ID of the geometry
  25072. */
  25073. id: string;
  25074. /**
  25075. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25076. */
  25077. delayLoadState: number;
  25078. /**
  25079. * Gets the file containing the data to load when running in delay load state
  25080. */
  25081. delayLoadingFile: Nullable<string>;
  25082. /**
  25083. * Callback called when the geometry is updated
  25084. */
  25085. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25086. private _scene;
  25087. private _engine;
  25088. private _meshes;
  25089. private _totalVertices;
  25090. /** @hidden */
  25091. _indices: IndicesArray;
  25092. /** @hidden */
  25093. _vertexBuffers: {
  25094. [key: string]: VertexBuffer;
  25095. };
  25096. private _isDisposed;
  25097. private _extend;
  25098. private _boundingBias;
  25099. /** @hidden */
  25100. _delayInfo: Array<string>;
  25101. private _indexBuffer;
  25102. private _indexBufferIsUpdatable;
  25103. /** @hidden */
  25104. _boundingInfo: Nullable<BoundingInfo>;
  25105. /** @hidden */
  25106. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25107. /** @hidden */
  25108. _softwareSkinningFrameId: number;
  25109. private _vertexArrayObjects;
  25110. private _updatable;
  25111. /** @hidden */
  25112. _positions: Nullable<Vector3[]>;
  25113. /**
  25114. * 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
  25115. */
  25116. /**
  25117. * 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
  25118. */
  25119. boundingBias: Vector2;
  25120. /**
  25121. * Static function used to attach a new empty geometry to a mesh
  25122. * @param mesh defines the mesh to attach the geometry to
  25123. * @returns the new Geometry
  25124. */
  25125. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25126. /**
  25127. * Creates a new geometry
  25128. * @param id defines the unique ID
  25129. * @param scene defines the hosting scene
  25130. * @param vertexData defines the VertexData used to get geometry data
  25131. * @param updatable defines if geometry must be updatable (false by default)
  25132. * @param mesh defines the mesh that will be associated with the geometry
  25133. */
  25134. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25135. /**
  25136. * Gets the current extend of the geometry
  25137. */
  25138. readonly extend: {
  25139. minimum: Vector3;
  25140. maximum: Vector3;
  25141. };
  25142. /**
  25143. * Gets the hosting scene
  25144. * @returns the hosting Scene
  25145. */
  25146. getScene(): Scene;
  25147. /**
  25148. * Gets the hosting engine
  25149. * @returns the hosting Engine
  25150. */
  25151. getEngine(): Engine;
  25152. /**
  25153. * Defines if the geometry is ready to use
  25154. * @returns true if the geometry is ready to be used
  25155. */
  25156. isReady(): boolean;
  25157. /**
  25158. * Gets a value indicating that the geometry should not be serialized
  25159. */
  25160. readonly doNotSerialize: boolean;
  25161. /** @hidden */
  25162. _rebuild(): void;
  25163. /**
  25164. * Affects all geometry data in one call
  25165. * @param vertexData defines the geometry data
  25166. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25167. */
  25168. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25169. /**
  25170. * Set specific vertex data
  25171. * @param kind defines the data kind (Position, normal, etc...)
  25172. * @param data defines the vertex data to use
  25173. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25174. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25175. */
  25176. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25177. /**
  25178. * Removes a specific vertex data
  25179. * @param kind defines the data kind (Position, normal, etc...)
  25180. */
  25181. removeVerticesData(kind: string): void;
  25182. /**
  25183. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25184. * @param buffer defines the vertex buffer to use
  25185. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25186. */
  25187. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25188. /**
  25189. * Update a specific vertex buffer
  25190. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25191. * It will do nothing if the buffer is not updatable
  25192. * @param kind defines the data kind (Position, normal, etc...)
  25193. * @param data defines the data to use
  25194. * @param offset defines the offset in the target buffer where to store the data
  25195. * @param useBytes set to true if the offset is in bytes
  25196. */
  25197. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25198. /**
  25199. * Update a specific vertex buffer
  25200. * This function will create a new buffer if the current one is not updatable
  25201. * @param kind defines the data kind (Position, normal, etc...)
  25202. * @param data defines the data to use
  25203. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25204. */
  25205. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25206. private _updateBoundingInfo;
  25207. /** @hidden */
  25208. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25209. /**
  25210. * Gets total number of vertices
  25211. * @returns the total number of vertices
  25212. */
  25213. getTotalVertices(): number;
  25214. /**
  25215. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25216. * @param kind defines the data kind (Position, normal, etc...)
  25217. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25218. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25219. * @returns a float array containing vertex data
  25220. */
  25221. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25222. /**
  25223. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25224. * @param kind defines the data kind (Position, normal, etc...)
  25225. * @returns true if the vertex buffer with the specified kind is updatable
  25226. */
  25227. isVertexBufferUpdatable(kind: string): boolean;
  25228. /**
  25229. * Gets a specific vertex buffer
  25230. * @param kind defines the data kind (Position, normal, etc...)
  25231. * @returns a VertexBuffer
  25232. */
  25233. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25234. /**
  25235. * Returns all vertex buffers
  25236. * @return an object holding all vertex buffers indexed by kind
  25237. */
  25238. getVertexBuffers(): Nullable<{
  25239. [key: string]: VertexBuffer;
  25240. }>;
  25241. /**
  25242. * Gets a boolean indicating if specific vertex buffer is present
  25243. * @param kind defines the data kind (Position, normal, etc...)
  25244. * @returns true if data is present
  25245. */
  25246. isVerticesDataPresent(kind: string): boolean;
  25247. /**
  25248. * Gets a list of all attached data kinds (Position, normal, etc...)
  25249. * @returns a list of string containing all kinds
  25250. */
  25251. getVerticesDataKinds(): string[];
  25252. /**
  25253. * Update index buffer
  25254. * @param indices defines the indices to store in the index buffer
  25255. * @param offset defines the offset in the target buffer where to store the data
  25256. */
  25257. updateIndices(indices: IndicesArray, offset?: number): void;
  25258. /**
  25259. * Creates a new index buffer
  25260. * @param indices defines the indices to store in the index buffer
  25261. * @param totalVertices defines the total number of vertices (could be null)
  25262. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25263. */
  25264. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25265. /**
  25266. * Return the total number of indices
  25267. * @returns the total number of indices
  25268. */
  25269. getTotalIndices(): number;
  25270. /**
  25271. * Gets the index buffer array
  25272. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25273. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25274. * @returns the index buffer array
  25275. */
  25276. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25277. /**
  25278. * Gets the index buffer
  25279. * @return the index buffer
  25280. */
  25281. getIndexBuffer(): Nullable<WebGLBuffer>;
  25282. /** @hidden */
  25283. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25284. /**
  25285. * Release the associated resources for a specific mesh
  25286. * @param mesh defines the source mesh
  25287. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25288. */
  25289. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25290. /**
  25291. * Apply current geometry to a given mesh
  25292. * @param mesh defines the mesh to apply geometry to
  25293. */
  25294. applyToMesh(mesh: Mesh): void;
  25295. private _updateExtend;
  25296. private _applyToMesh;
  25297. private notifyUpdate;
  25298. /**
  25299. * Load the geometry if it was flagged as delay loaded
  25300. * @param scene defines the hosting scene
  25301. * @param onLoaded defines a callback called when the geometry is loaded
  25302. */
  25303. load(scene: Scene, onLoaded?: () => void): void;
  25304. private _queueLoad;
  25305. /**
  25306. * Invert the geometry to move from a right handed system to a left handed one.
  25307. */
  25308. toLeftHanded(): void;
  25309. /** @hidden */
  25310. _resetPointsArrayCache(): void;
  25311. /** @hidden */
  25312. _generatePointsArray(): boolean;
  25313. /**
  25314. * Gets a value indicating if the geometry is disposed
  25315. * @returns true if the geometry was disposed
  25316. */
  25317. isDisposed(): boolean;
  25318. private _disposeVertexArrayObjects;
  25319. /**
  25320. * Free all associated resources
  25321. */
  25322. dispose(): void;
  25323. /**
  25324. * Clone the current geometry into a new geometry
  25325. * @param id defines the unique ID of the new geometry
  25326. * @returns a new geometry object
  25327. */
  25328. copy(id: string): Geometry;
  25329. /**
  25330. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25331. * @return a JSON representation of the current geometry data (without the vertices data)
  25332. */
  25333. serialize(): any;
  25334. private toNumberArray;
  25335. /**
  25336. * Serialize all vertices data into a JSON oject
  25337. * @returns a JSON representation of the current geometry data
  25338. */
  25339. serializeVerticeData(): any;
  25340. /**
  25341. * Extracts a clone of a mesh geometry
  25342. * @param mesh defines the source mesh
  25343. * @param id defines the unique ID of the new geometry object
  25344. * @returns the new geometry object
  25345. */
  25346. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25347. /**
  25348. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25349. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25350. * Be aware Math.random() could cause collisions, but:
  25351. * "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"
  25352. * @returns a string containing a new GUID
  25353. */
  25354. static RandomId(): string;
  25355. /** @hidden */
  25356. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25357. private static _CleanMatricesWeights;
  25358. /**
  25359. * Create a new geometry from persisted data (Using .babylon file format)
  25360. * @param parsedVertexData defines the persisted data
  25361. * @param scene defines the hosting scene
  25362. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25363. * @returns the new geometry object
  25364. */
  25365. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25366. }
  25367. /**
  25368. * Abstract class used to provide common services for all typed geometries
  25369. * @hidden
  25370. */
  25371. class _PrimitiveGeometry extends Geometry {
  25372. private _canBeRegenerated;
  25373. private _beingRegenerated;
  25374. /**
  25375. * Creates a new typed geometry
  25376. * @param id defines the unique ID of the geometry
  25377. * @param scene defines the hosting scene
  25378. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25379. * @param mesh defines the hosting mesh (can be null)
  25380. */
  25381. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25382. /**
  25383. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25384. * @returns true if the geometry can be regenerated
  25385. */
  25386. canBeRegenerated(): boolean;
  25387. /**
  25388. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25389. */
  25390. regenerate(): void;
  25391. /**
  25392. * Clone the geometry
  25393. * @param id defines the unique ID of the new geometry
  25394. * @returns the new geometry
  25395. */
  25396. asNewGeometry(id: string): Geometry;
  25397. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25398. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25399. /** @hidden */
  25400. _regenerateVertexData(): VertexData;
  25401. copy(id: string): Geometry;
  25402. serialize(): any;
  25403. }
  25404. /**
  25405. * Creates a ribbon geometry
  25406. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25407. */
  25408. class RibbonGeometry extends _PrimitiveGeometry {
  25409. /**
  25410. * Defines the array of paths to use
  25411. */
  25412. pathArray: Vector3[][];
  25413. /**
  25414. * Defines if the last and first points of each path in your pathArray must be joined
  25415. */
  25416. closeArray: boolean;
  25417. /**
  25418. * Defines if the last and first points of each path in your pathArray must be joined
  25419. */
  25420. closePath: boolean;
  25421. /**
  25422. * Defines the offset between points
  25423. */
  25424. offset: number;
  25425. /**
  25426. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25427. */
  25428. side: number;
  25429. /**
  25430. * Creates a ribbon geometry
  25431. * @param id defines the unique ID of the geometry
  25432. * @param scene defines the hosting scene
  25433. * @param pathArray defines the array of paths to use
  25434. * @param closeArray defines if the last path and the first path must be joined
  25435. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25436. * @param offset defines the offset between points
  25437. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25438. * @param mesh defines the hosting mesh (can be null)
  25439. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25440. */
  25441. constructor(id: string, scene: Scene,
  25442. /**
  25443. * Defines the array of paths to use
  25444. */
  25445. pathArray: Vector3[][],
  25446. /**
  25447. * Defines if the last and first points of each path in your pathArray must be joined
  25448. */
  25449. closeArray: boolean,
  25450. /**
  25451. * Defines if the last and first points of each path in your pathArray must be joined
  25452. */
  25453. closePath: boolean,
  25454. /**
  25455. * Defines the offset between points
  25456. */
  25457. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25458. /**
  25459. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25460. */
  25461. side?: number);
  25462. /** @hidden */
  25463. _regenerateVertexData(): VertexData;
  25464. copy(id: string): Geometry;
  25465. }
  25466. /**
  25467. * Creates a box geometry
  25468. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25469. */
  25470. class BoxGeometry extends _PrimitiveGeometry {
  25471. /**
  25472. * Defines the zise of the box (width, height and depth are the same)
  25473. */
  25474. size: number;
  25475. /**
  25476. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25477. */
  25478. side: number;
  25479. /**
  25480. * Creates a box geometry
  25481. * @param id defines the unique ID of the geometry
  25482. * @param scene defines the hosting scene
  25483. * @param size defines the zise of the box (width, height and depth are the same)
  25484. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25485. * @param mesh defines the hosting mesh (can be null)
  25486. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25487. */
  25488. constructor(id: string, scene: Scene,
  25489. /**
  25490. * Defines the zise of the box (width, height and depth are the same)
  25491. */
  25492. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25493. /**
  25494. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25495. */
  25496. side?: number);
  25497. /** @hidden */
  25498. _regenerateVertexData(): VertexData;
  25499. copy(id: string): Geometry;
  25500. serialize(): any;
  25501. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25502. }
  25503. /**
  25504. * Creates a sphere geometry
  25505. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25506. */
  25507. class SphereGeometry extends _PrimitiveGeometry {
  25508. /**
  25509. * Defines the number of segments to use to create the sphere
  25510. */
  25511. segments: number;
  25512. /**
  25513. * Defines the diameter of the sphere
  25514. */
  25515. diameter: number;
  25516. /**
  25517. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25518. */
  25519. side: number;
  25520. /**
  25521. * Create a new sphere geometry
  25522. * @param id defines the unique ID of the geometry
  25523. * @param scene defines the hosting scene
  25524. * @param segments defines the number of segments to use to create the sphere
  25525. * @param diameter defines the diameter of the sphere
  25526. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25527. * @param mesh defines the hosting mesh (can be null)
  25528. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25529. */
  25530. constructor(id: string, scene: Scene,
  25531. /**
  25532. * Defines the number of segments to use to create the sphere
  25533. */
  25534. segments: number,
  25535. /**
  25536. * Defines the diameter of the sphere
  25537. */
  25538. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25539. /**
  25540. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25541. */
  25542. side?: number);
  25543. /** @hidden */
  25544. _regenerateVertexData(): VertexData;
  25545. copy(id: string): Geometry;
  25546. serialize(): any;
  25547. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25548. }
  25549. /**
  25550. * Creates a disc geometry
  25551. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25552. */
  25553. class DiscGeometry extends _PrimitiveGeometry {
  25554. /**
  25555. * Defines the radius of the disc
  25556. */
  25557. radius: number;
  25558. /**
  25559. * Defines the tesselation factor to apply to the disc
  25560. */
  25561. tessellation: number;
  25562. /**
  25563. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25564. */
  25565. side: number;
  25566. /**
  25567. * Creates a new disc geometry
  25568. * @param id defines the unique ID of the geometry
  25569. * @param scene defines the hosting scene
  25570. * @param radius defines the radius of the disc
  25571. * @param tessellation defines the tesselation factor to apply to the disc
  25572. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25573. * @param mesh defines the hosting mesh (can be null)
  25574. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25575. */
  25576. constructor(id: string, scene: Scene,
  25577. /**
  25578. * Defines the radius of the disc
  25579. */
  25580. radius: number,
  25581. /**
  25582. * Defines the tesselation factor to apply to the disc
  25583. */
  25584. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25585. /**
  25586. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25587. */
  25588. side?: number);
  25589. /** @hidden */
  25590. _regenerateVertexData(): VertexData;
  25591. copy(id: string): Geometry;
  25592. }
  25593. /**
  25594. * Creates a new cylinder geometry
  25595. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25596. */
  25597. class CylinderGeometry extends _PrimitiveGeometry {
  25598. /**
  25599. * Defines the height of the cylinder
  25600. */
  25601. height: number;
  25602. /**
  25603. * Defines the diameter of the cylinder's top cap
  25604. */
  25605. diameterTop: number;
  25606. /**
  25607. * Defines the diameter of the cylinder's bottom cap
  25608. */
  25609. diameterBottom: number;
  25610. /**
  25611. * Defines the tessellation factor to apply to the cylinder
  25612. */
  25613. tessellation: number;
  25614. /**
  25615. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25616. */
  25617. subdivisions: number;
  25618. /**
  25619. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25620. */
  25621. side: number;
  25622. /**
  25623. * Creates a new cylinder geometry
  25624. * @param id defines the unique ID of the geometry
  25625. * @param scene defines the hosting scene
  25626. * @param height defines the height of the cylinder
  25627. * @param diameterTop defines the diameter of the cylinder's top cap
  25628. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25629. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25630. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25631. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25632. * @param mesh defines the hosting mesh (can be null)
  25633. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25634. */
  25635. constructor(id: string, scene: Scene,
  25636. /**
  25637. * Defines the height of the cylinder
  25638. */
  25639. height: number,
  25640. /**
  25641. * Defines the diameter of the cylinder's top cap
  25642. */
  25643. diameterTop: number,
  25644. /**
  25645. * Defines the diameter of the cylinder's bottom cap
  25646. */
  25647. diameterBottom: number,
  25648. /**
  25649. * Defines the tessellation factor to apply to the cylinder
  25650. */
  25651. tessellation: number,
  25652. /**
  25653. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25654. */
  25655. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25656. /**
  25657. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25658. */
  25659. side?: number);
  25660. /** @hidden */
  25661. _regenerateVertexData(): VertexData;
  25662. copy(id: string): Geometry;
  25663. serialize(): any;
  25664. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25665. }
  25666. /**
  25667. * Creates a new torus geometry
  25668. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25669. */
  25670. class TorusGeometry extends _PrimitiveGeometry {
  25671. /**
  25672. * Defines the diameter of the torus
  25673. */
  25674. diameter: number;
  25675. /**
  25676. * Defines the thickness of the torus (ie. internal diameter)
  25677. */
  25678. thickness: number;
  25679. /**
  25680. * Defines the tesselation factor to apply to the torus
  25681. */
  25682. tessellation: number;
  25683. /**
  25684. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25685. */
  25686. side: number;
  25687. /**
  25688. * Creates a new torus geometry
  25689. * @param id defines the unique ID of the geometry
  25690. * @param scene defines the hosting scene
  25691. * @param diameter defines the diameter of the torus
  25692. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25693. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25694. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25695. * @param mesh defines the hosting mesh (can be null)
  25696. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25697. */
  25698. constructor(id: string, scene: Scene,
  25699. /**
  25700. * Defines the diameter of the torus
  25701. */
  25702. diameter: number,
  25703. /**
  25704. * Defines the thickness of the torus (ie. internal diameter)
  25705. */
  25706. thickness: number,
  25707. /**
  25708. * Defines the tesselation factor to apply to the torus
  25709. */
  25710. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25711. /**
  25712. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25713. */
  25714. side?: number);
  25715. /** @hidden */
  25716. _regenerateVertexData(): VertexData;
  25717. copy(id: string): Geometry;
  25718. serialize(): any;
  25719. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25720. }
  25721. /**
  25722. * Creates a new ground geometry
  25723. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25724. */
  25725. class GroundGeometry extends _PrimitiveGeometry {
  25726. /**
  25727. * Defines the width of the ground
  25728. */
  25729. width: number;
  25730. /**
  25731. * Defines the height of the ground
  25732. */
  25733. height: number;
  25734. /**
  25735. * Defines the subdivisions to apply to the ground
  25736. */
  25737. subdivisions: number;
  25738. /**
  25739. * Creates a new ground geometry
  25740. * @param id defines the unique ID of the geometry
  25741. * @param scene defines the hosting scene
  25742. * @param width defines the width of the ground
  25743. * @param height defines the height of the ground
  25744. * @param subdivisions defines the subdivisions to apply to the ground
  25745. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25746. * @param mesh defines the hosting mesh (can be null)
  25747. */
  25748. constructor(id: string, scene: Scene,
  25749. /**
  25750. * Defines the width of the ground
  25751. */
  25752. width: number,
  25753. /**
  25754. * Defines the height of the ground
  25755. */
  25756. height: number,
  25757. /**
  25758. * Defines the subdivisions to apply to the ground
  25759. */
  25760. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25761. /** @hidden */
  25762. _regenerateVertexData(): VertexData;
  25763. copy(id: string): Geometry;
  25764. serialize(): any;
  25765. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25766. }
  25767. /**
  25768. * Creates a tiled ground geometry
  25769. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25770. */
  25771. class TiledGroundGeometry extends _PrimitiveGeometry {
  25772. /**
  25773. * Defines the minimum value on X axis
  25774. */
  25775. xmin: number;
  25776. /**
  25777. * Defines the minimum value on Z axis
  25778. */
  25779. zmin: number;
  25780. /**
  25781. * Defines the maximum value on X axis
  25782. */
  25783. xmax: number;
  25784. /**
  25785. * Defines the maximum value on Z axis
  25786. */
  25787. zmax: number;
  25788. /**
  25789. * Defines the subdivisions to apply to the ground
  25790. */
  25791. subdivisions: {
  25792. w: number;
  25793. h: number;
  25794. };
  25795. /**
  25796. * Defines the precision to use when computing the tiles
  25797. */
  25798. precision: {
  25799. w: number;
  25800. h: number;
  25801. };
  25802. /**
  25803. * Creates a tiled ground geometry
  25804. * @param id defines the unique ID of the geometry
  25805. * @param scene defines the hosting scene
  25806. * @param xmin defines the minimum value on X axis
  25807. * @param zmin defines the minimum value on Z axis
  25808. * @param xmax defines the maximum value on X axis
  25809. * @param zmax defines the maximum value on Z axis
  25810. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25811. * @param precision defines the precision to use when computing the tiles
  25812. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25813. * @param mesh defines the hosting mesh (can be null)
  25814. */
  25815. constructor(id: string, scene: Scene,
  25816. /**
  25817. * Defines the minimum value on X axis
  25818. */
  25819. xmin: number,
  25820. /**
  25821. * Defines the minimum value on Z axis
  25822. */
  25823. zmin: number,
  25824. /**
  25825. * Defines the maximum value on X axis
  25826. */
  25827. xmax: number,
  25828. /**
  25829. * Defines the maximum value on Z axis
  25830. */
  25831. zmax: number,
  25832. /**
  25833. * Defines the subdivisions to apply to the ground
  25834. */
  25835. subdivisions: {
  25836. w: number;
  25837. h: number;
  25838. },
  25839. /**
  25840. * Defines the precision to use when computing the tiles
  25841. */
  25842. precision: {
  25843. w: number;
  25844. h: number;
  25845. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25846. /** @hidden */
  25847. _regenerateVertexData(): VertexData;
  25848. copy(id: string): Geometry;
  25849. }
  25850. /**
  25851. * Creates a plane geometry
  25852. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25853. */
  25854. class PlaneGeometry extends _PrimitiveGeometry {
  25855. /**
  25856. * Defines the size of the plane (width === height)
  25857. */
  25858. size: number;
  25859. /**
  25860. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25861. */
  25862. side: number;
  25863. /**
  25864. * Creates a plane geometry
  25865. * @param id defines the unique ID of the geometry
  25866. * @param scene defines the hosting scene
  25867. * @param size defines the size of the plane (width === height)
  25868. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25869. * @param mesh defines the hosting mesh (can be null)
  25870. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25871. */
  25872. constructor(id: string, scene: Scene,
  25873. /**
  25874. * Defines the size of the plane (width === height)
  25875. */
  25876. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25877. /**
  25878. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25879. */
  25880. side?: number);
  25881. /** @hidden */
  25882. _regenerateVertexData(): VertexData;
  25883. copy(id: string): Geometry;
  25884. serialize(): any;
  25885. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25886. }
  25887. /**
  25888. * Creates a torus knot geometry
  25889. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25890. */
  25891. class TorusKnotGeometry extends _PrimitiveGeometry {
  25892. /**
  25893. * Defines the radius of the torus knot
  25894. */
  25895. radius: number;
  25896. /**
  25897. * Defines the thickness of the torus knot tube
  25898. */
  25899. tube: number;
  25900. /**
  25901. * Defines the number of radial segments
  25902. */
  25903. radialSegments: number;
  25904. /**
  25905. * Defines the number of tubular segments
  25906. */
  25907. tubularSegments: number;
  25908. /**
  25909. * Defines the first number of windings
  25910. */
  25911. p: number;
  25912. /**
  25913. * Defines the second number of windings
  25914. */
  25915. q: number;
  25916. /**
  25917. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25918. */
  25919. side: number;
  25920. /**
  25921. * Creates a torus knot geometry
  25922. * @param id defines the unique ID of the geometry
  25923. * @param scene defines the hosting scene
  25924. * @param radius defines the radius of the torus knot
  25925. * @param tube defines the thickness of the torus knot tube
  25926. * @param radialSegments defines the number of radial segments
  25927. * @param tubularSegments defines the number of tubular segments
  25928. * @param p defines the first number of windings
  25929. * @param q defines the second number of windings
  25930. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25931. * @param mesh defines the hosting mesh (can be null)
  25932. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25933. */
  25934. constructor(id: string, scene: Scene,
  25935. /**
  25936. * Defines the radius of the torus knot
  25937. */
  25938. radius: number,
  25939. /**
  25940. * Defines the thickness of the torus knot tube
  25941. */
  25942. tube: number,
  25943. /**
  25944. * Defines the number of radial segments
  25945. */
  25946. radialSegments: number,
  25947. /**
  25948. * Defines the number of tubular segments
  25949. */
  25950. tubularSegments: number,
  25951. /**
  25952. * Defines the first number of windings
  25953. */
  25954. p: number,
  25955. /**
  25956. * Defines the second number of windings
  25957. */
  25958. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25959. /**
  25960. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25961. */
  25962. side?: number);
  25963. /** @hidden */
  25964. _regenerateVertexData(): VertexData;
  25965. copy(id: string): Geometry;
  25966. serialize(): any;
  25967. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25968. }
  25969. }
  25970. declare module BABYLON {
  25971. /**
  25972. * Mesh representing the gorund
  25973. */
  25974. class GroundMesh extends Mesh {
  25975. /** If octree should be generated */
  25976. generateOctree: boolean;
  25977. private _heightQuads;
  25978. /** @hidden */
  25979. _subdivisionsX: number;
  25980. /** @hidden */
  25981. _subdivisionsY: number;
  25982. /** @hidden */
  25983. _width: number;
  25984. /** @hidden */
  25985. _height: number;
  25986. /** @hidden */
  25987. _minX: number;
  25988. /** @hidden */
  25989. _maxX: number;
  25990. /** @hidden */
  25991. _minZ: number;
  25992. /** @hidden */
  25993. _maxZ: number;
  25994. constructor(name: string, scene: Scene);
  25995. /**
  25996. * "GroundMesh"
  25997. * @returns "GroundMesh"
  25998. */
  25999. getClassName(): string;
  26000. /**
  26001. * The minimum of x and y subdivisions
  26002. */
  26003. readonly subdivisions: number;
  26004. /**
  26005. * X subdivisions
  26006. */
  26007. readonly subdivisionsX: number;
  26008. /**
  26009. * Y subdivisions
  26010. */
  26011. readonly subdivisionsY: number;
  26012. /**
  26013. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26014. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26015. * @param chunksCount the number of subdivisions for x and y
  26016. * @param octreeBlocksSize (Default: 32)
  26017. */
  26018. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26019. /**
  26020. * Returns a height (y) value in the Worl system :
  26021. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26022. * @param x x coordinate
  26023. * @param z z coordinate
  26024. * @returns the ground y position if (x, z) are outside the ground surface.
  26025. */
  26026. getHeightAtCoordinates(x: number, z: number): number;
  26027. /**
  26028. * Returns a normalized vector (Vector3) orthogonal to the ground
  26029. * at the ground coordinates (x, z) expressed in the World system.
  26030. * @param x x coordinate
  26031. * @param z z coordinate
  26032. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26033. */
  26034. getNormalAtCoordinates(x: number, z: number): Vector3;
  26035. /**
  26036. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26037. * at the ground coordinates (x, z) expressed in the World system.
  26038. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26039. * @param x x coordinate
  26040. * @param z z coordinate
  26041. * @param ref vector to store the result
  26042. * @returns the GroundMesh.
  26043. */
  26044. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26045. /**
  26046. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26047. * if the ground has been updated.
  26048. * This can be used in the render loop.
  26049. * @returns the GroundMesh.
  26050. */
  26051. updateCoordinateHeights(): GroundMesh;
  26052. private _getFacetAt;
  26053. private _initHeightQuads;
  26054. private _computeHeightQuads;
  26055. /**
  26056. * Serializes this ground mesh
  26057. * @param serializationObject object to write serialization to
  26058. */
  26059. serialize(serializationObject: any): void;
  26060. /**
  26061. * Parses a serialized ground mesh
  26062. * @param parsedMesh the serialized mesh
  26063. * @param scene the scene to create the ground mesh in
  26064. * @returns the created ground mesh
  26065. */
  26066. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26067. }
  26068. }
  26069. declare module BABYLON {
  26070. /**
  26071. * Creates an instance based on a source mesh.
  26072. */
  26073. class InstancedMesh extends AbstractMesh {
  26074. private _sourceMesh;
  26075. private _currentLOD;
  26076. constructor(name: string, source: Mesh);
  26077. /**
  26078. * Returns the string "InstancedMesh".
  26079. */
  26080. getClassName(): string;
  26081. /**
  26082. * If the source mesh receives shadows
  26083. */
  26084. readonly receiveShadows: boolean;
  26085. /**
  26086. * The material of the source mesh
  26087. */
  26088. readonly material: Nullable<Material>;
  26089. /**
  26090. * Visibility of the source mesh
  26091. */
  26092. readonly visibility: number;
  26093. /**
  26094. * Skeleton of the source mesh
  26095. */
  26096. readonly skeleton: Nullable<Skeleton>;
  26097. /**
  26098. * Rendering ground id of the source mesh
  26099. */
  26100. renderingGroupId: number;
  26101. /**
  26102. * Returns the total number of vertices (integer).
  26103. */
  26104. getTotalVertices(): number;
  26105. /**
  26106. * The source mesh of the instance
  26107. */
  26108. readonly sourceMesh: Mesh;
  26109. /**
  26110. * Is this node ready to be used/rendered
  26111. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26112. * @return {boolean} is it ready
  26113. */
  26114. isReady(completeCheck?: boolean): boolean;
  26115. /**
  26116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26117. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26118. * @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.
  26119. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26120. */
  26121. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26122. /**
  26123. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26124. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26125. * The `data` are either a numeric array either a Float32Array.
  26126. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26127. * 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).
  26128. * Note that a new underlying VertexBuffer object is created each call.
  26129. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26130. *
  26131. * Possible `kind` values :
  26132. * - BABYLON.VertexBuffer.PositionKind
  26133. * - BABYLON.VertexBuffer.UVKind
  26134. * - BABYLON.VertexBuffer.UV2Kind
  26135. * - BABYLON.VertexBuffer.UV3Kind
  26136. * - BABYLON.VertexBuffer.UV4Kind
  26137. * - BABYLON.VertexBuffer.UV5Kind
  26138. * - BABYLON.VertexBuffer.UV6Kind
  26139. * - BABYLON.VertexBuffer.ColorKind
  26140. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26141. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26142. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26143. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26144. *
  26145. * Returns the Mesh.
  26146. */
  26147. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26148. /**
  26149. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26150. * If the mesh has no geometry, it is simply returned as it is.
  26151. * The `data` are either a numeric array either a Float32Array.
  26152. * No new underlying VertexBuffer object is created.
  26153. * 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.
  26154. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26155. *
  26156. * Possible `kind` values :
  26157. * - BABYLON.VertexBuffer.PositionKind
  26158. * - BABYLON.VertexBuffer.UVKind
  26159. * - BABYLON.VertexBuffer.UV2Kind
  26160. * - BABYLON.VertexBuffer.UV3Kind
  26161. * - BABYLON.VertexBuffer.UV4Kind
  26162. * - BABYLON.VertexBuffer.UV5Kind
  26163. * - BABYLON.VertexBuffer.UV6Kind
  26164. * - BABYLON.VertexBuffer.ColorKind
  26165. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26166. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26167. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26168. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26169. *
  26170. * Returns the Mesh.
  26171. */
  26172. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26173. /**
  26174. * Sets the mesh indices.
  26175. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26176. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26177. * This method creates a new index buffer each call.
  26178. * Returns the Mesh.
  26179. */
  26180. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26181. /**
  26182. * Boolean : True if the mesh owns the requested kind of data.
  26183. */
  26184. isVerticesDataPresent(kind: string): boolean;
  26185. /**
  26186. * Returns an array of indices (IndicesArray).
  26187. */
  26188. getIndices(): Nullable<IndicesArray>;
  26189. readonly _positions: Nullable<Vector3[]>;
  26190. /**
  26191. * Sets a new updated BoundingInfo to the mesh.
  26192. * @returns the mesh.
  26193. */
  26194. refreshBoundingInfo(): InstancedMesh;
  26195. /** @hidden */
  26196. _preActivate(): InstancedMesh;
  26197. /** @hidden */
  26198. _activate(renderId: number): InstancedMesh;
  26199. /**
  26200. * Returns the current associated LOD AbstractMesh.
  26201. */
  26202. getLOD(camera: Camera): AbstractMesh;
  26203. /** @hidden */
  26204. _syncSubMeshes(): InstancedMesh;
  26205. /** @hidden */
  26206. _generatePointsArray(): boolean;
  26207. /**
  26208. * Creates a new InstancedMesh from the current mesh.
  26209. * - name (string) : the cloned mesh name
  26210. * - newParent (optional Node) : the optional Node to parent the clone to.
  26211. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26212. *
  26213. * Returns the clone.
  26214. */
  26215. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26216. /**
  26217. * Disposes the InstancedMesh.
  26218. * Returns nothing.
  26219. */
  26220. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26221. }
  26222. }
  26223. declare module BABYLON {
  26224. /**
  26225. * Line mesh
  26226. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26227. */
  26228. class LinesMesh extends Mesh {
  26229. /**
  26230. * If vertex color should be applied to the mesh
  26231. */
  26232. useVertexColor?: boolean | undefined;
  26233. /**
  26234. * If vertex alpha should be applied to the mesh
  26235. */
  26236. useVertexAlpha?: boolean | undefined;
  26237. /**
  26238. * Color of the line (Default: White)
  26239. */
  26240. color: Color3;
  26241. /**
  26242. * Alpha of the line (Default: 1)
  26243. */
  26244. alpha: number;
  26245. /**
  26246. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26247. * This margin is expressed in world space coordinates, so its value may vary.
  26248. * Default value is 0.1
  26249. * @returns the intersection Threshold value.
  26250. */
  26251. /**
  26252. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26253. * This margin is expressed in world space coordinates, so its value may vary.
  26254. */
  26255. intersectionThreshold: number;
  26256. private _intersectionThreshold;
  26257. private _colorShader;
  26258. /**
  26259. * Creates a new LinesMesh
  26260. * @param name defines the name
  26261. * @param scene defines the hosting scene
  26262. * @param parent defines the parent mesh if any
  26263. * @param source defines the optional source LinesMesh used to clone data from
  26264. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26265. * When false, achieved by calling a clone(), also passing False.
  26266. * This will make creation of children, recursive.
  26267. * @param useVertexColor defines if this LinesMesh supports vertex color
  26268. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26269. */
  26270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26271. /**
  26272. * If vertex color should be applied to the mesh
  26273. */
  26274. useVertexColor?: boolean | undefined,
  26275. /**
  26276. * If vertex alpha should be applied to the mesh
  26277. */
  26278. useVertexAlpha?: boolean | undefined);
  26279. /**
  26280. * Returns the string "LineMesh"
  26281. */
  26282. getClassName(): string;
  26283. /**
  26284. * @hidden
  26285. */
  26286. /**
  26287. * @hidden
  26288. */
  26289. material: Material;
  26290. /**
  26291. * @hidden
  26292. */
  26293. readonly checkCollisions: boolean;
  26294. /** @hidden */
  26295. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26296. /** @hidden */
  26297. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26298. /**
  26299. * Disposes of the line mesh
  26300. * @param doNotRecurse If children should be disposed
  26301. */
  26302. dispose(doNotRecurse?: boolean): void;
  26303. /**
  26304. * Returns a new LineMesh object cloned from the current one.
  26305. */
  26306. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26307. }
  26308. }
  26309. declare module BABYLON {
  26310. /**
  26311. * @hidden
  26312. **/
  26313. class _CreationDataStorage {
  26314. closePath?: boolean;
  26315. closeArray?: boolean;
  26316. idx: number[];
  26317. dashSize: number;
  26318. gapSize: number;
  26319. path3D: Path3D;
  26320. pathArray: Vector3[][];
  26321. arc: number;
  26322. radius: number;
  26323. cap: number;
  26324. tessellation: number;
  26325. }
  26326. /**
  26327. * @hidden
  26328. **/
  26329. class _InstanceDataStorage {
  26330. visibleInstances: any;
  26331. renderIdForInstances: number[];
  26332. batchCache: _InstancesBatch;
  26333. instancesBufferSize: number;
  26334. instancesBuffer: Nullable<Buffer>;
  26335. instancesData: Float32Array;
  26336. overridenInstanceCount: number;
  26337. }
  26338. /**
  26339. * @hidden
  26340. **/
  26341. class _InstancesBatch {
  26342. mustReturn: boolean;
  26343. visibleInstances: Nullable<InstancedMesh[]>[];
  26344. renderSelf: boolean[];
  26345. }
  26346. /**
  26347. * Class used to represent renderable models
  26348. */
  26349. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26350. /**
  26351. * Mesh side orientation : usually the external or front surface
  26352. */
  26353. static readonly FRONTSIDE: number;
  26354. /**
  26355. * Mesh side orientation : usually the internal or back surface
  26356. */
  26357. static readonly BACKSIDE: number;
  26358. /**
  26359. * Mesh side orientation : both internal and external or front and back surfaces
  26360. */
  26361. static readonly DOUBLESIDE: number;
  26362. /**
  26363. * Mesh side orientation : by default, `FRONTSIDE`
  26364. */
  26365. static readonly DEFAULTSIDE: number;
  26366. /**
  26367. * Mesh cap setting : no cap
  26368. */
  26369. static readonly NO_CAP: number;
  26370. /**
  26371. * Mesh cap setting : one cap at the beginning of the mesh
  26372. */
  26373. static readonly CAP_START: number;
  26374. /**
  26375. * Mesh cap setting : one cap at the end of the mesh
  26376. */
  26377. static readonly CAP_END: number;
  26378. /**
  26379. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26380. */
  26381. static readonly CAP_ALL: number;
  26382. private _onBeforeRenderObservable;
  26383. private _onAfterRenderObservable;
  26384. private _onBeforeDrawObservable;
  26385. /**
  26386. * An event triggered before rendering the mesh
  26387. */
  26388. readonly onBeforeRenderObservable: Observable<Mesh>;
  26389. /**
  26390. * An event triggered after rendering the mesh
  26391. */
  26392. readonly onAfterRenderObservable: Observable<Mesh>;
  26393. /**
  26394. * An event triggered before drawing the mesh
  26395. */
  26396. readonly onBeforeDrawObservable: Observable<Mesh>;
  26397. private _onBeforeDrawObserver;
  26398. /**
  26399. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26400. */
  26401. onBeforeDraw: () => void;
  26402. /**
  26403. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26404. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26405. */
  26406. delayLoadState: number;
  26407. /**
  26408. * Gets the list of instances created from this mesh
  26409. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26410. */
  26411. instances: InstancedMesh[];
  26412. /**
  26413. * Gets the file containing delay loading data for this mesh
  26414. */
  26415. delayLoadingFile: string;
  26416. /** @hidden */
  26417. _binaryInfo: any;
  26418. private _LODLevels;
  26419. /**
  26420. * User defined function used to change how LOD level selection is done
  26421. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26422. */
  26423. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26424. private _morphTargetManager;
  26425. /**
  26426. * Gets or sets the morph target manager
  26427. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26428. */
  26429. morphTargetManager: Nullable<MorphTargetManager>;
  26430. /** @hidden */
  26431. _creationDataStorage: Nullable<_CreationDataStorage>;
  26432. /** @hidden */
  26433. _geometry: Nullable<Geometry>;
  26434. /** @hidden */
  26435. _delayInfo: Array<string>;
  26436. /** @hidden */
  26437. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26438. /** @hidden */
  26439. _instanceDataStorage: _InstanceDataStorage;
  26440. private _effectiveMaterial;
  26441. /** @hidden */
  26442. _shouldGenerateFlatShading: boolean;
  26443. private _preActivateId;
  26444. /** @hidden */
  26445. _originalBuilderSideOrientation: number;
  26446. /**
  26447. * Use this property to change the original side orientation defined at construction time
  26448. */
  26449. overrideMaterialSideOrientation: Nullable<number>;
  26450. private _areNormalsFrozen;
  26451. private _sourcePositions;
  26452. private _sourceNormals;
  26453. private _source;
  26454. /**
  26455. * Gets the source mesh (the one used to clone this one from)
  26456. */
  26457. readonly source: Nullable<Mesh>;
  26458. /**
  26459. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26460. */
  26461. isUnIndexed: boolean;
  26462. /**
  26463. * @constructor
  26464. * @param name The value used by scene.getMeshByName() to do a lookup.
  26465. * @param scene The scene to add this mesh to.
  26466. * @param parent The parent of this mesh, if it has one
  26467. * @param source An optional Mesh from which geometry is shared, cloned.
  26468. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26469. * When false, achieved by calling a clone(), also passing False.
  26470. * This will make creation of children, recursive.
  26471. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26472. */
  26473. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26474. /**
  26475. * Gets the class name
  26476. * @returns the string "Mesh".
  26477. */
  26478. getClassName(): string;
  26479. /**
  26480. * Returns a description of this mesh
  26481. * @param fullDetails define if full details about this mesh must be used
  26482. * @returns a descriptive string representing this mesh
  26483. */
  26484. toString(fullDetails?: boolean): string;
  26485. /** @hidden */
  26486. _unBindEffect(): void;
  26487. /**
  26488. * Gets a boolean indicating if this mesh has LOD
  26489. */
  26490. readonly hasLODLevels: boolean;
  26491. /**
  26492. * Gets the list of MeshLODLevel associated with the current mesh
  26493. * @returns an array of MeshLODLevel
  26494. */
  26495. getLODLevels(): MeshLODLevel[];
  26496. private _sortLODLevels;
  26497. /**
  26498. * Add a mesh as LOD level triggered at the given distance.
  26499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26500. * @param distance The distance from the center of the object to show this level
  26501. * @param mesh The mesh to be added as LOD level (can be null)
  26502. * @return This mesh (for chaining)
  26503. */
  26504. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26505. /**
  26506. * Returns the LOD level mesh at the passed distance or null if not found.
  26507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26508. * @param distance The distance from the center of the object to show this level
  26509. * @returns a Mesh or `null`
  26510. */
  26511. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26512. /**
  26513. * Remove a mesh from the LOD array
  26514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26515. * @param mesh defines the mesh to be removed
  26516. * @return This mesh (for chaining)
  26517. */
  26518. removeLODLevel(mesh: Mesh): Mesh;
  26519. /**
  26520. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26522. * @param camera defines the camera to use to compute distance
  26523. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26524. * @return This mesh (for chaining)
  26525. */
  26526. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26527. /**
  26528. * Gets the mesh internal Geometry object
  26529. */
  26530. readonly geometry: Nullable<Geometry>;
  26531. /**
  26532. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26533. * @returns the total number of vertices
  26534. */
  26535. getTotalVertices(): number;
  26536. /**
  26537. * Returns the content of an associated vertex buffer
  26538. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26539. * - BABYLON.VertexBuffer.PositionKind
  26540. * - BABYLON.VertexBuffer.UVKind
  26541. * - BABYLON.VertexBuffer.UV2Kind
  26542. * - BABYLON.VertexBuffer.UV3Kind
  26543. * - BABYLON.VertexBuffer.UV4Kind
  26544. * - BABYLON.VertexBuffer.UV5Kind
  26545. * - BABYLON.VertexBuffer.UV6Kind
  26546. * - BABYLON.VertexBuffer.ColorKind
  26547. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26548. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26549. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26550. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26551. * @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
  26552. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26553. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26554. */
  26555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26556. /**
  26557. * Returns the mesh VertexBuffer object from the requested `kind`
  26558. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26559. * - BABYLON.VertexBuffer.PositionKind
  26560. * - BABYLON.VertexBuffer.UVKind
  26561. * - BABYLON.VertexBuffer.UV2Kind
  26562. * - BABYLON.VertexBuffer.UV3Kind
  26563. * - BABYLON.VertexBuffer.UV4Kind
  26564. * - BABYLON.VertexBuffer.UV5Kind
  26565. * - BABYLON.VertexBuffer.UV6Kind
  26566. * - BABYLON.VertexBuffer.ColorKind
  26567. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26568. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26569. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26570. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26571. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26572. */
  26573. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26574. /**
  26575. * Tests if a specific vertex buffer is associated with this mesh
  26576. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26577. * - BABYLON.VertexBuffer.PositionKind
  26578. * - BABYLON.VertexBuffer.UVKind
  26579. * - BABYLON.VertexBuffer.UV2Kind
  26580. * - BABYLON.VertexBuffer.UV3Kind
  26581. * - BABYLON.VertexBuffer.UV4Kind
  26582. * - BABYLON.VertexBuffer.UV5Kind
  26583. * - BABYLON.VertexBuffer.UV6Kind
  26584. * - BABYLON.VertexBuffer.ColorKind
  26585. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26586. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26587. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26588. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26589. * @returns a boolean
  26590. */
  26591. isVerticesDataPresent(kind: string): boolean;
  26592. /**
  26593. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26594. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26595. * - BABYLON.VertexBuffer.PositionKind
  26596. * - BABYLON.VertexBuffer.UVKind
  26597. * - BABYLON.VertexBuffer.UV2Kind
  26598. * - BABYLON.VertexBuffer.UV3Kind
  26599. * - BABYLON.VertexBuffer.UV4Kind
  26600. * - BABYLON.VertexBuffer.UV5Kind
  26601. * - BABYLON.VertexBuffer.UV6Kind
  26602. * - BABYLON.VertexBuffer.ColorKind
  26603. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26604. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26605. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26606. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26607. * @returns a boolean
  26608. */
  26609. isVertexBufferUpdatable(kind: string): boolean;
  26610. /**
  26611. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26612. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26613. * - BABYLON.VertexBuffer.PositionKind
  26614. * - BABYLON.VertexBuffer.UVKind
  26615. * - BABYLON.VertexBuffer.UV2Kind
  26616. * - BABYLON.VertexBuffer.UV3Kind
  26617. * - BABYLON.VertexBuffer.UV4Kind
  26618. * - BABYLON.VertexBuffer.UV5Kind
  26619. * - BABYLON.VertexBuffer.UV6Kind
  26620. * - BABYLON.VertexBuffer.ColorKind
  26621. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26622. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26623. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26624. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26625. * @returns an array of strings
  26626. */
  26627. getVerticesDataKinds(): string[];
  26628. /**
  26629. * Returns a positive integer : the total number of indices in this mesh geometry.
  26630. * @returns the numner of indices or zero if the mesh has no geometry.
  26631. */
  26632. getTotalIndices(): number;
  26633. /**
  26634. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26635. * @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.
  26636. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26637. * @returns the indices array or an empty array if the mesh has no geometry
  26638. */
  26639. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26640. readonly isBlocked: boolean;
  26641. /**
  26642. * Determine if the current mesh is ready to be rendered
  26643. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26644. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26645. * @returns true if all associated assets are ready (material, textures, shaders)
  26646. */
  26647. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26648. /**
  26649. * 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.
  26650. */
  26651. readonly areNormalsFrozen: boolean;
  26652. /**
  26653. * 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.
  26654. * @returns the current mesh
  26655. */
  26656. freezeNormals(): Mesh;
  26657. /**
  26658. * 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
  26659. * @returns the current mesh
  26660. */
  26661. unfreezeNormals(): Mesh;
  26662. /**
  26663. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26664. */
  26665. overridenInstanceCount: number;
  26666. /** @hidden */
  26667. _preActivate(): Mesh;
  26668. /** @hidden */
  26669. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26670. /** @hidden */
  26671. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26672. /**
  26673. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26674. * This means the mesh underlying bounding box and sphere are recomputed.
  26675. * @returns the current mesh
  26676. */
  26677. refreshBoundingInfo(): Mesh;
  26678. /** @hidden */
  26679. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26680. private _getPositionData;
  26681. /** @hidden */
  26682. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26683. /**
  26684. * This function will subdivide the mesh into multiple submeshes
  26685. * @param count defines the expected number of submeshes
  26686. */
  26687. subdivide(count: number): void;
  26688. /**
  26689. * Copy a FloatArray into a specific associated vertex buffer
  26690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26691. * - BABYLON.VertexBuffer.PositionKind
  26692. * - BABYLON.VertexBuffer.UVKind
  26693. * - BABYLON.VertexBuffer.UV2Kind
  26694. * - BABYLON.VertexBuffer.UV3Kind
  26695. * - BABYLON.VertexBuffer.UV4Kind
  26696. * - BABYLON.VertexBuffer.UV5Kind
  26697. * - BABYLON.VertexBuffer.UV6Kind
  26698. * - BABYLON.VertexBuffer.ColorKind
  26699. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26700. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26701. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26702. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26703. * @param data defines the data source
  26704. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26705. * @param stride defines the data stride size (can be null)
  26706. * @returns the current mesh
  26707. */
  26708. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26709. /**
  26710. * Flags an associated vertex buffer as updatable
  26711. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26712. * - BABYLON.VertexBuffer.PositionKind
  26713. * - BABYLON.VertexBuffer.UVKind
  26714. * - BABYLON.VertexBuffer.UV2Kind
  26715. * - BABYLON.VertexBuffer.UV3Kind
  26716. * - BABYLON.VertexBuffer.UV4Kind
  26717. * - BABYLON.VertexBuffer.UV5Kind
  26718. * - BABYLON.VertexBuffer.UV6Kind
  26719. * - BABYLON.VertexBuffer.ColorKind
  26720. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26721. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26722. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26723. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26725. */
  26726. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26727. /**
  26728. * Sets the mesh global Vertex Buffer
  26729. * @param buffer defines the buffer to use
  26730. * @returns the current mesh
  26731. */
  26732. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26733. /**
  26734. * Update a specific associated vertex buffer
  26735. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26736. * - BABYLON.VertexBuffer.PositionKind
  26737. * - BABYLON.VertexBuffer.UVKind
  26738. * - BABYLON.VertexBuffer.UV2Kind
  26739. * - BABYLON.VertexBuffer.UV3Kind
  26740. * - BABYLON.VertexBuffer.UV4Kind
  26741. * - BABYLON.VertexBuffer.UV5Kind
  26742. * - BABYLON.VertexBuffer.UV6Kind
  26743. * - BABYLON.VertexBuffer.ColorKind
  26744. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26745. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26746. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26747. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26748. * @param data defines the data source
  26749. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26750. * @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)
  26751. * @returns the current mesh
  26752. */
  26753. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26754. /**
  26755. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26756. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26757. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26758. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26759. * @returns the current mesh
  26760. */
  26761. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26762. /**
  26763. * Creates a un-shared specific occurence of the geometry for the mesh.
  26764. * @returns the current mesh
  26765. */
  26766. makeGeometryUnique(): Mesh;
  26767. /**
  26768. * Set the index buffer of this mesh
  26769. * @param indices defines the source data
  26770. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26771. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26772. * @returns the current mesh
  26773. */
  26774. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26775. /**
  26776. * Update the current index buffer
  26777. * @param indices defines the source data
  26778. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26779. * @returns the current mesh
  26780. */
  26781. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26782. /**
  26783. * Invert the geometry to move from a right handed system to a left handed one.
  26784. * @returns the current mesh
  26785. */
  26786. toLeftHanded(): Mesh;
  26787. /** @hidden */
  26788. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26789. /** @hidden */
  26790. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26791. /**
  26792. * Registers for this mesh a javascript function called just before the rendering process
  26793. * @param func defines the function to call before rendering this mesh
  26794. * @returns the current mesh
  26795. */
  26796. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26797. /**
  26798. * Disposes a previously registered javascript function called before the rendering
  26799. * @param func defines the function to remove
  26800. * @returns the current mesh
  26801. */
  26802. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26803. /**
  26804. * Registers for this mesh a javascript function called just after the rendering is complete
  26805. * @param func defines the function to call after rendering this mesh
  26806. * @returns the current mesh
  26807. */
  26808. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26809. /**
  26810. * Disposes a previously registered javascript function called after the rendering.
  26811. * @param func defines the function to remove
  26812. * @returns the current mesh
  26813. */
  26814. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26815. /** @hidden */
  26816. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26817. /** @hidden */
  26818. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26819. /** @hidden */
  26820. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26821. /**
  26822. * 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
  26823. * @param subMesh defines the subMesh to render
  26824. * @param enableAlphaMode defines if alpha mode can be changed
  26825. * @returns the current mesh
  26826. */
  26827. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26828. private _onBeforeDraw;
  26829. /**
  26830. * Renormalize the mesh and patch it up if there are no weights
  26831. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26832. * However in the case of zero weights then we set just a single influence to 1.
  26833. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26834. */
  26835. cleanMatrixWeights(): void;
  26836. private normalizeSkinFourWeights;
  26837. private normalizeSkinWeightsAndExtra;
  26838. /**
  26839. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26840. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26841. * the user know there was an issue with importing the mesh
  26842. * @returns a validation object with skinned, valid and report string
  26843. */
  26844. validateSkinning(): {
  26845. skinned: boolean;
  26846. valid: boolean;
  26847. report: string;
  26848. };
  26849. /** @hidden */
  26850. _checkDelayState(): Mesh;
  26851. private _queueLoad;
  26852. /**
  26853. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26854. * A mesh is in the frustum if its bounding box intersects the frustum
  26855. * @param frustumPlanes defines the frustum to test
  26856. * @returns true if the mesh is in the frustum planes
  26857. */
  26858. isInFrustum(frustumPlanes: Plane[]): boolean;
  26859. /**
  26860. * Sets the mesh material by the material or multiMaterial `id` property
  26861. * @param id is a string identifying the material or the multiMaterial
  26862. * @returns the current mesh
  26863. */
  26864. setMaterialByID(id: string): Mesh;
  26865. /**
  26866. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26867. * @returns an array of IAnimatable
  26868. */
  26869. getAnimatables(): IAnimatable[];
  26870. /**
  26871. * Modifies the mesh geometry according to the passed transformation matrix.
  26872. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26873. * The mesh normals are modified using the same transformation.
  26874. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26875. * @param transform defines the transform matrix to use
  26876. * @see http://doc.babylonjs.com/resources/baking_transformations
  26877. * @returns the current mesh
  26878. */
  26879. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26880. /**
  26881. * Modifies the mesh geometry according to its own current World Matrix.
  26882. * The mesh World Matrix is then reset.
  26883. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26884. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26885. * @see http://doc.babylonjs.com/resources/baking_transformations
  26886. * @returns the current mesh
  26887. */
  26888. bakeCurrentTransformIntoVertices(): Mesh;
  26889. /** @hidden */
  26890. readonly _positions: Nullable<Vector3[]>;
  26891. /** @hidden */
  26892. _resetPointsArrayCache(): Mesh;
  26893. /** @hidden */
  26894. _generatePointsArray(): boolean;
  26895. /**
  26896. * Returns a new Mesh object generated from the current mesh properties.
  26897. * This method must not get confused with createInstance()
  26898. * @param name is a string, the name given to the new mesh
  26899. * @param newParent can be any Node object (default `null`)
  26900. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26901. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26902. * @returns a new mesh
  26903. */
  26904. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26905. /**
  26906. * Releases resources associated with this mesh.
  26907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26909. */
  26910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26911. /**
  26912. * Modifies the mesh geometry according to a displacement map.
  26913. * 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.
  26914. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26915. * @param url is a string, the URL from the image file is to be downloaded.
  26916. * @param minHeight is the lower limit of the displacement.
  26917. * @param maxHeight is the upper limit of the displacement.
  26918. * @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.
  26919. * @param uvOffset is an optional vector2 used to offset UV.
  26920. * @param uvScale is an optional vector2 used to scale UV.
  26921. * @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.
  26922. * @returns the Mesh.
  26923. */
  26924. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26925. /**
  26926. * Modifies the mesh geometry according to a displacementMap buffer.
  26927. * 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.
  26928. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26929. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26930. * @param heightMapWidth is the width of the buffer image.
  26931. * @param heightMapHeight is the height of the buffer image.
  26932. * @param minHeight is the lower limit of the displacement.
  26933. * @param maxHeight is the upper limit of the displacement.
  26934. * @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.
  26935. * @param uvOffset is an optional vector2 used to offset UV.
  26936. * @param uvScale is an optional vector2 used to scale UV.
  26937. * @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.
  26938. * @returns the Mesh.
  26939. */
  26940. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26941. /**
  26942. * Modify the mesh to get a flat shading rendering.
  26943. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26944. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26945. * @returns current mesh
  26946. */
  26947. convertToFlatShadedMesh(): Mesh;
  26948. /**
  26949. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26950. * In other words, more vertices, no more indices and a single bigger VBO.
  26951. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26952. * @returns current mesh
  26953. */
  26954. convertToUnIndexedMesh(): Mesh;
  26955. /**
  26956. * Inverses facet orientations.
  26957. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26958. * @param flipNormals will also inverts the normals
  26959. * @returns current mesh
  26960. */
  26961. flipFaces(flipNormals?: boolean): Mesh;
  26962. /**
  26963. * Creates a new InstancedMesh object from the mesh model.
  26964. * Warning : this method is not supported for Line mesh and LineSystem
  26965. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26966. * @param name defines the name of the new instance
  26967. * @returns a new InstancedMesh
  26968. */
  26969. createInstance(name: string): InstancedMesh;
  26970. /**
  26971. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26972. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26973. * @returns the current mesh
  26974. */
  26975. synchronizeInstances(): Mesh;
  26976. /**
  26977. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26978. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26979. * This should be used together with the simplification to avoid disappearing triangles.
  26980. * @param successCallback an optional success callback to be called after the optimization finished.
  26981. * @returns the current mesh
  26982. */
  26983. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26984. /**
  26985. * Serialize current mesh
  26986. * @param serializationObject defines the object which will receive the serialization data
  26987. */
  26988. serialize(serializationObject: any): void;
  26989. /** @hidden */
  26990. _syncGeometryWithMorphTargetManager(): void;
  26991. /**
  26992. * Returns a new Mesh object parsed from the source provided.
  26993. * @param parsedMesh is the source
  26994. * @param scene defines the hosting scene
  26995. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26996. * @returns a new Mesh
  26997. */
  26998. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26999. /**
  27000. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27001. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27002. * @param name defines the name of the mesh to create
  27003. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27004. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27005. * @param closePath creates a seam between the first and the last points of each path of the path array
  27006. * @param offset is taken in account only if the `pathArray` is containing a single path
  27007. * @param scene defines the hosting scene
  27008. * @param updatable defines if the mesh must be flagged as updatable
  27009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27010. * @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)
  27011. * @returns a new Mesh
  27012. */
  27013. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27014. /**
  27015. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27016. * @param name defines the name of the mesh to create
  27017. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27018. * @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
  27019. * @param scene defines the hosting scene
  27020. * @param updatable defines if the mesh must be flagged as updatable
  27021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27022. * @returns a new Mesh
  27023. */
  27024. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27025. /**
  27026. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27027. * @param name defines the name of the mesh to create
  27028. * @param size sets the size (float) of each box side (default 1)
  27029. * @param scene defines the hosting scene
  27030. * @param updatable defines if the mesh must be flagged as updatable
  27031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27032. * @returns a new Mesh
  27033. */
  27034. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27035. /**
  27036. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27037. * @param name defines the name of the mesh to create
  27038. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27039. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27040. * @param scene defines the hosting scene
  27041. * @param updatable defines if the mesh must be flagged as updatable
  27042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27043. * @returns a new Mesh
  27044. */
  27045. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27046. /**
  27047. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27048. * @param name defines the name of the mesh to create
  27049. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27050. * @param diameterTop set the top cap diameter (floats, default 1)
  27051. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27052. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27053. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27054. * @param scene defines the hosting scene
  27055. * @param updatable defines if the mesh must be flagged as updatable
  27056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27057. * @returns a new Mesh
  27058. */
  27059. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27060. /**
  27061. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27062. * @param name defines the name of the mesh to create
  27063. * @param diameter sets the diameter size (float) of the torus (default 1)
  27064. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27065. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27066. * @param scene defines the hosting scene
  27067. * @param updatable defines if the mesh must be flagged as updatable
  27068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27069. * @returns a new Mesh
  27070. */
  27071. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27072. /**
  27073. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27074. * @param name defines the name of the mesh to create
  27075. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27076. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27077. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27078. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27079. * @param p the number of windings on X axis (positive integers, default 2)
  27080. * @param q the number of windings on Y axis (positive integers, default 3)
  27081. * @param scene defines the hosting scene
  27082. * @param updatable defines if the mesh must be flagged as updatable
  27083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27084. * @returns a new Mesh
  27085. */
  27086. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27087. /**
  27088. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27089. * @param name defines the name of the mesh to create
  27090. * @param points is an array successive Vector3
  27091. * @param scene defines the hosting scene
  27092. * @param updatable defines if the mesh must be flagged as updatable
  27093. * @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).
  27094. * @returns a new Mesh
  27095. */
  27096. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27097. /**
  27098. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27099. * @param name defines the name of the mesh to create
  27100. * @param points is an array successive Vector3
  27101. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27102. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27103. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27104. * @param scene defines the hosting scene
  27105. * @param updatable defines if the mesh must be flagged as updatable
  27106. * @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)
  27107. * @returns a new Mesh
  27108. */
  27109. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27110. /**
  27111. * Creates a polygon mesh.
  27112. * Please consider using the same method from the MeshBuilder class instead.
  27113. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27114. * 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.
  27115. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27116. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27117. * Remember you can only change the shape positions, not their number when updating a polygon.
  27118. */
  27119. /**
  27120. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27121. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27122. * @param name defines the name of the mesh to create
  27123. * @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
  27124. * @param scene defines the hosting scene
  27125. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27126. * @param updatable defines if the mesh must be flagged as updatable
  27127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27128. * @returns a new Mesh
  27129. */
  27130. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27131. /**
  27132. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27133. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27134. * @param name defines the name of the mesh to create
  27135. * @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
  27136. * @param depth defines the height of extrusion
  27137. * @param scene defines the hosting scene
  27138. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27139. * @param updatable defines if the mesh must be flagged as updatable
  27140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27141. * @returns a new Mesh
  27142. */
  27143. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27144. /**
  27145. * Creates an extruded shape mesh.
  27146. * 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
  27147. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27148. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27149. * @param name defines the name of the mesh to create
  27150. * @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
  27151. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27152. * @param scale is the value to scale the shape
  27153. * @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
  27154. * @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
  27155. * @param scene defines the hosting scene
  27156. * @param updatable defines if the mesh must be flagged as updatable
  27157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27158. * @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)
  27159. * @returns a new Mesh
  27160. */
  27161. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27162. /**
  27163. * Creates an custom extruded shape mesh.
  27164. * The custom extrusion is a parametric shape.
  27165. * It has no predefined shape. Its final shape will depend on the input parameters.
  27166. * Please consider using the same method from the MeshBuilder class instead
  27167. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27168. * @param name defines the name of the mesh to create
  27169. * @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
  27170. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27171. * @param scaleFunction is a custom Javascript function called on each path point
  27172. * @param rotationFunction is a custom Javascript function called on each path point
  27173. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27174. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27175. * @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
  27176. * @param scene defines the hosting scene
  27177. * @param updatable defines if the mesh must be flagged as updatable
  27178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27179. * @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)
  27180. * @returns a new Mesh
  27181. */
  27182. 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;
  27183. /**
  27184. * Creates lathe mesh.
  27185. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27186. * Please consider using the same method from the MeshBuilder class instead
  27187. * @param name defines the name of the mesh to create
  27188. * @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
  27189. * @param radius is the radius value of the lathe
  27190. * @param tessellation is the side number of the lathe.
  27191. * @param scene defines the hosting scene
  27192. * @param updatable defines if the mesh must be flagged as updatable
  27193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27194. * @returns a new Mesh
  27195. */
  27196. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27197. /**
  27198. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27199. * @param name defines the name of the mesh to create
  27200. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27201. * @param scene defines the hosting scene
  27202. * @param updatable defines if the mesh must be flagged as updatable
  27203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27204. * @returns a new Mesh
  27205. */
  27206. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27207. /**
  27208. * Creates a ground mesh.
  27209. * Please consider using the same method from the MeshBuilder class instead
  27210. * @param name defines the name of the mesh to create
  27211. * @param width set the width of the ground
  27212. * @param height set the height of the ground
  27213. * @param subdivisions sets the number of subdivisions per side
  27214. * @param scene defines the hosting scene
  27215. * @param updatable defines if the mesh must be flagged as updatable
  27216. * @returns a new Mesh
  27217. */
  27218. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27219. /**
  27220. * Creates a tiled ground mesh.
  27221. * Please consider using the same method from the MeshBuilder class instead
  27222. * @param name defines the name of the mesh to create
  27223. * @param xmin set the ground minimum X coordinate
  27224. * @param zmin set the ground minimum Y coordinate
  27225. * @param xmax set the ground maximum X coordinate
  27226. * @param zmax set the ground maximum Z coordinate
  27227. * @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
  27228. * @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
  27229. * @param scene defines the hosting scene
  27230. * @param updatable defines if the mesh must be flagged as updatable
  27231. * @returns a new Mesh
  27232. */
  27233. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27234. w: number;
  27235. h: number;
  27236. }, precision: {
  27237. w: number;
  27238. h: number;
  27239. }, scene: Scene, updatable?: boolean): Mesh;
  27240. /**
  27241. * Creates a ground mesh from a height map.
  27242. * Please consider using the same method from the MeshBuilder class instead
  27243. * @see http://doc.babylonjs.com/babylon101/height_map
  27244. * @param name defines the name of the mesh to create
  27245. * @param url sets the URL of the height map image resource
  27246. * @param width set the ground width size
  27247. * @param height set the ground height size
  27248. * @param subdivisions sets the number of subdivision per side
  27249. * @param minHeight is the minimum altitude on the ground
  27250. * @param maxHeight is the maximum altitude on the ground
  27251. * @param scene defines the hosting scene
  27252. * @param updatable defines if the mesh must be flagged as updatable
  27253. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27254. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27255. * @returns a new Mesh
  27256. */
  27257. 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;
  27258. /**
  27259. * Creates a tube mesh.
  27260. * The tube is a parametric shape.
  27261. * It has no predefined shape. Its final shape will depend on the input parameters.
  27262. * Please consider using the same method from the MeshBuilder class instead
  27263. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27264. * @param name defines the name of the mesh to create
  27265. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27266. * @param radius sets the tube radius size
  27267. * @param tessellation is the number of sides on the tubular surface
  27268. * @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
  27269. * @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
  27270. * @param scene defines the hosting scene
  27271. * @param updatable defines if the mesh must be flagged as updatable
  27272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27273. * @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)
  27274. * @returns a new Mesh
  27275. */
  27276. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27277. (i: number, distance: number): number;
  27278. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27279. /**
  27280. * Creates a polyhedron mesh.
  27281. * Please consider using the same method from the MeshBuilder class instead.
  27282. * * 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
  27283. * * The parameter `size` (positive float, default 1) sets the polygon size
  27284. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27285. * * 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`
  27286. * * 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
  27287. * * 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)`)
  27288. * * 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
  27289. * * 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
  27290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27291. * * 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
  27292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27293. * @param name defines the name of the mesh to create
  27294. * @param options defines the options used to create the mesh
  27295. * @param scene defines the hosting scene
  27296. * @returns a new Mesh
  27297. */
  27298. static CreatePolyhedron(name: string, options: {
  27299. type?: number;
  27300. size?: number;
  27301. sizeX?: number;
  27302. sizeY?: number;
  27303. sizeZ?: number;
  27304. custom?: any;
  27305. faceUV?: Vector4[];
  27306. faceColors?: Color4[];
  27307. updatable?: boolean;
  27308. sideOrientation?: number;
  27309. }, scene: Scene): Mesh;
  27310. /**
  27311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27313. * * 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`)
  27314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27315. * * 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
  27316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27317. * * 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
  27318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27319. * @param name defines the name of the mesh
  27320. * @param options defines the options used to create the mesh
  27321. * @param scene defines the hosting scene
  27322. * @returns a new Mesh
  27323. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27324. */
  27325. static CreateIcoSphere(name: string, options: {
  27326. radius?: number;
  27327. flat?: boolean;
  27328. subdivisions?: number;
  27329. sideOrientation?: number;
  27330. updatable?: boolean;
  27331. }, scene: Scene): Mesh;
  27332. /**
  27333. * Creates a decal mesh.
  27334. * Please consider using the same method from the MeshBuilder class instead.
  27335. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27336. * @param name defines the name of the mesh
  27337. * @param sourceMesh defines the mesh receiving the decal
  27338. * @param position sets the position of the decal in world coordinates
  27339. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27340. * @param size sets the decal scaling
  27341. * @param angle sets the angle to rotate the decal
  27342. * @returns a new Mesh
  27343. */
  27344. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27345. /**
  27346. * Prepare internal position array for software CPU skinning
  27347. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27348. */
  27349. setPositionsForCPUSkinning(): Float32Array;
  27350. /**
  27351. * Prepare internal normal array for software CPU skinning
  27352. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27353. */
  27354. setNormalsForCPUSkinning(): Float32Array;
  27355. /**
  27356. * Updates the vertex buffer by applying transformation from the bones
  27357. * @param skeleton defines the skeleton to apply to current mesh
  27358. * @returns the current mesh
  27359. */
  27360. applySkeleton(skeleton: Skeleton): Mesh;
  27361. /**
  27362. * 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
  27363. * @param meshes defines the list of meshes to scan
  27364. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27365. */
  27366. static MinMax(meshes: AbstractMesh[]): {
  27367. min: Vector3;
  27368. max: Vector3;
  27369. };
  27370. /**
  27371. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27372. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27373. * @returns a vector3
  27374. */
  27375. static Center(meshesOrMinMaxVector: {
  27376. min: Vector3;
  27377. max: Vector3;
  27378. } | AbstractMesh[]): Vector3;
  27379. /**
  27380. * Merge the array of meshes into a single mesh for performance reasons.
  27381. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27382. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27383. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27384. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27385. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27386. * @returns a new mesh
  27387. */
  27388. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27389. }
  27390. }
  27391. declare module BABYLON {
  27392. /**
  27393. * Define an interface for all classes that will get and set the data on vertices
  27394. */
  27395. interface IGetSetVerticesData {
  27396. /**
  27397. * Gets a boolean indicating if specific vertex data is present
  27398. * @param kind defines the vertex data kind to use
  27399. * @returns true is data kind is present
  27400. */
  27401. isVerticesDataPresent(kind: string): boolean;
  27402. /**
  27403. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27404. * @param kind defines the data kind (Position, normal, etc...)
  27405. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27406. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27407. * @returns a float array containing vertex data
  27408. */
  27409. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27410. /**
  27411. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27412. * @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.
  27413. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27414. * @returns the indices array or an empty array if the mesh has no geometry
  27415. */
  27416. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27417. /**
  27418. * Set specific vertex data
  27419. * @param kind defines the data kind (Position, normal, etc...)
  27420. * @param data defines the vertex data to use
  27421. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27422. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27423. */
  27424. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27425. /**
  27426. * Update a specific associated vertex buffer
  27427. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27428. * - BABYLON.VertexBuffer.PositionKind
  27429. * - BABYLON.VertexBuffer.UVKind
  27430. * - BABYLON.VertexBuffer.UV2Kind
  27431. * - BABYLON.VertexBuffer.UV3Kind
  27432. * - BABYLON.VertexBuffer.UV4Kind
  27433. * - BABYLON.VertexBuffer.UV5Kind
  27434. * - BABYLON.VertexBuffer.UV6Kind
  27435. * - BABYLON.VertexBuffer.ColorKind
  27436. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27437. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27438. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27439. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27440. * @param data defines the data source
  27441. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27442. * @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)
  27443. */
  27444. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27445. /**
  27446. * Creates a new index buffer
  27447. * @param indices defines the indices to store in the index buffer
  27448. * @param totalVertices defines the total number of vertices (could be null)
  27449. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27450. */
  27451. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27452. }
  27453. /**
  27454. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27455. */
  27456. class VertexData {
  27457. /**
  27458. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27459. */
  27460. positions: Nullable<FloatArray>;
  27461. /**
  27462. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27463. */
  27464. normals: Nullable<FloatArray>;
  27465. /**
  27466. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27467. */
  27468. tangents: Nullable<FloatArray>;
  27469. /**
  27470. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27471. */
  27472. uvs: Nullable<FloatArray>;
  27473. /**
  27474. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27475. */
  27476. uvs2: Nullable<FloatArray>;
  27477. /**
  27478. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27479. */
  27480. uvs3: Nullable<FloatArray>;
  27481. /**
  27482. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27483. */
  27484. uvs4: Nullable<FloatArray>;
  27485. /**
  27486. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27487. */
  27488. uvs5: Nullable<FloatArray>;
  27489. /**
  27490. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27491. */
  27492. uvs6: Nullable<FloatArray>;
  27493. /**
  27494. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27495. */
  27496. colors: Nullable<FloatArray>;
  27497. /**
  27498. * 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).
  27499. */
  27500. matricesIndices: Nullable<FloatArray>;
  27501. /**
  27502. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27503. */
  27504. matricesWeights: Nullable<FloatArray>;
  27505. /**
  27506. * An array extending the number of possible indices
  27507. */
  27508. matricesIndicesExtra: Nullable<FloatArray>;
  27509. /**
  27510. * An array extending the number of possible weights when the number of indices is extended
  27511. */
  27512. matricesWeightsExtra: Nullable<FloatArray>;
  27513. /**
  27514. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27515. */
  27516. indices: Nullable<IndicesArray>;
  27517. /**
  27518. * Uses the passed data array to set the set the values for the specified kind of data
  27519. * @param data a linear array of floating numbers
  27520. * @param kind the type of data that is being set, eg positions, colors etc
  27521. */
  27522. set(data: FloatArray, kind: string): void;
  27523. /**
  27524. * Associates the vertexData to the passed Mesh.
  27525. * Sets it as updatable or not (default `false`)
  27526. * @param mesh the mesh the vertexData is applied to
  27527. * @param updatable when used and having the value true allows new data to update the vertexData
  27528. * @returns the VertexData
  27529. */
  27530. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27531. /**
  27532. * Associates the vertexData to the passed Geometry.
  27533. * Sets it as updatable or not (default `false`)
  27534. * @param geometry the geometry the vertexData is applied to
  27535. * @param updatable when used and having the value true allows new data to update the vertexData
  27536. * @returns VertexData
  27537. */
  27538. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27539. /**
  27540. * Updates the associated mesh
  27541. * @param mesh the mesh to be updated
  27542. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27543. * @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
  27544. * @returns VertexData
  27545. */
  27546. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27547. /**
  27548. * Updates the associated geometry
  27549. * @param geometry the geometry to be updated
  27550. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27551. * @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
  27552. * @returns VertexData.
  27553. */
  27554. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27555. private _applyTo;
  27556. private _update;
  27557. /**
  27558. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27559. * @param matrix the transforming matrix
  27560. * @returns the VertexData
  27561. */
  27562. transform(matrix: Matrix): VertexData;
  27563. /**
  27564. * Merges the passed VertexData into the current one
  27565. * @param other the VertexData to be merged into the current one
  27566. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27567. * @returns the modified VertexData
  27568. */
  27569. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27570. private _mergeElement;
  27571. private _validate;
  27572. /**
  27573. * Serializes the VertexData
  27574. * @returns a serialized object
  27575. */
  27576. serialize(): any;
  27577. /**
  27578. * Extracts the vertexData from a mesh
  27579. * @param mesh the mesh from which to extract the VertexData
  27580. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27581. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27582. * @returns the object VertexData associated to the passed mesh
  27583. */
  27584. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27585. /**
  27586. * Extracts the vertexData from the geometry
  27587. * @param geometry the geometry from which to extract the VertexData
  27588. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27589. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27590. * @returns the object VertexData associated to the passed mesh
  27591. */
  27592. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27593. private static _ExtractFrom;
  27594. /**
  27595. * Creates the VertexData for a Ribbon
  27596. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27597. * * pathArray array of paths, each of which an array of successive Vector3
  27598. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27599. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27600. * * 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
  27601. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27602. * * 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)
  27603. * * 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)
  27604. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27605. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27606. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27607. * @returns the VertexData of the ribbon
  27608. */
  27609. static CreateRibbon(options: {
  27610. pathArray: Vector3[][];
  27611. closeArray?: boolean;
  27612. closePath?: boolean;
  27613. offset?: number;
  27614. sideOrientation?: number;
  27615. frontUVs?: Vector4;
  27616. backUVs?: Vector4;
  27617. invertUV?: boolean;
  27618. uvs?: Vector2[];
  27619. colors?: Color4[];
  27620. }): VertexData;
  27621. /**
  27622. * Creates the VertexData for a box
  27623. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27624. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27625. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27626. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27627. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27628. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27629. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27630. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27631. * * 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)
  27632. * * 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)
  27633. * @returns the VertexData of the box
  27634. */
  27635. static CreateBox(options: {
  27636. size?: number;
  27637. width?: number;
  27638. height?: number;
  27639. depth?: number;
  27640. faceUV?: Vector4[];
  27641. faceColors?: Color4[];
  27642. sideOrientation?: number;
  27643. frontUVs?: Vector4;
  27644. backUVs?: Vector4;
  27645. }): VertexData;
  27646. /**
  27647. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27648. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27649. * * segments sets the number of horizontal strips optional, default 32
  27650. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27651. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27652. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27653. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27654. * * 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
  27655. * * 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
  27656. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27657. * * 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)
  27658. * * 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)
  27659. * @returns the VertexData of the ellipsoid
  27660. */
  27661. static CreateSphere(options: {
  27662. segments?: number;
  27663. diameter?: number;
  27664. diameterX?: number;
  27665. diameterY?: number;
  27666. diameterZ?: number;
  27667. arc?: number;
  27668. slice?: number;
  27669. sideOrientation?: number;
  27670. frontUVs?: Vector4;
  27671. backUVs?: Vector4;
  27672. }): VertexData;
  27673. /**
  27674. * Creates the VertexData for a cylinder, cone or prism
  27675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27676. * * height sets the height (y direction) of the cylinder, optional, default 2
  27677. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27678. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27679. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27680. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27681. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27682. * * 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
  27683. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27684. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27685. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27686. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27687. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27688. * * 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)
  27689. * * 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)
  27690. * @returns the VertexData of the cylinder, cone or prism
  27691. */
  27692. static CreateCylinder(options: {
  27693. height?: number;
  27694. diameterTop?: number;
  27695. diameterBottom?: number;
  27696. diameter?: number;
  27697. tessellation?: number;
  27698. subdivisions?: number;
  27699. arc?: number;
  27700. faceColors?: Color4[];
  27701. faceUV?: Vector4[];
  27702. hasRings?: boolean;
  27703. enclose?: boolean;
  27704. sideOrientation?: number;
  27705. frontUVs?: Vector4;
  27706. backUVs?: Vector4;
  27707. }): VertexData;
  27708. /**
  27709. * Creates the VertexData for a torus
  27710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27711. * * diameter the diameter of the torus, optional default 1
  27712. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27713. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27714. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27715. * * 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)
  27716. * * 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)
  27717. * @returns the VertexData of the torus
  27718. */
  27719. static CreateTorus(options: {
  27720. diameter?: number;
  27721. thickness?: number;
  27722. tessellation?: number;
  27723. sideOrientation?: number;
  27724. frontUVs?: Vector4;
  27725. backUVs?: Vector4;
  27726. }): VertexData;
  27727. /**
  27728. * Creates the VertexData of the LineSystem
  27729. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27730. * - lines an array of lines, each line being an array of successive Vector3
  27731. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27732. * @returns the VertexData of the LineSystem
  27733. */
  27734. static CreateLineSystem(options: {
  27735. lines: Vector3[][];
  27736. colors?: Nullable<Color4[][]>;
  27737. }): VertexData;
  27738. /**
  27739. * Create the VertexData for a DashedLines
  27740. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27741. * - points an array successive Vector3
  27742. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27743. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27744. * - dashNb the intended total number of dashes, optional, default 200
  27745. * @returns the VertexData for the DashedLines
  27746. */
  27747. static CreateDashedLines(options: {
  27748. points: Vector3[];
  27749. dashSize?: number;
  27750. gapSize?: number;
  27751. dashNb?: number;
  27752. }): VertexData;
  27753. /**
  27754. * Creates the VertexData for a Ground
  27755. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27756. * - width the width (x direction) of the ground, optional, default 1
  27757. * - height the height (z direction) of the ground, optional, default 1
  27758. * - subdivisions the number of subdivisions per side, optional, default 1
  27759. * @returns the VertexData of the Ground
  27760. */
  27761. static CreateGround(options: {
  27762. width?: number;
  27763. height?: number;
  27764. subdivisions?: number;
  27765. subdivisionsX?: number;
  27766. subdivisionsY?: number;
  27767. }): VertexData;
  27768. /**
  27769. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27770. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27771. * * xmin the ground minimum X coordinate, optional, default -1
  27772. * * zmin the ground minimum Z coordinate, optional, default -1
  27773. * * xmax the ground maximum X coordinate, optional, default 1
  27774. * * zmax the ground maximum Z coordinate, optional, default 1
  27775. * * 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}
  27776. * * 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}
  27777. * @returns the VertexData of the TiledGround
  27778. */
  27779. static CreateTiledGround(options: {
  27780. xmin: number;
  27781. zmin: number;
  27782. xmax: number;
  27783. zmax: number;
  27784. subdivisions?: {
  27785. w: number;
  27786. h: number;
  27787. };
  27788. precision?: {
  27789. w: number;
  27790. h: number;
  27791. };
  27792. }): VertexData;
  27793. /**
  27794. * Creates the VertexData of the Ground designed from a heightmap
  27795. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27796. * * width the width (x direction) of the ground
  27797. * * height the height (z direction) of the ground
  27798. * * subdivisions the number of subdivisions per side
  27799. * * minHeight the minimum altitude on the ground, optional, default 0
  27800. * * maxHeight the maximum altitude on the ground, optional default 1
  27801. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27802. * * buffer the array holding the image color data
  27803. * * bufferWidth the width of image
  27804. * * bufferHeight the height of image
  27805. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27806. * @returns the VertexData of the Ground designed from a heightmap
  27807. */
  27808. static CreateGroundFromHeightMap(options: {
  27809. width: number;
  27810. height: number;
  27811. subdivisions: number;
  27812. minHeight: number;
  27813. maxHeight: number;
  27814. colorFilter: Color3;
  27815. buffer: Uint8Array;
  27816. bufferWidth: number;
  27817. bufferHeight: number;
  27818. alphaFilter: number;
  27819. }): VertexData;
  27820. /**
  27821. * Creates the VertexData for a Plane
  27822. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27823. * * size sets the width and height of the plane to the value of size, optional default 1
  27824. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27825. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27826. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27827. * * 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)
  27828. * * 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)
  27829. * @returns the VertexData of the box
  27830. */
  27831. static CreatePlane(options: {
  27832. size?: number;
  27833. width?: number;
  27834. height?: number;
  27835. sideOrientation?: number;
  27836. frontUVs?: Vector4;
  27837. backUVs?: Vector4;
  27838. }): VertexData;
  27839. /**
  27840. * Creates the VertexData of the Disc or regular Polygon
  27841. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27842. * * radius the radius of the disc, optional default 0.5
  27843. * * tessellation the number of polygon sides, optional, default 64
  27844. * * 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
  27845. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27846. * * 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)
  27847. * * 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)
  27848. * @returns the VertexData of the box
  27849. */
  27850. static CreateDisc(options: {
  27851. radius?: number;
  27852. tessellation?: number;
  27853. arc?: number;
  27854. sideOrientation?: number;
  27855. frontUVs?: Vector4;
  27856. backUVs?: Vector4;
  27857. }): VertexData;
  27858. /**
  27859. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27860. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27861. * @param polygon a mesh built from polygonTriangulation.build()
  27862. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27863. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27864. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27865. * @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)
  27866. * @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)
  27867. * @returns the VertexData of the Polygon
  27868. */
  27869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27870. /**
  27871. * Creates the VertexData of the IcoSphere
  27872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27873. * * radius the radius of the IcoSphere, optional default 1
  27874. * * radiusX allows stretching in the x direction, optional, default radius
  27875. * * radiusY allows stretching in the y direction, optional, default radius
  27876. * * radiusZ allows stretching in the z direction, optional, default radius
  27877. * * flat when true creates a flat shaded mesh, optional, default true
  27878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27879. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27880. * * 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)
  27881. * * 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)
  27882. * @returns the VertexData of the IcoSphere
  27883. */
  27884. static CreateIcoSphere(options: {
  27885. radius?: number;
  27886. radiusX?: number;
  27887. radiusY?: number;
  27888. radiusZ?: number;
  27889. flat?: boolean;
  27890. subdivisions?: number;
  27891. sideOrientation?: number;
  27892. frontUVs?: Vector4;
  27893. backUVs?: Vector4;
  27894. }): VertexData;
  27895. /**
  27896. * Creates the VertexData for a Polyhedron
  27897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27898. * * type provided types are:
  27899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27900. * * 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)
  27901. * * size the size of the IcoSphere, optional default 1
  27902. * * sizeX allows stretching in the x direction, optional, default size
  27903. * * sizeY allows stretching in the y direction, optional, default size
  27904. * * sizeZ allows stretching in the z direction, optional, default size
  27905. * * 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
  27906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27908. * * flat when true creates a flat shaded mesh, optional, default true
  27909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27910. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27911. * * 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)
  27912. * * 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)
  27913. * @returns the VertexData of the Polyhedron
  27914. */
  27915. static CreatePolyhedron(options: {
  27916. type?: number;
  27917. size?: number;
  27918. sizeX?: number;
  27919. sizeY?: number;
  27920. sizeZ?: number;
  27921. custom?: any;
  27922. faceUV?: Vector4[];
  27923. faceColors?: Color4[];
  27924. flat?: boolean;
  27925. sideOrientation?: number;
  27926. frontUVs?: Vector4;
  27927. backUVs?: Vector4;
  27928. }): VertexData;
  27929. /**
  27930. * Creates the VertexData for a TorusKnot
  27931. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27932. * * radius the radius of the torus knot, optional, default 2
  27933. * * tube the thickness of the tube, optional, default 0.5
  27934. * * radialSegments the number of sides on each tube segments, optional, default 32
  27935. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27936. * * p the number of windings around the z axis, optional, default 2
  27937. * * q the number of windings around the x axis, optional, default 3
  27938. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27939. * * 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)
  27940. * * 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)
  27941. * @returns the VertexData of the Torus Knot
  27942. */
  27943. static CreateTorusKnot(options: {
  27944. radius?: number;
  27945. tube?: number;
  27946. radialSegments?: number;
  27947. tubularSegments?: number;
  27948. p?: number;
  27949. q?: number;
  27950. sideOrientation?: number;
  27951. frontUVs?: Vector4;
  27952. backUVs?: Vector4;
  27953. }): VertexData;
  27954. /**
  27955. * Compute normals for given positions and indices
  27956. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27957. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27958. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27959. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27960. * * facetNormals : optional array of facet normals (vector3)
  27961. * * facetPositions : optional array of facet positions (vector3)
  27962. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27963. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27964. * * bInfo : optional bounding info, required for facetPartitioning computation
  27965. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27966. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27967. * * useRightHandedSystem: optional boolean to for right handed system computation
  27968. * * depthSort : optional boolean to enable the facet depth sort computation
  27969. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27970. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27971. */
  27972. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27973. facetNormals?: any;
  27974. facetPositions?: any;
  27975. facetPartitioning?: any;
  27976. ratio?: number;
  27977. bInfo?: any;
  27978. bbSize?: Vector3;
  27979. subDiv?: any;
  27980. useRightHandedSystem?: boolean;
  27981. depthSort?: boolean;
  27982. distanceTo?: Vector3;
  27983. depthSortedFacets?: any;
  27984. }): void;
  27985. private static _ComputeSides;
  27986. /**
  27987. * Applies VertexData created from the imported parameters to the geometry
  27988. * @param parsedVertexData the parsed data from an imported file
  27989. * @param geometry the geometry to apply the VertexData to
  27990. */
  27991. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27992. }
  27993. }
  27994. declare module BABYLON {
  27995. /**
  27996. * Class containing static functions to help procedurally build meshes
  27997. */
  27998. class MeshBuilder {
  27999. private static updateSideOrientation;
  28000. /**
  28001. * Creates a box mesh
  28002. * * The parameter `size` sets the size (float) of each box side (default 1)
  28003. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28004. * * 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)
  28005. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28007. * * 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
  28008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28009. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  28010. * @param name defines the name of the mesh
  28011. * @param options defines the options used to create the mesh
  28012. * @param scene defines the hosting scene
  28013. * @returns the box mesh
  28014. */
  28015. static CreateBox(name: string, options: {
  28016. size?: number;
  28017. width?: number;
  28018. height?: number;
  28019. depth?: number;
  28020. faceUV?: Vector4[];
  28021. faceColors?: Color4[];
  28022. sideOrientation?: number;
  28023. frontUVs?: Vector4;
  28024. backUVs?: Vector4;
  28025. updatable?: boolean;
  28026. }, scene?: Nullable<Scene>): Mesh;
  28027. /**
  28028. * Creates a sphere mesh
  28029. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28030. * * 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`)
  28031. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28032. * * 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
  28033. * * 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)
  28034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28035. * * 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
  28036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28037. * @param name defines the name of the mesh
  28038. * @param options defines the options used to create the mesh
  28039. * @param scene defines the hosting scene
  28040. * @returns the sphere mesh
  28041. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  28042. */
  28043. static CreateSphere(name: string, options: {
  28044. segments?: number;
  28045. diameter?: number;
  28046. diameterX?: number;
  28047. diameterY?: number;
  28048. diameterZ?: number;
  28049. arc?: number;
  28050. slice?: number;
  28051. sideOrientation?: number;
  28052. frontUVs?: Vector4;
  28053. backUVs?: Vector4;
  28054. updatable?: boolean;
  28055. }, scene: any): Mesh;
  28056. /**
  28057. * Creates a plane polygonal mesh. By default, this is a disc
  28058. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28059. * * 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
  28060. * * 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
  28061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28062. * * 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
  28063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28064. * @param name defines the name of the mesh
  28065. * @param options defines the options used to create the mesh
  28066. * @param scene defines the hosting scene
  28067. * @returns the plane polygonal mesh
  28068. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28069. */
  28070. static CreateDisc(name: string, options: {
  28071. radius?: number;
  28072. tessellation?: number;
  28073. arc?: number;
  28074. updatable?: boolean;
  28075. sideOrientation?: number;
  28076. frontUVs?: Vector4;
  28077. backUVs?: Vector4;
  28078. }, scene?: Nullable<Scene>): Mesh;
  28079. /**
  28080. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28081. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28082. * * 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`)
  28083. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28084. * * 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
  28085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28086. * * 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
  28087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28088. * @param name defines the name of the mesh
  28089. * @param options defines the options used to create the mesh
  28090. * @param scene defines the hosting scene
  28091. * @returns the icosahedron mesh
  28092. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28093. */
  28094. static CreateIcoSphere(name: string, options: {
  28095. radius?: number;
  28096. radiusX?: number;
  28097. radiusY?: number;
  28098. radiusZ?: number;
  28099. flat?: boolean;
  28100. subdivisions?: number;
  28101. sideOrientation?: number;
  28102. frontUVs?: Vector4;
  28103. backUVs?: Vector4;
  28104. updatable?: boolean;
  28105. }, scene: Scene): Mesh;
  28106. /**
  28107. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28108. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28109. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28110. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28111. * * 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
  28112. * * 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
  28113. * * 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
  28114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28117. * * 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
  28118. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28119. * * 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
  28120. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28122. * @param name defines the name of the mesh
  28123. * @param options defines the options used to create the mesh
  28124. * @param scene defines the hosting scene
  28125. * @returns the ribbon mesh
  28126. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28127. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28128. */
  28129. static CreateRibbon(name: string, options: {
  28130. pathArray: Vector3[][];
  28131. closeArray?: boolean;
  28132. closePath?: boolean;
  28133. offset?: number;
  28134. updatable?: boolean;
  28135. sideOrientation?: number;
  28136. frontUVs?: Vector4;
  28137. backUVs?: Vector4;
  28138. instance?: Mesh;
  28139. invertUV?: boolean;
  28140. uvs?: Vector2[];
  28141. colors?: Color4[];
  28142. }, scene?: Nullable<Scene>): Mesh;
  28143. /**
  28144. * Creates a cylinder or a cone mesh
  28145. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28146. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28147. * * 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.
  28148. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28149. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28150. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28151. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28152. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28153. * * 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).
  28154. * * 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
  28155. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28156. * * 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
  28157. * * 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.
  28158. * * If `enclose` is false, a ring surface is one element.
  28159. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28160. * * 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
  28161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28162. * * 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
  28163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28164. * @param name defines the name of the mesh
  28165. * @param options defines the options used to create the mesh
  28166. * @param scene defines the hosting scene
  28167. * @returns the cylinder mesh
  28168. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28169. */
  28170. static CreateCylinder(name: string, options: {
  28171. height?: number;
  28172. diameterTop?: number;
  28173. diameterBottom?: number;
  28174. diameter?: number;
  28175. tessellation?: number;
  28176. subdivisions?: number;
  28177. arc?: number;
  28178. faceColors?: Color4[];
  28179. faceUV?: Vector4[];
  28180. updatable?: boolean;
  28181. hasRings?: boolean;
  28182. enclose?: boolean;
  28183. sideOrientation?: number;
  28184. frontUVs?: Vector4;
  28185. backUVs?: Vector4;
  28186. }, scene: any): Mesh;
  28187. /**
  28188. * Creates a torus mesh
  28189. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28190. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28191. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28193. * * 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
  28194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28195. * @param name defines the name of the mesh
  28196. * @param options defines the options used to create the mesh
  28197. * @param scene defines the hosting scene
  28198. * @returns the torus mesh
  28199. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28200. */
  28201. static CreateTorus(name: string, options: {
  28202. diameter?: number;
  28203. thickness?: number;
  28204. tessellation?: number;
  28205. updatable?: boolean;
  28206. sideOrientation?: number;
  28207. frontUVs?: Vector4;
  28208. backUVs?: Vector4;
  28209. }, scene: any): Mesh;
  28210. /**
  28211. * Creates a torus knot mesh
  28212. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28213. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28214. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28215. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28217. * * 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
  28218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28219. * @param name defines the name of the mesh
  28220. * @param options defines the options used to create the mesh
  28221. * @param scene defines the hosting scene
  28222. * @returns the torus knot mesh
  28223. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28224. */
  28225. static CreateTorusKnot(name: string, options: {
  28226. radius?: number;
  28227. tube?: number;
  28228. radialSegments?: number;
  28229. tubularSegments?: number;
  28230. p?: number;
  28231. q?: number;
  28232. updatable?: boolean;
  28233. sideOrientation?: number;
  28234. frontUVs?: Vector4;
  28235. backUVs?: Vector4;
  28236. }, scene: any): Mesh;
  28237. /**
  28238. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28239. * * 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
  28240. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28241. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28242. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28243. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28244. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28245. * * 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
  28246. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28248. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28249. * @param name defines the name of the new line system
  28250. * @param options defines the options used to create the line system
  28251. * @param scene defines the hosting scene
  28252. * @returns a new line system mesh
  28253. */
  28254. static CreateLineSystem(name: string, options: {
  28255. lines: Vector3[][];
  28256. updatable?: boolean;
  28257. instance?: Nullable<LinesMesh>;
  28258. colors?: Nullable<Color4[][]>;
  28259. useVertexAlpha?: boolean;
  28260. }, scene: Nullable<Scene>): LinesMesh;
  28261. /**
  28262. * Creates a line mesh
  28263. * 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
  28264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28265. * * The parameter `points` is an array successive Vector3
  28266. * * 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
  28267. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28268. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28269. * * When updating an instance, remember that only point positions can change, not the number of points
  28270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28271. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28272. * @param name defines the name of the new line system
  28273. * @param options defines the options used to create the line system
  28274. * @param scene defines the hosting scene
  28275. * @returns a new line mesh
  28276. */
  28277. static CreateLines(name: string, options: {
  28278. points: Vector3[];
  28279. updatable?: boolean;
  28280. instance?: Nullable<LinesMesh>;
  28281. colors?: Color4[];
  28282. useVertexAlpha?: boolean;
  28283. }, scene?: Nullable<Scene>): LinesMesh;
  28284. /**
  28285. * Creates a dashed line mesh
  28286. * * 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
  28287. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28288. * * The parameter `points` is an array successive Vector3
  28289. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28290. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28291. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28292. * * 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
  28293. * * When updating an instance, remember that only point positions can change, not the number of points
  28294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28295. * @param name defines the name of the mesh
  28296. * @param options defines the options used to create the mesh
  28297. * @param scene defines the hosting scene
  28298. * @returns the dashed line mesh
  28299. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28300. */
  28301. static CreateDashedLines(name: string, options: {
  28302. points: Vector3[];
  28303. dashSize?: number;
  28304. gapSize?: number;
  28305. dashNb?: number;
  28306. updatable?: boolean;
  28307. instance?: LinesMesh;
  28308. }, scene?: Nullable<Scene>): LinesMesh;
  28309. /**
  28310. * 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.
  28311. * * 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.
  28312. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28313. * * 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.
  28314. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28315. * * 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
  28316. * * 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
  28317. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28319. * * 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
  28320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28322. * @param name defines the name of the mesh
  28323. * @param options defines the options used to create the mesh
  28324. * @param scene defines the hosting scene
  28325. * @returns the extruded shape mesh
  28326. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28328. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28329. */
  28330. static ExtrudeShape(name: string, options: {
  28331. shape: Vector3[];
  28332. path: Vector3[];
  28333. scale?: number;
  28334. rotation?: number;
  28335. cap?: number;
  28336. updatable?: boolean;
  28337. sideOrientation?: number;
  28338. frontUVs?: Vector4;
  28339. backUVs?: Vector4;
  28340. instance?: Mesh;
  28341. invertUV?: boolean;
  28342. }, scene?: Nullable<Scene>): Mesh;
  28343. /**
  28344. * Creates an custom extruded shape mesh.
  28345. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28346. * * 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.
  28347. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28348. * * 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
  28349. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28350. * * 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
  28351. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28352. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28353. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28354. * * 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
  28355. * * 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
  28356. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28358. * * 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
  28359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28361. * @param name defines the name of the mesh
  28362. * @param options defines the options used to create the mesh
  28363. * @param scene defines the hosting scene
  28364. * @returns the custom extruded shape mesh
  28365. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28366. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28367. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28368. */
  28369. static ExtrudeShapeCustom(name: string, options: {
  28370. shape: Vector3[];
  28371. path: Vector3[];
  28372. scaleFunction?: any;
  28373. rotationFunction?: any;
  28374. ribbonCloseArray?: boolean;
  28375. ribbonClosePath?: boolean;
  28376. cap?: number;
  28377. updatable?: boolean;
  28378. sideOrientation?: number;
  28379. frontUVs?: Vector4;
  28380. backUVs?: Vector4;
  28381. instance?: Mesh;
  28382. invertUV?: boolean;
  28383. }, scene: Scene): Mesh;
  28384. /**
  28385. * Creates lathe mesh.
  28386. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28387. * * 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
  28388. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28389. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28390. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28391. * * 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
  28392. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28393. * * 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
  28394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28395. * * 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
  28396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28398. * @param name defines the name of the mesh
  28399. * @param options defines the options used to create the mesh
  28400. * @param scene defines the hosting scene
  28401. * @returns the lathe mesh
  28402. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28403. */
  28404. static CreateLathe(name: string, options: {
  28405. shape: Vector3[];
  28406. radius?: number;
  28407. tessellation?: number;
  28408. clip?: number;
  28409. arc?: number;
  28410. closed?: boolean;
  28411. updatable?: boolean;
  28412. sideOrientation?: number;
  28413. frontUVs?: Vector4;
  28414. backUVs?: Vector4;
  28415. cap?: number;
  28416. invertUV?: boolean;
  28417. }, scene: Scene): Mesh;
  28418. /**
  28419. * Creates a plane mesh
  28420. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28421. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28422. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28424. * * 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
  28425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28426. * @param name defines the name of the mesh
  28427. * @param options defines the options used to create the mesh
  28428. * @param scene defines the hosting scene
  28429. * @returns the plane mesh
  28430. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28431. */
  28432. static CreatePlane(name: string, options: {
  28433. size?: number;
  28434. width?: number;
  28435. height?: number;
  28436. sideOrientation?: number;
  28437. frontUVs?: Vector4;
  28438. backUVs?: Vector4;
  28439. updatable?: boolean;
  28440. sourcePlane?: Plane;
  28441. }, scene: Scene): Mesh;
  28442. /**
  28443. * Creates a ground mesh
  28444. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28445. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28447. * @param name defines the name of the mesh
  28448. * @param options defines the options used to create the mesh
  28449. * @param scene defines the hosting scene
  28450. * @returns the ground mesh
  28451. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28452. */
  28453. static CreateGround(name: string, options: {
  28454. width?: number;
  28455. height?: number;
  28456. subdivisions?: number;
  28457. subdivisionsX?: number;
  28458. subdivisionsY?: number;
  28459. updatable?: boolean;
  28460. }, scene: any): Mesh;
  28461. /**
  28462. * Creates a tiled ground mesh
  28463. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28464. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28465. * * 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
  28466. * * 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
  28467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28468. * @param name defines the name of the mesh
  28469. * @param options defines the options used to create the mesh
  28470. * @param scene defines the hosting scene
  28471. * @returns the tiled ground mesh
  28472. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28473. */
  28474. static CreateTiledGround(name: string, options: {
  28475. xmin: number;
  28476. zmin: number;
  28477. xmax: number;
  28478. zmax: number;
  28479. subdivisions?: {
  28480. w: number;
  28481. h: number;
  28482. };
  28483. precision?: {
  28484. w: number;
  28485. h: number;
  28486. };
  28487. updatable?: boolean;
  28488. }, scene: Scene): Mesh;
  28489. /**
  28490. * Creates a ground mesh from a height map
  28491. * * The parameter `url` sets the URL of the height map image resource.
  28492. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28493. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28494. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28495. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28496. * * 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.
  28497. * * 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).
  28498. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28500. * @param name defines the name of the mesh
  28501. * @param url defines the url to the height map
  28502. * @param options defines the options used to create the mesh
  28503. * @param scene defines the hosting scene
  28504. * @returns the ground mesh
  28505. * @see http://doc.babylonjs.com/babylon101/height_map
  28506. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28507. */
  28508. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28509. width?: number;
  28510. height?: number;
  28511. subdivisions?: number;
  28512. minHeight?: number;
  28513. maxHeight?: number;
  28514. colorFilter?: Color3;
  28515. alphaFilter?: number;
  28516. updatable?: boolean;
  28517. onReady?: (mesh: GroundMesh) => void;
  28518. }, scene: Scene): GroundMesh;
  28519. /**
  28520. * Creates a polygon mesh
  28521. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28522. * * 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
  28523. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28525. * * 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)
  28526. * * Remember you can only change the shape positions, not their number when updating a polygon
  28527. * @param name defines the name of the mesh
  28528. * @param options defines the options used to create the mesh
  28529. * @param scene defines the hosting scene
  28530. * @returns the polygon mesh
  28531. */
  28532. static CreatePolygon(name: string, options: {
  28533. shape: Vector3[];
  28534. holes?: Vector3[][];
  28535. depth?: number;
  28536. faceUV?: Vector4[];
  28537. faceColors?: Color4[];
  28538. updatable?: boolean;
  28539. sideOrientation?: number;
  28540. frontUVs?: Vector4;
  28541. backUVs?: Vector4;
  28542. }, scene: Scene): Mesh;
  28543. /**
  28544. * Creates an extruded polygon mesh, with depth in the Y direction.
  28545. * * 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)
  28546. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28547. * @param name defines the name of the mesh
  28548. * @param options defines the options used to create the mesh
  28549. * @param scene defines the hosting scene
  28550. * @returns the polygon mesh
  28551. */
  28552. static ExtrudePolygon(name: string, options: {
  28553. shape: Vector3[];
  28554. holes?: Vector3[][];
  28555. depth?: number;
  28556. faceUV?: Vector4[];
  28557. faceColors?: Color4[];
  28558. updatable?: boolean;
  28559. sideOrientation?: number;
  28560. frontUVs?: Vector4;
  28561. backUVs?: Vector4;
  28562. }, scene: Scene): Mesh;
  28563. /**
  28564. * Creates a tube mesh.
  28565. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28566. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28567. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28568. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28569. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28570. * * 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)
  28571. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28572. * * 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
  28573. * * 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
  28574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28575. * * 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
  28576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28578. * @param name defines the name of the mesh
  28579. * @param options defines the options used to create the mesh
  28580. * @param scene defines the hosting scene
  28581. * @returns the tube mesh
  28582. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28583. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28584. */
  28585. static CreateTube(name: string, options: {
  28586. path: Vector3[];
  28587. radius?: number;
  28588. tessellation?: number;
  28589. radiusFunction?: {
  28590. (i: number, distance: number): number;
  28591. };
  28592. cap?: number;
  28593. arc?: number;
  28594. updatable?: boolean;
  28595. sideOrientation?: number;
  28596. frontUVs?: Vector4;
  28597. backUVs?: Vector4;
  28598. instance?: Mesh;
  28599. invertUV?: boolean;
  28600. }, scene: Scene): Mesh;
  28601. /**
  28602. * Creates a polyhedron mesh
  28603. * * 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
  28604. * * The parameter `size` (positive float, default 1) sets the polygon size
  28605. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28606. * * 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`
  28607. * * 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
  28608. * * 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)`)
  28609. * * 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
  28610. * * 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
  28611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28612. * * 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
  28613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28614. * @param name defines the name of the mesh
  28615. * @param options defines the options used to create the mesh
  28616. * @param scene defines the hosting scene
  28617. * @returns the polyhedron mesh
  28618. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28619. */
  28620. static CreatePolyhedron(name: string, options: {
  28621. type?: number;
  28622. size?: number;
  28623. sizeX?: number;
  28624. sizeY?: number;
  28625. sizeZ?: number;
  28626. custom?: any;
  28627. faceUV?: Vector4[];
  28628. faceColors?: Color4[];
  28629. flat?: boolean;
  28630. updatable?: boolean;
  28631. sideOrientation?: number;
  28632. frontUVs?: Vector4;
  28633. backUVs?: Vector4;
  28634. }, scene: Scene): Mesh;
  28635. /**
  28636. * Creates a decal mesh.
  28637. * 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
  28638. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28639. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28640. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28641. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28642. * @param name defines the name of the mesh
  28643. * @param sourceMesh defines the mesh where the decal must be applied
  28644. * @param options defines the options used to create the mesh
  28645. * @param scene defines the hosting scene
  28646. * @returns the decal mesh
  28647. * @see http://doc.babylonjs.com/how_to/decals
  28648. */
  28649. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28650. position?: Vector3;
  28651. normal?: Vector3;
  28652. size?: Vector3;
  28653. angle?: number;
  28654. }): Mesh;
  28655. private static _ExtrudeShapeGeneric;
  28656. }
  28657. }
  28658. declare module BABYLON {
  28659. /**
  28660. * Class used to represent a specific level of detail of a mesh
  28661. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28662. */
  28663. class MeshLODLevel {
  28664. /** Defines the distance where this level should star being displayed */
  28665. distance: number;
  28666. /** Defines the mesh to use to render this level */
  28667. mesh: Nullable<Mesh>;
  28668. /**
  28669. * Creates a new LOD level
  28670. * @param distance defines the distance where this level should star being displayed
  28671. * @param mesh defines the mesh to use to render this level
  28672. */
  28673. constructor(
  28674. /** Defines the distance where this level should star being displayed */
  28675. distance: number,
  28676. /** Defines the mesh to use to render this level */
  28677. mesh: Nullable<Mesh>);
  28678. }
  28679. }
  28680. declare module BABYLON {
  28681. /**
  28682. * A simplifier interface for future simplification implementations
  28683. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28684. */
  28685. interface ISimplifier {
  28686. /**
  28687. * Simplification of a given mesh according to the given settings.
  28688. * Since this requires computation, it is assumed that the function runs async.
  28689. * @param settings The settings of the simplification, including quality and distance
  28690. * @param successCallback A callback that will be called after the mesh was simplified.
  28691. * @param errorCallback in case of an error, this callback will be called. optional.
  28692. */
  28693. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28694. }
  28695. /**
  28696. * Expected simplification settings.
  28697. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28698. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28699. */
  28700. interface ISimplificationSettings {
  28701. /**
  28702. * Gets or sets the expected quality
  28703. */
  28704. quality: number;
  28705. /**
  28706. * Gets or sets the distance when this optimized version should be used
  28707. */
  28708. distance: number;
  28709. /**
  28710. * Gets an already optimized mesh
  28711. */
  28712. optimizeMesh?: boolean;
  28713. }
  28714. /**
  28715. * Class used to specify simplification options
  28716. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28717. */
  28718. class SimplificationSettings implements ISimplificationSettings {
  28719. /** expected quality */
  28720. quality: number;
  28721. /** distance when this optimized version should be used */
  28722. distance: number;
  28723. /** already optimized mesh */
  28724. optimizeMesh?: boolean | undefined;
  28725. /**
  28726. * Creates a SimplificationSettings
  28727. * @param quality expected quality
  28728. * @param distance distance when this optimized version should be used
  28729. * @param optimizeMesh already optimized mesh
  28730. */
  28731. constructor(
  28732. /** expected quality */
  28733. quality: number,
  28734. /** distance when this optimized version should be used */
  28735. distance: number,
  28736. /** already optimized mesh */
  28737. optimizeMesh?: boolean | undefined);
  28738. }
  28739. /**
  28740. * Interface used to define a simplification task
  28741. */
  28742. interface ISimplificationTask {
  28743. /**
  28744. * Array of settings
  28745. */
  28746. settings: Array<ISimplificationSettings>;
  28747. /**
  28748. * Simplification type
  28749. */
  28750. simplificationType: SimplificationType;
  28751. /**
  28752. * Mesh to simplify
  28753. */
  28754. mesh: Mesh;
  28755. /**
  28756. * Callback called on success
  28757. */
  28758. successCallback?: () => void;
  28759. /**
  28760. * Defines if parallel processing can be used
  28761. */
  28762. parallelProcessing: boolean;
  28763. }
  28764. /**
  28765. * Queue used to order the simplification tasks
  28766. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28767. */
  28768. class SimplificationQueue {
  28769. private _simplificationArray;
  28770. /**
  28771. * Gets a boolean indicating that the process is still running
  28772. */
  28773. running: boolean;
  28774. /**
  28775. * Creates a new queue
  28776. */
  28777. constructor();
  28778. /**
  28779. * Adds a new simplification task
  28780. * @param task defines a task to add
  28781. */
  28782. addTask(task: ISimplificationTask): void;
  28783. /**
  28784. * Execute next task
  28785. */
  28786. executeNext(): void;
  28787. /**
  28788. * Execute a simplification task
  28789. * @param task defines the task to run
  28790. */
  28791. runSimplification(task: ISimplificationTask): void;
  28792. private getSimplifier;
  28793. }
  28794. /**
  28795. * The implemented types of simplification
  28796. * At the moment only Quadratic Error Decimation is implemented
  28797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28798. */
  28799. enum SimplificationType {
  28800. /** Quadratic error decimation */
  28801. QUADRATIC = 0
  28802. }
  28803. }
  28804. declare module BABYLON {
  28805. interface Scene {
  28806. /** @hidden (Backing field) */
  28807. _simplificationQueue: SimplificationQueue;
  28808. /**
  28809. * Gets or sets the simplification queue attached to the scene
  28810. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28811. */
  28812. simplificationQueue: SimplificationQueue;
  28813. }
  28814. interface Mesh {
  28815. /**
  28816. * Simplify the mesh according to the given array of settings.
  28817. * Function will return immediately and will simplify async
  28818. * @param settings a collection of simplification settings
  28819. * @param parallelProcessing should all levels calculate parallel or one after the other
  28820. * @param simplificationType the type of simplification to run
  28821. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28822. * @returns the current mesh
  28823. */
  28824. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28825. }
  28826. /**
  28827. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28828. * created in a scene
  28829. */
  28830. class SimplicationQueueSceneComponent implements ISceneComponent {
  28831. /**
  28832. * The component name helpfull to identify the component in the list of scene components.
  28833. */
  28834. readonly name: string;
  28835. /**
  28836. * The scene the component belongs to.
  28837. */
  28838. scene: Scene;
  28839. /**
  28840. * Creates a new instance of the component for the given scene
  28841. * @param scene Defines the scene to register the component in
  28842. */
  28843. constructor(scene: Scene);
  28844. /**
  28845. * Registers the component in a given scene
  28846. */
  28847. register(): void;
  28848. /**
  28849. * Rebuilds the elements related to this component in case of
  28850. * context lost for instance.
  28851. */
  28852. rebuild(): void;
  28853. /**
  28854. * Disposes the component and the associated ressources
  28855. */
  28856. dispose(): void;
  28857. private _beforeCameraUpdate;
  28858. }
  28859. }
  28860. declare module BABYLON {
  28861. /**
  28862. * Polygon
  28863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28864. */
  28865. class Polygon {
  28866. /**
  28867. * Creates a rectangle
  28868. * @param xmin bottom X coord
  28869. * @param ymin bottom Y coord
  28870. * @param xmax top X coord
  28871. * @param ymax top Y coord
  28872. * @returns points that make the resulting rectation
  28873. */
  28874. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28875. /**
  28876. * Creates a circle
  28877. * @param radius radius of circle
  28878. * @param cx scale in x
  28879. * @param cy scale in y
  28880. * @param numberOfSides number of sides that make up the circle
  28881. * @returns points that make the resulting circle
  28882. */
  28883. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28884. /**
  28885. * Creates a polygon from input string
  28886. * @param input Input polygon data
  28887. * @returns the parsed points
  28888. */
  28889. static Parse(input: string): Vector2[];
  28890. /**
  28891. * Starts building a polygon from x and y coordinates
  28892. * @param x x coordinate
  28893. * @param y y coordinate
  28894. * @returns the started path2
  28895. */
  28896. static StartingAt(x: number, y: number): Path2;
  28897. }
  28898. /**
  28899. * Builds a polygon
  28900. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28901. */
  28902. class PolygonMeshBuilder {
  28903. private _points;
  28904. private _outlinepoints;
  28905. private _holes;
  28906. private _name;
  28907. private _scene;
  28908. private _epoints;
  28909. private _eholes;
  28910. private _addToepoint;
  28911. /**
  28912. * Creates a PolygonMeshBuilder
  28913. * @param name name of the builder
  28914. * @param contours Path of the polygon
  28915. * @param scene scene to add to
  28916. */
  28917. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28918. /**
  28919. * Adds a whole within the polygon
  28920. * @param hole Array of points defining the hole
  28921. * @returns this
  28922. */
  28923. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28924. /**
  28925. * Creates the polygon
  28926. * @param updatable If the mesh should be updatable
  28927. * @param depth The depth of the mesh created
  28928. * @returns the created mesh
  28929. */
  28930. build(updatable?: boolean, depth?: number): Mesh;
  28931. /**
  28932. * Adds a side to the polygon
  28933. * @param positions points that make the polygon
  28934. * @param normals normals of the polygon
  28935. * @param uvs uvs of the polygon
  28936. * @param indices indices of the polygon
  28937. * @param bounds bounds of the polygon
  28938. * @param points points of the polygon
  28939. * @param depth depth of the polygon
  28940. * @param flip flip of the polygon
  28941. */
  28942. private addSide;
  28943. }
  28944. }
  28945. declare module BABYLON {
  28946. /**
  28947. * Base class for submeshes
  28948. */
  28949. class BaseSubMesh {
  28950. /** @hidden */
  28951. _materialDefines: Nullable<MaterialDefines>;
  28952. /** @hidden */
  28953. _materialEffect: Nullable<Effect>;
  28954. /**
  28955. * Gets associated effect
  28956. */
  28957. readonly effect: Nullable<Effect>;
  28958. /**
  28959. * Sets associated effect (effect used to render this submesh)
  28960. * @param effect defines the effect to associate with
  28961. * @param defines defines the set of defines used to compile this effect
  28962. */
  28963. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28964. }
  28965. /**
  28966. * Defines a subdivision inside a mesh
  28967. */
  28968. class SubMesh extends BaseSubMesh implements ICullable {
  28969. /** the material index to use */
  28970. materialIndex: number;
  28971. /** vertex index start */
  28972. verticesStart: number;
  28973. /** vertices count */
  28974. verticesCount: number;
  28975. /** index start */
  28976. indexStart: number;
  28977. /** indices count */
  28978. indexCount: number;
  28979. /** @hidden */
  28980. _linesIndexCount: number;
  28981. private _mesh;
  28982. private _renderingMesh;
  28983. private _boundingInfo;
  28984. private _linesIndexBuffer;
  28985. /** @hidden */
  28986. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28987. /** @hidden */
  28988. _trianglePlanes: Plane[];
  28989. /** @hidden */
  28990. _lastColliderTransformMatrix: Matrix;
  28991. /** @hidden */
  28992. _renderId: number;
  28993. /** @hidden */
  28994. _alphaIndex: number;
  28995. /** @hidden */
  28996. _distanceToCamera: number;
  28997. /** @hidden */
  28998. _id: number;
  28999. private _currentMaterial;
  29000. /**
  29001. * Add a new submesh to a mesh
  29002. * @param materialIndex defines the material index to use
  29003. * @param verticesStart defines vertex index start
  29004. * @param verticesCount defines vertices count
  29005. * @param indexStart defines index start
  29006. * @param indexCount defines indices count
  29007. * @param mesh defines the parent mesh
  29008. * @param renderingMesh defines an optional rendering mesh
  29009. * @param createBoundingBox defines if bounding box should be created for this submesh
  29010. * @returns the new submesh
  29011. */
  29012. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29013. /**
  29014. * Creates a new submesh
  29015. * @param materialIndex defines the material index to use
  29016. * @param verticesStart defines vertex index start
  29017. * @param verticesCount defines vertices count
  29018. * @param indexStart defines index start
  29019. * @param indexCount defines indices count
  29020. * @param mesh defines the parent mesh
  29021. * @param renderingMesh defines an optional rendering mesh
  29022. * @param createBoundingBox defines if bounding box should be created for this submesh
  29023. */
  29024. constructor(
  29025. /** the material index to use */
  29026. materialIndex: number,
  29027. /** vertex index start */
  29028. verticesStart: number,
  29029. /** vertices count */
  29030. verticesCount: number,
  29031. /** index start */
  29032. indexStart: number,
  29033. /** indices count */
  29034. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29035. /**
  29036. * Returns true if this submesh covers the entire parent mesh
  29037. * @ignorenaming
  29038. */
  29039. readonly IsGlobal: boolean;
  29040. /**
  29041. * Returns the submesh BoudingInfo object
  29042. * @returns current bounding info (or mesh's one if the submesh is global)
  29043. */
  29044. getBoundingInfo(): BoundingInfo;
  29045. /**
  29046. * Sets the submesh BoundingInfo
  29047. * @param boundingInfo defines the new bounding info to use
  29048. * @returns the SubMesh
  29049. */
  29050. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29051. /**
  29052. * Returns the mesh of the current submesh
  29053. * @return the parent mesh
  29054. */
  29055. getMesh(): AbstractMesh;
  29056. /**
  29057. * Returns the rendering mesh of the submesh
  29058. * @returns the rendering mesh (could be different from parent mesh)
  29059. */
  29060. getRenderingMesh(): Mesh;
  29061. /**
  29062. * Returns the submesh material
  29063. * @returns null or the current material
  29064. */
  29065. getMaterial(): Nullable<Material>;
  29066. /**
  29067. * Sets a new updated BoundingInfo object to the submesh
  29068. * @returns the SubMesh
  29069. */
  29070. refreshBoundingInfo(): SubMesh;
  29071. /** @hidden */
  29072. _checkCollision(collider: Collider): boolean;
  29073. /**
  29074. * Updates the submesh BoundingInfo
  29075. * @param world defines the world matrix to use to update the bounding info
  29076. * @returns the submesh
  29077. */
  29078. updateBoundingInfo(world: Matrix): SubMesh;
  29079. /**
  29080. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29081. * @param frustumPlanes defines the frustum planes
  29082. * @returns true if the submesh is intersecting with the frustum
  29083. */
  29084. isInFrustum(frustumPlanes: Plane[]): boolean;
  29085. /**
  29086. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29087. * @param frustumPlanes defines the frustum planes
  29088. * @returns true if the submesh is inside the frustum
  29089. */
  29090. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29091. /**
  29092. * Renders the submesh
  29093. * @param enableAlphaMode defines if alpha needs to be used
  29094. * @returns the submesh
  29095. */
  29096. render(enableAlphaMode: boolean): SubMesh;
  29097. /**
  29098. * @hidden
  29099. */
  29100. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29101. /**
  29102. * Checks if the submesh intersects with a ray
  29103. * @param ray defines the ray to test
  29104. * @returns true is the passed ray intersects the submesh bounding box
  29105. */
  29106. canIntersects(ray: Ray): boolean;
  29107. /**
  29108. * Intersects current submesh with a ray
  29109. * @param ray defines the ray to test
  29110. * @param positions defines mesh's positions array
  29111. * @param indices defines mesh's indices array
  29112. * @param fastCheck defines if only bounding info should be used
  29113. * @returns intersection info or null if no intersection
  29114. */
  29115. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29116. /** @hidden */
  29117. private _intersectLines;
  29118. /** @hidden */
  29119. private _intersectTriangles;
  29120. /** @hidden */
  29121. _rebuild(): void;
  29122. /**
  29123. * Creates a new submesh from the passed mesh
  29124. * @param newMesh defines the new hosting mesh
  29125. * @param newRenderingMesh defines an optional rendering mesh
  29126. * @returns the new submesh
  29127. */
  29128. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29129. /**
  29130. * Release associated resources
  29131. */
  29132. dispose(): void;
  29133. /**
  29134. * Creates a new submesh from indices data
  29135. * @param materialIndex the index of the main mesh material
  29136. * @param startIndex the index where to start the copy in the mesh indices array
  29137. * @param indexCount the number of indices to copy then from the startIndex
  29138. * @param mesh the main mesh to create the submesh from
  29139. * @param renderingMesh the optional rendering mesh
  29140. * @returns a new submesh
  29141. */
  29142. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29143. }
  29144. }
  29145. declare module BABYLON {
  29146. /**
  29147. * 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.
  29148. * @see https://doc.babylonjs.com/how_to/transformnode
  29149. */
  29150. class TransformNode extends Node {
  29151. /**
  29152. * Object will not rotate to face the camera
  29153. */
  29154. static BILLBOARDMODE_NONE: number;
  29155. /**
  29156. * Object will rotate to face the camera but only on the x axis
  29157. */
  29158. static BILLBOARDMODE_X: number;
  29159. /**
  29160. * Object will rotate to face the camera but only on the y axis
  29161. */
  29162. static BILLBOARDMODE_Y: number;
  29163. /**
  29164. * Object will rotate to face the camera but only on the z axis
  29165. */
  29166. static BILLBOARDMODE_Z: number;
  29167. /**
  29168. * Object will rotate to face the camera
  29169. */
  29170. static BILLBOARDMODE_ALL: number;
  29171. private _forward;
  29172. private _forwardInverted;
  29173. private _up;
  29174. private _right;
  29175. private _rightInverted;
  29176. private _position;
  29177. private _rotation;
  29178. private _rotationQuaternion;
  29179. protected _scaling: Vector3;
  29180. protected _isDirty: boolean;
  29181. private _transformToBoneReferal;
  29182. /**
  29183. * Set the billboard mode. Default is 0.
  29184. *
  29185. * | Value | Type | Description |
  29186. * | --- | --- | --- |
  29187. * | 0 | BILLBOARDMODE_NONE | |
  29188. * | 1 | BILLBOARDMODE_X | |
  29189. * | 2 | BILLBOARDMODE_Y | |
  29190. * | 4 | BILLBOARDMODE_Z | |
  29191. * | 7 | BILLBOARDMODE_ALL | |
  29192. *
  29193. */
  29194. billboardMode: number;
  29195. /**
  29196. * 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
  29197. */
  29198. scalingDeterminant: number;
  29199. /**
  29200. * Sets the distance of the object to max, often used by skybox
  29201. */
  29202. infiniteDistance: boolean;
  29203. /**
  29204. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29205. * By default the system will update normals to compensate
  29206. */
  29207. ignoreNonUniformScaling: boolean;
  29208. /** @hidden */
  29209. _poseMatrix: Matrix;
  29210. private _localWorld;
  29211. private _absolutePosition;
  29212. private _pivotMatrix;
  29213. private _pivotMatrixInverse;
  29214. private _postMultiplyPivotMatrix;
  29215. protected _isWorldMatrixFrozen: boolean;
  29216. /** @hidden */
  29217. _indexInSceneTransformNodesArray: number;
  29218. /**
  29219. * An event triggered after the world matrix is updated
  29220. */
  29221. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29222. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29223. /**
  29224. * Gets a string identifying the name of the class
  29225. * @returns "TransformNode" string
  29226. */
  29227. getClassName(): string;
  29228. /**
  29229. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29230. */
  29231. position: Vector3;
  29232. /**
  29233. * 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)).
  29234. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29235. */
  29236. rotation: Vector3;
  29237. /**
  29238. * 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)).
  29239. */
  29240. scaling: Vector3;
  29241. /**
  29242. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29243. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29244. */
  29245. rotationQuaternion: Nullable<Quaternion>;
  29246. /**
  29247. * The forward direction of that transform in world space.
  29248. */
  29249. readonly forward: Vector3;
  29250. /**
  29251. * The up direction of that transform in world space.
  29252. */
  29253. readonly up: Vector3;
  29254. /**
  29255. * The right direction of that transform in world space.
  29256. */
  29257. readonly right: Vector3;
  29258. /**
  29259. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29260. * @param matrix the matrix to copy the pose from
  29261. * @returns this TransformNode.
  29262. */
  29263. updatePoseMatrix(matrix: Matrix): TransformNode;
  29264. /**
  29265. * Returns the mesh Pose matrix.
  29266. * @returns the pose matrix
  29267. */
  29268. getPoseMatrix(): Matrix;
  29269. /** @hidden */
  29270. _isSynchronized(): boolean;
  29271. /** @hidden */
  29272. _initCache(): void;
  29273. /**
  29274. * Flag the transform node as dirty (Forcing it to update everything)
  29275. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29276. * @returns this transform node
  29277. */
  29278. markAsDirty(property: string): TransformNode;
  29279. /**
  29280. * Returns the current mesh absolute position.
  29281. * Returns a Vector3.
  29282. */
  29283. readonly absolutePosition: Vector3;
  29284. /**
  29285. * Sets a new matrix to apply before all other transformation
  29286. * @param matrix defines the transform matrix
  29287. * @returns the current TransformNode
  29288. */
  29289. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29290. /**
  29291. * Sets a new pivot matrix to the current node
  29292. * @param matrix defines the new pivot matrix to use
  29293. * @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
  29294. * @returns the current TransformNode
  29295. */
  29296. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  29297. /**
  29298. * Returns the mesh pivot matrix.
  29299. * Default : Identity.
  29300. * @returns the matrix
  29301. */
  29302. getPivotMatrix(): Matrix;
  29303. /**
  29304. * Prevents the World matrix to be computed any longer.
  29305. * @returns the TransformNode.
  29306. */
  29307. freezeWorldMatrix(): TransformNode;
  29308. /**
  29309. * Allows back the World matrix computation.
  29310. * @returns the TransformNode.
  29311. */
  29312. unfreezeWorldMatrix(): this;
  29313. /**
  29314. * True if the World matrix has been frozen.
  29315. */
  29316. readonly isWorldMatrixFrozen: boolean;
  29317. /**
  29318. * Retuns the mesh absolute position in the World.
  29319. * @returns a Vector3.
  29320. */
  29321. getAbsolutePosition(): Vector3;
  29322. /**
  29323. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29324. * @param absolutePosition the absolute position to set
  29325. * @returns the TransformNode.
  29326. */
  29327. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29328. /**
  29329. * Sets the mesh position in its local space.
  29330. * @param vector3 the position to set in localspace
  29331. * @returns the TransformNode.
  29332. */
  29333. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29334. /**
  29335. * Returns the mesh position in the local space from the current World matrix values.
  29336. * @returns a new Vector3.
  29337. */
  29338. getPositionExpressedInLocalSpace(): Vector3;
  29339. /**
  29340. * Translates the mesh along the passed Vector3 in its local space.
  29341. * @param vector3 the distance to translate in localspace
  29342. * @returns the TransformNode.
  29343. */
  29344. locallyTranslate(vector3: Vector3): TransformNode;
  29345. private static _lookAtVectorCache;
  29346. /**
  29347. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29348. * @param targetPoint the position (must be in same space as current mesh) to look at
  29349. * @param yawCor optional yaw (y-axis) correction in radians
  29350. * @param pitchCor optional pitch (x-axis) correction in radians
  29351. * @param rollCor optional roll (z-axis) correction in radians
  29352. * @param space the choosen space of the target
  29353. * @returns the TransformNode.
  29354. */
  29355. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29356. /**
  29357. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29358. * This Vector3 is expressed in the World space.
  29359. * @param localAxis axis to rotate
  29360. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29361. */
  29362. getDirection(localAxis: Vector3): Vector3;
  29363. /**
  29364. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29365. * localAxis is expressed in the mesh local space.
  29366. * result is computed in the Wordl space from the mesh World matrix.
  29367. * @param localAxis axis to rotate
  29368. * @param result the resulting transformnode
  29369. * @returns this TransformNode.
  29370. */
  29371. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29372. /**
  29373. * Sets a new pivot point to the current node
  29374. * @param point defines the new pivot point to use
  29375. * @param space defines if the point is in world or local space (local by default)
  29376. * @returns the current TransformNode
  29377. */
  29378. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29379. /**
  29380. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29381. * @returns the pivot point
  29382. */
  29383. getPivotPoint(): Vector3;
  29384. /**
  29385. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29386. * @param result the vector3 to store the result
  29387. * @returns this TransformNode.
  29388. */
  29389. getPivotPointToRef(result: Vector3): TransformNode;
  29390. /**
  29391. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29392. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29393. */
  29394. getAbsolutePivotPoint(): Vector3;
  29395. /**
  29396. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29397. * @param result vector3 to store the result
  29398. * @returns this TransformNode.
  29399. */
  29400. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29401. /**
  29402. * Defines the passed node as the parent of the current node.
  29403. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29404. * @param node the node ot set as the parent
  29405. * @returns this TransformNode.
  29406. */
  29407. setParent(node: Nullable<Node>): TransformNode;
  29408. private _nonUniformScaling;
  29409. /**
  29410. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29411. */
  29412. readonly nonUniformScaling: boolean;
  29413. /** @hidden */
  29414. _updateNonUniformScalingState(value: boolean): boolean;
  29415. /**
  29416. * Attach the current TransformNode to another TransformNode associated with a bone
  29417. * @param bone Bone affecting the TransformNode
  29418. * @param affectedTransformNode TransformNode associated with the bone
  29419. * @returns this object
  29420. */
  29421. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29422. /**
  29423. * Detach the transform node if its associated with a bone
  29424. * @returns this object
  29425. */
  29426. detachFromBone(): TransformNode;
  29427. private static _rotationAxisCache;
  29428. /**
  29429. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29430. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29431. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29432. * The passed axis is also normalized.
  29433. * @param axis the axis to rotate around
  29434. * @param amount the amount to rotate in radians
  29435. * @param space Space to rotate in (Default: local)
  29436. * @returns the TransformNode.
  29437. */
  29438. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29439. /**
  29440. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29441. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29442. * The passed axis is also normalized. .
  29443. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29444. * @param point the point to rotate around
  29445. * @param axis the axis to rotate around
  29446. * @param amount the amount to rotate in radians
  29447. * @returns the TransformNode
  29448. */
  29449. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29450. /**
  29451. * Translates the mesh along the axis vector for the passed distance in the given space.
  29452. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29453. * @param axis the axis to translate in
  29454. * @param distance the distance to translate
  29455. * @param space Space to rotate in (Default: local)
  29456. * @returns the TransformNode.
  29457. */
  29458. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29459. /**
  29460. * Adds a rotation step to the mesh current rotation.
  29461. * x, y, z are Euler angles expressed in radians.
  29462. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29463. * This means this rotation is made in the mesh local space only.
  29464. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29465. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29466. * ```javascript
  29467. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29468. * ```
  29469. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29470. * 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.
  29471. * @param x Rotation to add
  29472. * @param y Rotation to add
  29473. * @param z Rotation to add
  29474. * @returns the TransformNode.
  29475. */
  29476. addRotation(x: number, y: number, z: number): TransformNode;
  29477. /**
  29478. * Computes the world matrix of the node
  29479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29480. * @returns the world matrix
  29481. */
  29482. computeWorldMatrix(force?: boolean): Matrix;
  29483. protected _afterComputeWorldMatrix(): void;
  29484. /**
  29485. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29486. * @param func callback function to add
  29487. *
  29488. * @returns the TransformNode.
  29489. */
  29490. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29491. /**
  29492. * Removes a registered callback function.
  29493. * @param func callback function to remove
  29494. * @returns the TransformNode.
  29495. */
  29496. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29497. /**
  29498. * Clone the current transform node
  29499. * @param name Name of the new clone
  29500. * @param newParent New parent for the clone
  29501. * @param doNotCloneChildren Do not clone children hierarchy
  29502. * @returns the new transform node
  29503. */
  29504. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29505. /**
  29506. * Serializes the objects information.
  29507. * @param currentSerializationObject defines the object to serialize in
  29508. * @returns the serialized object
  29509. */
  29510. serialize(currentSerializationObject?: any): any;
  29511. /**
  29512. * Returns a new TransformNode object parsed from the source provided.
  29513. * @param parsedTransformNode is the source.
  29514. * @param scene the scne the object belongs to
  29515. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29516. * @returns a new TransformNode object parsed from the source provided.
  29517. */
  29518. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29519. /**
  29520. * Releases resources associated with this transform node.
  29521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29523. */
  29524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29525. }
  29526. }
  29527. declare module BABYLON {
  29528. /**
  29529. * Specialized buffer used to store vertex data
  29530. */
  29531. class VertexBuffer {
  29532. /** @hidden */
  29533. _buffer: Buffer;
  29534. private _kind;
  29535. private _size;
  29536. private _ownsBuffer;
  29537. private _instanced;
  29538. private _instanceDivisor;
  29539. /**
  29540. * The byte type.
  29541. */
  29542. static readonly BYTE: number;
  29543. /**
  29544. * The unsigned byte type.
  29545. */
  29546. static readonly UNSIGNED_BYTE: number;
  29547. /**
  29548. * The short type.
  29549. */
  29550. static readonly SHORT: number;
  29551. /**
  29552. * The unsigned short type.
  29553. */
  29554. static readonly UNSIGNED_SHORT: number;
  29555. /**
  29556. * The integer type.
  29557. */
  29558. static readonly INT: number;
  29559. /**
  29560. * The unsigned integer type.
  29561. */
  29562. static readonly UNSIGNED_INT: number;
  29563. /**
  29564. * The float type.
  29565. */
  29566. static readonly FLOAT: number;
  29567. /**
  29568. * Gets or sets the instance divisor when in instanced mode
  29569. */
  29570. instanceDivisor: number;
  29571. /**
  29572. * Gets the byte stride.
  29573. */
  29574. readonly byteStride: number;
  29575. /**
  29576. * Gets the byte offset.
  29577. */
  29578. readonly byteOffset: number;
  29579. /**
  29580. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29581. */
  29582. readonly normalized: boolean;
  29583. /**
  29584. * Gets the data type of each component in the array.
  29585. */
  29586. readonly type: number;
  29587. /**
  29588. * Constructor
  29589. * @param engine the engine
  29590. * @param data the data to use for this vertex buffer
  29591. * @param kind the vertex buffer kind
  29592. * @param updatable whether the data is updatable
  29593. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29594. * @param stride the stride (optional)
  29595. * @param instanced whether the buffer is instanced (optional)
  29596. * @param offset the offset of the data (optional)
  29597. * @param size the number of components (optional)
  29598. * @param type the type of the component (optional)
  29599. * @param normalized whether the data contains normalized data (optional)
  29600. * @param useBytes set to true if stride and offset are in bytes (optional)
  29601. */
  29602. 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);
  29603. /** @hidden */
  29604. _rebuild(): void;
  29605. /**
  29606. * Returns the kind of the VertexBuffer (string)
  29607. * @returns a string
  29608. */
  29609. getKind(): string;
  29610. /**
  29611. * Gets a boolean indicating if the VertexBuffer is updatable?
  29612. * @returns true if the buffer is updatable
  29613. */
  29614. isUpdatable(): boolean;
  29615. /**
  29616. * Gets current buffer's data
  29617. * @returns a DataArray or null
  29618. */
  29619. getData(): Nullable<DataArray>;
  29620. /**
  29621. * Gets underlying native buffer
  29622. * @returns underlying native buffer
  29623. */
  29624. getBuffer(): Nullable<WebGLBuffer>;
  29625. /**
  29626. * Gets the stride in float32 units (i.e. byte stride / 4).
  29627. * May not be an integer if the byte stride is not divisible by 4.
  29628. * DEPRECATED. Use byteStride instead.
  29629. * @returns the stride in float32 units
  29630. */
  29631. getStrideSize(): number;
  29632. /**
  29633. * Returns the offset as a multiple of the type byte length.
  29634. * DEPRECATED. Use byteOffset instead.
  29635. * @returns the offset in bytes
  29636. */
  29637. getOffset(): number;
  29638. /**
  29639. * Returns the number of components per vertex attribute (integer)
  29640. * @returns the size in float
  29641. */
  29642. getSize(): number;
  29643. /**
  29644. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29645. * @returns true if this buffer is instanced
  29646. */
  29647. getIsInstanced(): boolean;
  29648. /**
  29649. * Returns the instancing divisor, zero for non-instanced (integer).
  29650. * @returns a number
  29651. */
  29652. getInstanceDivisor(): number;
  29653. /**
  29654. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29655. * @param data defines the data to store
  29656. */
  29657. create(data?: DataArray): void;
  29658. /**
  29659. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29660. * This function will create a new buffer if the current one is not updatable
  29661. * @param data defines the data to store
  29662. */
  29663. update(data: DataArray): void;
  29664. /**
  29665. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29666. * Returns the directly updated WebGLBuffer.
  29667. * @param data the new data
  29668. * @param offset the new offset
  29669. * @param useBytes set to true if the offset is in bytes
  29670. */
  29671. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29672. /**
  29673. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29674. */
  29675. dispose(): void;
  29676. /**
  29677. * Enumerates each value of this vertex buffer as numbers.
  29678. * @param count the number of values to enumerate
  29679. * @param callback the callback function called for each value
  29680. */
  29681. forEach(count: number, callback: (value: number, index: number) => void): void;
  29682. /**
  29683. * Positions
  29684. */
  29685. static readonly PositionKind: string;
  29686. /**
  29687. * Normals
  29688. */
  29689. static readonly NormalKind: string;
  29690. /**
  29691. * Tangents
  29692. */
  29693. static readonly TangentKind: string;
  29694. /**
  29695. * Texture coordinates
  29696. */
  29697. static readonly UVKind: string;
  29698. /**
  29699. * Texture coordinates 2
  29700. */
  29701. static readonly UV2Kind: string;
  29702. /**
  29703. * Texture coordinates 3
  29704. */
  29705. static readonly UV3Kind: string;
  29706. /**
  29707. * Texture coordinates 4
  29708. */
  29709. static readonly UV4Kind: string;
  29710. /**
  29711. * Texture coordinates 5
  29712. */
  29713. static readonly UV5Kind: string;
  29714. /**
  29715. * Texture coordinates 6
  29716. */
  29717. static readonly UV6Kind: string;
  29718. /**
  29719. * Colors
  29720. */
  29721. static readonly ColorKind: string;
  29722. /**
  29723. * Matrix indices (for bones)
  29724. */
  29725. static readonly MatricesIndicesKind: string;
  29726. /**
  29727. * Matrix weights (for bones)
  29728. */
  29729. static readonly MatricesWeightsKind: string;
  29730. /**
  29731. * Additional matrix indices (for bones)
  29732. */
  29733. static readonly MatricesIndicesExtraKind: string;
  29734. /**
  29735. * Additional matrix weights (for bones)
  29736. */
  29737. static readonly MatricesWeightsExtraKind: string;
  29738. /**
  29739. * Deduces the stride given a kind.
  29740. * @param kind The kind string to deduce
  29741. * @returns The deduced stride
  29742. */
  29743. static DeduceStride(kind: string): number;
  29744. /**
  29745. * Gets the byte length of the given type.
  29746. * @param type the type
  29747. * @returns the number of bytes
  29748. */
  29749. static GetTypeByteLength(type: number): number;
  29750. /**
  29751. * Enumerates each value of the given parameters as numbers.
  29752. * @param data the data to enumerate
  29753. * @param byteOffset the byte offset of the data
  29754. * @param byteStride the byte stride of the data
  29755. * @param componentCount the number of components per element
  29756. * @param componentType the type of the component
  29757. * @param count the total number of components
  29758. * @param normalized whether the data is normalized
  29759. * @param callback the callback function called for each value
  29760. */
  29761. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29762. private static _GetFloatValue;
  29763. }
  29764. }
  29765. declare module BABYLON {
  29766. /**
  29767. * This represents the base class for particle system in Babylon.
  29768. * 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.
  29769. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  29770. * @example https://doc.babylonjs.com/babylon101/particles
  29771. */
  29772. class BaseParticleSystem {
  29773. /**
  29774. * Source color is added to the destination color without alpha affecting the result
  29775. */
  29776. static BLENDMODE_ONEONE: number;
  29777. /**
  29778. * Blend current color and particle color using particle’s alpha
  29779. */
  29780. static BLENDMODE_STANDARD: number;
  29781. /**
  29782. * Add current color and particle color multiplied by particle’s alpha
  29783. */
  29784. static BLENDMODE_ADD: number;
  29785. /**
  29786. * Multiply current color with particle color
  29787. */
  29788. static BLENDMODE_MULTIPLY: number;
  29789. /**
  29790. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29791. */
  29792. static BLENDMODE_MULTIPLYADD: number;
  29793. /**
  29794. * List of animations used by the particle system.
  29795. */
  29796. animations: Animation[];
  29797. /**
  29798. * The id of the Particle system.
  29799. */
  29800. id: string;
  29801. /**
  29802. * The friendly name of the Particle system.
  29803. */
  29804. name: string;
  29805. /**
  29806. * The rendering group used by the Particle system to chose when to render.
  29807. */
  29808. renderingGroupId: number;
  29809. /**
  29810. * The emitter represents the Mesh or position we are attaching the particle system to.
  29811. */
  29812. emitter: Nullable<AbstractMesh | Vector3>;
  29813. /**
  29814. * The maximum number of particles to emit per frame
  29815. */
  29816. emitRate: number;
  29817. /**
  29818. * If you want to launch only a few particles at once, that can be done, as well.
  29819. */
  29820. manualEmitCount: number;
  29821. /**
  29822. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29823. */
  29824. updateSpeed: number;
  29825. /**
  29826. * The amount of time the particle system is running (depends of the overall update speed).
  29827. */
  29828. targetStopDuration: number;
  29829. /**
  29830. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29831. */
  29832. disposeOnStop: boolean;
  29833. /**
  29834. * Minimum power of emitting particles.
  29835. */
  29836. minEmitPower: number;
  29837. /**
  29838. * Maximum power of emitting particles.
  29839. */
  29840. maxEmitPower: number;
  29841. /**
  29842. * Minimum life time of emitting particles.
  29843. */
  29844. minLifeTime: number;
  29845. /**
  29846. * Maximum life time of emitting particles.
  29847. */
  29848. maxLifeTime: number;
  29849. /**
  29850. * Minimum Size of emitting particles.
  29851. */
  29852. minSize: number;
  29853. /**
  29854. * Maximum Size of emitting particles.
  29855. */
  29856. maxSize: number;
  29857. /**
  29858. * Minimum scale of emitting particles on X axis.
  29859. */
  29860. minScaleX: number;
  29861. /**
  29862. * Maximum scale of emitting particles on X axis.
  29863. */
  29864. maxScaleX: number;
  29865. /**
  29866. * Minimum scale of emitting particles on Y axis.
  29867. */
  29868. minScaleY: number;
  29869. /**
  29870. * Maximum scale of emitting particles on Y axis.
  29871. */
  29872. maxScaleY: number;
  29873. /**
  29874. * Gets or sets the minimal initial rotation in radians.
  29875. */
  29876. minInitialRotation: number;
  29877. /**
  29878. * Gets or sets the maximal initial rotation in radians.
  29879. */
  29880. maxInitialRotation: number;
  29881. /**
  29882. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29883. */
  29884. minAngularSpeed: number;
  29885. /**
  29886. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29887. */
  29888. maxAngularSpeed: number;
  29889. /**
  29890. * The texture used to render each particle. (this can be a spritesheet)
  29891. */
  29892. particleTexture: Nullable<Texture>;
  29893. /**
  29894. * The layer mask we are rendering the particles through.
  29895. */
  29896. layerMask: number;
  29897. /**
  29898. * This can help using your own shader to render the particle system.
  29899. * The according effect will be created
  29900. */
  29901. customShader: any;
  29902. /**
  29903. * By default particle system starts as soon as they are created. This prevents the
  29904. * automatic start to happen and let you decide when to start emitting particles.
  29905. */
  29906. preventAutoStart: boolean;
  29907. /**
  29908. * Gets or sets a texture used to add random noise to particle positions
  29909. */
  29910. noiseTexture: Nullable<ProceduralTexture>;
  29911. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29912. noiseStrength: Vector3;
  29913. /**
  29914. * Callback triggered when the particle animation is ending.
  29915. */
  29916. onAnimationEnd: Nullable<() => void>;
  29917. /**
  29918. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  29919. */
  29920. blendMode: number;
  29921. /**
  29922. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29923. * to override the particles.
  29924. */
  29925. forceDepthWrite: boolean;
  29926. /** 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 */
  29927. preWarmCycles: number;
  29928. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  29929. preWarmStepOffset: number;
  29930. /**
  29931. * 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)
  29932. */
  29933. spriteCellChangeSpeed: number;
  29934. /**
  29935. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29936. */
  29937. startSpriteCellID: number;
  29938. /**
  29939. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29940. */
  29941. endSpriteCellID: number;
  29942. /**
  29943. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29944. */
  29945. spriteCellWidth: number;
  29946. /**
  29947. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29948. */
  29949. spriteCellHeight: number;
  29950. /**
  29951. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29952. */
  29953. spriteRandomStartCell: boolean;
  29954. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  29955. translationPivot: Vector2;
  29956. /** @hidden */
  29957. protected _isAnimationSheetEnabled: boolean;
  29958. /**
  29959. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  29960. */
  29961. beginAnimationOnStart: boolean;
  29962. /**
  29963. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  29964. */
  29965. beginAnimationFrom: number;
  29966. /**
  29967. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  29968. */
  29969. beginAnimationTo: number;
  29970. /**
  29971. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  29972. */
  29973. beginAnimationLoop: boolean;
  29974. /**
  29975. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  29976. */
  29977. isAnimationSheetEnabled: boolean;
  29978. /**
  29979. * Get hosting scene
  29980. * @returns the scene
  29981. */
  29982. getScene(): Scene;
  29983. /**
  29984. * You can use gravity if you want to give an orientation to your particles.
  29985. */
  29986. gravity: Vector3;
  29987. protected _colorGradients: Nullable<Array<ColorGradient>>;
  29988. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  29989. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  29990. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  29991. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  29992. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  29993. protected _dragGradients: Nullable<Array<FactorGradient>>;
  29994. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  29995. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  29996. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  29997. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  29998. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  29999. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30000. /**
  30001. * Defines the delay in milliseconds before starting the system (0 by default)
  30002. */
  30003. startDelay: number;
  30004. /**
  30005. * Gets the current list of drag gradients.
  30006. * You must use addDragGradient and removeDragGradient to udpate this list
  30007. * @returns the list of drag gradients
  30008. */
  30009. getDragGradients(): Nullable<Array<FactorGradient>>;
  30010. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30011. limitVelocityDamping: number;
  30012. /**
  30013. * Gets the current list of limit velocity gradients.
  30014. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30015. * @returns the list of limit velocity gradients
  30016. */
  30017. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30018. /**
  30019. * Gets the current list of color gradients.
  30020. * You must use addColorGradient and removeColorGradient to udpate this list
  30021. * @returns the list of color gradients
  30022. */
  30023. getColorGradients(): Nullable<Array<ColorGradient>>;
  30024. /**
  30025. * Gets the current list of size gradients.
  30026. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30027. * @returns the list of size gradients
  30028. */
  30029. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30030. /**
  30031. * Gets the current list of color remap gradients.
  30032. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30033. * @returns the list of color remap gradients
  30034. */
  30035. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30036. /**
  30037. * Gets the current list of alpha remap gradients.
  30038. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30039. * @returns the list of alpha remap gradients
  30040. */
  30041. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30042. /**
  30043. * Gets the current list of life time gradients.
  30044. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30045. * @returns the list of life time gradients
  30046. */
  30047. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30048. /**
  30049. * Gets the current list of angular speed gradients.
  30050. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30051. * @returns the list of angular speed gradients
  30052. */
  30053. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30054. /**
  30055. * Gets the current list of velocity gradients.
  30056. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30057. * @returns the list of velocity gradients
  30058. */
  30059. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30060. /**
  30061. * Gets the current list of start size gradients.
  30062. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30063. * @returns the list of start size gradients
  30064. */
  30065. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30066. /**
  30067. * Gets the current list of emit rate gradients.
  30068. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30069. * @returns the list of emit rate gradients
  30070. */
  30071. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30072. /**
  30073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30075. */
  30076. direction1: Vector3;
  30077. /**
  30078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30080. */
  30081. direction2: Vector3;
  30082. /**
  30083. * 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.
  30084. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30085. */
  30086. minEmitBox: Vector3;
  30087. /**
  30088. * 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.
  30089. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30090. */
  30091. maxEmitBox: Vector3;
  30092. /**
  30093. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30094. */
  30095. color1: Color4;
  30096. /**
  30097. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30098. */
  30099. color2: Color4;
  30100. /**
  30101. * Color the particle will have at the end of its lifetime
  30102. */
  30103. colorDead: Color4;
  30104. /**
  30105. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30106. */
  30107. textureMask: Color4;
  30108. /**
  30109. * The particle emitter type defines the emitter used by the particle system.
  30110. * It can be for example box, sphere, or cone...
  30111. */
  30112. particleEmitterType: IParticleEmitterType;
  30113. /** @hidden */
  30114. _isSubEmitter: boolean;
  30115. /**
  30116. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30117. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30118. */
  30119. billboardMode: number;
  30120. protected _isBillboardBased: boolean;
  30121. /**
  30122. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30123. */
  30124. isBillboardBased: boolean;
  30125. /**
  30126. * The scene the particle system belongs to.
  30127. */
  30128. protected _scene: Scene;
  30129. /**
  30130. * Local cache of defines for image processing.
  30131. */
  30132. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30133. /**
  30134. * Default configuration related to image processing available in the standard Material.
  30135. */
  30136. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30137. /**
  30138. * Gets the image processing configuration used either in this material.
  30139. */
  30140. /**
  30141. * Sets the Default image processing configuration used either in the this material.
  30142. *
  30143. * If sets to null, the scene one is in use.
  30144. */
  30145. imageProcessingConfiguration: ImageProcessingConfiguration;
  30146. /**
  30147. * Attaches a new image processing configuration to the Standard Material.
  30148. * @param configuration
  30149. */
  30150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30151. /** @hidden */
  30152. protected _reset(): void;
  30153. /** @hidden */
  30154. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30155. /**
  30156. * Instantiates a particle system.
  30157. * 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.
  30158. * @param name The name of the particle system
  30159. */
  30160. constructor(name: string);
  30161. /**
  30162. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30165. * @returns the emitter
  30166. */
  30167. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30168. /**
  30169. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30170. * @param radius The radius of the hemisphere to emit from
  30171. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30172. * @returns the emitter
  30173. */
  30174. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30175. /**
  30176. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30177. * @param radius The radius of the sphere to emit from
  30178. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30179. * @returns the emitter
  30180. */
  30181. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30182. /**
  30183. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30184. * @param radius The radius of the sphere to emit from
  30185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30187. * @returns the emitter
  30188. */
  30189. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30190. /**
  30191. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30192. * @param radius The radius of the emission cylinder
  30193. * @param height The height of the emission cylinder
  30194. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30195. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30196. * @returns the emitter
  30197. */
  30198. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30199. /**
  30200. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30201. * @param radius The radius of the cylinder to emit from
  30202. * @param height The height of the emission cylinder
  30203. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30204. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30205. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30206. * @returns the emitter
  30207. */
  30208. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30209. /**
  30210. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30211. * @param radius The radius of the cone to emit from
  30212. * @param angle The base angle of the cone
  30213. * @returns the emitter
  30214. */
  30215. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30216. /**
  30217. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30218. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30219. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30220. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30221. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30222. * @returns the emitter
  30223. */
  30224. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30225. }
  30226. }
  30227. declare module BABYLON {
  30228. /**
  30229. * This represents a GPU particle system in Babylon
  30230. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30231. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30232. */
  30233. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30234. /**
  30235. * The layer mask we are rendering the particles through.
  30236. */
  30237. layerMask: number;
  30238. private _capacity;
  30239. private _activeCount;
  30240. private _currentActiveCount;
  30241. private _accumulatedCount;
  30242. private _renderEffect;
  30243. private _updateEffect;
  30244. private _buffer0;
  30245. private _buffer1;
  30246. private _spriteBuffer;
  30247. private _updateVAO;
  30248. private _renderVAO;
  30249. private _targetIndex;
  30250. private _sourceBuffer;
  30251. private _targetBuffer;
  30252. private _engine;
  30253. private _currentRenderId;
  30254. private _started;
  30255. private _stopped;
  30256. private _timeDelta;
  30257. private _randomTexture;
  30258. private _randomTexture2;
  30259. private _attributesStrideSize;
  30260. private _updateEffectOptions;
  30261. private _randomTextureSize;
  30262. private _actualFrame;
  30263. private readonly _rawTextureWidth;
  30264. /**
  30265. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30266. */
  30267. static readonly IsSupported: boolean;
  30268. /**
  30269. * An event triggered when the system is disposed.
  30270. */
  30271. onDisposeObservable: Observable<GPUParticleSystem>;
  30272. /**
  30273. * Gets the maximum number of particles active at the same time.
  30274. * @returns The max number of active particles.
  30275. */
  30276. getCapacity(): number;
  30277. /**
  30278. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30279. * to override the particles.
  30280. */
  30281. forceDepthWrite: boolean;
  30282. /**
  30283. * Gets or set the number of active particles
  30284. */
  30285. activeParticleCount: number;
  30286. private _preWarmDone;
  30287. /**
  30288. * Is this system ready to be used/rendered
  30289. * @return true if the system is ready
  30290. */
  30291. isReady(): boolean;
  30292. /**
  30293. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30294. * @returns True if it has been started, otherwise false.
  30295. */
  30296. isStarted(): boolean;
  30297. /**
  30298. * Starts the particle system and begins to emit
  30299. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30300. */
  30301. start(delay?: number): void;
  30302. /**
  30303. * Stops the particle system.
  30304. */
  30305. stop(): void;
  30306. /**
  30307. * Remove all active particles
  30308. */
  30309. reset(): void;
  30310. /**
  30311. * Returns the string "GPUParticleSystem"
  30312. * @returns a string containing the class name
  30313. */
  30314. getClassName(): string;
  30315. private _colorGradientsTexture;
  30316. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30317. /**
  30318. * Adds a new color gradient
  30319. * @param gradient defines the gradient to use (between 0 and 1)
  30320. * @param color1 defines the color to affect to the specified gradient
  30321. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30322. * @returns the current particle system
  30323. */
  30324. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30325. /**
  30326. * Remove a specific color gradient
  30327. * @param gradient defines the gradient to remove
  30328. * @returns the current particle system
  30329. */
  30330. removeColorGradient(gradient: number): GPUParticleSystem;
  30331. private _angularSpeedGradientsTexture;
  30332. private _sizeGradientsTexture;
  30333. private _velocityGradientsTexture;
  30334. private _limitVelocityGradientsTexture;
  30335. private _dragGradientsTexture;
  30336. private _addFactorGradient;
  30337. /**
  30338. * Adds a new size gradient
  30339. * @param gradient defines the gradient to use (between 0 and 1)
  30340. * @param factor defines the size factor to affect to the specified gradient
  30341. * @returns the current particle system
  30342. */
  30343. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30344. /**
  30345. * Remove a specific size gradient
  30346. * @param gradient defines the gradient to remove
  30347. * @returns the current particle system
  30348. */
  30349. removeSizeGradient(gradient: number): GPUParticleSystem;
  30350. /**
  30351. * Adds a new angular speed gradient
  30352. * @param gradient defines the gradient to use (between 0 and 1)
  30353. * @param factor defines the angular speed to affect to the specified gradient
  30354. * @returns the current particle system
  30355. */
  30356. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30357. /**
  30358. * Remove a specific angular speed gradient
  30359. * @param gradient defines the gradient to remove
  30360. * @returns the current particle system
  30361. */
  30362. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30363. /**
  30364. * Adds a new velocity gradient
  30365. * @param gradient defines the gradient to use (between 0 and 1)
  30366. * @param factor defines the velocity to affect to the specified gradient
  30367. * @returns the current particle system
  30368. */
  30369. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30370. /**
  30371. * Remove a specific velocity gradient
  30372. * @param gradient defines the gradient to remove
  30373. * @returns the current particle system
  30374. */
  30375. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30376. /**
  30377. * Adds a new limit velocity gradient
  30378. * @param gradient defines the gradient to use (between 0 and 1)
  30379. * @param factor defines the limit velocity value to affect to the specified gradient
  30380. * @returns the current particle system
  30381. */
  30382. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30383. /**
  30384. * Remove a specific limit velocity gradient
  30385. * @param gradient defines the gradient to remove
  30386. * @returns the current particle system
  30387. */
  30388. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30389. /**
  30390. * Adds a new drag gradient
  30391. * @param gradient defines the gradient to use (between 0 and 1)
  30392. * @param factor defines the drag value to affect to the specified gradient
  30393. * @returns the current particle system
  30394. */
  30395. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30396. /**
  30397. * Remove a specific drag gradient
  30398. * @param gradient defines the gradient to remove
  30399. * @returns the current particle system
  30400. */
  30401. removeDragGradient(gradient: number): GPUParticleSystem;
  30402. /**
  30403. * Not supported by GPUParticleSystem
  30404. * @param gradient defines the gradient to use (between 0 and 1)
  30405. * @param factor defines the emit rate value to affect to the specified gradient
  30406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30407. * @returns the current particle system
  30408. */
  30409. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30410. /**
  30411. * Not supported by GPUParticleSystem
  30412. * @param gradient defines the gradient to remove
  30413. * @returns the current particle system
  30414. */
  30415. removeEmitRateGradient(gradient: number): IParticleSystem;
  30416. /**
  30417. * Not supported by GPUParticleSystem
  30418. * @param gradient defines the gradient to use (between 0 and 1)
  30419. * @param factor defines the start size value to affect to the specified gradient
  30420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30421. * @returns the current particle system
  30422. */
  30423. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30424. /**
  30425. * Not supported by GPUParticleSystem
  30426. * @param gradient defines the gradient to remove
  30427. * @returns the current particle system
  30428. */
  30429. removeStartSizeGradient(gradient: number): IParticleSystem;
  30430. /**
  30431. * Not supported by GPUParticleSystem
  30432. * @param gradient defines the gradient to use (between 0 and 1)
  30433. * @param min defines the color remap minimal range
  30434. * @param max defines the color remap maximal range
  30435. * @returns the current particle system
  30436. */
  30437. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30438. /**
  30439. * Not supported by GPUParticleSystem
  30440. * @param gradient defines the gradient to remove
  30441. * @returns the current particle system
  30442. */
  30443. removeColorRemapGradient(gradient: number): IParticleSystem;
  30444. /**
  30445. * Not supported by GPUParticleSystem
  30446. * @param gradient defines the gradient to use (between 0 and 1)
  30447. * @param min defines the alpha remap minimal range
  30448. * @param max defines the alpha remap maximal range
  30449. * @returns the current particle system
  30450. */
  30451. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30452. /**
  30453. * Not supported by GPUParticleSystem
  30454. * @param gradient defines the gradient to remove
  30455. * @returns the current particle system
  30456. */
  30457. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30458. /**
  30459. * Not supported by GPUParticleSystem
  30460. * @param gradient defines the gradient to use (between 0 and 1)
  30461. * @param color defines the color to affect to the specified gradient
  30462. * @returns the current particle system
  30463. */
  30464. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30465. /**
  30466. * Not supported by GPUParticleSystem
  30467. * @param gradient defines the gradient to remove
  30468. * @returns the current particle system
  30469. */
  30470. removeRampGradient(gradient: number): IParticleSystem;
  30471. /**
  30472. * Not supported by GPUParticleSystem
  30473. * @returns the list of ramp gradients
  30474. */
  30475. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30476. /**
  30477. * Not supported by GPUParticleSystem
  30478. * Gets or sets a boolean indicating that ramp gradients must be used
  30479. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30480. */
  30481. useRampGradients: boolean;
  30482. /**
  30483. * Not supported by GPUParticleSystem
  30484. * @param gradient defines the gradient to use (between 0 and 1)
  30485. * @param factor defines the life time factor to affect to the specified gradient
  30486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30487. * @returns the current particle system
  30488. */
  30489. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30490. /**
  30491. * Not supported by GPUParticleSystem
  30492. * @param gradient defines the gradient to remove
  30493. * @returns the current particle system
  30494. */
  30495. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30496. /**
  30497. * Instantiates a GPU particle system.
  30498. * 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.
  30499. * @param name The name of the particle system
  30500. * @param options The options used to create the system
  30501. * @param scene The scene the particle system belongs to
  30502. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30503. */
  30504. constructor(name: string, options: Partial<{
  30505. capacity: number;
  30506. randomTextureSize: number;
  30507. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30508. protected _reset(): void;
  30509. private _createUpdateVAO;
  30510. private _createRenderVAO;
  30511. private _initialize;
  30512. /** @hidden */
  30513. _recreateUpdateEffect(): void;
  30514. /** @hidden */
  30515. _recreateRenderEffect(): void;
  30516. /**
  30517. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30518. * @param preWarm defines if we are in the pre-warmimg phase
  30519. */
  30520. animate(preWarm?: boolean): void;
  30521. private _createFactorGradientTexture;
  30522. private _createSizeGradientTexture;
  30523. private _createAngularSpeedGradientTexture;
  30524. private _createVelocityGradientTexture;
  30525. private _createLimitVelocityGradientTexture;
  30526. private _createDragGradientTexture;
  30527. private _createColorGradientTexture;
  30528. /**
  30529. * Renders the particle system in its current state
  30530. * @param preWarm defines if the system should only update the particles but not render them
  30531. * @returns the current number of particles
  30532. */
  30533. render(preWarm?: boolean): number;
  30534. /**
  30535. * Rebuilds the particle system
  30536. */
  30537. rebuild(): void;
  30538. private _releaseBuffers;
  30539. private _releaseVAOs;
  30540. /**
  30541. * Disposes the particle system and free the associated resources
  30542. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30543. */
  30544. dispose(disposeTexture?: boolean): void;
  30545. /**
  30546. * Clones the particle system.
  30547. * @param name The name of the cloned object
  30548. * @param newEmitter The new emitter to use
  30549. * @returns the cloned particle system
  30550. */
  30551. clone(name: string, newEmitter: any): GPUParticleSystem;
  30552. /**
  30553. * Serializes the particle system to a JSON object.
  30554. * @returns the JSON object
  30555. */
  30556. serialize(): any;
  30557. /**
  30558. * Parses a JSON object to create a GPU particle system.
  30559. * @param parsedParticleSystem The JSON object to parse
  30560. * @param scene The scene to create the particle system in
  30561. * @param rootUrl The root url to use to load external dependencies like texture
  30562. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30563. * @returns the parsed GPU particle system
  30564. */
  30565. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30566. }
  30567. }
  30568. declare module BABYLON {
  30569. /**
  30570. * Interface representing a particle system in Babylon.js.
  30571. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30572. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30573. */
  30574. interface IParticleSystem {
  30575. /**
  30576. * List of animations used by the particle system.
  30577. */
  30578. animations: Animation[];
  30579. /**
  30580. * The id of the Particle system.
  30581. */
  30582. id: string;
  30583. /**
  30584. * The name of the Particle system.
  30585. */
  30586. name: string;
  30587. /**
  30588. * The emitter represents the Mesh or position we are attaching the particle system to.
  30589. */
  30590. emitter: Nullable<AbstractMesh | Vector3>;
  30591. /**
  30592. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30593. */
  30594. isBillboardBased: boolean;
  30595. /**
  30596. * The rendering group used by the Particle system to chose when to render.
  30597. */
  30598. renderingGroupId: number;
  30599. /**
  30600. * The layer mask we are rendering the particles through.
  30601. */
  30602. layerMask: number;
  30603. /**
  30604. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30605. */
  30606. updateSpeed: number;
  30607. /**
  30608. * The amount of time the particle system is running (depends of the overall update speed).
  30609. */
  30610. targetStopDuration: number;
  30611. /**
  30612. * The texture used to render each particle. (this can be a spritesheet)
  30613. */
  30614. particleTexture: Nullable<Texture>;
  30615. /**
  30616. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30617. */
  30618. blendMode: number;
  30619. /**
  30620. * Minimum life time of emitting particles.
  30621. */
  30622. minLifeTime: number;
  30623. /**
  30624. * Maximum life time of emitting particles.
  30625. */
  30626. maxLifeTime: number;
  30627. /**
  30628. * Minimum Size of emitting particles.
  30629. */
  30630. minSize: number;
  30631. /**
  30632. * Maximum Size of emitting particles.
  30633. */
  30634. maxSize: number;
  30635. /**
  30636. * Minimum scale of emitting particles on X axis.
  30637. */
  30638. minScaleX: number;
  30639. /**
  30640. * Maximum scale of emitting particles on X axis.
  30641. */
  30642. maxScaleX: number;
  30643. /**
  30644. * Minimum scale of emitting particles on Y axis.
  30645. */
  30646. minScaleY: number;
  30647. /**
  30648. * Maximum scale of emitting particles on Y axis.
  30649. */
  30650. maxScaleY: number;
  30651. /**
  30652. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30653. */
  30654. color1: Color4;
  30655. /**
  30656. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30657. */
  30658. color2: Color4;
  30659. /**
  30660. * Color the particle will have at the end of its lifetime.
  30661. */
  30662. colorDead: Color4;
  30663. /**
  30664. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30665. */
  30666. emitRate: number;
  30667. /**
  30668. * You can use gravity if you want to give an orientation to your particles.
  30669. */
  30670. gravity: Vector3;
  30671. /**
  30672. * Minimum power of emitting particles.
  30673. */
  30674. minEmitPower: number;
  30675. /**
  30676. * Maximum power of emitting particles.
  30677. */
  30678. maxEmitPower: number;
  30679. /**
  30680. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30681. */
  30682. minAngularSpeed: number;
  30683. /**
  30684. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30685. */
  30686. maxAngularSpeed: number;
  30687. /**
  30688. * Gets or sets the minimal initial rotation in radians.
  30689. */
  30690. minInitialRotation: number;
  30691. /**
  30692. * Gets or sets the maximal initial rotation in radians.
  30693. */
  30694. maxInitialRotation: number;
  30695. /**
  30696. * The particle emitter type defines the emitter used by the particle system.
  30697. * It can be for example box, sphere, or cone...
  30698. */
  30699. particleEmitterType: Nullable<IParticleEmitterType>;
  30700. /**
  30701. * Defines the delay in milliseconds before starting the system (0 by default)
  30702. */
  30703. startDelay: number;
  30704. /**
  30705. * 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
  30706. */
  30707. preWarmCycles: number;
  30708. /**
  30709. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30710. */
  30711. preWarmStepOffset: number;
  30712. /**
  30713. * 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)
  30714. */
  30715. spriteCellChangeSpeed: number;
  30716. /**
  30717. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30718. */
  30719. startSpriteCellID: number;
  30720. /**
  30721. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30722. */
  30723. endSpriteCellID: number;
  30724. /**
  30725. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30726. */
  30727. spriteCellWidth: number;
  30728. /**
  30729. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30730. */
  30731. spriteCellHeight: number;
  30732. /**
  30733. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30734. */
  30735. spriteRandomStartCell: boolean;
  30736. /**
  30737. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  30738. */
  30739. isAnimationSheetEnabled: boolean;
  30740. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30741. translationPivot: Vector2;
  30742. /**
  30743. * Gets or sets a texture used to add random noise to particle positions
  30744. */
  30745. noiseTexture: Nullable<BaseTexture>;
  30746. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30747. noiseStrength: Vector3;
  30748. /**
  30749. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30750. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30751. */
  30752. billboardMode: number;
  30753. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30754. limitVelocityDamping: number;
  30755. /**
  30756. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30757. */
  30758. beginAnimationOnStart: boolean;
  30759. /**
  30760. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30761. */
  30762. beginAnimationFrom: number;
  30763. /**
  30764. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30765. */
  30766. beginAnimationTo: number;
  30767. /**
  30768. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30769. */
  30770. beginAnimationLoop: boolean;
  30771. /**
  30772. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30773. */
  30774. disposeOnStop: boolean;
  30775. /**
  30776. * Gets the maximum number of particles active at the same time.
  30777. * @returns The max number of active particles.
  30778. */
  30779. getCapacity(): number;
  30780. /**
  30781. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30782. * @returns True if it has been started, otherwise false.
  30783. */
  30784. isStarted(): boolean;
  30785. /**
  30786. * Animates the particle system for this frame.
  30787. */
  30788. animate(): void;
  30789. /**
  30790. * Renders the particle system in its current state.
  30791. * @returns the current number of particles
  30792. */
  30793. render(): number;
  30794. /**
  30795. * Dispose the particle system and frees its associated resources.
  30796. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30797. */
  30798. dispose(disposeTexture?: boolean): void;
  30799. /**
  30800. * Clones the particle system.
  30801. * @param name The name of the cloned object
  30802. * @param newEmitter The new emitter to use
  30803. * @returns the cloned particle system
  30804. */
  30805. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  30806. /**
  30807. * Serializes the particle system to a JSON object.
  30808. * @returns the JSON object
  30809. */
  30810. serialize(): any;
  30811. /**
  30812. * Rebuild the particle system
  30813. */
  30814. rebuild(): void;
  30815. /**
  30816. * Starts the particle system and begins to emit
  30817. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  30818. */
  30819. start(delay?: number): void;
  30820. /**
  30821. * Stops the particle system.
  30822. */
  30823. stop(): void;
  30824. /**
  30825. * Remove all active particles
  30826. */
  30827. reset(): void;
  30828. /**
  30829. * Is this system ready to be used/rendered
  30830. * @return true if the system is ready
  30831. */
  30832. isReady(): boolean;
  30833. /**
  30834. * Adds a new color gradient
  30835. * @param gradient defines the gradient to use (between 0 and 1)
  30836. * @param color1 defines the color to affect to the specified gradient
  30837. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30838. * @returns the current particle system
  30839. */
  30840. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30841. /**
  30842. * Remove a specific color gradient
  30843. * @param gradient defines the gradient to remove
  30844. * @returns the current particle system
  30845. */
  30846. removeColorGradient(gradient: number): IParticleSystem;
  30847. /**
  30848. * Adds a new size gradient
  30849. * @param gradient defines the gradient to use (between 0 and 1)
  30850. * @param factor defines the size factor to affect to the specified gradient
  30851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30852. * @returns the current particle system
  30853. */
  30854. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30855. /**
  30856. * Remove a specific size gradient
  30857. * @param gradient defines the gradient to remove
  30858. * @returns the current particle system
  30859. */
  30860. removeSizeGradient(gradient: number): IParticleSystem;
  30861. /**
  30862. * Gets the current list of color gradients.
  30863. * You must use addColorGradient and removeColorGradient to udpate this list
  30864. * @returns the list of color gradients
  30865. */
  30866. getColorGradients(): Nullable<Array<ColorGradient>>;
  30867. /**
  30868. * Gets the current list of size gradients.
  30869. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30870. * @returns the list of size gradients
  30871. */
  30872. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30873. /**
  30874. * Gets the current list of angular speed gradients.
  30875. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30876. * @returns the list of angular speed gradients
  30877. */
  30878. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30879. /**
  30880. * Adds a new angular speed gradient
  30881. * @param gradient defines the gradient to use (between 0 and 1)
  30882. * @param factor defines the angular speed to affect to the specified gradient
  30883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30884. * @returns the current particle system
  30885. */
  30886. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30887. /**
  30888. * Remove a specific angular speed gradient
  30889. * @param gradient defines the gradient to remove
  30890. * @returns the current particle system
  30891. */
  30892. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30893. /**
  30894. * Gets the current list of velocity gradients.
  30895. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30896. * @returns the list of velocity gradients
  30897. */
  30898. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30899. /**
  30900. * Adds a new velocity gradient
  30901. * @param gradient defines the gradient to use (between 0 and 1)
  30902. * @param factor defines the velocity to affect to the specified gradient
  30903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30904. * @returns the current particle system
  30905. */
  30906. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30907. /**
  30908. * Remove a specific velocity gradient
  30909. * @param gradient defines the gradient to remove
  30910. * @returns the current particle system
  30911. */
  30912. removeVelocityGradient(gradient: number): IParticleSystem;
  30913. /**
  30914. * Gets the current list of limit velocity gradients.
  30915. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30916. * @returns the list of limit velocity gradients
  30917. */
  30918. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30919. /**
  30920. * Adds a new limit velocity gradient
  30921. * @param gradient defines the gradient to use (between 0 and 1)
  30922. * @param factor defines the limit velocity to affect to the specified gradient
  30923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30924. * @returns the current particle system
  30925. */
  30926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30927. /**
  30928. * Remove a specific limit velocity gradient
  30929. * @param gradient defines the gradient to remove
  30930. * @returns the current particle system
  30931. */
  30932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30933. /**
  30934. * Adds a new drag gradient
  30935. * @param gradient defines the gradient to use (between 0 and 1)
  30936. * @param factor defines the drag to affect to the specified gradient
  30937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30938. * @returns the current particle system
  30939. */
  30940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30941. /**
  30942. * Remove a specific drag gradient
  30943. * @param gradient defines the gradient to remove
  30944. * @returns the current particle system
  30945. */
  30946. removeDragGradient(gradient: number): IParticleSystem;
  30947. /**
  30948. * Gets the current list of drag gradients.
  30949. * You must use addDragGradient and removeDragGradient to udpate this list
  30950. * @returns the list of drag gradients
  30951. */
  30952. getDragGradients(): Nullable<Array<FactorGradient>>;
  30953. /**
  30954. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  30955. * @param gradient defines the gradient to use (between 0 and 1)
  30956. * @param factor defines the emit rate to affect to the specified gradient
  30957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30958. * @returns the current particle system
  30959. */
  30960. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30961. /**
  30962. * Remove a specific emit rate gradient
  30963. * @param gradient defines the gradient to remove
  30964. * @returns the current particle system
  30965. */
  30966. removeEmitRateGradient(gradient: number): IParticleSystem;
  30967. /**
  30968. * Gets the current list of emit rate gradients.
  30969. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30970. * @returns the list of emit rate gradients
  30971. */
  30972. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30973. /**
  30974. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  30975. * @param gradient defines the gradient to use (between 0 and 1)
  30976. * @param factor defines the start size to affect to the specified gradient
  30977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30978. * @returns the current particle system
  30979. */
  30980. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30981. /**
  30982. * Remove a specific start size gradient
  30983. * @param gradient defines the gradient to remove
  30984. * @returns the current particle system
  30985. */
  30986. removeStartSizeGradient(gradient: number): IParticleSystem;
  30987. /**
  30988. * Gets the current list of start size gradients.
  30989. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30990. * @returns the list of start size gradients
  30991. */
  30992. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30993. /**
  30994. * Adds a new life time gradient
  30995. * @param gradient defines the gradient to use (between 0 and 1)
  30996. * @param factor defines the life time factor to affect to the specified gradient
  30997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30998. * @returns the current particle system
  30999. */
  31000. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31001. /**
  31002. * Remove a specific life time gradient
  31003. * @param gradient defines the gradient to remove
  31004. * @returns the current particle system
  31005. */
  31006. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31007. /**
  31008. * Gets the current list of life time gradients.
  31009. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31010. * @returns the list of life time gradients
  31011. */
  31012. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31013. /**
  31014. * Gets the current list of color gradients.
  31015. * You must use addColorGradient and removeColorGradient to udpate this list
  31016. * @returns the list of color gradients
  31017. */
  31018. getColorGradients(): Nullable<Array<ColorGradient>>;
  31019. /**
  31020. * Adds a new ramp gradient used to remap particle colors
  31021. * @param gradient defines the gradient to use (between 0 and 1)
  31022. * @param color defines the color to affect to the specified gradient
  31023. * @returns the current particle system
  31024. */
  31025. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31026. /**
  31027. * Gets the current list of ramp gradients.
  31028. * You must use addRampGradient and removeRampGradient to udpate this list
  31029. * @returns the list of ramp gradients
  31030. */
  31031. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31032. /** Gets or sets a boolean indicating that ramp gradients must be used
  31033. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31034. */
  31035. useRampGradients: boolean;
  31036. /**
  31037. * Adds a new color remap gradient
  31038. * @param gradient defines the gradient to use (between 0 and 1)
  31039. * @param min defines the color remap minimal range
  31040. * @param max defines the color remap maximal range
  31041. * @returns the current particle system
  31042. */
  31043. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31044. /**
  31045. * Gets the current list of color remap gradients.
  31046. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31047. * @returns the list of color remap gradients
  31048. */
  31049. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31050. /**
  31051. * Adds a new alpha remap gradient
  31052. * @param gradient defines the gradient to use (between 0 and 1)
  31053. * @param min defines the alpha remap minimal range
  31054. * @param max defines the alpha remap maximal range
  31055. * @returns the current particle system
  31056. */
  31057. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31058. /**
  31059. * Gets the current list of alpha remap gradients.
  31060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31061. * @returns the list of alpha remap gradients
  31062. */
  31063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31064. /**
  31065. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31066. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31067. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31068. * @returns the emitter
  31069. */
  31070. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31071. /**
  31072. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31073. * @param radius The radius of the hemisphere to emit from
  31074. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31075. * @returns the emitter
  31076. */
  31077. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31078. /**
  31079. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31080. * @param radius The radius of the sphere to emit from
  31081. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31082. * @returns the emitter
  31083. */
  31084. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31085. /**
  31086. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31087. * @param radius The radius of the sphere to emit from
  31088. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31089. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31090. * @returns the emitter
  31091. */
  31092. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31093. /**
  31094. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31095. * @param radius The radius of the emission cylinder
  31096. * @param height The height of the emission cylinder
  31097. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31098. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31099. * @returns the emitter
  31100. */
  31101. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31102. /**
  31103. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31104. * @param radius The radius of the cylinder to emit from
  31105. * @param height The height of the emission cylinder
  31106. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31107. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31108. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31109. * @returns the emitter
  31110. */
  31111. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31112. /**
  31113. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31114. * @param radius The radius of the cone to emit from
  31115. * @param angle The base angle of the cone
  31116. * @returns the emitter
  31117. */
  31118. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31119. /**
  31120. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31121. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31122. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31123. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31124. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31125. * @returns the emitter
  31126. */
  31127. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31128. /**
  31129. * Get hosting scene
  31130. * @returns the scene
  31131. */
  31132. getScene(): Scene;
  31133. }
  31134. }
  31135. declare module BABYLON {
  31136. /**
  31137. * A particle represents one of the element emitted by a particle system.
  31138. * This is mainly define by its coordinates, direction, velocity and age.
  31139. */
  31140. class Particle {
  31141. /**
  31142. * The particle system the particle belongs to.
  31143. */
  31144. particleSystem: ParticleSystem;
  31145. private static _Count;
  31146. /**
  31147. * Unique ID of the particle
  31148. */
  31149. id: number;
  31150. /**
  31151. * The world position of the particle in the scene.
  31152. */
  31153. position: Vector3;
  31154. /**
  31155. * The world direction of the particle in the scene.
  31156. */
  31157. direction: Vector3;
  31158. /**
  31159. * The color of the particle.
  31160. */
  31161. color: Color4;
  31162. /**
  31163. * The color change of the particle per step.
  31164. */
  31165. colorStep: Color4;
  31166. /**
  31167. * Defines how long will the life of the particle be.
  31168. */
  31169. lifeTime: number;
  31170. /**
  31171. * The current age of the particle.
  31172. */
  31173. age: number;
  31174. /**
  31175. * The current size of the particle.
  31176. */
  31177. size: number;
  31178. /**
  31179. * The current scale of the particle.
  31180. */
  31181. scale: Vector2;
  31182. /**
  31183. * The current angle of the particle.
  31184. */
  31185. angle: number;
  31186. /**
  31187. * Defines how fast is the angle changing.
  31188. */
  31189. angularSpeed: number;
  31190. /**
  31191. * Defines the cell index used by the particle to be rendered from a sprite.
  31192. */
  31193. cellIndex: number;
  31194. /**
  31195. * The information required to support color remapping
  31196. */
  31197. remapData: Vector4;
  31198. /** @hidden */
  31199. _randomCellOffset?: number;
  31200. /** @hidden */
  31201. _initialDirection: Nullable<Vector3>;
  31202. /** @hidden */
  31203. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31204. /** @hidden */
  31205. _initialStartSpriteCellID: number;
  31206. /** @hidden */
  31207. _initialEndSpriteCellID: number;
  31208. /** @hidden */
  31209. _currentColorGradient: Nullable<ColorGradient>;
  31210. /** @hidden */
  31211. _currentColor1: Color4;
  31212. /** @hidden */
  31213. _currentColor2: Color4;
  31214. /** @hidden */
  31215. _currentSizeGradient: Nullable<FactorGradient>;
  31216. /** @hidden */
  31217. _currentSize1: number;
  31218. /** @hidden */
  31219. _currentSize2: number;
  31220. /** @hidden */
  31221. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31222. /** @hidden */
  31223. _currentAngularSpeed1: number;
  31224. /** @hidden */
  31225. _currentAngularSpeed2: number;
  31226. /** @hidden */
  31227. _currentVelocityGradient: Nullable<FactorGradient>;
  31228. /** @hidden */
  31229. _currentVelocity1: number;
  31230. /** @hidden */
  31231. _currentVelocity2: number;
  31232. /** @hidden */
  31233. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31234. /** @hidden */
  31235. _currentLimitVelocity1: number;
  31236. /** @hidden */
  31237. _currentLimitVelocity2: number;
  31238. /** @hidden */
  31239. _currentDragGradient: Nullable<FactorGradient>;
  31240. /** @hidden */
  31241. _currentDrag1: number;
  31242. /** @hidden */
  31243. _currentDrag2: number;
  31244. /** @hidden */
  31245. _randomNoiseCoordinates1: Vector3;
  31246. /** @hidden */
  31247. _randomNoiseCoordinates2: Vector3;
  31248. /**
  31249. * Creates a new instance Particle
  31250. * @param particleSystem the particle system the particle belongs to
  31251. */
  31252. constructor(
  31253. /**
  31254. * The particle system the particle belongs to.
  31255. */
  31256. particleSystem: ParticleSystem);
  31257. private updateCellInfoFromSystem;
  31258. /**
  31259. * Defines how the sprite cell index is updated for the particle
  31260. */
  31261. updateCellIndex(): void;
  31262. /** @hidden */
  31263. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31264. /** @hidden */
  31265. _inheritParticleInfoToSubEmitters(): void;
  31266. /** @hidden */
  31267. _reset(): void;
  31268. /**
  31269. * Copy the properties of particle to another one.
  31270. * @param other the particle to copy the information to.
  31271. */
  31272. copyTo(other: Particle): void;
  31273. }
  31274. }
  31275. declare module BABYLON {
  31276. /**
  31277. * This class is made for on one-liner static method to help creating particle system set.
  31278. */
  31279. class ParticleHelper {
  31280. /**
  31281. * Gets or sets base Assets URL
  31282. */
  31283. static BaseAssetsUrl: string;
  31284. /**
  31285. * Create a default particle system that you can tweak
  31286. * @param emitter defines the emitter to use
  31287. * @param capacity defines the system capacity (default is 500 particles)
  31288. * @param scene defines the hosting scene
  31289. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31290. * @returns the new Particle system
  31291. */
  31292. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31293. /**
  31294. * This is the main static method (one-liner) of this helper to create different particle systems
  31295. * @param type This string represents the type to the particle system to create
  31296. * @param scene The scene where the particle system should live
  31297. * @param gpu If the system will use gpu
  31298. * @returns the ParticleSystemSet created
  31299. */
  31300. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31301. /**
  31302. * Static function used to export a particle system to a ParticleSystemSet variable.
  31303. * Please note that the emitter shape is not exported
  31304. * @param systems defines the particle systems to export
  31305. * @returns the created particle system set
  31306. */
  31307. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31308. }
  31309. }
  31310. declare module BABYLON {
  31311. /**
  31312. * This represents a particle system in Babylon.
  31313. * 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.
  31314. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31315. * @example https://doc.babylonjs.com/babylon101/particles
  31316. */
  31317. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31318. /**
  31319. * Billboard mode will only apply to Y axis
  31320. */
  31321. static readonly BILLBOARDMODE_Y: number;
  31322. /**
  31323. * Billboard mode will apply to all axes
  31324. */
  31325. static readonly BILLBOARDMODE_ALL: number;
  31326. /**
  31327. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31328. */
  31329. static readonly BILLBOARDMODE_STRETCHED: number;
  31330. /**
  31331. * This function can be defined to provide custom update for active particles.
  31332. * This function will be called instead of regular update (age, position, color, etc.).
  31333. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31334. */
  31335. updateFunction: (particles: Particle[]) => void;
  31336. private _emitterWorldMatrix;
  31337. /**
  31338. * This function can be defined to specify initial direction for every new particle.
  31339. * It by default use the emitterType defined function
  31340. */
  31341. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31342. /**
  31343. * This function can be defined to specify initial position for every new particle.
  31344. * It by default use the emitterType defined function
  31345. */
  31346. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31347. /**
  31348. * @hidden
  31349. */
  31350. _inheritedVelocityOffset: Vector3;
  31351. /**
  31352. * An event triggered when the system is disposed
  31353. */
  31354. onDisposeObservable: Observable<ParticleSystem>;
  31355. private _onDisposeObserver;
  31356. /**
  31357. * Sets a callback that will be triggered when the system is disposed
  31358. */
  31359. onDispose: () => void;
  31360. private _particles;
  31361. private _epsilon;
  31362. private _capacity;
  31363. private _stockParticles;
  31364. private _newPartsExcess;
  31365. private _vertexData;
  31366. private _vertexBuffer;
  31367. private _vertexBuffers;
  31368. private _spriteBuffer;
  31369. private _indexBuffer;
  31370. private _effect;
  31371. private _customEffect;
  31372. private _cachedDefines;
  31373. private _scaledColorStep;
  31374. private _colorDiff;
  31375. private _scaledDirection;
  31376. private _scaledGravity;
  31377. private _currentRenderId;
  31378. private _alive;
  31379. private _useInstancing;
  31380. private _started;
  31381. private _stopped;
  31382. private _actualFrame;
  31383. private _scaledUpdateSpeed;
  31384. private _vertexBufferSize;
  31385. /** @hidden */
  31386. _currentEmitRateGradient: Nullable<FactorGradient>;
  31387. /** @hidden */
  31388. _currentEmitRate1: number;
  31389. /** @hidden */
  31390. _currentEmitRate2: number;
  31391. /** @hidden */
  31392. _currentStartSizeGradient: Nullable<FactorGradient>;
  31393. /** @hidden */
  31394. _currentStartSize1: number;
  31395. /** @hidden */
  31396. _currentStartSize2: number;
  31397. private readonly _rawTextureWidth;
  31398. private _rampGradientsTexture;
  31399. private _useRampGradients;
  31400. /** Gets or sets a boolean indicating that ramp gradients must be used
  31401. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31402. */
  31403. useRampGradients: boolean;
  31404. /**
  31405. * 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.
  31406. * 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: [])
  31407. */
  31408. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31409. private _subEmitters;
  31410. /**
  31411. * @hidden
  31412. * If the particle systems emitter should be disposed when the particle system is disposed
  31413. */
  31414. _disposeEmitterOnDispose: boolean;
  31415. /**
  31416. * The current active Sub-systems, this property is used by the root particle system only.
  31417. */
  31418. activeSubSystems: Array<ParticleSystem>;
  31419. private _rootParticleSystem;
  31420. /**
  31421. * Gets the current list of active particles
  31422. */
  31423. readonly particles: Particle[];
  31424. /**
  31425. * Returns the string "ParticleSystem"
  31426. * @returns a string containing the class name
  31427. */
  31428. getClassName(): string;
  31429. /**
  31430. * Instantiates a particle system.
  31431. * 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.
  31432. * @param name The name of the particle system
  31433. * @param capacity The max number of particles alive at the same time
  31434. * @param scene The scene the particle system belongs to
  31435. * @param customEffect a custom effect used to change the way particles are rendered by default
  31436. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31437. * @param epsilon Offset used to render the particles
  31438. */
  31439. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31440. private _addFactorGradient;
  31441. private _removeFactorGradient;
  31442. /**
  31443. * Adds a new life time gradient
  31444. * @param gradient defines the gradient to use (between 0 and 1)
  31445. * @param factor defines the life time factor to affect to the specified gradient
  31446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31447. * @returns the current particle system
  31448. */
  31449. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31450. /**
  31451. * Remove a specific life time gradient
  31452. * @param gradient defines the gradient to remove
  31453. * @returns the current particle system
  31454. */
  31455. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31456. /**
  31457. * Adds a new size gradient
  31458. * @param gradient defines the gradient to use (between 0 and 1)
  31459. * @param factor defines the size factor to affect to the specified gradient
  31460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31461. * @returns the current particle system
  31462. */
  31463. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31464. /**
  31465. * Remove a specific size gradient
  31466. * @param gradient defines the gradient to remove
  31467. * @returns the current particle system
  31468. */
  31469. removeSizeGradient(gradient: number): IParticleSystem;
  31470. /**
  31471. * Adds a new color remap gradient
  31472. * @param gradient defines the gradient to use (between 0 and 1)
  31473. * @param min defines the color remap minimal range
  31474. * @param max defines the color remap maximal range
  31475. * @returns the current particle system
  31476. */
  31477. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31478. /**
  31479. * Remove a specific color remap gradient
  31480. * @param gradient defines the gradient to remove
  31481. * @returns the current particle system
  31482. */
  31483. removeColorRemapGradient(gradient: number): IParticleSystem;
  31484. /**
  31485. * Adds a new alpha remap gradient
  31486. * @param gradient defines the gradient to use (between 0 and 1)
  31487. * @param min defines the alpha remap minimal range
  31488. * @param max defines the alpha remap maximal range
  31489. * @returns the current particle system
  31490. */
  31491. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31492. /**
  31493. * Remove a specific alpha remap gradient
  31494. * @param gradient defines the gradient to remove
  31495. * @returns the current particle system
  31496. */
  31497. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31498. /**
  31499. * Adds a new angular speed gradient
  31500. * @param gradient defines the gradient to use (between 0 and 1)
  31501. * @param factor defines the angular speed to affect to the specified gradient
  31502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31503. * @returns the current particle system
  31504. */
  31505. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31506. /**
  31507. * Remove a specific angular speed gradient
  31508. * @param gradient defines the gradient to remove
  31509. * @returns the current particle system
  31510. */
  31511. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31512. /**
  31513. * Adds a new velocity gradient
  31514. * @param gradient defines the gradient to use (between 0 and 1)
  31515. * @param factor defines the velocity to affect to the specified gradient
  31516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31517. * @returns the current particle system
  31518. */
  31519. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31520. /**
  31521. * Remove a specific velocity gradient
  31522. * @param gradient defines the gradient to remove
  31523. * @returns the current particle system
  31524. */
  31525. removeVelocityGradient(gradient: number): IParticleSystem;
  31526. /**
  31527. * Adds a new limit velocity gradient
  31528. * @param gradient defines the gradient to use (between 0 and 1)
  31529. * @param factor defines the limit velocity value to affect to the specified gradient
  31530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31531. * @returns the current particle system
  31532. */
  31533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31534. /**
  31535. * Remove a specific limit velocity gradient
  31536. * @param gradient defines the gradient to remove
  31537. * @returns the current particle system
  31538. */
  31539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31540. /**
  31541. * Adds a new drag gradient
  31542. * @param gradient defines the gradient to use (between 0 and 1)
  31543. * @param factor defines the drag value to affect to the specified gradient
  31544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31545. * @returns the current particle system
  31546. */
  31547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31548. /**
  31549. * Remove a specific drag gradient
  31550. * @param gradient defines the gradient to remove
  31551. * @returns the current particle system
  31552. */
  31553. removeDragGradient(gradient: number): IParticleSystem;
  31554. /**
  31555. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31556. * @param gradient defines the gradient to use (between 0 and 1)
  31557. * @param factor defines the emit rate value to affect to the specified gradient
  31558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31559. * @returns the current particle system
  31560. */
  31561. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31562. /**
  31563. * Remove a specific emit rate gradient
  31564. * @param gradient defines the gradient to remove
  31565. * @returns the current particle system
  31566. */
  31567. removeEmitRateGradient(gradient: number): IParticleSystem;
  31568. /**
  31569. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31570. * @param gradient defines the gradient to use (between 0 and 1)
  31571. * @param factor defines the start size value to affect to the specified gradient
  31572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31573. * @returns the current particle system
  31574. */
  31575. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31576. /**
  31577. * Remove a specific start size gradient
  31578. * @param gradient defines the gradient to remove
  31579. * @returns the current particle system
  31580. */
  31581. removeStartSizeGradient(gradient: number): IParticleSystem;
  31582. private _createRampGradientTexture;
  31583. /**
  31584. * Gets the current list of ramp gradients.
  31585. * You must use addRampGradient and removeRampGradient to udpate this list
  31586. * @returns the list of ramp gradients
  31587. */
  31588. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31589. /**
  31590. * Adds a new ramp gradient used to remap particle colors
  31591. * @param gradient defines the gradient to use (between 0 and 1)
  31592. * @param color defines the color to affect to the specified gradient
  31593. * @returns the current particle system
  31594. */
  31595. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31596. /**
  31597. * Remove a specific ramp gradient
  31598. * @param gradient defines the gradient to remove
  31599. * @returns the current particle system
  31600. */
  31601. removeRampGradient(gradient: number): ParticleSystem;
  31602. /**
  31603. * Adds a new color gradient
  31604. * @param gradient defines the gradient to use (between 0 and 1)
  31605. * @param color1 defines the color to affect to the specified gradient
  31606. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31607. * @returns this particle system
  31608. */
  31609. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31610. /**
  31611. * Remove a specific color gradient
  31612. * @param gradient defines the gradient to remove
  31613. * @returns this particle system
  31614. */
  31615. removeColorGradient(gradient: number): IParticleSystem;
  31616. private _fetchR;
  31617. protected _reset(): void;
  31618. private _resetEffect;
  31619. private _createVertexBuffers;
  31620. private _createIndexBuffer;
  31621. /**
  31622. * Gets the maximum number of particles active at the same time.
  31623. * @returns The max number of active particles.
  31624. */
  31625. getCapacity(): number;
  31626. /**
  31627. * Gets whether there are still active particles in the system.
  31628. * @returns True if it is alive, otherwise false.
  31629. */
  31630. isAlive(): boolean;
  31631. /**
  31632. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31633. * @returns True if it has been started, otherwise false.
  31634. */
  31635. isStarted(): boolean;
  31636. private _prepareSubEmitterInternalArray;
  31637. /**
  31638. * Starts the particle system and begins to emit
  31639. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31640. */
  31641. start(delay?: number): void;
  31642. /**
  31643. * Stops the particle system.
  31644. * @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.
  31645. */
  31646. stop(stopSubEmitters?: boolean): void;
  31647. /**
  31648. * Remove all active particles
  31649. */
  31650. reset(): void;
  31651. /**
  31652. * @hidden (for internal use only)
  31653. */
  31654. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31655. /**
  31656. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31657. * Its lifetime will start back at 0.
  31658. */
  31659. recycleParticle: (particle: Particle) => void;
  31660. private _stopSubEmitters;
  31661. private _createParticle;
  31662. private _removeFromRoot;
  31663. private _emitFromParticle;
  31664. private _update;
  31665. /** @hidden */
  31666. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31667. /** @hidden */
  31668. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31669. /** @hidden */
  31670. private _getEffect;
  31671. /**
  31672. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31673. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31674. */
  31675. animate(preWarmOnly?: boolean): void;
  31676. private _appendParticleVertices;
  31677. /**
  31678. * Rebuilds the particle system.
  31679. */
  31680. rebuild(): void;
  31681. /**
  31682. * Is this system ready to be used/rendered
  31683. * @return true if the system is ready
  31684. */
  31685. isReady(): boolean;
  31686. private _render;
  31687. /**
  31688. * Renders the particle system in its current state.
  31689. * @returns the current number of particles
  31690. */
  31691. render(): number;
  31692. /**
  31693. * Disposes the particle system and free the associated resources
  31694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31695. */
  31696. dispose(disposeTexture?: boolean): void;
  31697. /**
  31698. * Clones the particle system.
  31699. * @param name The name of the cloned object
  31700. * @param newEmitter The new emitter to use
  31701. * @returns the cloned particle system
  31702. */
  31703. clone(name: string, newEmitter: any): ParticleSystem;
  31704. /**
  31705. * Serializes the particle system to a JSON object.
  31706. * @returns the JSON object
  31707. */
  31708. serialize(): any;
  31709. /** @hidden */
  31710. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31711. /** @hidden */
  31712. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31713. /**
  31714. * Parses a JSON object to create a particle system.
  31715. * @param parsedParticleSystem The JSON object to parse
  31716. * @param scene The scene to create the particle system in
  31717. * @param rootUrl The root url to use to load external dependencies like texture
  31718. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31719. * @returns the Parsed particle system
  31720. */
  31721. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31722. }
  31723. }
  31724. declare module BABYLON {
  31725. interface Engine {
  31726. /**
  31727. * Create an effect to use with particle systems.
  31728. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31729. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31730. * @param uniformsNames defines a list of attribute names
  31731. * @param samplers defines an array of string used to represent textures
  31732. * @param defines defines the string containing the defines to use to compile the shaders
  31733. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31734. * @param onCompiled defines a function to call when the effect creation is successful
  31735. * @param onError defines a function to call when the effect creation has failed
  31736. * @returns the new Effect
  31737. */
  31738. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  31739. }
  31740. interface Mesh {
  31741. /**
  31742. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  31743. * @returns an array of IParticleSystem
  31744. */
  31745. getEmittedParticleSystems(): IParticleSystem[];
  31746. /**
  31747. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  31748. * @returns an array of IParticleSystem
  31749. */
  31750. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  31751. }
  31752. }
  31753. declare module BABYLON {
  31754. /**
  31755. * Represents a set of particle systems working together to create a specific effect
  31756. */
  31757. class ParticleSystemSet implements IDisposable {
  31758. private _emitterCreationOptions;
  31759. private _emitterNode;
  31760. /**
  31761. * Gets the particle system list
  31762. */
  31763. systems: IParticleSystem[];
  31764. /**
  31765. * Gets the emitter node used with this set
  31766. */
  31767. readonly emitterNode: Nullable<TransformNode>;
  31768. /**
  31769. * Creates a new emitter mesh as a sphere
  31770. * @param options defines the options used to create the sphere
  31771. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  31772. * @param scene defines the hosting scene
  31773. */
  31774. setEmitterAsSphere(options: {
  31775. diameter: number;
  31776. segments: number;
  31777. color: Color3;
  31778. }, renderingGroupId: number, scene: Scene): void;
  31779. /**
  31780. * Starts all particle systems of the set
  31781. * @param emitter defines an optional mesh to use as emitter for the particle systems
  31782. */
  31783. start(emitter?: AbstractMesh): void;
  31784. /**
  31785. * Release all associated resources
  31786. */
  31787. dispose(): void;
  31788. /**
  31789. * Serialize the set into a JSON compatible object
  31790. * @returns a JSON compatible representation of the set
  31791. */
  31792. serialize(): any;
  31793. /**
  31794. * Parse a new ParticleSystemSet from a serialized source
  31795. * @param data defines a JSON compatible representation of the set
  31796. * @param scene defines the hosting scene
  31797. * @param gpu defines if we want GPU particles or CPU particles
  31798. * @returns a new ParticleSystemSet
  31799. */
  31800. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  31801. }
  31802. }
  31803. declare module BABYLON {
  31804. /**
  31805. * Represents one particle of a solid particle system.
  31806. */
  31807. class SolidParticle {
  31808. /**
  31809. * particle global index
  31810. */
  31811. idx: number;
  31812. /**
  31813. * The color of the particle
  31814. */
  31815. color: Nullable<Color4>;
  31816. /**
  31817. * The world space position of the particle.
  31818. */
  31819. position: Vector3;
  31820. /**
  31821. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31822. */
  31823. rotation: Vector3;
  31824. /**
  31825. * The world space rotation quaternion of the particle.
  31826. */
  31827. rotationQuaternion: Nullable<Quaternion>;
  31828. /**
  31829. * The scaling of the particle.
  31830. */
  31831. scaling: Vector3;
  31832. /**
  31833. * The uvs of the particle.
  31834. */
  31835. uvs: Vector4;
  31836. /**
  31837. * The current speed of the particle.
  31838. */
  31839. velocity: Vector3;
  31840. /**
  31841. * The pivot point in the particle local space.
  31842. */
  31843. pivot: Vector3;
  31844. /**
  31845. * Must the particle be translated from its pivot point in its local space ?
  31846. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31847. * Default : false
  31848. */
  31849. translateFromPivot: boolean;
  31850. /**
  31851. * Is the particle active or not ?
  31852. */
  31853. alive: boolean;
  31854. /**
  31855. * Is the particle visible or not ?
  31856. */
  31857. isVisible: boolean;
  31858. /**
  31859. * Index of this particle in the global "positions" array (Internal use)
  31860. * @hidden
  31861. */
  31862. _pos: number;
  31863. /**
  31864. * @hidden Index of this particle in the global "indices" array (Internal use)
  31865. */
  31866. _ind: number;
  31867. /**
  31868. * @hidden ModelShape of this particle (Internal use)
  31869. */
  31870. _model: ModelShape;
  31871. /**
  31872. * ModelShape id of this particle
  31873. */
  31874. shapeId: number;
  31875. /**
  31876. * Index of the particle in its shape id (Internal use)
  31877. */
  31878. idxInShape: number;
  31879. /**
  31880. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31881. */
  31882. _modelBoundingInfo: BoundingInfo;
  31883. /**
  31884. * @hidden Particle BoundingInfo object (Internal use)
  31885. */
  31886. _boundingInfo: BoundingInfo;
  31887. /**
  31888. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31889. */
  31890. _sps: SolidParticleSystem;
  31891. /**
  31892. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31893. */
  31894. _stillInvisible: boolean;
  31895. /**
  31896. * @hidden Last computed particle rotation matrix
  31897. */
  31898. _rotationMatrix: number[];
  31899. /**
  31900. * Parent particle Id, if any.
  31901. * Default null.
  31902. */
  31903. parentId: Nullable<number>;
  31904. /**
  31905. * @hidden Internal global position in the SPS.
  31906. */
  31907. _globalPosition: Vector3;
  31908. /**
  31909. * Creates a Solid Particle object.
  31910. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31911. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  31912. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31913. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31914. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31915. * @param shapeId (integer) is the model shape identifier in the SPS.
  31916. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31917. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31918. */
  31919. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  31920. /**
  31921. * Legacy support, changed scale to scaling
  31922. */
  31923. /**
  31924. * Legacy support, changed scale to scaling
  31925. */
  31926. scale: Vector3;
  31927. /**
  31928. * Legacy support, changed quaternion to rotationQuaternion
  31929. */
  31930. /**
  31931. * Legacy support, changed quaternion to rotationQuaternion
  31932. */
  31933. quaternion: Nullable<Quaternion>;
  31934. /**
  31935. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31936. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31937. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31938. * @returns true if it intersects
  31939. */
  31940. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31941. /**
  31942. * get the rotation matrix of the particle
  31943. * @hidden
  31944. */
  31945. getRotationMatrix(m: Matrix): void;
  31946. }
  31947. /**
  31948. * Represents the shape of the model used by one particle of a solid particle system.
  31949. * SPS internal tool, don't use it manually.
  31950. */
  31951. class ModelShape {
  31952. /**
  31953. * The shape id
  31954. * @hidden
  31955. */
  31956. shapeID: number;
  31957. /**
  31958. * flat array of model positions (internal use)
  31959. * @hidden
  31960. */
  31961. _shape: Vector3[];
  31962. /**
  31963. * flat array of model UVs (internal use)
  31964. * @hidden
  31965. */
  31966. _shapeUV: number[];
  31967. /**
  31968. * length of the shape in the model indices array (internal use)
  31969. * @hidden
  31970. */
  31971. _indicesLength: number;
  31972. /**
  31973. * Custom position function (internal use)
  31974. * @hidden
  31975. */
  31976. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31977. /**
  31978. * Custom vertex function (internal use)
  31979. * @hidden
  31980. */
  31981. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31982. /**
  31983. * 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.
  31984. * SPS internal tool, don't use it manually.
  31985. * @hidden
  31986. */
  31987. 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>);
  31988. }
  31989. /**
  31990. * Represents a Depth Sorted Particle in the solid particle system.
  31991. */
  31992. class DepthSortedParticle {
  31993. /**
  31994. * Index of the particle in the "indices" array
  31995. */
  31996. ind: number;
  31997. /**
  31998. * Length of the particle shape in the "indices" array
  31999. */
  32000. indicesLength: number;
  32001. /**
  32002. * Squared distance from the particle to the camera
  32003. */
  32004. sqDistance: number;
  32005. }
  32006. }
  32007. declare module BABYLON {
  32008. /**
  32009. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32010. *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.
  32011. * The SPS is also a particle system. It provides some methods to manage the particles.
  32012. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32013. *
  32014. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32015. */
  32016. class SolidParticleSystem implements IDisposable {
  32017. /**
  32018. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32019. * Example : var p = SPS.particles[i];
  32020. */
  32021. particles: SolidParticle[];
  32022. /**
  32023. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32024. */
  32025. nbParticles: number;
  32026. /**
  32027. * If the particles must ever face the camera (default false). Useful for planar particles.
  32028. */
  32029. billboard: boolean;
  32030. /**
  32031. * Recompute normals when adding a shape
  32032. */
  32033. recomputeNormals: boolean;
  32034. /**
  32035. * This a counter ofr your own usage. It's not set by any SPS functions.
  32036. */
  32037. counter: number;
  32038. /**
  32039. * The SPS name. This name is also given to the underlying mesh.
  32040. */
  32041. name: string;
  32042. /**
  32043. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32044. */
  32045. mesh: Mesh;
  32046. /**
  32047. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32048. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32049. */
  32050. vars: any;
  32051. /**
  32052. * This array is populated when the SPS is set as 'pickable'.
  32053. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32054. * Each element of this array is an object `{idx: int, faceId: int}`.
  32055. * `idx` is the picked particle index in the `SPS.particles` array
  32056. * `faceId` is the picked face index counted within this particle.
  32057. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32058. */
  32059. pickedParticles: {
  32060. idx: number;
  32061. faceId: number;
  32062. }[];
  32063. /**
  32064. * This array is populated when `enableDepthSort` is set to true.
  32065. * Each element of this array is an instance of the class DepthSortedParticle.
  32066. */
  32067. depthSortedParticles: DepthSortedParticle[];
  32068. /**
  32069. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32070. * @hidden
  32071. */
  32072. _bSphereOnly: boolean;
  32073. /**
  32074. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32075. * @hidden
  32076. */
  32077. _bSphereRadiusFactor: number;
  32078. private _scene;
  32079. private _positions;
  32080. private _indices;
  32081. private _normals;
  32082. private _colors;
  32083. private _uvs;
  32084. private _indices32;
  32085. private _positions32;
  32086. private _normals32;
  32087. private _fixedNormal32;
  32088. private _colors32;
  32089. private _uvs32;
  32090. private _index;
  32091. private _updatable;
  32092. private _pickable;
  32093. private _isVisibilityBoxLocked;
  32094. private _alwaysVisible;
  32095. private _depthSort;
  32096. private _shapeCounter;
  32097. private _copy;
  32098. private _color;
  32099. private _computeParticleColor;
  32100. private _computeParticleTexture;
  32101. private _computeParticleRotation;
  32102. private _computeParticleVertex;
  32103. private _computeBoundingBox;
  32104. private _depthSortParticles;
  32105. private _camera;
  32106. private _mustUnrotateFixedNormals;
  32107. private _particlesIntersect;
  32108. private _needs32Bits;
  32109. /**
  32110. * Creates a SPS (Solid Particle System) object.
  32111. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32112. * @param scene (Scene) is the scene in which the SPS is added.
  32113. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32114. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32115. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32116. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32117. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32118. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32119. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32120. */
  32121. constructor(name: string, scene: Scene, options?: {
  32122. updatable?: boolean;
  32123. isPickable?: boolean;
  32124. enableDepthSort?: boolean;
  32125. particleIntersection?: boolean;
  32126. boundingSphereOnly?: boolean;
  32127. bSphereRadiusFactor?: number;
  32128. });
  32129. /**
  32130. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32131. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32132. * @returns the created mesh
  32133. */
  32134. buildMesh(): Mesh;
  32135. /**
  32136. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32137. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32138. * Thus the particles generated from `digest()` have their property `position` set yet.
  32139. * @param mesh ( Mesh ) is the mesh to be digested
  32140. * @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
  32141. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32142. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32143. * @returns the current SPS
  32144. */
  32145. digest(mesh: Mesh, options?: {
  32146. facetNb?: number;
  32147. number?: number;
  32148. delta?: number;
  32149. }): SolidParticleSystem;
  32150. private _unrotateFixedNormals;
  32151. private _resetCopy;
  32152. private _meshBuilder;
  32153. private _posToShape;
  32154. private _uvsToShapeUV;
  32155. private _addParticle;
  32156. /**
  32157. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32158. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32159. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32160. * @param nb (positive integer) the number of particles to be created from this model
  32161. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32162. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32163. * @returns the number of shapes in the system
  32164. */
  32165. addShape(mesh: Mesh, nb: number, options?: {
  32166. positionFunction?: any;
  32167. vertexFunction?: any;
  32168. }): number;
  32169. private _rebuildParticle;
  32170. /**
  32171. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32172. * @returns the SPS.
  32173. */
  32174. rebuildMesh(): SolidParticleSystem;
  32175. /**
  32176. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32177. * This method calls `updateParticle()` for each particle of the SPS.
  32178. * For an animated SPS, it is usually called within the render loop.
  32179. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32180. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32181. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32182. * @returns the SPS.
  32183. */
  32184. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32185. /**
  32186. * Disposes the SPS.
  32187. */
  32188. dispose(): void;
  32189. /**
  32190. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32191. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32192. * @returns the SPS.
  32193. */
  32194. refreshVisibleSize(): SolidParticleSystem;
  32195. /**
  32196. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32197. * @param size the size (float) of the visibility box
  32198. * note : this doesn't lock the SPS mesh bounding box.
  32199. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32200. */
  32201. setVisibilityBox(size: number): void;
  32202. /**
  32203. * Gets whether the SPS as always visible or not
  32204. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32205. */
  32206. /**
  32207. * Sets the SPS as always visible or not
  32208. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32209. */
  32210. isAlwaysVisible: boolean;
  32211. /**
  32212. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32213. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32214. */
  32215. /**
  32216. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32217. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32218. */
  32219. isVisibilityBoxLocked: boolean;
  32220. /**
  32221. * Tells to `setParticles()` to compute the particle rotations or not.
  32222. * Default value : true. The SPS is faster when it's set to false.
  32223. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32224. */
  32225. /**
  32226. * Gets if `setParticles()` computes the particle rotations or not.
  32227. * Default value : true. The SPS is faster when it's set to false.
  32228. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32229. */
  32230. computeParticleRotation: boolean;
  32231. /**
  32232. * Tells to `setParticles()` to compute the particle colors or not.
  32233. * Default value : true. The SPS is faster when it's set to false.
  32234. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32235. */
  32236. /**
  32237. * Gets if `setParticles()` computes the particle colors or not.
  32238. * Default value : true. The SPS is faster when it's set to false.
  32239. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32240. */
  32241. computeParticleColor: boolean;
  32242. /**
  32243. * Gets if `setParticles()` computes the particle textures or not.
  32244. * Default value : true. The SPS is faster when it's set to false.
  32245. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32246. */
  32247. computeParticleTexture: boolean;
  32248. /**
  32249. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32250. * Default value : false. The SPS is faster when it's set to false.
  32251. * Note : the particle custom vertex positions aren't stored values.
  32252. */
  32253. /**
  32254. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32255. * Default value : false. The SPS is faster when it's set to false.
  32256. * Note : the particle custom vertex positions aren't stored values.
  32257. */
  32258. computeParticleVertex: boolean;
  32259. /**
  32260. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32261. */
  32262. /**
  32263. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32264. */
  32265. computeBoundingBox: boolean;
  32266. /**
  32267. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32268. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32269. * Default : `true`
  32270. */
  32271. /**
  32272. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32273. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32274. * Default : `true`
  32275. */
  32276. depthSortParticles: boolean;
  32277. /**
  32278. * This function does nothing. It may be overwritten to set all the particle first values.
  32279. * The SPS doesn't call this function, you may have to call it by your own.
  32280. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32281. */
  32282. initParticles(): void;
  32283. /**
  32284. * This function does nothing. It may be overwritten to recycle a particle.
  32285. * The SPS doesn't call this function, you may have to call it by your own.
  32286. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32287. * @param particle The particle to recycle
  32288. * @returns the recycled particle
  32289. */
  32290. recycleParticle(particle: SolidParticle): SolidParticle;
  32291. /**
  32292. * Updates a particle : this function should be overwritten by the user.
  32293. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32294. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32295. * @example : just set a particle position or velocity and recycle conditions
  32296. * @param particle The particle to update
  32297. * @returns the updated particle
  32298. */
  32299. updateParticle(particle: SolidParticle): SolidParticle;
  32300. /**
  32301. * Updates a vertex of a particle : it can be overwritten by the user.
  32302. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32303. * @param particle the current particle
  32304. * @param vertex the current index of the current particle
  32305. * @param pt the index of the current vertex in the particle shape
  32306. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32307. * @example : just set a vertex particle position
  32308. * @returns the updated vertex
  32309. */
  32310. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32311. /**
  32312. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32313. * This does nothing and may be overwritten by the user.
  32314. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32315. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32316. * @param update the boolean update value actually passed to setParticles()
  32317. */
  32318. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32319. /**
  32320. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32321. * This will be passed three parameters.
  32322. * This does nothing and may be overwritten by the user.
  32323. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32324. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32325. * @param update the boolean update value actually passed to setParticles()
  32326. */
  32327. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32328. }
  32329. }
  32330. declare module BABYLON {
  32331. /**
  32332. * Type of sub emitter
  32333. */
  32334. enum SubEmitterType {
  32335. /**
  32336. * Attached to the particle over it's lifetime
  32337. */
  32338. ATTACHED = 0,
  32339. /**
  32340. * Created when the particle dies
  32341. */
  32342. END = 1
  32343. }
  32344. /**
  32345. * Sub emitter class used to emit particles from an existing particle
  32346. */
  32347. class SubEmitter {
  32348. /**
  32349. * the particle system to be used by the sub emitter
  32350. */
  32351. particleSystem: ParticleSystem;
  32352. /**
  32353. * Type of the submitter (Default: END)
  32354. */
  32355. type: SubEmitterType;
  32356. /**
  32357. * 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)
  32358. * Note: This only is supported when using an emitter of type Mesh
  32359. */
  32360. inheritDirection: boolean;
  32361. /**
  32362. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32363. */
  32364. inheritedVelocityAmount: number;
  32365. /**
  32366. * Creates a sub emitter
  32367. * @param particleSystem the particle system to be used by the sub emitter
  32368. */
  32369. constructor(
  32370. /**
  32371. * the particle system to be used by the sub emitter
  32372. */
  32373. particleSystem: ParticleSystem);
  32374. /**
  32375. * Clones the sub emitter
  32376. * @returns the cloned sub emitter
  32377. */
  32378. clone(): SubEmitter;
  32379. /**
  32380. * Serialize current object to a JSON object
  32381. * @returns the serialized object
  32382. */
  32383. serialize(): any;
  32384. /**
  32385. * Creates a new SubEmitter from a serialized JSON version
  32386. * @param serializationObject defines the JSON object to read from
  32387. * @param scene defines the hosting scene
  32388. * @param rootUrl defines the rootUrl for data loading
  32389. * @returns a new SubEmitter
  32390. */
  32391. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32392. /** Release associated resources */
  32393. dispose(): void;
  32394. }
  32395. }
  32396. declare module BABYLON {
  32397. /**
  32398. * Interface used to describe a physics joint
  32399. */
  32400. interface PhysicsImpostorJoint {
  32401. /** Defines the main impostor to which the joint is linked */
  32402. mainImpostor: PhysicsImpostor;
  32403. /** Defines the impostor that is connected to the main impostor using this joint */
  32404. connectedImpostor: PhysicsImpostor;
  32405. /** Defines the joint itself */
  32406. joint: PhysicsJoint;
  32407. }
  32408. /** @hidden */
  32409. interface IPhysicsEnginePlugin {
  32410. world: any;
  32411. name: string;
  32412. setGravity(gravity: Vector3): void;
  32413. setTimeStep(timeStep: number): void;
  32414. getTimeStep(): number;
  32415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32419. removePhysicsBody(impostor: PhysicsImpostor): void;
  32420. generateJoint(joint: PhysicsImpostorJoint): void;
  32421. removeJoint(joint: PhysicsImpostorJoint): void;
  32422. isSupported(): boolean;
  32423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32430. getBodyMass(impostor: PhysicsImpostor): number;
  32431. getBodyFriction(impostor: PhysicsImpostor): number;
  32432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32433. getBodyRestitution(impostor: PhysicsImpostor): number;
  32434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32435. sleepBody(impostor: PhysicsImpostor): void;
  32436. wakeUpBody(impostor: PhysicsImpostor): void;
  32437. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32438. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32440. getRadius(impostor: PhysicsImpostor): number;
  32441. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32442. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32443. dispose(): void;
  32444. }
  32445. /**
  32446. * Interface used to define a physics engine
  32447. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32448. */
  32449. interface IPhysicsEngine {
  32450. /**
  32451. * Gets the gravity vector used by the simulation
  32452. */
  32453. gravity: Vector3;
  32454. /**
  32455. * Sets the gravity vector used by the simulation
  32456. * @param gravity defines the gravity vector to use
  32457. */
  32458. setGravity(gravity: Vector3): void;
  32459. /**
  32460. * Set the time step of the physics engine.
  32461. * Default is 1/60.
  32462. * To slow it down, enter 1/600 for example.
  32463. * To speed it up, 1/30
  32464. * @param newTimeStep the new timestep to apply to this world.
  32465. */
  32466. setTimeStep(newTimeStep: number): void;
  32467. /**
  32468. * Get the time step of the physics engine.
  32469. * @returns the current time step
  32470. */
  32471. getTimeStep(): number;
  32472. /**
  32473. * Release all resources
  32474. */
  32475. dispose(): void;
  32476. /**
  32477. * Gets the name of the current physics plugin
  32478. * @returns the name of the plugin
  32479. */
  32480. getPhysicsPluginName(): string;
  32481. /**
  32482. * Adding a new impostor for the impostor tracking.
  32483. * This will be done by the impostor itself.
  32484. * @param impostor the impostor to add
  32485. */
  32486. addImpostor(impostor: PhysicsImpostor): void;
  32487. /**
  32488. * Remove an impostor from the engine.
  32489. * This impostor and its mesh will not longer be updated by the physics engine.
  32490. * @param impostor the impostor to remove
  32491. */
  32492. removeImpostor(impostor: PhysicsImpostor): void;
  32493. /**
  32494. * Add a joint to the physics engine
  32495. * @param mainImpostor defines the main impostor to which the joint is added.
  32496. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32497. * @param joint defines the joint that will connect both impostors.
  32498. */
  32499. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32500. /**
  32501. * Removes a joint from the simulation
  32502. * @param mainImpostor defines the impostor used with the joint
  32503. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32504. * @param joint defines the joint to remove
  32505. */
  32506. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32507. /**
  32508. * Gets the current plugin used to run the simulation
  32509. * @returns current plugin
  32510. */
  32511. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32512. /**
  32513. * Gets the list of physic impostors
  32514. * @returns an array of PhysicsImpostor
  32515. */
  32516. getImpostors(): Array<PhysicsImpostor>;
  32517. /**
  32518. * Gets the impostor for a physics enabled object
  32519. * @param object defines the object impersonated by the impostor
  32520. * @returns the PhysicsImpostor or null if not found
  32521. */
  32522. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32523. /**
  32524. * Gets the impostor for a physics body object
  32525. * @param body defines physics body used by the impostor
  32526. * @returns the PhysicsImpostor or null if not found
  32527. */
  32528. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32529. /**
  32530. * Called by the scene. No need to call it.
  32531. * @param delta defines the timespam between frames
  32532. */
  32533. _step(delta: number): void;
  32534. }
  32535. }
  32536. declare module BABYLON {
  32537. /**
  32538. * Class used to control physics engine
  32539. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32540. */
  32541. class PhysicsEngine implements IPhysicsEngine {
  32542. private _physicsPlugin;
  32543. /**
  32544. * Global value used to control the smallest number supported by the simulation
  32545. */
  32546. static Epsilon: number;
  32547. private _impostors;
  32548. private _joints;
  32549. /**
  32550. * Gets the gravity vector used by the simulation
  32551. */
  32552. gravity: Vector3;
  32553. /**
  32554. * Creates a new Physics Engine
  32555. * @param gravity defines the gravity vector used by the simulation
  32556. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32557. */
  32558. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32559. /**
  32560. * Sets the gravity vector used by the simulation
  32561. * @param gravity defines the gravity vector to use
  32562. */
  32563. setGravity(gravity: Vector3): void;
  32564. /**
  32565. * Set the time step of the physics engine.
  32566. * Default is 1/60.
  32567. * To slow it down, enter 1/600 for example.
  32568. * To speed it up, 1/30
  32569. * @param newTimeStep defines the new timestep to apply to this world.
  32570. */
  32571. setTimeStep(newTimeStep?: number): void;
  32572. /**
  32573. * Get the time step of the physics engine.
  32574. * @returns the current time step
  32575. */
  32576. getTimeStep(): number;
  32577. /**
  32578. * Release all resources
  32579. */
  32580. dispose(): void;
  32581. /**
  32582. * Gets the name of the current physics plugin
  32583. * @returns the name of the plugin
  32584. */
  32585. getPhysicsPluginName(): string;
  32586. /**
  32587. * Adding a new impostor for the impostor tracking.
  32588. * This will be done by the impostor itself.
  32589. * @param impostor the impostor to add
  32590. */
  32591. addImpostor(impostor: PhysicsImpostor): void;
  32592. /**
  32593. * Remove an impostor from the engine.
  32594. * This impostor and its mesh will not longer be updated by the physics engine.
  32595. * @param impostor the impostor to remove
  32596. */
  32597. removeImpostor(impostor: PhysicsImpostor): void;
  32598. /**
  32599. * Add a joint to the physics engine
  32600. * @param mainImpostor defines the main impostor to which the joint is added.
  32601. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32602. * @param joint defines the joint that will connect both impostors.
  32603. */
  32604. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32605. /**
  32606. * Removes a joint from the simulation
  32607. * @param mainImpostor defines the impostor used with the joint
  32608. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32609. * @param joint defines the joint to remove
  32610. */
  32611. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32612. /**
  32613. * Called by the scene. No need to call it.
  32614. * @param delta defines the timespam between frames
  32615. */
  32616. _step(delta: number): void;
  32617. /**
  32618. * Gets the current plugin used to run the simulation
  32619. * @returns current plugin
  32620. */
  32621. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32622. /**
  32623. * Gets the list of physic impostors
  32624. * @returns an array of PhysicsImpostor
  32625. */
  32626. getImpostors(): Array<PhysicsImpostor>;
  32627. /**
  32628. * Gets the impostor for a physics enabled object
  32629. * @param object defines the object impersonated by the impostor
  32630. * @returns the PhysicsImpostor or null if not found
  32631. */
  32632. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32633. /**
  32634. * Gets the impostor for a physics body object
  32635. * @param body defines physics body used by the impostor
  32636. * @returns the PhysicsImpostor or null if not found
  32637. */
  32638. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32639. }
  32640. }
  32641. declare module BABYLON {
  32642. interface Scene {
  32643. /** @hidden (Backing field) */
  32644. _physicsEngine: Nullable<IPhysicsEngine>;
  32645. /**
  32646. * Gets the current physics engine
  32647. * @returns a IPhysicsEngine or null if none attached
  32648. */
  32649. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32650. /**
  32651. * Enables physics to the current scene
  32652. * @param gravity defines the scene's gravity for the physics engine
  32653. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32654. * @return a boolean indicating if the physics engine was initialized
  32655. */
  32656. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32657. /**
  32658. * Disables and disposes the physics engine associated with the scene
  32659. */
  32660. disablePhysicsEngine(): void;
  32661. /**
  32662. * Gets a boolean indicating if there is an active physics engine
  32663. * @returns a boolean indicating if there is an active physics engine
  32664. */
  32665. isPhysicsEnabled(): boolean;
  32666. /**
  32667. * Deletes a physics compound impostor
  32668. * @param compound defines the compound to delete
  32669. */
  32670. deleteCompoundImpostor(compound: any): void;
  32671. /**
  32672. * An event triggered when physic simulation is about to be run
  32673. */
  32674. onBeforePhysicsObservable: Observable<Scene>;
  32675. /**
  32676. * An event triggered when physic simulation has been done
  32677. */
  32678. onAfterPhysicsObservable: Observable<Scene>;
  32679. }
  32680. interface AbstractMesh {
  32681. /** @hidden */
  32682. _physicsImpostor: Nullable<PhysicsImpostor>;
  32683. /**
  32684. * Gets or sets impostor used for physic simulation
  32685. * @see http://doc.babylonjs.com/features/physics_engine
  32686. */
  32687. physicsImpostor: Nullable<PhysicsImpostor>;
  32688. /**
  32689. * Gets the current physics impostor
  32690. * @see http://doc.babylonjs.com/features/physics_engine
  32691. * @returns a physics impostor or null
  32692. */
  32693. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32694. /** Apply a physic impulse to the mesh
  32695. * @param force defines the force to apply
  32696. * @param contactPoint defines where to apply the force
  32697. * @returns the current mesh
  32698. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32699. */
  32700. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32701. /**
  32702. * Creates a physic joint between two meshes
  32703. * @param otherMesh defines the other mesh to use
  32704. * @param pivot1 defines the pivot to use on this mesh
  32705. * @param pivot2 defines the pivot to use on the other mesh
  32706. * @param options defines additional options (can be plugin dependent)
  32707. * @returns the current mesh
  32708. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32709. */
  32710. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32711. /** @hidden */
  32712. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32713. }
  32714. /**
  32715. * Defines the physics engine scene component responsible to manage a physics engine
  32716. */
  32717. class PhysicsEngineSceneComponent implements ISceneComponent {
  32718. /**
  32719. * The component name helpful to identify the component in the list of scene components.
  32720. */
  32721. readonly name: string;
  32722. /**
  32723. * The scene the component belongs to.
  32724. */
  32725. scene: Scene;
  32726. /**
  32727. * Creates a new instance of the component for the given scene
  32728. * @param scene Defines the scene to register the component in
  32729. */
  32730. constructor(scene: Scene);
  32731. /**
  32732. * Registers the component in a given scene
  32733. */
  32734. register(): void;
  32735. /**
  32736. * Rebuilds the elements related to this component in case of
  32737. * context lost for instance.
  32738. */
  32739. rebuild(): void;
  32740. /**
  32741. * Disposes the component and the associated ressources
  32742. */
  32743. dispose(): void;
  32744. }
  32745. }
  32746. declare module BABYLON {
  32747. /**
  32748. * A helper for physics simulations
  32749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32750. */
  32751. class PhysicsHelper {
  32752. private _scene;
  32753. private _physicsEngine;
  32754. /**
  32755. * Initializes the Physics helper
  32756. * @param scene Babylon.js scene
  32757. */
  32758. constructor(scene: Scene);
  32759. /**
  32760. * Applies a radial explosion impulse
  32761. * @param origin the origin of the explosion
  32762. * @param radius the explosion radius
  32763. * @param strength the explosion strength
  32764. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32765. * @returns A physics radial explosion event, or null
  32766. */
  32767. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32768. /**
  32769. * Applies a radial explosion force
  32770. * @param origin the origin of the explosion
  32771. * @param radius the explosion radius
  32772. * @param strength the explosion strength
  32773. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32774. * @returns A physics radial explosion event, or null
  32775. */
  32776. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32777. /**
  32778. * Creates a gravitational field
  32779. * @param origin the origin of the explosion
  32780. * @param radius the explosion radius
  32781. * @param strength the explosion strength
  32782. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32783. * @returns A physics gravitational field event, or null
  32784. */
  32785. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  32786. /**
  32787. * Creates a physics updraft event
  32788. * @param origin the origin of the updraft
  32789. * @param radius the radius of the updraft
  32790. * @param strength the strength of the updraft
  32791. * @param height the height of the updraft
  32792. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  32793. * @returns A physics updraft event, or null
  32794. */
  32795. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  32796. /**
  32797. * Creates a physics vortex event
  32798. * @param origin the of the vortex
  32799. * @param radius the radius of the vortex
  32800. * @param strength the strength of the vortex
  32801. * @param height the height of the vortex
  32802. * @returns a Physics vortex event, or null
  32803. * A physics vortex event or null
  32804. */
  32805. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  32806. }
  32807. /**
  32808. * Represents a physics radial explosion event
  32809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32810. */
  32811. class PhysicsRadialExplosionEvent {
  32812. private _scene;
  32813. private _sphere;
  32814. private _sphereOptions;
  32815. private _rays;
  32816. private _dataFetched;
  32817. /**
  32818. * Initializes a radial explosioin event
  32819. * @param scene BabylonJS scene
  32820. */
  32821. constructor(scene: Scene);
  32822. /**
  32823. * Returns the data related to the radial explosion event (sphere & rays).
  32824. * @returns The radial explosion event data
  32825. */
  32826. getData(): PhysicsRadialExplosionEventData;
  32827. /**
  32828. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  32829. * @param impostor A physics imposter
  32830. * @param origin the origin of the explosion
  32831. * @param radius the explosion radius
  32832. * @param strength the explosion strength
  32833. * @param falloff possible options: Constant & Linear
  32834. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  32835. */
  32836. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  32837. /**
  32838. * Disposes the sphere.
  32839. * @param force Specifies if the sphere should be disposed by force
  32840. */
  32841. dispose(force?: boolean): void;
  32842. /*** Helpers ***/
  32843. private _prepareSphere;
  32844. private _intersectsWithSphere;
  32845. }
  32846. /**
  32847. * Represents a gravitational field event
  32848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32849. */
  32850. class PhysicsGravitationalFieldEvent {
  32851. private _physicsHelper;
  32852. private _scene;
  32853. private _origin;
  32854. private _radius;
  32855. private _strength;
  32856. private _falloff;
  32857. private _tickCallback;
  32858. private _sphere;
  32859. private _dataFetched;
  32860. /**
  32861. * Initializes the physics gravitational field event
  32862. * @param physicsHelper A physics helper
  32863. * @param scene BabylonJS scene
  32864. * @param origin The origin position of the gravitational field event
  32865. * @param radius The radius of the gravitational field event
  32866. * @param strength The strength of the gravitational field event
  32867. * @param falloff The falloff for the gravitational field event
  32868. */
  32869. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  32870. /**
  32871. * Returns the data related to the gravitational field event (sphere).
  32872. * @returns A gravitational field event
  32873. */
  32874. getData(): PhysicsGravitationalFieldEventData;
  32875. /**
  32876. * Enables the gravitational field.
  32877. */
  32878. enable(): void;
  32879. /**
  32880. * Disables the gravitational field.
  32881. */
  32882. disable(): void;
  32883. /**
  32884. * Disposes the sphere.
  32885. * @param force The force to dispose from the gravitational field event
  32886. */
  32887. dispose(force?: boolean): void;
  32888. private _tick;
  32889. }
  32890. /**
  32891. * Represents a physics updraft event
  32892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32893. */
  32894. class PhysicsUpdraftEvent {
  32895. private _scene;
  32896. private _origin;
  32897. private _radius;
  32898. private _strength;
  32899. private _height;
  32900. private _updraftMode;
  32901. private _physicsEngine;
  32902. private _originTop;
  32903. private _originDirection;
  32904. private _tickCallback;
  32905. private _cylinder;
  32906. private _cylinderPosition;
  32907. private _dataFetched;
  32908. /**
  32909. * Initializes the physics updraft event
  32910. * @param _scene BabylonJS scene
  32911. * @param _origin The origin position of the updraft
  32912. * @param _radius The radius of the updraft
  32913. * @param _strength The strength of the updraft
  32914. * @param _height The height of the updraft
  32915. * @param _updraftMode The mode of the updraft
  32916. */
  32917. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  32918. /**
  32919. * Returns the data related to the updraft event (cylinder).
  32920. * @returns A physics updraft event
  32921. */
  32922. getData(): PhysicsUpdraftEventData;
  32923. /**
  32924. * Enables the updraft.
  32925. */
  32926. enable(): void;
  32927. /**
  32928. * Disables the cortex.
  32929. */
  32930. disable(): void;
  32931. /**
  32932. * Disposes the sphere.
  32933. * @param force Specifies if the updraft should be disposed by force
  32934. */
  32935. dispose(force?: boolean): void;
  32936. private getImpostorForceAndContactPoint;
  32937. private _tick;
  32938. /*** Helpers ***/
  32939. private _prepareCylinder;
  32940. private _intersectsWithCylinder;
  32941. }
  32942. /**
  32943. * Represents a physics vortex event
  32944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32945. */
  32946. class PhysicsVortexEvent {
  32947. private _scene;
  32948. private _origin;
  32949. private _radius;
  32950. private _strength;
  32951. private _height;
  32952. private _physicsEngine;
  32953. private _originTop;
  32954. private _centripetalForceThreshold;
  32955. private _updraftMultiplier;
  32956. private _tickCallback;
  32957. private _cylinder;
  32958. private _cylinderPosition;
  32959. private _dataFetched;
  32960. /**
  32961. * Initializes the physics vortex event
  32962. * @param _scene The BabylonJS scene
  32963. * @param _origin The origin position of the vortex
  32964. * @param _radius The radius of the vortex
  32965. * @param _strength The strength of the vortex
  32966. * @param _height The height of the vortex
  32967. */
  32968. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  32969. /**
  32970. * Returns the data related to the vortex event (cylinder).
  32971. * @returns The physics vortex event data
  32972. */
  32973. getData(): PhysicsVortexEventData;
  32974. /**
  32975. * Enables the vortex.
  32976. */
  32977. enable(): void;
  32978. /**
  32979. * Disables the cortex.
  32980. */
  32981. disable(): void;
  32982. /**
  32983. * Disposes the sphere.
  32984. * @param force
  32985. */
  32986. dispose(force?: boolean): void;
  32987. private getImpostorForceAndContactPoint;
  32988. private _tick;
  32989. /*** Helpers ***/
  32990. private _prepareCylinder;
  32991. private _intersectsWithCylinder;
  32992. }
  32993. /**
  32994. * The strenght of the force in correspondence to the distance of the affected object
  32995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32996. */
  32997. enum PhysicsRadialImpulseFalloff {
  32998. /** Defines that impulse is constant in strength across it's whole radius */
  32999. Constant = 0,
  33000. /** DEfines that impulse gets weaker if it's further from the origin */
  33001. Linear = 1
  33002. }
  33003. /**
  33004. * The strength of the force in correspondence to the distance of the affected object
  33005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33006. */
  33007. enum PhysicsUpdraftMode {
  33008. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33009. Center = 0,
  33010. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33011. Perpendicular = 1
  33012. }
  33013. /**
  33014. * Interface for a physics force and contact point
  33015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33016. */
  33017. interface PhysicsForceAndContactPoint {
  33018. /**
  33019. * The force applied at the contact point
  33020. */
  33021. force: Vector3;
  33022. /**
  33023. * The contact point
  33024. */
  33025. contactPoint: Vector3;
  33026. }
  33027. /**
  33028. * Interface for radial explosion event data
  33029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33030. */
  33031. interface PhysicsRadialExplosionEventData {
  33032. /**
  33033. * A sphere used for the radial explosion event
  33034. */
  33035. sphere: Mesh;
  33036. /**
  33037. * An array of rays for the radial explosion event
  33038. */
  33039. rays: Array<Ray>;
  33040. }
  33041. /**
  33042. * Interface for gravitational field event data
  33043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33044. */
  33045. interface PhysicsGravitationalFieldEventData {
  33046. /**
  33047. * A sphere mesh used for the gravitational field event
  33048. */
  33049. sphere: Mesh;
  33050. }
  33051. /**
  33052. * Interface for updraft event data
  33053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33054. */
  33055. interface PhysicsUpdraftEventData {
  33056. /**
  33057. * A cylinder used for the updraft event
  33058. */
  33059. cylinder: Mesh;
  33060. }
  33061. /**
  33062. * Interface for vortex event data
  33063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33064. */
  33065. interface PhysicsVortexEventData {
  33066. /**
  33067. * A cylinder used for the vortex event
  33068. */
  33069. cylinder: Mesh;
  33070. }
  33071. }
  33072. declare module BABYLON {
  33073. /**
  33074. * The interface for the physics imposter parameters
  33075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33076. */
  33077. interface PhysicsImpostorParameters {
  33078. /**
  33079. * The mass of the physics imposter
  33080. */
  33081. mass: number;
  33082. /**
  33083. * The friction of the physics imposter
  33084. */
  33085. friction?: number;
  33086. /**
  33087. * The coefficient of restitution of the physics imposter
  33088. */
  33089. restitution?: number;
  33090. /**
  33091. * The native options of the physics imposter
  33092. */
  33093. nativeOptions?: any;
  33094. /**
  33095. * Specifies if the parent should be ignored
  33096. */
  33097. ignoreParent?: boolean;
  33098. /**
  33099. * Specifies if bi-directional transformations should be disabled
  33100. */
  33101. disableBidirectionalTransformation?: boolean;
  33102. }
  33103. /**
  33104. * Interface for a physics-enabled object
  33105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33106. */
  33107. interface IPhysicsEnabledObject {
  33108. /**
  33109. * The position of the physics-enabled object
  33110. */
  33111. position: Vector3;
  33112. /**
  33113. * The rotation of the physics-enabled object
  33114. */
  33115. rotationQuaternion: Nullable<Quaternion>;
  33116. /**
  33117. * The scale of the physics-enabled object
  33118. */
  33119. scaling: Vector3;
  33120. /**
  33121. * The rotation of the physics-enabled object
  33122. */
  33123. rotation?: Vector3;
  33124. /**
  33125. * The parent of the physics-enabled object
  33126. */
  33127. parent?: any;
  33128. /**
  33129. * The bounding info of the physics-enabled object
  33130. * @returns The bounding info of the physics-enabled object
  33131. */
  33132. getBoundingInfo(): BoundingInfo;
  33133. /**
  33134. * Computes the world matrix
  33135. * @param force Specifies if the world matrix should be computed by force
  33136. * @returns A world matrix
  33137. */
  33138. computeWorldMatrix(force: boolean): Matrix;
  33139. /**
  33140. * Gets the world matrix
  33141. * @returns A world matrix
  33142. */
  33143. getWorldMatrix?(): Matrix;
  33144. /**
  33145. * Gets the child meshes
  33146. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33147. * @returns An array of abstract meshes
  33148. */
  33149. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33150. /**
  33151. * Gets the vertex data
  33152. * @param kind The type of vertex data
  33153. * @returns A nullable array of numbers, or a float32 array
  33154. */
  33155. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33156. /**
  33157. * Gets the indices from the mesh
  33158. * @returns A nullable array of index arrays
  33159. */
  33160. getIndices?(): Nullable<IndicesArray>;
  33161. /**
  33162. * Gets the scene from the mesh
  33163. * @returns the indices array or null
  33164. */
  33165. getScene?(): Scene;
  33166. /**
  33167. * Gets the absolute position from the mesh
  33168. * @returns the absolute position
  33169. */
  33170. getAbsolutePosition(): Vector3;
  33171. /**
  33172. * Gets the absolute pivot point from the mesh
  33173. * @returns the absolute pivot point
  33174. */
  33175. getAbsolutePivotPoint(): Vector3;
  33176. /**
  33177. * Rotates the mesh
  33178. * @param axis The axis of rotation
  33179. * @param amount The amount of rotation
  33180. * @param space The space of the rotation
  33181. * @returns The rotation transform node
  33182. */
  33183. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33184. /**
  33185. * Translates the mesh
  33186. * @param axis The axis of translation
  33187. * @param distance The distance of translation
  33188. * @param space The space of the translation
  33189. * @returns The transform node
  33190. */
  33191. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33192. /**
  33193. * Sets the absolute position of the mesh
  33194. * @param absolutePosition The absolute position of the mesh
  33195. * @returns The transform node
  33196. */
  33197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33198. /**
  33199. * Gets the class name of the mesh
  33200. * @returns The class name
  33201. */
  33202. getClassName(): string;
  33203. }
  33204. /**
  33205. * Represents a physics imposter
  33206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33207. */
  33208. class PhysicsImpostor {
  33209. /**
  33210. * The physics-enabled object used as the physics imposter
  33211. */
  33212. object: IPhysicsEnabledObject;
  33213. /**
  33214. * The type of the physics imposter
  33215. */
  33216. type: number;
  33217. private _options;
  33218. private _scene?;
  33219. /**
  33220. * The default object size of the imposter
  33221. */
  33222. static DEFAULT_OBJECT_SIZE: Vector3;
  33223. /**
  33224. * The identity quaternion of the imposter
  33225. */
  33226. static IDENTITY_QUATERNION: Quaternion;
  33227. private _physicsEngine;
  33228. private _physicsBody;
  33229. private _bodyUpdateRequired;
  33230. private _onBeforePhysicsStepCallbacks;
  33231. private _onAfterPhysicsStepCallbacks;
  33232. private _onPhysicsCollideCallbacks;
  33233. private _deltaPosition;
  33234. private _deltaRotation;
  33235. private _deltaRotationConjugated;
  33236. private _parent;
  33237. private _isDisposed;
  33238. private static _tmpVecs;
  33239. private static _tmpQuat;
  33240. /**
  33241. * Specifies if the physics imposter is disposed
  33242. */
  33243. readonly isDisposed: boolean;
  33244. /**
  33245. * Gets the mass of the physics imposter
  33246. */
  33247. mass: number;
  33248. /**
  33249. * Gets the coefficient of friction
  33250. */
  33251. /**
  33252. * Sets the coefficient of friction
  33253. */
  33254. friction: number;
  33255. /**
  33256. * Gets the coefficient of restitution
  33257. */
  33258. /**
  33259. * Sets the coefficient of restitution
  33260. */
  33261. restitution: number;
  33262. /**
  33263. * The unique id of the physics imposter
  33264. * set by the physics engine when adding this impostor to the array
  33265. */
  33266. uniqueId: number;
  33267. private _joints;
  33268. /**
  33269. * Initializes the physics imposter
  33270. * @param object The physics-enabled object used as the physics imposter
  33271. * @param type The type of the physics imposter
  33272. * @param _options The options for the physics imposter
  33273. * @param _scene The Babylon scene
  33274. */
  33275. constructor(
  33276. /**
  33277. * The physics-enabled object used as the physics imposter
  33278. */
  33279. object: IPhysicsEnabledObject,
  33280. /**
  33281. * The type of the physics imposter
  33282. */
  33283. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33284. /**
  33285. * This function will completly initialize this impostor.
  33286. * It will create a new body - but only if this mesh has no parent.
  33287. * If it has, this impostor will not be used other than to define the impostor
  33288. * of the child mesh.
  33289. * @hidden
  33290. */
  33291. _init(): void;
  33292. private _getPhysicsParent;
  33293. /**
  33294. * Should a new body be generated.
  33295. * @returns boolean specifying if body initialization is required
  33296. */
  33297. isBodyInitRequired(): boolean;
  33298. /**
  33299. * Sets the updated scaling
  33300. * @param updated Specifies if the scaling is updated
  33301. */
  33302. setScalingUpdated(updated: boolean): void;
  33303. /**
  33304. * Force a regeneration of this or the parent's impostor's body.
  33305. * Use under cautious - This will remove all joints already implemented.
  33306. */
  33307. forceUpdate(): void;
  33308. /**
  33309. * Gets the body that holds this impostor. Either its own, or its parent.
  33310. */
  33311. /**
  33312. * Set the physics body. Used mainly by the physics engine/plugin
  33313. */
  33314. physicsBody: any;
  33315. /**
  33316. * Get the parent of the physics imposter
  33317. * @returns Physics imposter or null
  33318. */
  33319. /**
  33320. * Sets the parent of the physics imposter
  33321. */
  33322. parent: Nullable<PhysicsImpostor>;
  33323. /**
  33324. * Resets the update flags
  33325. */
  33326. resetUpdateFlags(): void;
  33327. /**
  33328. * Gets the object extend size
  33329. * @returns the object extend size
  33330. */
  33331. getObjectExtendSize(): Vector3;
  33332. /**
  33333. * Gets the object center
  33334. * @returns The object center
  33335. */
  33336. getObjectCenter(): Vector3;
  33337. /**
  33338. * Get a specific parametes from the options parameter
  33339. * @param paramName The object parameter name
  33340. * @returns The object parameter
  33341. */
  33342. getParam(paramName: string): any;
  33343. /**
  33344. * Sets a specific parameter in the options given to the physics plugin
  33345. * @param paramName The parameter name
  33346. * @param value The value of the parameter
  33347. */
  33348. setParam(paramName: string, value: number): void;
  33349. /**
  33350. * Specifically change the body's mass option. Won't recreate the physics body object
  33351. * @param mass The mass of the physics imposter
  33352. */
  33353. setMass(mass: number): void;
  33354. /**
  33355. * Gets the linear velocity
  33356. * @returns linear velocity or null
  33357. */
  33358. getLinearVelocity(): Nullable<Vector3>;
  33359. /**
  33360. * Sets the linear velocity
  33361. * @param velocity linear velocity or null
  33362. */
  33363. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33364. /**
  33365. * Gets the angular velocity
  33366. * @returns angular velocity or null
  33367. */
  33368. getAngularVelocity(): Nullable<Vector3>;
  33369. /**
  33370. * Sets the angular velocity
  33371. * @param velocity The velocity or null
  33372. */
  33373. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33374. /**
  33375. * Execute a function with the physics plugin native code
  33376. * Provide a function the will have two variables - the world object and the physics body object
  33377. * @param func The function to execute with the physics plugin native code
  33378. */
  33379. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33380. /**
  33381. * Register a function that will be executed before the physics world is stepping forward
  33382. * @param func The function to execute before the physics world is stepped forward
  33383. */
  33384. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33385. /**
  33386. * Unregister a function that will be executed before the physics world is stepping forward
  33387. * @param func The function to execute before the physics world is stepped forward
  33388. */
  33389. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33390. /**
  33391. * Register a function that will be executed after the physics step
  33392. * @param func The function to execute after physics step
  33393. */
  33394. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33395. /**
  33396. * Unregisters a function that will be executed after the physics step
  33397. * @param func The function to execute after physics step
  33398. */
  33399. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33400. /**
  33401. * register a function that will be executed when this impostor collides against a different body
  33402. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33403. * @param func Callback that is executed on collision
  33404. */
  33405. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33406. /**
  33407. * Unregisters the physics imposter on contact
  33408. * @param collideAgainst The physics object to collide against
  33409. * @param func Callback to execute on collision
  33410. */
  33411. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33412. private _tmpQuat;
  33413. private _tmpQuat2;
  33414. /**
  33415. * Get the parent rotation
  33416. * @returns The parent rotation
  33417. */
  33418. getParentsRotation(): Quaternion;
  33419. /**
  33420. * this function is executed by the physics engine.
  33421. */
  33422. beforeStep: () => void;
  33423. /**
  33424. * this function is executed by the physics engine
  33425. */
  33426. afterStep: () => void;
  33427. /**
  33428. * Legacy collision detection event support
  33429. */
  33430. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33431. /**
  33432. * event and body object due to cannon's event-based architecture.
  33433. */
  33434. onCollide: (e: {
  33435. body: any;
  33436. }) => void;
  33437. /**
  33438. * Apply a force
  33439. * @param force The force to apply
  33440. * @param contactPoint The contact point for the force
  33441. * @returns The physics imposter
  33442. */
  33443. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33444. /**
  33445. * Apply an impulse
  33446. * @param force The impulse force
  33447. * @param contactPoint The contact point for the impulse force
  33448. * @returns The physics imposter
  33449. */
  33450. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33451. /**
  33452. * A help function to create a joint
  33453. * @param otherImpostor A physics imposter used to create a joint
  33454. * @param jointType The type of joint
  33455. * @param jointData The data for the joint
  33456. * @returns The physics imposter
  33457. */
  33458. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33459. /**
  33460. * Add a joint to this impostor with a different impostor
  33461. * @param otherImpostor A physics imposter used to add a joint
  33462. * @param joint The joint to add
  33463. * @returns The physics imposter
  33464. */
  33465. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33466. /**
  33467. * Will keep this body still, in a sleep mode.
  33468. * @returns the physics imposter
  33469. */
  33470. sleep(): PhysicsImpostor;
  33471. /**
  33472. * Wake the body up.
  33473. * @returns The physics imposter
  33474. */
  33475. wakeUp(): PhysicsImpostor;
  33476. /**
  33477. * Clones the physics imposter
  33478. * @param newObject The physics imposter clones to this physics-enabled object
  33479. * @returns A nullable physics imposter
  33480. */
  33481. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33482. /**
  33483. * Disposes the physics imposter
  33484. */
  33485. dispose(): void;
  33486. /**
  33487. * Sets the delta position
  33488. * @param position The delta position amount
  33489. */
  33490. setDeltaPosition(position: Vector3): void;
  33491. /**
  33492. * Sets the delta rotation
  33493. * @param rotation The delta rotation amount
  33494. */
  33495. setDeltaRotation(rotation: Quaternion): void;
  33496. /**
  33497. * Gets the box size of the physics imposter and stores the result in the input parameter
  33498. * @param result Stores the box size
  33499. * @returns The physics imposter
  33500. */
  33501. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33502. /**
  33503. * Gets the radius of the physics imposter
  33504. * @returns Radius of the physics imposter
  33505. */
  33506. getRadius(): number;
  33507. /**
  33508. * Sync a bone with this impostor
  33509. * @param bone The bone to sync to the impostor.
  33510. * @param boneMesh The mesh that the bone is influencing.
  33511. * @param jointPivot The pivot of the joint / bone in local space.
  33512. * @param distToJoint Optional distance from the impostor to the joint.
  33513. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33514. */
  33515. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33516. /**
  33517. * Sync impostor to a bone
  33518. * @param bone The bone that the impostor will be synced to.
  33519. * @param boneMesh The mesh that the bone is influencing.
  33520. * @param jointPivot The pivot of the joint / bone in local space.
  33521. * @param distToJoint Optional distance from the impostor to the joint.
  33522. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33523. * @param boneAxis Optional vector3 axis the bone is aligned with
  33524. */
  33525. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33526. /**
  33527. * No-Imposter type
  33528. */
  33529. static NoImpostor: number;
  33530. /**
  33531. * Sphere-Imposter type
  33532. */
  33533. static SphereImpostor: number;
  33534. /**
  33535. * Box-Imposter type
  33536. */
  33537. static BoxImpostor: number;
  33538. /**
  33539. * Plane-Imposter type
  33540. */
  33541. static PlaneImpostor: number;
  33542. /**
  33543. * Mesh-imposter type
  33544. */
  33545. static MeshImpostor: number;
  33546. /**
  33547. * Cylinder-Imposter type
  33548. */
  33549. static CylinderImpostor: number;
  33550. /**
  33551. * Particle-Imposter type
  33552. */
  33553. static ParticleImpostor: number;
  33554. /**
  33555. * Heightmap-Imposter type
  33556. */
  33557. static HeightmapImpostor: number;
  33558. }
  33559. }
  33560. declare module BABYLON {
  33561. /**
  33562. * Interface for Physics-Joint data
  33563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33564. */
  33565. interface PhysicsJointData {
  33566. /**
  33567. * The main pivot of the joint
  33568. */
  33569. mainPivot?: Vector3;
  33570. /**
  33571. * The connected pivot of the joint
  33572. */
  33573. connectedPivot?: Vector3;
  33574. /**
  33575. * The main axis of the joint
  33576. */
  33577. mainAxis?: Vector3;
  33578. /**
  33579. * The connected axis of the joint
  33580. */
  33581. connectedAxis?: Vector3;
  33582. /**
  33583. * The collision of the joint
  33584. */
  33585. collision?: boolean;
  33586. /**
  33587. * Native Oimo/Cannon/Energy data
  33588. */
  33589. nativeParams?: any;
  33590. }
  33591. /**
  33592. * This is a holder class for the physics joint created by the physics plugin
  33593. * It holds a set of functions to control the underlying joint
  33594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33595. */
  33596. class PhysicsJoint {
  33597. /**
  33598. * The type of the physics joint
  33599. */
  33600. type: number;
  33601. /**
  33602. * The data for the physics joint
  33603. */
  33604. jointData: PhysicsJointData;
  33605. private _physicsJoint;
  33606. protected _physicsPlugin: IPhysicsEnginePlugin;
  33607. /**
  33608. * Initializes the physics joint
  33609. * @param type The type of the physics joint
  33610. * @param jointData The data for the physics joint
  33611. */
  33612. constructor(
  33613. /**
  33614. * The type of the physics joint
  33615. */
  33616. type: number,
  33617. /**
  33618. * The data for the physics joint
  33619. */
  33620. jointData: PhysicsJointData);
  33621. /**
  33622. * Gets the physics joint
  33623. */
  33624. /**
  33625. * Sets the physics joint
  33626. */
  33627. physicsJoint: any;
  33628. /**
  33629. * Sets the physics plugin
  33630. */
  33631. physicsPlugin: IPhysicsEnginePlugin;
  33632. /**
  33633. * Execute a function that is physics-plugin specific.
  33634. * @param {Function} func the function that will be executed.
  33635. * It accepts two parameters: the physics world and the physics joint
  33636. */
  33637. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33638. /**
  33639. * Distance-Joint type
  33640. */
  33641. static DistanceJoint: number;
  33642. /**
  33643. * Hinge-Joint type
  33644. */
  33645. static HingeJoint: number;
  33646. /**
  33647. * Ball-and-Socket joint type
  33648. */
  33649. static BallAndSocketJoint: number;
  33650. /**
  33651. * Wheel-Joint type
  33652. */
  33653. static WheelJoint: number;
  33654. /**
  33655. * Slider-Joint type
  33656. */
  33657. static SliderJoint: number;
  33658. /**
  33659. * Prismatic-Joint type
  33660. */
  33661. static PrismaticJoint: number;
  33662. /**
  33663. * Universal-Joint type
  33664. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33665. */
  33666. static UniversalJoint: number;
  33667. /**
  33668. * Hinge-Joint 2 type
  33669. */
  33670. static Hinge2Joint: number;
  33671. /**
  33672. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33673. */
  33674. static PointToPointJoint: number;
  33675. /**
  33676. * Spring-Joint type
  33677. */
  33678. static SpringJoint: number;
  33679. /**
  33680. * Lock-Joint type
  33681. */
  33682. static LockJoint: number;
  33683. }
  33684. /**
  33685. * A class representing a physics distance joint
  33686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33687. */
  33688. class DistanceJoint extends PhysicsJoint {
  33689. /**
  33690. *
  33691. * @param jointData The data for the Distance-Joint
  33692. */
  33693. constructor(jointData: DistanceJointData);
  33694. /**
  33695. * Update the predefined distance.
  33696. * @param maxDistance The maximum preferred distance
  33697. * @param minDistance The minimum preferred distance
  33698. */
  33699. updateDistance(maxDistance: number, minDistance?: number): void;
  33700. }
  33701. /**
  33702. * Represents a Motor-Enabled Joint
  33703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33704. */
  33705. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33706. /**
  33707. * Initializes the Motor-Enabled Joint
  33708. * @param type The type of the joint
  33709. * @param jointData The physica joint data for the joint
  33710. */
  33711. constructor(type: number, jointData: PhysicsJointData);
  33712. /**
  33713. * Set the motor values.
  33714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33715. * @param force the force to apply
  33716. * @param maxForce max force for this motor.
  33717. */
  33718. setMotor(force?: number, maxForce?: number): void;
  33719. /**
  33720. * Set the motor's limits.
  33721. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33722. * @param upperLimit The upper limit of the motor
  33723. * @param lowerLimit The lower limit of the motor
  33724. */
  33725. setLimit(upperLimit: number, lowerLimit?: number): void;
  33726. }
  33727. /**
  33728. * This class represents a single physics Hinge-Joint
  33729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33730. */
  33731. class HingeJoint extends MotorEnabledJoint {
  33732. /**
  33733. * Initializes the Hinge-Joint
  33734. * @param jointData The joint data for the Hinge-Joint
  33735. */
  33736. constructor(jointData: PhysicsJointData);
  33737. /**
  33738. * Set the motor values.
  33739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33740. * @param {number} force the force to apply
  33741. * @param {number} maxForce max force for this motor.
  33742. */
  33743. setMotor(force?: number, maxForce?: number): void;
  33744. /**
  33745. * Set the motor's limits.
  33746. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33747. * @param upperLimit The upper limit of the motor
  33748. * @param lowerLimit The lower limit of the motor
  33749. */
  33750. setLimit(upperLimit: number, lowerLimit?: number): void;
  33751. }
  33752. /**
  33753. * This class represents a dual hinge physics joint (same as wheel joint)
  33754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33755. */
  33756. class Hinge2Joint extends MotorEnabledJoint {
  33757. /**
  33758. * Initializes the Hinge2-Joint
  33759. * @param jointData The joint data for the Hinge2-Joint
  33760. */
  33761. constructor(jointData: PhysicsJointData);
  33762. /**
  33763. * Set the motor values.
  33764. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33765. * @param {number} force the force to apply
  33766. * @param {number} maxForce max force for this motor.
  33767. * @param {motorIndex} the motor's index, 0 or 1.
  33768. */
  33769. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33770. /**
  33771. * Set the motor limits.
  33772. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33773. * @param {number} upperLimit the upper limit
  33774. * @param {number} lowerLimit lower limit
  33775. * @param {motorIndex} the motor's index, 0 or 1.
  33776. */
  33777. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33778. }
  33779. /**
  33780. * Interface for a motor enabled joint
  33781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33782. */
  33783. interface IMotorEnabledJoint {
  33784. /**
  33785. * Physics joint
  33786. */
  33787. physicsJoint: any;
  33788. /**
  33789. * Sets the motor of the motor-enabled joint
  33790. * @param force The force of the motor
  33791. * @param maxForce The maximum force of the motor
  33792. * @param motorIndex The index of the motor
  33793. */
  33794. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33795. /**
  33796. * Sets the limit of the motor
  33797. * @param upperLimit The upper limit of the motor
  33798. * @param lowerLimit The lower limit of the motor
  33799. * @param motorIndex The index of the motor
  33800. */
  33801. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33802. }
  33803. /**
  33804. * Joint data for a Distance-Joint
  33805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33806. */
  33807. interface DistanceJointData extends PhysicsJointData {
  33808. /**
  33809. * Max distance the 2 joint objects can be apart
  33810. */
  33811. maxDistance: number;
  33812. }
  33813. /**
  33814. * Joint data from a spring joint
  33815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33816. */
  33817. interface SpringJointData extends PhysicsJointData {
  33818. /**
  33819. * Length of the spring
  33820. */
  33821. length: number;
  33822. /**
  33823. * Stiffness of the spring
  33824. */
  33825. stiffness: number;
  33826. /**
  33827. * Damping of the spring
  33828. */
  33829. damping: number;
  33830. /** this callback will be called when applying the force to the impostors. */
  33831. forceApplicationCallback: () => void;
  33832. }
  33833. }
  33834. declare module BABYLON {
  33835. interface Scene {
  33836. /**
  33837. * The list of reflection probes added to the scene
  33838. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33839. */
  33840. reflectionProbes: Array<ReflectionProbe>;
  33841. }
  33842. /**
  33843. * Class used to generate realtime reflection / refraction cube textures
  33844. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  33845. */
  33846. class ReflectionProbe {
  33847. /** defines the name of the probe */
  33848. name: string;
  33849. private _scene;
  33850. private _renderTargetTexture;
  33851. private _projectionMatrix;
  33852. private _viewMatrix;
  33853. private _target;
  33854. private _add;
  33855. private _attachedMesh;
  33856. private _invertYAxis;
  33857. /** Gets or sets probe position (center of the cube map) */
  33858. position: Vector3;
  33859. /**
  33860. * Creates a new reflection probe
  33861. * @param name defines the name of the probe
  33862. * @param size defines the texture resolution (for each face)
  33863. * @param scene defines the hosting scene
  33864. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  33865. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  33866. */
  33867. constructor(
  33868. /** defines the name of the probe */
  33869. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  33870. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  33871. samples: number;
  33872. /** Gets or sets the refresh rate to use (on every frame by default) */
  33873. refreshRate: number;
  33874. /**
  33875. * Gets the hosting scene
  33876. * @returns a Scene
  33877. */
  33878. getScene(): Scene;
  33879. /** Gets the internal CubeTexture used to render to */
  33880. readonly cubeTexture: RenderTargetTexture;
  33881. /** Gets the list of meshes to render */
  33882. readonly renderList: Nullable<AbstractMesh[]>;
  33883. /**
  33884. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  33885. * @param mesh defines the mesh to attach to
  33886. */
  33887. attachToMesh(mesh: AbstractMesh): void;
  33888. /**
  33889. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  33890. * @param renderingGroupId The rendering group id corresponding to its index
  33891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33892. */
  33893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33894. /**
  33895. * Clean all associated resources
  33896. */
  33897. dispose(): void;
  33898. }
  33899. }
  33900. declare module BABYLON {
  33901. /**
  33902. * Postprocess used to generate anaglyphic rendering
  33903. */
  33904. class AnaglyphPostProcess extends PostProcess {
  33905. private _passedProcess;
  33906. /**
  33907. * Creates a new AnaglyphPostProcess
  33908. * @param name defines postprocess name
  33909. * @param options defines creation options or target ratio scale
  33910. * @param rigCameras defines cameras using this postprocess
  33911. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  33912. * @param engine defines hosting engine
  33913. * @param reusable defines if the postprocess will be reused multiple times per frame
  33914. */
  33915. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  33916. }
  33917. }
  33918. declare module BABYLON {
  33919. /**
  33920. * Post process used to render in black and white
  33921. */
  33922. class BlackAndWhitePostProcess extends PostProcess {
  33923. /**
  33924. * Linear about to convert he result to black and white (default: 1)
  33925. */
  33926. degree: number;
  33927. /**
  33928. * Creates a black and white post process
  33929. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  33930. * @param name The name of the effect.
  33931. * @param options The required width/height ratio to downsize to before computing the render pass.
  33932. * @param camera The camera to apply the render pass to.
  33933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33934. * @param engine The engine which the post process will be applied. (default: current engine)
  33935. * @param reusable If the post process can be reused on the same frame. (default: false)
  33936. */
  33937. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33938. }
  33939. }
  33940. declare module BABYLON {
  33941. /**
  33942. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  33943. */
  33944. class BloomEffect extends PostProcessRenderEffect {
  33945. private bloomScale;
  33946. /**
  33947. * @hidden Internal
  33948. */
  33949. _effects: Array<PostProcess>;
  33950. /**
  33951. * @hidden Internal
  33952. */
  33953. _downscale: ExtractHighlightsPostProcess;
  33954. private _blurX;
  33955. private _blurY;
  33956. private _merge;
  33957. /**
  33958. * The luminance threshold to find bright areas of the image to bloom.
  33959. */
  33960. threshold: number;
  33961. /**
  33962. * The strength of the bloom.
  33963. */
  33964. weight: number;
  33965. /**
  33966. * Specifies the size of the bloom blur kernel, relative to the final output size
  33967. */
  33968. kernel: number;
  33969. /**
  33970. * Creates a new instance of @see BloomEffect
  33971. * @param scene The scene the effect belongs to.
  33972. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  33973. * @param bloomKernel The size of the kernel to be used when applying the blur.
  33974. * @param bloomWeight The the strength of bloom.
  33975. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33976. * @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)
  33977. */
  33978. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  33979. /**
  33980. * Disposes each of the internal effects for a given camera.
  33981. * @param camera The camera to dispose the effect on.
  33982. */
  33983. disposeEffects(camera: Camera): void;
  33984. /**
  33985. * @hidden Internal
  33986. */
  33987. _updateEffects(): void;
  33988. /**
  33989. * Internal
  33990. * @returns if all the contained post processes are ready.
  33991. * @hidden
  33992. */
  33993. _isReady(): boolean;
  33994. }
  33995. }
  33996. declare module BABYLON {
  33997. /**
  33998. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33999. */
  34000. class BloomMergePostProcess extends PostProcess {
  34001. /** Weight of the bloom to be added to the original input. */
  34002. weight: number;
  34003. /**
  34004. * Creates a new instance of @see BloomMergePostProcess
  34005. * @param name The name of the effect.
  34006. * @param originalFromInput Post process which's input will be used for the merge.
  34007. * @param blurred Blurred highlights post process which's output will be used.
  34008. * @param weight Weight of the bloom to be added to the original input.
  34009. * @param options The required width/height ratio to downsize to before computing the render pass.
  34010. * @param camera The camera to apply the render pass to.
  34011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34012. * @param engine The engine which the post process will be applied. (default: current engine)
  34013. * @param reusable If the post process can be reused on the same frame. (default: false)
  34014. * @param textureType Type of textures used when performing the post process. (default: 0)
  34015. * @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)
  34016. */
  34017. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34018. /** Weight of the bloom to be added to the original input. */
  34019. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34020. }
  34021. }
  34022. declare module BABYLON {
  34023. /**
  34024. * The Blur Post Process which blurs an image based on a kernel and direction.
  34025. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34026. */
  34027. class BlurPostProcess extends PostProcess {
  34028. /** The direction in which to blur the image. */
  34029. direction: Vector2;
  34030. private blockCompilation;
  34031. protected _kernel: number;
  34032. protected _idealKernel: number;
  34033. protected _packedFloat: boolean;
  34034. private _staticDefines;
  34035. /**
  34036. * Sets the length in pixels of the blur sample region
  34037. */
  34038. /**
  34039. * Gets the length in pixels of the blur sample region
  34040. */
  34041. kernel: number;
  34042. /**
  34043. * Sets wether or not the blur needs to unpack/repack floats
  34044. */
  34045. /**
  34046. * Gets wether or not the blur is unpacking/repacking floats
  34047. */
  34048. packedFloat: boolean;
  34049. /**
  34050. * Creates a new instance BlurPostProcess
  34051. * @param name The name of the effect.
  34052. * @param direction The direction in which to blur the image.
  34053. * @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.
  34054. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34055. * @param camera The camera to apply the render pass to.
  34056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34057. * @param engine The engine which the post process will be applied. (default: current engine)
  34058. * @param reusable If the post process can be reused on the same frame. (default: false)
  34059. * @param textureType Type of textures used when performing the post process. (default: 0)
  34060. * @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)
  34061. */
  34062. constructor(name: string,
  34063. /** The direction in which to blur the image. */
  34064. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34065. /**
  34066. * Updates the effect with the current post process compile time values and recompiles the shader.
  34067. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34068. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34069. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34070. * @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
  34071. * @param onCompiled Called when the shader has been compiled.
  34072. * @param onError Called if there is an error when compiling a shader.
  34073. */
  34074. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34075. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34076. /**
  34077. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34078. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34079. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34080. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34081. * The gaps between physical kernels are compensated for in the weighting of the samples
  34082. * @param idealKernel Ideal blur kernel.
  34083. * @return Nearest best kernel.
  34084. */
  34085. protected _nearestBestKernel(idealKernel: number): number;
  34086. /**
  34087. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34088. * @param x The point on the Gaussian distribution to sample.
  34089. * @return the value of the Gaussian function at x.
  34090. */
  34091. protected _gaussianWeight(x: number): number;
  34092. /**
  34093. * Generates a string that can be used as a floating point number in GLSL.
  34094. * @param x Value to print.
  34095. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34096. * @return GLSL float string.
  34097. */
  34098. protected _glslFloat(x: number, decimalFigures?: number): string;
  34099. }
  34100. }
  34101. declare module BABYLON {
  34102. /**
  34103. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34104. */
  34105. class ChromaticAberrationPostProcess extends PostProcess {
  34106. /**
  34107. * The amount of seperation of rgb channels (default: 30)
  34108. */
  34109. aberrationAmount: number;
  34110. /**
  34111. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34112. */
  34113. radialIntensity: number;
  34114. /**
  34115. * 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))
  34116. */
  34117. direction: Vector2;
  34118. /**
  34119. * 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))
  34120. */
  34121. centerPosition: Vector2;
  34122. /**
  34123. * Creates a new instance ChromaticAberrationPostProcess
  34124. * @param name The name of the effect.
  34125. * @param screenWidth The width of the screen to apply the effect on.
  34126. * @param screenHeight The height of the screen to apply the effect on.
  34127. * @param options The required width/height ratio to downsize to before computing the render pass.
  34128. * @param camera The camera to apply the render pass to.
  34129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34130. * @param engine The engine which the post process will be applied. (default: current engine)
  34131. * @param reusable If the post process can be reused on the same frame. (default: false)
  34132. * @param textureType Type of textures used when performing the post process. (default: 0)
  34133. * @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)
  34134. */
  34135. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34136. }
  34137. }
  34138. declare module BABYLON {
  34139. /**
  34140. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34141. */
  34142. class CircleOfConfusionPostProcess extends PostProcess {
  34143. /**
  34144. * 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.
  34145. */
  34146. lensSize: number;
  34147. /**
  34148. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34149. */
  34150. fStop: number;
  34151. /**
  34152. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34153. */
  34154. focusDistance: number;
  34155. /**
  34156. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34157. */
  34158. focalLength: number;
  34159. private _depthTexture;
  34160. /**
  34161. * Creates a new instance CircleOfConfusionPostProcess
  34162. * @param name The name of the effect.
  34163. * @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.
  34164. * @param options The required width/height ratio to downsize to before computing the render pass.
  34165. * @param camera The camera to apply the render pass to.
  34166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34167. * @param engine The engine which the post process will be applied. (default: current engine)
  34168. * @param reusable If the post process can be reused on the same frame. (default: false)
  34169. * @param textureType Type of textures used when performing the post process. (default: 0)
  34170. * @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)
  34171. */
  34172. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34173. /**
  34174. * 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.
  34175. */
  34176. depthTexture: RenderTargetTexture;
  34177. }
  34178. }
  34179. declare module BABYLON {
  34180. /**
  34181. *
  34182. * This post-process allows the modification of rendered colors by using
  34183. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34184. *
  34185. * The object needs to be provided an url to a texture containing the color
  34186. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34187. * Use an image editing software to tweak the LUT to match your needs.
  34188. *
  34189. * For an example of a color LUT, see here:
  34190. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34191. * For explanations on color grading, see here:
  34192. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34193. *
  34194. */
  34195. class ColorCorrectionPostProcess extends PostProcess {
  34196. private _colorTableTexture;
  34197. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34198. }
  34199. }
  34200. declare module BABYLON {
  34201. /**
  34202. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34203. * input texture to perform effects such as edge detection or sharpening
  34204. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34205. */
  34206. class ConvolutionPostProcess extends PostProcess {
  34207. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34208. kernel: number[];
  34209. /**
  34210. * Creates a new instance ConvolutionPostProcess
  34211. * @param name The name of the effect.
  34212. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34213. * @param options The required width/height ratio to downsize to before computing the render pass.
  34214. * @param camera The camera to apply the render pass to.
  34215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34216. * @param engine The engine which the post process will be applied. (default: current engine)
  34217. * @param reusable If the post process can be reused on the same frame. (default: false)
  34218. * @param textureType Type of textures used when performing the post process. (default: 0)
  34219. */
  34220. constructor(name: string,
  34221. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34222. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34223. /**
  34224. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34225. */
  34226. static EdgeDetect0Kernel: number[];
  34227. /**
  34228. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34229. */
  34230. static EdgeDetect1Kernel: number[];
  34231. /**
  34232. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34233. */
  34234. static EdgeDetect2Kernel: number[];
  34235. /**
  34236. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34237. */
  34238. static SharpenKernel: number[];
  34239. /**
  34240. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34241. */
  34242. static EmbossKernel: number[];
  34243. /**
  34244. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34245. */
  34246. static GaussianKernel: number[];
  34247. }
  34248. }
  34249. declare module BABYLON {
  34250. /**
  34251. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34252. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34253. * based on samples that have a large difference in distance than the center pixel.
  34254. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34255. */
  34256. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34257. direction: Vector2;
  34258. /**
  34259. * Creates a new instance CircleOfConfusionPostProcess
  34260. * @param name The name of the effect.
  34261. * @param scene The scene the effect belongs to.
  34262. * @param direction The direction the blur should be applied.
  34263. * @param kernel The size of the kernel used to blur.
  34264. * @param options The required width/height ratio to downsize to before computing the render pass.
  34265. * @param camera The camera to apply the render pass to.
  34266. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34267. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34269. * @param engine The engine which the post process will be applied. (default: current engine)
  34270. * @param reusable If the post process can be reused on the same frame. (default: false)
  34271. * @param textureType Type of textures used when performing the post process. (default: 0)
  34272. * @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)
  34273. */
  34274. 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);
  34275. }
  34276. }
  34277. declare module BABYLON {
  34278. /**
  34279. * Specifies the level of max blur that should be applied when using the depth of field effect
  34280. */
  34281. enum DepthOfFieldEffectBlurLevel {
  34282. /**
  34283. * Subtle blur
  34284. */
  34285. Low = 0,
  34286. /**
  34287. * Medium blur
  34288. */
  34289. Medium = 1,
  34290. /**
  34291. * Large blur
  34292. */
  34293. High = 2
  34294. }
  34295. /**
  34296. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34297. */
  34298. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34299. private _circleOfConfusion;
  34300. /**
  34301. * @hidden Internal, blurs from high to low
  34302. */
  34303. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34304. private _depthOfFieldBlurY;
  34305. private _dofMerge;
  34306. /**
  34307. * @hidden Internal post processes in depth of field effect
  34308. */
  34309. _effects: Array<PostProcess>;
  34310. /**
  34311. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34312. */
  34313. focalLength: number;
  34314. /**
  34315. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34316. */
  34317. fStop: number;
  34318. /**
  34319. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34320. */
  34321. focusDistance: number;
  34322. /**
  34323. * 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.
  34324. */
  34325. lensSize: number;
  34326. /**
  34327. * Creates a new instance DepthOfFieldEffect
  34328. * @param scene The scene the effect belongs to.
  34329. * @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.
  34330. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34331. * @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)
  34332. */
  34333. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34334. /**
  34335. * 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.
  34336. */
  34337. depthTexture: RenderTargetTexture;
  34338. /**
  34339. * Disposes each of the internal effects for a given camera.
  34340. * @param camera The camera to dispose the effect on.
  34341. */
  34342. disposeEffects(camera: Camera): void;
  34343. /**
  34344. * @hidden Internal
  34345. */
  34346. _updateEffects(): void;
  34347. /**
  34348. * Internal
  34349. * @returns if all the contained post processes are ready.
  34350. * @hidden
  34351. */
  34352. _isReady(): boolean;
  34353. }
  34354. }
  34355. declare module BABYLON {
  34356. /**
  34357. * Options to be set when merging outputs from the default pipeline.
  34358. */
  34359. class DepthOfFieldMergePostProcessOptions {
  34360. /**
  34361. * The original image to merge on top of
  34362. */
  34363. originalFromInput: PostProcess;
  34364. /**
  34365. * Parameters to perform the merge of the depth of field effect
  34366. */
  34367. depthOfField?: {
  34368. circleOfConfusion: PostProcess;
  34369. blurSteps: Array<PostProcess>;
  34370. };
  34371. /**
  34372. * Parameters to perform the merge of bloom effect
  34373. */
  34374. bloom?: {
  34375. blurred: PostProcess;
  34376. weight: number;
  34377. };
  34378. }
  34379. /**
  34380. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34381. */
  34382. class DepthOfFieldMergePostProcess extends PostProcess {
  34383. private blurSteps;
  34384. /**
  34385. * Creates a new instance of DepthOfFieldMergePostProcess
  34386. * @param name The name of the effect.
  34387. * @param originalFromInput Post process which's input will be used for the merge.
  34388. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34389. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34390. * @param options The required width/height ratio to downsize to before computing the render pass.
  34391. * @param camera The camera to apply the render pass to.
  34392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34393. * @param engine The engine which the post process will be applied. (default: current engine)
  34394. * @param reusable If the post process can be reused on the same frame. (default: false)
  34395. * @param textureType Type of textures used when performing the post process. (default: 0)
  34396. * @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)
  34397. */
  34398. 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);
  34399. /**
  34400. * Updates the effect with the current post process compile time values and recompiles the shader.
  34401. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34402. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34403. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34404. * @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
  34405. * @param onCompiled Called when the shader has been compiled.
  34406. * @param onError Called if there is an error when compiling a shader.
  34407. */
  34408. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34409. }
  34410. }
  34411. declare module BABYLON {
  34412. /**
  34413. * DisplayPassPostProcess which produces an output the same as it's input
  34414. */
  34415. class DisplayPassPostProcess extends PostProcess {
  34416. /**
  34417. * Creates the DisplayPassPostProcess
  34418. * @param name The name of the effect.
  34419. * @param options The required width/height ratio to downsize to before computing the render pass.
  34420. * @param camera The camera to apply the render pass to.
  34421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34422. * @param engine The engine which the post process will be applied. (default: current engine)
  34423. * @param reusable If the post process can be reused on the same frame. (default: false)
  34424. */
  34425. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34426. }
  34427. }
  34428. declare module BABYLON {
  34429. /**
  34430. * 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.
  34431. */
  34432. class ExtractHighlightsPostProcess extends PostProcess {
  34433. /**
  34434. * The luminance threshold, pixels below this value will be set to black.
  34435. */
  34436. threshold: number;
  34437. /** @hidden */
  34438. _exposure: number;
  34439. /**
  34440. * Post process which has the input texture to be used when performing highlight extraction
  34441. * @hidden
  34442. */
  34443. _inputPostProcess: Nullable<PostProcess>;
  34444. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34445. }
  34446. }
  34447. declare module BABYLON {
  34448. /**
  34449. * Applies a kernel filter to the image
  34450. */
  34451. class FilterPostProcess extends PostProcess {
  34452. /** The matrix to be applied to the image */
  34453. kernelMatrix: Matrix;
  34454. /**
  34455. *
  34456. * @param name The name of the effect.
  34457. * @param kernelMatrix The matrix to be applied to the image
  34458. * @param options The required width/height ratio to downsize to before computing the render pass.
  34459. * @param camera The camera to apply the render pass to.
  34460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34461. * @param engine The engine which the post process will be applied. (default: current engine)
  34462. * @param reusable If the post process can be reused on the same frame. (default: false)
  34463. */
  34464. constructor(name: string,
  34465. /** The matrix to be applied to the image */
  34466. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34467. }
  34468. }
  34469. declare module BABYLON {
  34470. /**
  34471. * Fxaa post process
  34472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34473. */
  34474. class FxaaPostProcess extends PostProcess {
  34475. /** @hidden */
  34476. texelWidth: number;
  34477. /** @hidden */
  34478. texelHeight: number;
  34479. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34480. private _getDefines;
  34481. }
  34482. }
  34483. declare module BABYLON {
  34484. /**
  34485. * The GrainPostProcess adds noise to the image at mid luminance levels
  34486. */
  34487. class GrainPostProcess extends PostProcess {
  34488. /**
  34489. * The intensity of the grain added (default: 30)
  34490. */
  34491. intensity: number;
  34492. /**
  34493. * If the grain should be randomized on every frame
  34494. */
  34495. animated: boolean;
  34496. /**
  34497. * Creates a new instance of @see GrainPostProcess
  34498. * @param name The name of the effect.
  34499. * @param options The required width/height ratio to downsize to before computing the render pass.
  34500. * @param camera The camera to apply the render pass to.
  34501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34502. * @param engine The engine which the post process will be applied. (default: current engine)
  34503. * @param reusable If the post process can be reused on the same frame. (default: false)
  34504. * @param textureType Type of textures used when performing the post process. (default: 0)
  34505. * @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)
  34506. */
  34507. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34508. }
  34509. }
  34510. declare module BABYLON {
  34511. /**
  34512. * Extracts highlights from the image
  34513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34514. */
  34515. class HighlightsPostProcess extends PostProcess {
  34516. /**
  34517. * Extracts highlights from the image
  34518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34519. * @param name The name of the effect.
  34520. * @param options The required width/height ratio to downsize to before computing the render pass.
  34521. * @param camera The camera to apply the render pass to.
  34522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34523. * @param engine The engine which the post process will be applied. (default: current engine)
  34524. * @param reusable If the post process can be reused on the same frame. (default: false)
  34525. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34526. */
  34527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34528. }
  34529. }
  34530. declare module BABYLON {
  34531. /**
  34532. * ImageProcessingPostProcess
  34533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34534. */
  34535. class ImageProcessingPostProcess extends PostProcess {
  34536. /**
  34537. * Default configuration related to image processing available in the PBR Material.
  34538. */
  34539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34540. /**
  34541. * Gets the image processing configuration used either in this material.
  34542. */
  34543. /**
  34544. * Sets the Default image processing configuration used either in the this material.
  34545. *
  34546. * If sets to null, the scene one is in use.
  34547. */
  34548. imageProcessingConfiguration: ImageProcessingConfiguration;
  34549. /**
  34550. * Keep track of the image processing observer to allow dispose and replace.
  34551. */
  34552. private _imageProcessingObserver;
  34553. /**
  34554. * Attaches a new image processing configuration to the PBR Material.
  34555. * @param configuration
  34556. */
  34557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34558. /**
  34559. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34560. */
  34561. /**
  34562. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34563. */
  34564. colorCurves: Nullable<ColorCurves>;
  34565. /**
  34566. * Gets wether the color curves effect is enabled.
  34567. */
  34568. /**
  34569. * Sets wether the color curves effect is enabled.
  34570. */
  34571. colorCurvesEnabled: boolean;
  34572. /**
  34573. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34574. */
  34575. /**
  34576. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34577. */
  34578. colorGradingTexture: Nullable<BaseTexture>;
  34579. /**
  34580. * Gets wether the color grading effect is enabled.
  34581. */
  34582. /**
  34583. * Gets wether the color grading effect is enabled.
  34584. */
  34585. colorGradingEnabled: boolean;
  34586. /**
  34587. * Gets exposure used in the effect.
  34588. */
  34589. /**
  34590. * Sets exposure used in the effect.
  34591. */
  34592. exposure: number;
  34593. /**
  34594. * Gets wether tonemapping is enabled or not.
  34595. */
  34596. /**
  34597. * Sets wether tonemapping is enabled or not
  34598. */
  34599. toneMappingEnabled: boolean;
  34600. /**
  34601. * Gets contrast used in the effect.
  34602. */
  34603. /**
  34604. * Sets contrast used in the effect.
  34605. */
  34606. contrast: number;
  34607. /**
  34608. * Gets Vignette stretch size.
  34609. */
  34610. /**
  34611. * Sets Vignette stretch size.
  34612. */
  34613. vignetteStretch: number;
  34614. /**
  34615. * Gets Vignette centre X Offset.
  34616. */
  34617. /**
  34618. * Sets Vignette centre X Offset.
  34619. */
  34620. vignetteCentreX: number;
  34621. /**
  34622. * Gets Vignette centre Y Offset.
  34623. */
  34624. /**
  34625. * Sets Vignette centre Y Offset.
  34626. */
  34627. vignetteCentreY: number;
  34628. /**
  34629. * Gets Vignette weight or intensity of the vignette effect.
  34630. */
  34631. /**
  34632. * Sets Vignette weight or intensity of the vignette effect.
  34633. */
  34634. vignetteWeight: number;
  34635. /**
  34636. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34637. * if vignetteEnabled is set to true.
  34638. */
  34639. /**
  34640. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34641. * if vignetteEnabled is set to true.
  34642. */
  34643. vignetteColor: Color4;
  34644. /**
  34645. * Gets Camera field of view used by the Vignette effect.
  34646. */
  34647. /**
  34648. * Sets Camera field of view used by the Vignette effect.
  34649. */
  34650. vignetteCameraFov: number;
  34651. /**
  34652. * Gets the vignette blend mode allowing different kind of effect.
  34653. */
  34654. /**
  34655. * Sets the vignette blend mode allowing different kind of effect.
  34656. */
  34657. vignetteBlendMode: number;
  34658. /**
  34659. * Gets wether the vignette effect is enabled.
  34660. */
  34661. /**
  34662. * Sets wether the vignette effect is enabled.
  34663. */
  34664. vignetteEnabled: boolean;
  34665. private _fromLinearSpace;
  34666. /**
  34667. * Gets wether the input of the processing is in Gamma or Linear Space.
  34668. */
  34669. /**
  34670. * Sets wether the input of the processing is in Gamma or Linear Space.
  34671. */
  34672. fromLinearSpace: boolean;
  34673. /**
  34674. * Defines cache preventing GC.
  34675. */
  34676. private _defines;
  34677. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34678. /**
  34679. * "ImageProcessingPostProcess"
  34680. * @returns "ImageProcessingPostProcess"
  34681. */
  34682. getClassName(): string;
  34683. protected _updateParameters(): void;
  34684. dispose(camera?: Camera): void;
  34685. }
  34686. }
  34687. declare module BABYLON {
  34688. /**
  34689. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34690. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34691. * As an example, all you have to do is to create the post-process:
  34692. * var mb = new BABYLON.MotionBlurPostProcess(
  34693. * 'mb', // The name of the effect.
  34694. * scene, // The scene containing the objects to blur according to their velocity.
  34695. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34696. * camera // The camera to apply the render pass to.
  34697. * );
  34698. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34699. */
  34700. class MotionBlurPostProcess extends PostProcess {
  34701. /**
  34702. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34703. */
  34704. motionStrength: number;
  34705. /**
  34706. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34707. */
  34708. /**
  34709. * Sets the number of iterations to be used for motion blur quality
  34710. */
  34711. motionBlurSamples: number;
  34712. private _motionBlurSamples;
  34713. private _geometryBufferRenderer;
  34714. /**
  34715. * Creates a new instance MotionBlurPostProcess
  34716. * @param name The name of the effect.
  34717. * @param scene The scene containing the objects to blur according to their velocity.
  34718. * @param options The required width/height ratio to downsize to before computing the render pass.
  34719. * @param camera The camera to apply the render pass to.
  34720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34721. * @param engine The engine which the post process will be applied. (default: current engine)
  34722. * @param reusable If the post process can be reused on the same frame. (default: false)
  34723. * @param textureType Type of textures used when performing the post process. (default: 0)
  34724. * @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)
  34725. */
  34726. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34727. /**
  34728. * Disposes the post process.
  34729. * @param camera The camera to dispose the post process on.
  34730. */
  34731. dispose(camera?: Camera): void;
  34732. }
  34733. }
  34734. declare module BABYLON {
  34735. /**
  34736. * PassPostProcess which produces an output the same as it's input
  34737. */
  34738. class PassPostProcess extends PostProcess {
  34739. /**
  34740. * Creates the PassPostProcess
  34741. * @param name The name of the effect.
  34742. * @param options The required width/height ratio to downsize to before computing the render pass.
  34743. * @param camera The camera to apply the render pass to.
  34744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34745. * @param engine The engine which the post process will be applied. (default: current engine)
  34746. * @param reusable If the post process can be reused on the same frame. (default: false)
  34747. * @param textureType The type of texture to be used when performing the post processing.
  34748. * @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)
  34749. */
  34750. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34751. }
  34752. }
  34753. declare module BABYLON {
  34754. /**
  34755. * Size options for a post process
  34756. */
  34757. type PostProcessOptions = {
  34758. width: number;
  34759. height: number;
  34760. };
  34761. /**
  34762. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34763. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34764. */
  34765. class PostProcess {
  34766. /** Name of the PostProcess. */
  34767. name: string;
  34768. /**
  34769. * Width of the texture to apply the post process on
  34770. */
  34771. width: number;
  34772. /**
  34773. * Height of the texture to apply the post process on
  34774. */
  34775. height: number;
  34776. /**
  34777. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34778. * @hidden
  34779. */
  34780. _outputTexture: Nullable<InternalTexture>;
  34781. /**
  34782. * Sampling mode used by the shader
  34783. * See https://doc.babylonjs.com/classes/3.1/texture
  34784. */
  34785. renderTargetSamplingMode: number;
  34786. /**
  34787. * Clear color to use when screen clearing
  34788. */
  34789. clearColor: Color4;
  34790. /**
  34791. * If the buffer needs to be cleared before applying the post process. (default: true)
  34792. * Should be set to false if shader will overwrite all previous pixels.
  34793. */
  34794. autoClear: boolean;
  34795. /**
  34796. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34797. */
  34798. alphaMode: number;
  34799. /**
  34800. * Sets the setAlphaBlendConstants of the babylon engine
  34801. */
  34802. alphaConstants: Color4;
  34803. /**
  34804. * Animations to be used for the post processing
  34805. */
  34806. animations: Animation[];
  34807. /**
  34808. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34809. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34810. */
  34811. enablePixelPerfectMode: boolean;
  34812. /**
  34813. * Force the postprocess to be applied without taking in account viewport
  34814. */
  34815. forceFullscreenViewport: boolean;
  34816. /**
  34817. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34818. *
  34819. * | Value | Type | Description |
  34820. * | ----- | ----------------------------------- | ----------- |
  34821. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34822. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34823. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34824. *
  34825. */
  34826. scaleMode: number;
  34827. /**
  34828. * Force textures to be a power of two (default: false)
  34829. */
  34830. alwaysForcePOT: boolean;
  34831. private _samples;
  34832. /**
  34833. * Number of sample textures (default: 1)
  34834. */
  34835. samples: number;
  34836. /**
  34837. * Modify the scale of the post process to be the same as the viewport (default: false)
  34838. */
  34839. adaptScaleToCurrentViewport: boolean;
  34840. private _camera;
  34841. private _scene;
  34842. private _engine;
  34843. private _options;
  34844. private _reusable;
  34845. private _textureType;
  34846. /**
  34847. * Smart array of input and output textures for the post process.
  34848. * @hidden
  34849. */
  34850. _textures: SmartArray<InternalTexture>;
  34851. /**
  34852. * The index in _textures that corresponds to the output texture.
  34853. * @hidden
  34854. */
  34855. _currentRenderTextureInd: number;
  34856. private _effect;
  34857. private _samplers;
  34858. private _fragmentUrl;
  34859. private _vertexUrl;
  34860. private _parameters;
  34861. private _scaleRatio;
  34862. protected _indexParameters: any;
  34863. private _shareOutputWithPostProcess;
  34864. private _texelSize;
  34865. private _forcedOutputTexture;
  34866. /**
  34867. * An event triggered when the postprocess is activated.
  34868. */
  34869. onActivateObservable: Observable<Camera>;
  34870. private _onActivateObserver;
  34871. /**
  34872. * A function that is added to the onActivateObservable
  34873. */
  34874. onActivate: Nullable<(camera: Camera) => void>;
  34875. /**
  34876. * An event triggered when the postprocess changes its size.
  34877. */
  34878. onSizeChangedObservable: Observable<PostProcess>;
  34879. private _onSizeChangedObserver;
  34880. /**
  34881. * A function that is added to the onSizeChangedObservable
  34882. */
  34883. onSizeChanged: (postProcess: PostProcess) => void;
  34884. /**
  34885. * An event triggered when the postprocess applies its effect.
  34886. */
  34887. onApplyObservable: Observable<Effect>;
  34888. private _onApplyObserver;
  34889. /**
  34890. * A function that is added to the onApplyObservable
  34891. */
  34892. onApply: (effect: Effect) => void;
  34893. /**
  34894. * An event triggered before rendering the postprocess
  34895. */
  34896. onBeforeRenderObservable: Observable<Effect>;
  34897. private _onBeforeRenderObserver;
  34898. /**
  34899. * A function that is added to the onBeforeRenderObservable
  34900. */
  34901. onBeforeRender: (effect: Effect) => void;
  34902. /**
  34903. * An event triggered after rendering the postprocess
  34904. */
  34905. onAfterRenderObservable: Observable<Effect>;
  34906. private _onAfterRenderObserver;
  34907. /**
  34908. * A function that is added to the onAfterRenderObservable
  34909. */
  34910. onAfterRender: (efect: Effect) => void;
  34911. /**
  34912. * 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
  34913. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  34914. */
  34915. inputTexture: InternalTexture;
  34916. /**
  34917. * Gets the camera which post process is applied to.
  34918. * @returns The camera the post process is applied to.
  34919. */
  34920. getCamera(): Camera;
  34921. /**
  34922. * Gets the texel size of the postprocess.
  34923. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  34924. */
  34925. readonly texelSize: Vector2;
  34926. /**
  34927. * Creates a new instance PostProcess
  34928. * @param name The name of the PostProcess.
  34929. * @param fragmentUrl The url of the fragment shader to be used.
  34930. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  34931. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  34932. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34933. * @param camera The camera to apply the render pass to.
  34934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34935. * @param engine The engine which the post process will be applied. (default: current engine)
  34936. * @param reusable If the post process can be reused on the same frame. (default: false)
  34937. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  34938. * @param textureType Type of textures used when performing the post process. (default: 0)
  34939. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  34940. * @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
  34941. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  34942. */
  34943. constructor(
  34944. /** Name of the PostProcess. */
  34945. 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);
  34946. /**
  34947. * Gets the engine which this post process belongs to.
  34948. * @returns The engine the post process was enabled with.
  34949. */
  34950. getEngine(): Engine;
  34951. /**
  34952. * The effect that is created when initializing the post process.
  34953. * @returns The created effect corrisponding the the postprocess.
  34954. */
  34955. getEffect(): Effect;
  34956. /**
  34957. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  34958. * @param postProcess The post process to share the output with.
  34959. * @returns This post process.
  34960. */
  34961. shareOutputWith(postProcess: PostProcess): PostProcess;
  34962. /**
  34963. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  34964. * This should be called if the post process that shares output with this post process is disabled/disposed.
  34965. */
  34966. useOwnOutput(): void;
  34967. /**
  34968. * Updates the effect with the current post process compile time values and recompiles the shader.
  34969. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34970. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34971. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34972. * @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
  34973. * @param onCompiled Called when the shader has been compiled.
  34974. * @param onError Called if there is an error when compiling a shader.
  34975. */
  34976. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34977. /**
  34978. * The post process is reusable if it can be used multiple times within one frame.
  34979. * @returns If the post process is reusable
  34980. */
  34981. isReusable(): boolean;
  34982. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  34983. markTextureDirty(): void;
  34984. /**
  34985. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  34986. * 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.
  34987. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  34988. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  34989. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  34990. * @returns The target texture that was bound to be written to.
  34991. */
  34992. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  34993. /**
  34994. * If the post process is supported.
  34995. */
  34996. readonly isSupported: boolean;
  34997. /**
  34998. * The aspect ratio of the output texture.
  34999. */
  35000. readonly aspectRatio: number;
  35001. /**
  35002. * Get a value indicating if the post-process is ready to be used
  35003. * @returns true if the post-process is ready (shader is compiled)
  35004. */
  35005. isReady(): boolean;
  35006. /**
  35007. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35008. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35009. */
  35010. apply(): Nullable<Effect>;
  35011. private _disposeTextures;
  35012. /**
  35013. * Disposes the post process.
  35014. * @param camera The camera to dispose the post process on.
  35015. */
  35016. dispose(camera?: Camera): void;
  35017. }
  35018. }
  35019. declare module BABYLON {
  35020. /**
  35021. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35022. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35023. */
  35024. class PostProcessManager {
  35025. private _scene;
  35026. private _indexBuffer;
  35027. private _vertexBuffers;
  35028. /**
  35029. * Creates a new instance PostProcess
  35030. * @param scene The scene that the post process is associated with.
  35031. */
  35032. constructor(scene: Scene);
  35033. private _prepareBuffers;
  35034. private _buildIndexBuffer;
  35035. /**
  35036. * Rebuilds the vertex buffers of the manager.
  35037. * @hidden
  35038. */
  35039. _rebuild(): void;
  35040. /**
  35041. * Prepares a frame to be run through a post process.
  35042. * @param sourceTexture The input texture to the post procesess. (default: null)
  35043. * @param postProcesses An array of post processes to be run. (default: null)
  35044. * @returns True if the post processes were able to be run.
  35045. * @hidden
  35046. */
  35047. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35048. /**
  35049. * Manually render a set of post processes to a texture.
  35050. * @param postProcesses An array of post processes to be run.
  35051. * @param targetTexture The target texture to render to.
  35052. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35053. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35054. * @param lodLevel defines which lod of the texture to render to
  35055. */
  35056. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35057. /**
  35058. * Finalize the result of the output of the postprocesses.
  35059. * @param doNotPresent If true the result will not be displayed to the screen.
  35060. * @param targetTexture The target texture to render to.
  35061. * @param faceIndex The index of the face to bind the target texture to.
  35062. * @param postProcesses The array of post processes to render.
  35063. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35064. * @hidden
  35065. */
  35066. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35067. /**
  35068. * Disposes of the post process manager.
  35069. */
  35070. dispose(): void;
  35071. }
  35072. }
  35073. declare module BABYLON {
  35074. /**
  35075. * Post process which applies a refractin texture
  35076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35077. */
  35078. class RefractionPostProcess extends PostProcess {
  35079. /** the base color of the refraction (used to taint the rendering) */
  35080. color: Color3;
  35081. /** simulated refraction depth */
  35082. depth: number;
  35083. /** the coefficient of the base color (0 to remove base color tainting) */
  35084. colorLevel: number;
  35085. private _refTexture;
  35086. private _ownRefractionTexture;
  35087. /**
  35088. * Gets or sets the refraction texture
  35089. * Please note that you are responsible for disposing the texture if you set it manually
  35090. */
  35091. refractionTexture: Texture;
  35092. /**
  35093. * Initializes the RefractionPostProcess
  35094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35095. * @param name The name of the effect.
  35096. * @param refractionTextureUrl Url of the refraction texture to use
  35097. * @param color the base color of the refraction (used to taint the rendering)
  35098. * @param depth simulated refraction depth
  35099. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35100. * @param camera The camera to apply the render pass to.
  35101. * @param options The required width/height ratio to downsize to before computing the render pass.
  35102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35103. * @param engine The engine which the post process will be applied. (default: current engine)
  35104. * @param reusable If the post process can be reused on the same frame. (default: false)
  35105. */
  35106. constructor(name: string, refractionTextureUrl: string,
  35107. /** the base color of the refraction (used to taint the rendering) */
  35108. color: Color3,
  35109. /** simulated refraction depth */
  35110. depth: number,
  35111. /** the coefficient of the base color (0 to remove base color tainting) */
  35112. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35113. /**
  35114. * Disposes of the post process
  35115. * @param camera Camera to dispose post process on
  35116. */
  35117. dispose(camera: Camera): void;
  35118. }
  35119. }
  35120. declare module BABYLON {
  35121. /**
  35122. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35123. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35124. */
  35125. class SharpenPostProcess extends PostProcess {
  35126. /**
  35127. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35128. */
  35129. colorAmount: number;
  35130. /**
  35131. * How much sharpness should be applied (default: 0.3)
  35132. */
  35133. edgeAmount: number;
  35134. /**
  35135. * Creates a new instance ConvolutionPostProcess
  35136. * @param name The name of the effect.
  35137. * @param options The required width/height ratio to downsize to before computing the render pass.
  35138. * @param camera The camera to apply the render pass to.
  35139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35140. * @param engine The engine which the post process will be applied. (default: current engine)
  35141. * @param reusable If the post process can be reused on the same frame. (default: false)
  35142. * @param textureType Type of textures used when performing the post process. (default: 0)
  35143. * @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)
  35144. */
  35145. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /**
  35150. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35151. */
  35152. class StereoscopicInterlacePostProcess extends PostProcess {
  35153. private _stepSize;
  35154. private _passedProcess;
  35155. /**
  35156. * Initializes a StereoscopicInterlacePostProcess
  35157. * @param name The name of the effect.
  35158. * @param rigCameras The rig cameras to be appled to the post process
  35159. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35161. * @param engine The engine which the post process will be applied. (default: current engine)
  35162. * @param reusable If the post process can be reused on the same frame. (default: false)
  35163. */
  35164. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35165. }
  35166. }
  35167. declare module BABYLON {
  35168. /** Defines operator used for tonemapping */
  35169. enum TonemappingOperator {
  35170. /** Hable */
  35171. Hable = 0,
  35172. /** Reinhard */
  35173. Reinhard = 1,
  35174. /** HejiDawson */
  35175. HejiDawson = 2,
  35176. /** Photographic */
  35177. Photographic = 3
  35178. }
  35179. /**
  35180. * Defines a post process to apply tone mapping
  35181. */
  35182. class TonemapPostProcess extends PostProcess {
  35183. private _operator;
  35184. /** Defines the required exposure adjustement */
  35185. exposureAdjustment: number;
  35186. /**
  35187. * Creates a new TonemapPostProcess
  35188. * @param name defines the name of the postprocess
  35189. * @param _operator defines the operator to use
  35190. * @param exposureAdjustment defines the required exposure adjustement
  35191. * @param camera defines the camera to use (can be null)
  35192. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35193. * @param engine defines the hosting engine (can be ignore if camera is set)
  35194. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35195. */
  35196. constructor(name: string, _operator: TonemappingOperator,
  35197. /** Defines the required exposure adjustement */
  35198. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35199. }
  35200. }
  35201. declare module BABYLON {
  35202. /**
  35203. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35204. */
  35205. class VolumetricLightScatteringPostProcess extends PostProcess {
  35206. private _volumetricLightScatteringPass;
  35207. private _volumetricLightScatteringRTT;
  35208. private _viewPort;
  35209. private _screenCoordinates;
  35210. private _cachedDefines;
  35211. /**
  35212. * If not undefined, the mesh position is computed from the attached node position
  35213. */
  35214. attachedNode: {
  35215. position: Vector3;
  35216. };
  35217. /**
  35218. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35219. */
  35220. customMeshPosition: Vector3;
  35221. /**
  35222. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35223. */
  35224. useCustomMeshPosition: boolean;
  35225. /**
  35226. * If the post-process should inverse the light scattering direction
  35227. */
  35228. invert: boolean;
  35229. /**
  35230. * The internal mesh used by the post-process
  35231. */
  35232. mesh: Mesh;
  35233. /**
  35234. * @hidden
  35235. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35236. */
  35237. useDiffuseColor: boolean;
  35238. /**
  35239. * Array containing the excluded meshes not rendered in the internal pass
  35240. */
  35241. excludedMeshes: AbstractMesh[];
  35242. /**
  35243. * Controls the overall intensity of the post-process
  35244. */
  35245. exposure: number;
  35246. /**
  35247. * Dissipates each sample's contribution in range [0, 1]
  35248. */
  35249. decay: number;
  35250. /**
  35251. * Controls the overall intensity of each sample
  35252. */
  35253. weight: number;
  35254. /**
  35255. * Controls the density of each sample
  35256. */
  35257. density: number;
  35258. /**
  35259. * @constructor
  35260. * @param name The post-process name
  35261. * @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)
  35262. * @param camera The camera that the post-process will be attached to
  35263. * @param mesh The mesh used to create the light scattering
  35264. * @param samples The post-process quality, default 100
  35265. * @param samplingModeThe post-process filtering mode
  35266. * @param engine The babylon engine
  35267. * @param reusable If the post-process is reusable
  35268. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35269. */
  35270. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35271. /**
  35272. * Returns the string "VolumetricLightScatteringPostProcess"
  35273. * @returns "VolumetricLightScatteringPostProcess"
  35274. */
  35275. getClassName(): string;
  35276. private _isReady;
  35277. /**
  35278. * Sets the new light position for light scattering effect
  35279. * @param position The new custom light position
  35280. */
  35281. setCustomMeshPosition(position: Vector3): void;
  35282. /**
  35283. * Returns the light position for light scattering effect
  35284. * @return Vector3 The custom light position
  35285. */
  35286. getCustomMeshPosition(): Vector3;
  35287. /**
  35288. * Disposes the internal assets and detaches the post-process from the camera
  35289. */
  35290. dispose(camera: Camera): void;
  35291. /**
  35292. * Returns the render target texture used by the post-process
  35293. * @return the render target texture used by the post-process
  35294. */
  35295. getPass(): RenderTargetTexture;
  35296. private _meshExcluded;
  35297. private _createPass;
  35298. private _updateMeshScreenCoordinates;
  35299. /**
  35300. * Creates a default mesh for the Volumeric Light Scattering post-process
  35301. * @param name The mesh name
  35302. * @param scene The scene where to create the mesh
  35303. * @return the default mesh
  35304. */
  35305. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35306. }
  35307. }
  35308. declare module BABYLON {
  35309. /**
  35310. * VRDistortionCorrectionPostProcess used for mobile VR
  35311. */
  35312. class VRDistortionCorrectionPostProcess extends PostProcess {
  35313. private _isRightEye;
  35314. private _distortionFactors;
  35315. private _postProcessScaleFactor;
  35316. private _lensCenterOffset;
  35317. private _scaleIn;
  35318. private _scaleFactor;
  35319. private _lensCenter;
  35320. /**
  35321. * Initializes the VRDistortionCorrectionPostProcess
  35322. * @param name The name of the effect.
  35323. * @param camera The camera to apply the render pass to.
  35324. * @param isRightEye If this is for the right eye distortion
  35325. * @param vrMetrics All the required metrics for the VR camera
  35326. */
  35327. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35328. }
  35329. }
  35330. declare module BABYLON {
  35331. interface Scene {
  35332. /** @hidden (Backing field) */
  35333. _boundingBoxRenderer: BoundingBoxRenderer;
  35334. /** @hidden (Backing field) */
  35335. _forceShowBoundingBoxes: boolean;
  35336. /**
  35337. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35338. */
  35339. forceShowBoundingBoxes: boolean;
  35340. /**
  35341. * Gets the bounding box renderer associated with the scene
  35342. * @returns a BoundingBoxRenderer
  35343. */
  35344. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35345. }
  35346. interface AbstractMesh {
  35347. /** @hidden (Backing field) */
  35348. _showBoundingBox: boolean;
  35349. /**
  35350. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35351. */
  35352. showBoundingBox: boolean;
  35353. }
  35354. /**
  35355. * Component responsible of rendering the bounding box of the meshes in a scene.
  35356. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35357. */
  35358. class BoundingBoxRenderer implements ISceneComponent {
  35359. /**
  35360. * The component name helpfull to identify the component in the list of scene components.
  35361. */
  35362. readonly name: string;
  35363. /**
  35364. * The scene the component belongs to.
  35365. */
  35366. scene: Scene;
  35367. /**
  35368. * Color of the bounding box lines placed in front of an object
  35369. */
  35370. frontColor: Color3;
  35371. /**
  35372. * Color of the bounding box lines placed behind an object
  35373. */
  35374. backColor: Color3;
  35375. /**
  35376. * Defines if the renderer should show the back lines or not
  35377. */
  35378. showBackLines: boolean;
  35379. /**
  35380. * @hidden
  35381. */
  35382. renderList: SmartArray<BoundingBox>;
  35383. private _colorShader;
  35384. private _vertexBuffers;
  35385. private _indexBuffer;
  35386. /**
  35387. * Instantiates a new bounding box renderer in a scene.
  35388. * @param scene the scene the renderer renders in
  35389. */
  35390. constructor(scene: Scene);
  35391. /**
  35392. * Registers the component in a given scene
  35393. */
  35394. register(): void;
  35395. private _evaluateSubMesh;
  35396. private _activeMesh;
  35397. private _prepareRessources;
  35398. private _createIndexBuffer;
  35399. /**
  35400. * Rebuilds the elements related to this component in case of
  35401. * context lost for instance.
  35402. */
  35403. rebuild(): void;
  35404. /**
  35405. * @hidden
  35406. */
  35407. reset(): void;
  35408. /**
  35409. * Render the bounding boxes of a specific rendering group
  35410. * @param renderingGroupId defines the rendering group to render
  35411. */
  35412. render(renderingGroupId: number): void;
  35413. /**
  35414. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35415. * @param mesh Define the mesh to render the occlusion bounding box for
  35416. */
  35417. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35418. /**
  35419. * Dispose and release the resources attached to this renderer.
  35420. */
  35421. dispose(): void;
  35422. }
  35423. }
  35424. declare module BABYLON {
  35425. /**
  35426. * This represents a depth renderer in Babylon.
  35427. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35428. */
  35429. class DepthRenderer {
  35430. private _scene;
  35431. private _depthMap;
  35432. private _effect;
  35433. private _cachedDefines;
  35434. private _camera;
  35435. /**
  35436. * Specifiess that the depth renderer will only be used within
  35437. * the camera it is created for.
  35438. * This can help forcing its rendering during the camera processing.
  35439. */
  35440. useOnlyInActiveCamera: boolean;
  35441. /**
  35442. * Instantiates a depth renderer
  35443. * @param scene The scene the renderer belongs to
  35444. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35445. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35446. */
  35447. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35448. /**
  35449. * Creates the depth rendering effect and checks if the effect is ready.
  35450. * @param subMesh The submesh to be used to render the depth map of
  35451. * @param useInstances If multiple world instances should be used
  35452. * @returns if the depth renderer is ready to render the depth map
  35453. */
  35454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35455. /**
  35456. * Gets the texture which the depth map will be written to.
  35457. * @returns The depth map texture
  35458. */
  35459. getDepthMap(): RenderTargetTexture;
  35460. /**
  35461. * Disposes of the depth renderer.
  35462. */
  35463. dispose(): void;
  35464. }
  35465. }
  35466. declare module BABYLON {
  35467. interface Scene {
  35468. /** @hidden (Backing field) */
  35469. _depthRenderer: {
  35470. [id: string]: DepthRenderer;
  35471. };
  35472. /**
  35473. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35474. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35475. * @returns the created depth renderer
  35476. */
  35477. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35478. /**
  35479. * Disables a depth renderer for a given camera
  35480. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35481. */
  35482. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35483. }
  35484. /**
  35485. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35486. * in several rendering techniques.
  35487. */
  35488. class DepthRendererSceneComponent implements ISceneComponent {
  35489. /**
  35490. * The component name helpfull to identify the component in the list of scene components.
  35491. */
  35492. readonly name: string;
  35493. /**
  35494. * The scene the component belongs to.
  35495. */
  35496. scene: Scene;
  35497. /**
  35498. * Creates a new instance of the component for the given scene
  35499. * @param scene Defines the scene to register the component in
  35500. */
  35501. constructor(scene: Scene);
  35502. /**
  35503. * Registers the component in a given scene
  35504. */
  35505. register(): void;
  35506. /**
  35507. * Rebuilds the elements related to this component in case of
  35508. * context lost for instance.
  35509. */
  35510. rebuild(): void;
  35511. /**
  35512. * Disposes the component and the associated ressources
  35513. */
  35514. dispose(): void;
  35515. private _gatherRenderTargets;
  35516. private _gatherActiveCameraRenderTargets;
  35517. }
  35518. }
  35519. declare module BABYLON {
  35520. interface AbstractMesh {
  35521. /**
  35522. * Disables the mesh edge rendering mode
  35523. * @returns the currentAbstractMesh
  35524. */
  35525. disableEdgesRendering(): AbstractMesh;
  35526. /**
  35527. * Enables the edge rendering mode on the mesh.
  35528. * This mode makes the mesh edges visible
  35529. * @param epsilon defines the maximal distance between two angles to detect a face
  35530. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35531. * @returns the currentAbstractMesh
  35532. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35533. */
  35534. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35535. /**
  35536. * Gets the edgesRenderer associated with the mesh
  35537. */
  35538. edgesRenderer: Nullable<EdgesRenderer>;
  35539. }
  35540. interface LinesMesh {
  35541. /**
  35542. * Enables the edge rendering mode on the mesh.
  35543. * This mode makes the mesh edges visible
  35544. * @param epsilon defines the maximal distance between two angles to detect a face
  35545. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35546. * @returns the currentAbstractMesh
  35547. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35548. */
  35549. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35550. }
  35551. /**
  35552. * Defines the minimum contract an Edges renderer should follow.
  35553. */
  35554. interface IEdgesRenderer extends IDisposable {
  35555. /**
  35556. * Gets or sets a boolean indicating if the edgesRenderer is active
  35557. */
  35558. isEnabled: boolean;
  35559. /**
  35560. * Renders the edges of the attached mesh,
  35561. */
  35562. render(): void;
  35563. /**
  35564. * Checks wether or not the edges renderer is ready to render.
  35565. * @return true if ready, otherwise false.
  35566. */
  35567. isReady(): boolean;
  35568. }
  35569. /**
  35570. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35571. */
  35572. class EdgesRenderer implements IEdgesRenderer {
  35573. /**
  35574. * Define the size of the edges with an orthographic camera
  35575. */
  35576. edgesWidthScalerForOrthographic: number;
  35577. /**
  35578. * Define the size of the edges with a perspective camera
  35579. */
  35580. edgesWidthScalerForPerspective: number;
  35581. protected _source: AbstractMesh;
  35582. protected _linesPositions: number[];
  35583. protected _linesNormals: number[];
  35584. protected _linesIndices: number[];
  35585. protected _epsilon: number;
  35586. protected _indicesCount: number;
  35587. protected _lineShader: ShaderMaterial;
  35588. protected _ib: WebGLBuffer;
  35589. protected _buffers: {
  35590. [key: string]: Nullable<VertexBuffer>;
  35591. };
  35592. protected _checkVerticesInsteadOfIndices: boolean;
  35593. private _meshRebuildObserver;
  35594. private _meshDisposeObserver;
  35595. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35596. isEnabled: boolean;
  35597. /**
  35598. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35599. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35600. * @param source Mesh used to create edges
  35601. * @param epsilon sum of angles in adjacency to check for edge
  35602. * @param checkVerticesInsteadOfIndices
  35603. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35604. */
  35605. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35606. protected _prepareRessources(): void;
  35607. /** @hidden */
  35608. _rebuild(): void;
  35609. /**
  35610. * Releases the required resources for the edges renderer
  35611. */
  35612. dispose(): void;
  35613. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35614. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35615. /**
  35616. * Checks if the pair of p0 and p1 is en edge
  35617. * @param faceIndex
  35618. * @param edge
  35619. * @param faceNormals
  35620. * @param p0
  35621. * @param p1
  35622. * @private
  35623. */
  35624. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35625. /**
  35626. * Generates lines edges from adjacencjes
  35627. * @private
  35628. */
  35629. _generateEdgesLines(): void;
  35630. /**
  35631. * Checks wether or not the edges renderer is ready to render.
  35632. * @return true if ready, otherwise false.
  35633. */
  35634. isReady(): boolean;
  35635. /**
  35636. * Renders the edges of the attached mesh,
  35637. */
  35638. render(): void;
  35639. }
  35640. }
  35641. declare module BABYLON {
  35642. /**
  35643. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35644. */
  35645. class GeometryBufferRenderer {
  35646. /**
  35647. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35648. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35649. */
  35650. static readonly POSITION_TEXTURE_TYPE: number;
  35651. /**
  35652. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35653. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35654. */
  35655. static readonly VELOCITY_TEXTURE_TYPE: number;
  35656. /**
  35657. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35658. * in order to compute objects velocities when enableVelocity is set to "true"
  35659. * @hidden
  35660. */
  35661. _previousTransformationMatrices: {
  35662. [index: number]: Matrix;
  35663. };
  35664. private _scene;
  35665. private _multiRenderTarget;
  35666. private _ratio;
  35667. private _enablePosition;
  35668. private _enableVelocity;
  35669. private _positionIndex;
  35670. private _velocityIndex;
  35671. protected _effect: Effect;
  35672. protected _cachedDefines: string;
  35673. /**
  35674. * Set the render list (meshes to be rendered) used in the G buffer.
  35675. */
  35676. renderList: Mesh[];
  35677. /**
  35678. * Gets wether or not G buffer are supported by the running hardware.
  35679. * This requires draw buffer supports
  35680. */
  35681. readonly isSupported: boolean;
  35682. /**
  35683. * Returns the index of the given texture type in the G-Buffer textures array
  35684. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35685. * @returns the index of the given texture type in the G-Buffer textures array
  35686. */
  35687. getTextureIndex(textureType: number): number;
  35688. /**
  35689. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35690. */
  35691. /**
  35692. * Sets whether or not objects positions are enabled for the G buffer.
  35693. */
  35694. enablePosition: boolean;
  35695. /**
  35696. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35697. */
  35698. /**
  35699. * Sets wether or not objects velocities are enabled for the G buffer.
  35700. */
  35701. enableVelocity: boolean;
  35702. /**
  35703. * Gets the scene associated with the buffer.
  35704. */
  35705. readonly scene: Scene;
  35706. /**
  35707. * Gets the ratio used by the buffer during its creation.
  35708. * How big is the buffer related to the main canvas.
  35709. */
  35710. readonly ratio: number;
  35711. /**
  35712. * Creates a new G Buffer for the scene
  35713. * @param scene The scene the buffer belongs to
  35714. * @param ratio How big is the buffer related to the main canvas.
  35715. */
  35716. constructor(scene: Scene, ratio?: number);
  35717. /**
  35718. * Checks wether everything is ready to render a submesh to the G buffer.
  35719. * @param subMesh the submesh to check readiness for
  35720. * @param useInstances is the mesh drawn using instance or not
  35721. * @returns true if ready otherwise false
  35722. */
  35723. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35724. /**
  35725. * Gets the current underlying G Buffer.
  35726. * @returns the buffer
  35727. */
  35728. getGBuffer(): MultiRenderTarget;
  35729. /**
  35730. * Gets the number of samples used to render the buffer (anti aliasing).
  35731. */
  35732. /**
  35733. * Sets the number of samples used to render the buffer (anti aliasing).
  35734. */
  35735. samples: number;
  35736. /**
  35737. * Disposes the renderer and frees up associated resources.
  35738. */
  35739. dispose(): void;
  35740. protected _createRenderTargets(): void;
  35741. }
  35742. }
  35743. declare module BABYLON {
  35744. interface Scene {
  35745. /** @hidden (Backing field) */
  35746. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35747. /**
  35748. * Gets or Sets the current geometry buffer associated to the scene.
  35749. */
  35750. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35751. /**
  35752. * Enables a GeometryBufferRender and associates it with the scene
  35753. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35754. * @returns the GeometryBufferRenderer
  35755. */
  35756. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35757. /**
  35758. * Disables the GeometryBufferRender associated with the scene
  35759. */
  35760. disableGeometryBufferRenderer(): void;
  35761. }
  35762. /**
  35763. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35764. * in several rendering techniques.
  35765. */
  35766. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35767. /**
  35768. * The component name helpful to identify the component in the list of scene components.
  35769. */
  35770. readonly name: string;
  35771. /**
  35772. * The scene the component belongs to.
  35773. */
  35774. scene: Scene;
  35775. /**
  35776. * Creates a new instance of the component for the given scene
  35777. * @param scene Defines the scene to register the component in
  35778. */
  35779. constructor(scene: Scene);
  35780. /**
  35781. * Registers the component in a given scene
  35782. */
  35783. register(): void;
  35784. /**
  35785. * Rebuilds the elements related to this component in case of
  35786. * context lost for instance.
  35787. */
  35788. rebuild(): void;
  35789. /**
  35790. * Disposes the component and the associated ressources
  35791. */
  35792. dispose(): void;
  35793. private _gatherRenderTargets;
  35794. }
  35795. }
  35796. declare module BABYLON {
  35797. /**
  35798. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35799. */
  35800. class LineEdgesRenderer extends EdgesRenderer {
  35801. /**
  35802. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35803. * @param source LineMesh used to generate edges
  35804. * @param epsilon not important (specified angle for edge detection)
  35805. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35806. */
  35807. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35808. /**
  35809. * Always create the edge since its a line so only important things are p0 and p1
  35810. * @param faceIndex not important for LineMesh
  35811. * @param edge not important for LineMesh
  35812. * @param faceNormals not important for LineMesh
  35813. * @param p0 beginnig of line
  35814. * @param p1 end of line
  35815. */
  35816. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35817. /**
  35818. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35819. */
  35820. _generateEdgesLines(): void;
  35821. }
  35822. }
  35823. declare module BABYLON {
  35824. interface Scene {
  35825. /** @hidden */
  35826. _outlineRenderer: OutlineRenderer;
  35827. /**
  35828. * Gets the outline renderer associated with the scene
  35829. * @returns a OutlineRenderer
  35830. */
  35831. getOutlineRenderer(): OutlineRenderer;
  35832. }
  35833. interface AbstractMesh {
  35834. /** @hidden (Backing field) */
  35835. _renderOutline: boolean;
  35836. /**
  35837. * Gets or sets a boolean indicating if the outline must be rendered as well
  35838. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35839. */
  35840. renderOutline: boolean;
  35841. /** @hidden (Backing field) */
  35842. _renderOverlay: boolean;
  35843. /**
  35844. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35845. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35846. */
  35847. renderOverlay: boolean;
  35848. }
  35849. /**
  35850. * This class is responsible to draw bothe outline/overlay of meshes.
  35851. * It should not be used directly but through the available method on mesh.
  35852. */
  35853. class OutlineRenderer implements ISceneComponent {
  35854. /**
  35855. * The name of the component. Each component must have a unique name.
  35856. */
  35857. name: string;
  35858. /**
  35859. * The scene the component belongs to.
  35860. */
  35861. scene: Scene;
  35862. /**
  35863. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35864. */
  35865. zOffset: number;
  35866. private _engine;
  35867. private _effect;
  35868. private _cachedDefines;
  35869. private _savedDepthWrite;
  35870. /**
  35871. * Instantiates a new outline renderer. (There could be only one per scene).
  35872. * @param scene Defines the scene it belongs to
  35873. */
  35874. constructor(scene: Scene);
  35875. /**
  35876. * Register the component to one instance of a scene.
  35877. */
  35878. register(): void;
  35879. /**
  35880. * Rebuilds the elements related to this component in case of
  35881. * context lost for instance.
  35882. */
  35883. rebuild(): void;
  35884. /**
  35885. * Disposes the component and the associated ressources.
  35886. */
  35887. dispose(): void;
  35888. /**
  35889. * Renders the outline in the canvas.
  35890. * @param subMesh Defines the sumesh to render
  35891. * @param batch Defines the batch of meshes in case of instances
  35892. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35893. */
  35894. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35895. /**
  35896. * Returns whether or not the outline renderer is ready for a given submesh.
  35897. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35898. * @param subMesh Defines the submesh to check readyness for
  35899. * @param useInstances Defines wheter wee are trying to render instances or not
  35900. * @returns true if ready otherwise false
  35901. */
  35902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35903. private _beforeRenderingMesh;
  35904. private _afterRenderingMesh;
  35905. }
  35906. }
  35907. declare module BABYLON {
  35908. /**
  35909. * This represents the object necessary to create a rendering group.
  35910. * This is exclusively used and created by the rendering manager.
  35911. * To modify the behavior, you use the available helpers in your scene or meshes.
  35912. * @hidden
  35913. */
  35914. class RenderingGroup {
  35915. index: number;
  35916. private _scene;
  35917. private _opaqueSubMeshes;
  35918. private _transparentSubMeshes;
  35919. private _alphaTestSubMeshes;
  35920. private _depthOnlySubMeshes;
  35921. private _particleSystems;
  35922. private _spriteManagers;
  35923. private _opaqueSortCompareFn;
  35924. private _alphaTestSortCompareFn;
  35925. private _transparentSortCompareFn;
  35926. private _renderOpaque;
  35927. private _renderAlphaTest;
  35928. private _renderTransparent;
  35929. private _edgesRenderers;
  35930. onBeforeTransparentRendering: () => void;
  35931. /**
  35932. * Set the opaque sort comparison function.
  35933. * If null the sub meshes will be render in the order they were created
  35934. */
  35935. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35936. /**
  35937. * Set the alpha test sort comparison function.
  35938. * If null the sub meshes will be render in the order they were created
  35939. */
  35940. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35941. /**
  35942. * Set the transparent sort comparison function.
  35943. * If null the sub meshes will be render in the order they were created
  35944. */
  35945. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35946. /**
  35947. * Creates a new rendering group.
  35948. * @param index The rendering group index
  35949. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35950. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35951. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35952. */
  35953. 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>);
  35954. /**
  35955. * Render all the sub meshes contained in the group.
  35956. * @param customRenderFunction Used to override the default render behaviour of the group.
  35957. * @returns true if rendered some submeshes.
  35958. */
  35959. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  35960. /**
  35961. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  35962. * @param subMeshes The submeshes to render
  35963. */
  35964. private renderOpaqueSorted;
  35965. /**
  35966. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  35967. * @param subMeshes The submeshes to render
  35968. */
  35969. private renderAlphaTestSorted;
  35970. /**
  35971. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  35972. * @param subMeshes The submeshes to render
  35973. */
  35974. private renderTransparentSorted;
  35975. /**
  35976. * Renders the submeshes in a specified order.
  35977. * @param subMeshes The submeshes to sort before render
  35978. * @param sortCompareFn The comparison function use to sort
  35979. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  35980. * @param transparent Specifies to activate blending if true
  35981. */
  35982. private static renderSorted;
  35983. /**
  35984. * Renders the submeshes in the order they were dispatched (no sort applied).
  35985. * @param subMeshes The submeshes to render
  35986. */
  35987. private static renderUnsorted;
  35988. /**
  35989. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35990. * are rendered back to front if in the same alpha index.
  35991. *
  35992. * @param a The first submesh
  35993. * @param b The second submesh
  35994. * @returns The result of the comparison
  35995. */
  35996. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  35997. /**
  35998. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  35999. * are rendered back to front.
  36000. *
  36001. * @param a The first submesh
  36002. * @param b The second submesh
  36003. * @returns The result of the comparison
  36004. */
  36005. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36006. /**
  36007. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36008. * are rendered front to back (prevent overdraw).
  36009. *
  36010. * @param a The first submesh
  36011. * @param b The second submesh
  36012. * @returns The result of the comparison
  36013. */
  36014. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36015. /**
  36016. * Resets the different lists of submeshes to prepare a new frame.
  36017. */
  36018. prepare(): void;
  36019. dispose(): void;
  36020. /**
  36021. * Inserts the submesh in its correct queue depending on its material.
  36022. * @param subMesh The submesh to dispatch
  36023. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36024. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36025. */
  36026. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36027. dispatchSprites(spriteManager: ISpriteManager): void;
  36028. dispatchParticles(particleSystem: IParticleSystem): void;
  36029. private _renderParticles;
  36030. private _renderSprites;
  36031. }
  36032. }
  36033. declare module BABYLON {
  36034. /**
  36035. * Interface describing the different options available in the rendering manager
  36036. * regarding Auto Clear between groups.
  36037. */
  36038. interface IRenderingManagerAutoClearSetup {
  36039. /**
  36040. * Defines whether or not autoclear is enable.
  36041. */
  36042. autoClear: boolean;
  36043. /**
  36044. * Defines whether or not to autoclear the depth buffer.
  36045. */
  36046. depth: boolean;
  36047. /**
  36048. * Defines whether or not to autoclear the stencil buffer.
  36049. */
  36050. stencil: boolean;
  36051. }
  36052. /**
  36053. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36054. * It is enable to manage the different groups as well as the different necessary sort functions.
  36055. * This should not be used directly aside of the few static configurations
  36056. */
  36057. class RenderingManager {
  36058. /**
  36059. * The max id used for rendering groups (not included)
  36060. */
  36061. static MAX_RENDERINGGROUPS: number;
  36062. /**
  36063. * The min id used for rendering groups (included)
  36064. */
  36065. static MIN_RENDERINGGROUPS: number;
  36066. /**
  36067. * Used to globally prevent autoclearing scenes.
  36068. */
  36069. static AUTOCLEAR: boolean;
  36070. /**
  36071. * @hidden
  36072. */
  36073. _useSceneAutoClearSetup: boolean;
  36074. private _scene;
  36075. private _renderingGroups;
  36076. private _depthStencilBufferAlreadyCleaned;
  36077. private _autoClearDepthStencil;
  36078. private _customOpaqueSortCompareFn;
  36079. private _customAlphaTestSortCompareFn;
  36080. private _customTransparentSortCompareFn;
  36081. private _renderingGroupInfo;
  36082. /**
  36083. * Instantiates a new rendering group for a particular scene
  36084. * @param scene Defines the scene the groups belongs to
  36085. */
  36086. constructor(scene: Scene);
  36087. private _clearDepthStencilBuffer;
  36088. /**
  36089. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36090. * @hidden
  36091. */
  36092. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36093. /**
  36094. * Resets the different information of the group to prepare a new frame
  36095. * @hidden
  36096. */
  36097. reset(): void;
  36098. /**
  36099. * Dispose and release the group and its associated resources.
  36100. * @hidden
  36101. */
  36102. dispose(): void;
  36103. /**
  36104. * Clear the info related to rendering groups preventing retention points during dispose.
  36105. */
  36106. freeRenderingGroups(): void;
  36107. private _prepareRenderingGroup;
  36108. /**
  36109. * Add a sprite manager to the rendering manager in order to render it this frame.
  36110. * @param spriteManager Define the sprite manager to render
  36111. */
  36112. dispatchSprites(spriteManager: ISpriteManager): void;
  36113. /**
  36114. * Add a particle system to the rendering manager in order to render it this frame.
  36115. * @param particleSystem Define the particle system to render
  36116. */
  36117. dispatchParticles(particleSystem: IParticleSystem): void;
  36118. /**
  36119. * Add a submesh to the manager in order to render it this frame
  36120. * @param subMesh The submesh to dispatch
  36121. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36122. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36123. */
  36124. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36125. /**
  36126. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36127. * This allowed control for front to back rendering or reversly depending of the special needs.
  36128. *
  36129. * @param renderingGroupId The rendering group id corresponding to its index
  36130. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36131. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36132. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36133. */
  36134. 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;
  36135. /**
  36136. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36137. *
  36138. * @param renderingGroupId The rendering group id corresponding to its index
  36139. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36140. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36141. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36142. */
  36143. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36144. /**
  36145. * Gets the current auto clear configuration for one rendering group of the rendering
  36146. * manager.
  36147. * @param index the rendering group index to get the information for
  36148. * @returns The auto clear setup for the requested rendering group
  36149. */
  36150. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36151. }
  36152. }
  36153. declare module BABYLON {
  36154. /**
  36155. * Renders a layer on top of an existing scene
  36156. */
  36157. class UtilityLayerRenderer implements IDisposable {
  36158. /** the original scene that will be rendered on top of */
  36159. originalScene: Scene;
  36160. private _pointerCaptures;
  36161. private _lastPointerEvents;
  36162. private static _DefaultUtilityLayer;
  36163. private static _DefaultKeepDepthUtilityLayer;
  36164. /**
  36165. * 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)
  36166. */
  36167. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36168. /**
  36169. * 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)
  36170. */
  36171. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36172. /**
  36173. * The scene that is rendered on top of the original scene
  36174. */
  36175. utilityLayerScene: Scene;
  36176. /**
  36177. * If the utility layer should automatically be rendered on top of existing scene
  36178. */
  36179. shouldRender: boolean;
  36180. /**
  36181. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36182. */
  36183. onlyCheckPointerDownEvents: boolean;
  36184. /**
  36185. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36186. */
  36187. processAllEvents: boolean;
  36188. /**
  36189. * Observable raised when the pointer move from the utility layer scene to the main scene
  36190. */
  36191. onPointerOutObservable: Observable<number>;
  36192. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36193. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36194. private _afterRenderObserver;
  36195. private _sceneDisposeObserver;
  36196. private _originalPointerObserver;
  36197. /**
  36198. * Instantiates a UtilityLayerRenderer
  36199. * @param originalScene the original scene that will be rendered on top of
  36200. */
  36201. constructor(
  36202. /** the original scene that will be rendered on top of */
  36203. originalScene: Scene);
  36204. private _notifyObservers;
  36205. /**
  36206. * Renders the utility layers scene on top of the original scene
  36207. */
  36208. render(): void;
  36209. /**
  36210. * Disposes of the renderer
  36211. */
  36212. dispose(): void;
  36213. private _updateCamera;
  36214. }
  36215. }
  36216. declare module BABYLON {
  36217. /**
  36218. * Class used to represent a sprite
  36219. * @see http://doc.babylonjs.com/babylon101/sprites
  36220. */
  36221. class Sprite {
  36222. /** defines the name */
  36223. name: string;
  36224. /** Gets or sets the current world position */
  36225. position: Vector3;
  36226. /** Gets or sets the main color */
  36227. color: Color4;
  36228. /** Gets or sets the width */
  36229. width: number;
  36230. /** Gets or sets the height */
  36231. height: number;
  36232. /** Gets or sets rotation angle */
  36233. angle: number;
  36234. /** Gets or sets the cell index in the sprite sheet */
  36235. cellIndex: number;
  36236. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36237. invertU: number;
  36238. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36239. invertV: number;
  36240. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36241. disposeWhenFinishedAnimating: boolean;
  36242. /** Gets the list of attached animations */
  36243. animations: Animation[];
  36244. /** Gets or sets a boolean indicating if the sprite can be picked */
  36245. isPickable: boolean;
  36246. /**
  36247. * Gets or sets the associated action manager
  36248. */
  36249. actionManager: Nullable<ActionManager>;
  36250. private _animationStarted;
  36251. private _loopAnimation;
  36252. private _fromIndex;
  36253. private _toIndex;
  36254. private _delay;
  36255. private _direction;
  36256. private _manager;
  36257. private _time;
  36258. private _onAnimationEnd;
  36259. /**
  36260. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36261. */
  36262. isVisible: boolean;
  36263. /**
  36264. * Gets or sets the sprite size
  36265. */
  36266. size: number;
  36267. /**
  36268. * Creates a new Sprite
  36269. * @param name defines the name
  36270. * @param manager defines the manager
  36271. */
  36272. constructor(
  36273. /** defines the name */
  36274. name: string, manager: ISpriteManager);
  36275. /**
  36276. * Starts an animation
  36277. * @param from defines the initial key
  36278. * @param to defines the end key
  36279. * @param loop defines if the animation must loop
  36280. * @param delay defines the start delay (in ms)
  36281. * @param onAnimationEnd defines a callback to call when animation ends
  36282. */
  36283. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36284. /** Stops current animation (if any) */
  36285. stopAnimation(): void;
  36286. /** @hidden */
  36287. _animate(deltaTime: number): void;
  36288. /** Release associated resources */
  36289. dispose(): void;
  36290. }
  36291. }
  36292. declare module BABYLON {
  36293. /**
  36294. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36295. */
  36296. interface ISpriteManager extends IDisposable {
  36297. /**
  36298. * Restricts the camera to viewing objects with the same layerMask.
  36299. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36300. */
  36301. layerMask: number;
  36302. /**
  36303. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36304. */
  36305. isPickable: boolean;
  36306. /**
  36307. * Specifies the rendering group id for this mesh (0 by default)
  36308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36309. */
  36310. renderingGroupId: number;
  36311. /**
  36312. * Defines the list of sprites managed by the manager.
  36313. */
  36314. sprites: Array<Sprite>;
  36315. /**
  36316. * Tests the intersection of a sprite with a specific ray.
  36317. * @param ray The ray we are sending to test the collision
  36318. * @param camera The camera space we are sending rays in
  36319. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36320. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36321. * @returns picking info or null.
  36322. */
  36323. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36324. /**
  36325. * Renders the list of sprites on screen.
  36326. */
  36327. render(): void;
  36328. }
  36329. /**
  36330. * Class used to manage multiple sprites on the same spritesheet
  36331. * @see http://doc.babylonjs.com/babylon101/sprites
  36332. */
  36333. class SpriteManager implements ISpriteManager {
  36334. /** defines the manager's name */
  36335. name: string;
  36336. /** Gets the list of sprites */
  36337. sprites: Sprite[];
  36338. /** Gets or sets the rendering group id (0 by default) */
  36339. renderingGroupId: number;
  36340. /** Gets or sets camera layer mask */
  36341. layerMask: number;
  36342. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36343. fogEnabled: boolean;
  36344. /** Gets or sets a boolean indicating if the sprites are pickable */
  36345. isPickable: boolean;
  36346. /** Defines the default width of a cell in the spritesheet */
  36347. cellWidth: number;
  36348. /** Defines the default height of a cell in the spritesheet */
  36349. cellHeight: number;
  36350. /**
  36351. * An event triggered when the manager is disposed.
  36352. */
  36353. onDisposeObservable: Observable<SpriteManager>;
  36354. private _onDisposeObserver;
  36355. /**
  36356. * Callback called when the manager is disposed
  36357. */
  36358. onDispose: () => void;
  36359. private _capacity;
  36360. private _spriteTexture;
  36361. private _epsilon;
  36362. private _scene;
  36363. private _vertexData;
  36364. private _buffer;
  36365. private _vertexBuffers;
  36366. private _indexBuffer;
  36367. private _effectBase;
  36368. private _effectFog;
  36369. /**
  36370. * Gets or sets the spritesheet texture
  36371. */
  36372. texture: Texture;
  36373. /**
  36374. * Creates a new sprite manager
  36375. * @param name defines the manager's name
  36376. * @param imgUrl defines the sprite sheet url
  36377. * @param capacity defines the maximum allowed number of sprites
  36378. * @param cellSize defines the size of a sprite cell
  36379. * @param scene defines the hosting scene
  36380. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36381. * @param samplingMode defines the smapling mode to use with spritesheet
  36382. */
  36383. constructor(
  36384. /** defines the manager's name */
  36385. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36386. private _appendSpriteVertex;
  36387. /**
  36388. * Intersects the sprites with a ray
  36389. * @param ray defines the ray to intersect with
  36390. * @param camera defines the current active camera
  36391. * @param predicate defines a predicate used to select candidate sprites
  36392. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36393. * @returns null if no hit or a PickingInfo
  36394. */
  36395. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36396. /**
  36397. * Render all child sprites
  36398. */
  36399. render(): void;
  36400. /**
  36401. * Release associated resources
  36402. */
  36403. dispose(): void;
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. interface Scene {
  36408. /** @hidden */
  36409. _pointerOverSprite: Nullable<Sprite>;
  36410. /** @hidden */
  36411. _pickedDownSprite: Nullable<Sprite>;
  36412. /** @hidden */
  36413. _tempSpritePickingRay: Nullable<Ray>;
  36414. /**
  36415. * All of the sprite managers added to this scene
  36416. * @see http://doc.babylonjs.com/babylon101/sprites
  36417. */
  36418. spriteManagers: Array<ISpriteManager>;
  36419. /**
  36420. * An event triggered when sprites rendering is about to start
  36421. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36422. */
  36423. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36424. /**
  36425. * An event triggered when sprites rendering is done
  36426. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36427. */
  36428. onAfterSpritesRenderingObservable: Observable<Scene>;
  36429. /** @hidden */
  36430. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36431. /** Launch a ray to try to pick a sprite in the scene
  36432. * @param x position on screen
  36433. * @param y position on screen
  36434. * @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
  36435. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36437. * @returns a PickingInfo
  36438. */
  36439. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36440. /** Use the given ray to pick a sprite in the scene
  36441. * @param ray The ray (in world space) to use to pick meshes
  36442. * @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
  36443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36444. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36445. * @returns a PickingInfo
  36446. */
  36447. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36448. /**
  36449. * Force the sprite under the pointer
  36450. * @param sprite defines the sprite to use
  36451. */
  36452. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36453. /**
  36454. * Gets the sprite under the pointer
  36455. * @returns a Sprite or null if no sprite is under the pointer
  36456. */
  36457. getPointerOverSprite(): Nullable<Sprite>;
  36458. }
  36459. /**
  36460. * Defines the sprite scene component responsible to manage sprites
  36461. * in a given scene.
  36462. */
  36463. class SpriteSceneComponent implements ISceneComponent {
  36464. /**
  36465. * The component name helpfull to identify the component in the list of scene components.
  36466. */
  36467. readonly name: string;
  36468. /**
  36469. * The scene the component belongs to.
  36470. */
  36471. scene: Scene;
  36472. /** @hidden */
  36473. private _spritePredicate;
  36474. /**
  36475. * Creates a new instance of the component for the given scene
  36476. * @param scene Defines the scene to register the component in
  36477. */
  36478. constructor(scene: Scene);
  36479. /**
  36480. * Registers the component in a given scene
  36481. */
  36482. register(): void;
  36483. /**
  36484. * Rebuilds the elements related to this component in case of
  36485. * context lost for instance.
  36486. */
  36487. rebuild(): void;
  36488. /**
  36489. * Disposes the component and the associated ressources.
  36490. */
  36491. dispose(): void;
  36492. private _pickSpriteButKeepRay;
  36493. private _pointerMove;
  36494. private _pointerDown;
  36495. private _pointerUp;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /**
  36500. * @hidden
  36501. **/
  36502. class _AlphaState {
  36503. private _isAlphaBlendDirty;
  36504. private _isBlendFunctionParametersDirty;
  36505. private _isBlendEquationParametersDirty;
  36506. private _isBlendConstantsDirty;
  36507. private _alphaBlend;
  36508. private _blendFunctionParameters;
  36509. private _blendEquationParameters;
  36510. private _blendConstants;
  36511. /**
  36512. * Initializes the state.
  36513. */
  36514. constructor();
  36515. readonly isDirty: boolean;
  36516. alphaBlend: boolean;
  36517. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36518. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36519. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36520. reset(): void;
  36521. apply(gl: WebGLRenderingContext): void;
  36522. }
  36523. }
  36524. declare module BABYLON {
  36525. /**
  36526. * @hidden
  36527. **/
  36528. class _DepthCullingState {
  36529. private _isDepthTestDirty;
  36530. private _isDepthMaskDirty;
  36531. private _isDepthFuncDirty;
  36532. private _isCullFaceDirty;
  36533. private _isCullDirty;
  36534. private _isZOffsetDirty;
  36535. private _isFrontFaceDirty;
  36536. private _depthTest;
  36537. private _depthMask;
  36538. private _depthFunc;
  36539. private _cull;
  36540. private _cullFace;
  36541. private _zOffset;
  36542. private _frontFace;
  36543. /**
  36544. * Initializes the state.
  36545. */
  36546. constructor();
  36547. readonly isDirty: boolean;
  36548. zOffset: number;
  36549. cullFace: Nullable<number>;
  36550. cull: Nullable<boolean>;
  36551. depthFunc: Nullable<number>;
  36552. depthMask: boolean;
  36553. depthTest: boolean;
  36554. frontFace: Nullable<number>;
  36555. reset(): void;
  36556. apply(gl: WebGLRenderingContext): void;
  36557. }
  36558. }
  36559. declare module BABYLON {
  36560. /**
  36561. * @hidden
  36562. **/
  36563. class _StencilState {
  36564. private _isStencilTestDirty;
  36565. private _isStencilMaskDirty;
  36566. private _isStencilFuncDirty;
  36567. private _isStencilOpDirty;
  36568. private _stencilTest;
  36569. private _stencilMask;
  36570. private _stencilFunc;
  36571. private _stencilFuncRef;
  36572. private _stencilFuncMask;
  36573. private _stencilOpStencilFail;
  36574. private _stencilOpDepthFail;
  36575. private _stencilOpStencilDepthPass;
  36576. readonly isDirty: boolean;
  36577. stencilFunc: number;
  36578. stencilFuncRef: number;
  36579. stencilFuncMask: number;
  36580. stencilOpStencilFail: number;
  36581. stencilOpDepthFail: number;
  36582. stencilOpStencilDepthPass: number;
  36583. stencilMask: number;
  36584. stencilTest: boolean;
  36585. constructor();
  36586. reset(): void;
  36587. apply(gl: WebGLRenderingContext): void;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * Class used to evalaute queries containing `and` and `or` operators
  36593. */
  36594. class AndOrNotEvaluator {
  36595. /**
  36596. * Evaluate a query
  36597. * @param query defines the query to evaluate
  36598. * @param evaluateCallback defines the callback used to filter result
  36599. * @returns true if the query matches
  36600. */
  36601. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36602. private static _HandleParenthesisContent;
  36603. private static _SimplifyNegation;
  36604. }
  36605. }
  36606. declare module BABYLON {
  36607. /**
  36608. * Defines the list of states available for a task inside a AssetsManager
  36609. */
  36610. enum AssetTaskState {
  36611. /**
  36612. * Initialization
  36613. */
  36614. INIT = 0,
  36615. /**
  36616. * Running
  36617. */
  36618. RUNNING = 1,
  36619. /**
  36620. * Done
  36621. */
  36622. DONE = 2,
  36623. /**
  36624. * Error
  36625. */
  36626. ERROR = 3
  36627. }
  36628. /**
  36629. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36630. */
  36631. abstract class AbstractAssetTask {
  36632. /**
  36633. * Task name
  36634. */ name: string;
  36635. /**
  36636. * Callback called when the task is successful
  36637. */
  36638. onSuccess: (task: any) => void;
  36639. /**
  36640. * Callback called when the task is not successful
  36641. */
  36642. onError: (task: any, message?: string, exception?: any) => void;
  36643. /**
  36644. * Creates a new AssetsManager
  36645. * @param name defines the name of the task
  36646. */
  36647. constructor(
  36648. /**
  36649. * Task name
  36650. */ name: string);
  36651. private _isCompleted;
  36652. private _taskState;
  36653. private _errorObject;
  36654. /**
  36655. * Get if the task is completed
  36656. */
  36657. readonly isCompleted: boolean;
  36658. /**
  36659. * Gets the current state of the task
  36660. */
  36661. readonly taskState: AssetTaskState;
  36662. /**
  36663. * Gets the current error object (if task is in error)
  36664. */
  36665. readonly errorObject: {
  36666. message?: string;
  36667. exception?: any;
  36668. };
  36669. /**
  36670. * Internal only
  36671. * @hidden
  36672. */
  36673. _setErrorObject(message?: string, exception?: any): void;
  36674. /**
  36675. * Execute the current task
  36676. * @param scene defines the scene where you want your assets to be loaded
  36677. * @param onSuccess is a callback called when the task is successfully executed
  36678. * @param onError is a callback called if an error occurs
  36679. */
  36680. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36681. /**
  36682. * Execute the current task
  36683. * @param scene defines the scene where you want your assets to be loaded
  36684. * @param onSuccess is a callback called when the task is successfully executed
  36685. * @param onError is a callback called if an error occurs
  36686. */
  36687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36688. /**
  36689. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36690. * This can be used with failed tasks that have the reason for failure fixed.
  36691. */
  36692. reset(): void;
  36693. private onErrorCallback;
  36694. private onDoneCallback;
  36695. }
  36696. /**
  36697. * Define the interface used by progress events raised during assets loading
  36698. */
  36699. interface IAssetsProgressEvent {
  36700. /**
  36701. * Defines the number of remaining tasks to process
  36702. */
  36703. remainingCount: number;
  36704. /**
  36705. * Defines the total number of tasks
  36706. */
  36707. totalCount: number;
  36708. /**
  36709. * Defines the task that was just processed
  36710. */
  36711. task: AbstractAssetTask;
  36712. }
  36713. /**
  36714. * Class used to share progress information about assets loading
  36715. */
  36716. class AssetsProgressEvent implements IAssetsProgressEvent {
  36717. /**
  36718. * Defines the number of remaining tasks to process
  36719. */
  36720. remainingCount: number;
  36721. /**
  36722. * Defines the total number of tasks
  36723. */
  36724. totalCount: number;
  36725. /**
  36726. * Defines the task that was just processed
  36727. */
  36728. task: AbstractAssetTask;
  36729. /**
  36730. * Creates a AssetsProgressEvent
  36731. * @param remainingCount defines the number of remaining tasks to process
  36732. * @param totalCount defines the total number of tasks
  36733. * @param task defines the task that was just processed
  36734. */
  36735. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36736. }
  36737. /**
  36738. * Define a task used by AssetsManager to load meshes
  36739. */
  36740. class MeshAssetTask extends AbstractAssetTask {
  36741. /**
  36742. * Defines the name of the task
  36743. */
  36744. name: string;
  36745. /**
  36746. * Defines the list of mesh's names you want to load
  36747. */
  36748. meshesNames: any;
  36749. /**
  36750. * Defines the root url to use as a base to load your meshes and associated resources
  36751. */
  36752. rootUrl: string;
  36753. /**
  36754. * Defines the filename of the scene to load from
  36755. */
  36756. sceneFilename: string;
  36757. /**
  36758. * Gets the list of loaded meshes
  36759. */
  36760. loadedMeshes: Array<AbstractMesh>;
  36761. /**
  36762. * Gets the list of loaded particle systems
  36763. */
  36764. loadedParticleSystems: Array<IParticleSystem>;
  36765. /**
  36766. * Gets the list of loaded skeletons
  36767. */
  36768. loadedSkeletons: Array<Skeleton>;
  36769. /**
  36770. * Callback called when the task is successful
  36771. */
  36772. onSuccess: (task: MeshAssetTask) => void;
  36773. /**
  36774. * Callback called when the task is successful
  36775. */
  36776. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36777. /**
  36778. * Creates a new MeshAssetTask
  36779. * @param name defines the name of the task
  36780. * @param meshesNames defines the list of mesh's names you want to load
  36781. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36782. * @param sceneFilename defines the filename of the scene to load from
  36783. */
  36784. constructor(
  36785. /**
  36786. * Defines the name of the task
  36787. */
  36788. name: string,
  36789. /**
  36790. * Defines the list of mesh's names you want to load
  36791. */
  36792. meshesNames: any,
  36793. /**
  36794. * Defines the root url to use as a base to load your meshes and associated resources
  36795. */
  36796. rootUrl: string,
  36797. /**
  36798. * Defines the filename of the scene to load from
  36799. */
  36800. sceneFilename: string);
  36801. /**
  36802. * Execute the current task
  36803. * @param scene defines the scene where you want your assets to be loaded
  36804. * @param onSuccess is a callback called when the task is successfully executed
  36805. * @param onError is a callback called if an error occurs
  36806. */
  36807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36808. }
  36809. /**
  36810. * Define a task used by AssetsManager to load text content
  36811. */
  36812. class TextFileAssetTask extends AbstractAssetTask {
  36813. /**
  36814. * Defines the name of the task
  36815. */
  36816. name: string;
  36817. /**
  36818. * Defines the location of the file to load
  36819. */
  36820. url: string;
  36821. /**
  36822. * Gets the loaded text string
  36823. */
  36824. text: string;
  36825. /**
  36826. * Callback called when the task is successful
  36827. */
  36828. onSuccess: (task: TextFileAssetTask) => void;
  36829. /**
  36830. * Callback called when the task is successful
  36831. */
  36832. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36833. /**
  36834. * Creates a new TextFileAssetTask object
  36835. * @param name defines the name of the task
  36836. * @param url defines the location of the file to load
  36837. */
  36838. constructor(
  36839. /**
  36840. * Defines the name of the task
  36841. */
  36842. name: string,
  36843. /**
  36844. * Defines the location of the file to load
  36845. */
  36846. url: string);
  36847. /**
  36848. * Execute the current task
  36849. * @param scene defines the scene where you want your assets to be loaded
  36850. * @param onSuccess is a callback called when the task is successfully executed
  36851. * @param onError is a callback called if an error occurs
  36852. */
  36853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36854. }
  36855. /**
  36856. * Define a task used by AssetsManager to load binary data
  36857. */
  36858. class BinaryFileAssetTask extends AbstractAssetTask {
  36859. /**
  36860. * Defines the name of the task
  36861. */
  36862. name: string;
  36863. /**
  36864. * Defines the location of the file to load
  36865. */
  36866. url: string;
  36867. /**
  36868. * Gets the lodaded data (as an array buffer)
  36869. */
  36870. data: ArrayBuffer;
  36871. /**
  36872. * Callback called when the task is successful
  36873. */
  36874. onSuccess: (task: BinaryFileAssetTask) => void;
  36875. /**
  36876. * Callback called when the task is successful
  36877. */
  36878. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36879. /**
  36880. * Creates a new BinaryFileAssetTask object
  36881. * @param name defines the name of the new task
  36882. * @param url defines the location of the file to load
  36883. */
  36884. constructor(
  36885. /**
  36886. * Defines the name of the task
  36887. */
  36888. name: string,
  36889. /**
  36890. * Defines the location of the file to load
  36891. */
  36892. url: string);
  36893. /**
  36894. * Execute the current task
  36895. * @param scene defines the scene where you want your assets to be loaded
  36896. * @param onSuccess is a callback called when the task is successfully executed
  36897. * @param onError is a callback called if an error occurs
  36898. */
  36899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36900. }
  36901. /**
  36902. * Define a task used by AssetsManager to load images
  36903. */
  36904. class ImageAssetTask extends AbstractAssetTask {
  36905. /**
  36906. * Defines the name of the task
  36907. */
  36908. name: string;
  36909. /**
  36910. * Defines the location of the image to load
  36911. */
  36912. url: string;
  36913. /**
  36914. * Gets the loaded images
  36915. */
  36916. image: HTMLImageElement;
  36917. /**
  36918. * Callback called when the task is successful
  36919. */
  36920. onSuccess: (task: ImageAssetTask) => void;
  36921. /**
  36922. * Callback called when the task is successful
  36923. */
  36924. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36925. /**
  36926. * Creates a new ImageAssetTask
  36927. * @param name defines the name of the task
  36928. * @param url defines the location of the image to load
  36929. */
  36930. constructor(
  36931. /**
  36932. * Defines the name of the task
  36933. */
  36934. name: string,
  36935. /**
  36936. * Defines the location of the image to load
  36937. */
  36938. url: string);
  36939. /**
  36940. * Execute the current task
  36941. * @param scene defines the scene where you want your assets to be loaded
  36942. * @param onSuccess is a callback called when the task is successfully executed
  36943. * @param onError is a callback called if an error occurs
  36944. */
  36945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36946. }
  36947. /**
  36948. * Defines the interface used by texture loading tasks
  36949. */
  36950. interface ITextureAssetTask<TEX extends BaseTexture> {
  36951. /**
  36952. * Gets the loaded texture
  36953. */
  36954. texture: TEX;
  36955. }
  36956. /**
  36957. * Define a task used by AssetsManager to load 2D textures
  36958. */
  36959. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  36960. /**
  36961. * Defines the name of the task
  36962. */
  36963. name: string;
  36964. /**
  36965. * Defines the location of the file to load
  36966. */
  36967. url: string;
  36968. /**
  36969. * Defines if mipmap should not be generated (default is false)
  36970. */
  36971. noMipmap?: boolean | undefined;
  36972. /**
  36973. * Defines if texture must be inverted on Y axis (default is false)
  36974. */
  36975. invertY?: boolean | undefined;
  36976. /**
  36977. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36978. */
  36979. samplingMode: number;
  36980. /**
  36981. * Gets the loaded texture
  36982. */
  36983. texture: Texture;
  36984. /**
  36985. * Callback called when the task is successful
  36986. */
  36987. onSuccess: (task: TextureAssetTask) => void;
  36988. /**
  36989. * Callback called when the task is successful
  36990. */
  36991. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  36992. /**
  36993. * Creates a new TextureAssetTask object
  36994. * @param name defines the name of the task
  36995. * @param url defines the location of the file to load
  36996. * @param noMipmap defines if mipmap should not be generated (default is false)
  36997. * @param invertY defines if texture must be inverted on Y axis (default is false)
  36998. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  36999. */
  37000. constructor(
  37001. /**
  37002. * Defines the name of the task
  37003. */
  37004. name: string,
  37005. /**
  37006. * Defines the location of the file to load
  37007. */
  37008. url: string,
  37009. /**
  37010. * Defines if mipmap should not be generated (default is false)
  37011. */
  37012. noMipmap?: boolean | undefined,
  37013. /**
  37014. * Defines if texture must be inverted on Y axis (default is false)
  37015. */
  37016. invertY?: boolean | undefined,
  37017. /**
  37018. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37019. */
  37020. samplingMode?: number);
  37021. /**
  37022. * Execute the current task
  37023. * @param scene defines the scene where you want your assets to be loaded
  37024. * @param onSuccess is a callback called when the task is successfully executed
  37025. * @param onError is a callback called if an error occurs
  37026. */
  37027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37028. }
  37029. /**
  37030. * Define a task used by AssetsManager to load cube textures
  37031. */
  37032. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37033. /**
  37034. * Defines the name of the task
  37035. */
  37036. name: string;
  37037. /**
  37038. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37039. */
  37040. url: string;
  37041. /**
  37042. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37043. */
  37044. extensions?: string[] | undefined;
  37045. /**
  37046. * Defines if mipmaps should not be generated (default is false)
  37047. */
  37048. noMipmap?: boolean | undefined;
  37049. /**
  37050. * Defines the explicit list of files (undefined by default)
  37051. */
  37052. files?: string[] | undefined;
  37053. /**
  37054. * Gets the loaded texture
  37055. */
  37056. texture: CubeTexture;
  37057. /**
  37058. * Callback called when the task is successful
  37059. */
  37060. onSuccess: (task: CubeTextureAssetTask) => void;
  37061. /**
  37062. * Callback called when the task is successful
  37063. */
  37064. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37065. /**
  37066. * Creates a new CubeTextureAssetTask
  37067. * @param name defines the name of the task
  37068. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37069. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37070. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37071. * @param files defines the explicit list of files (undefined by default)
  37072. */
  37073. constructor(
  37074. /**
  37075. * Defines the name of the task
  37076. */
  37077. name: string,
  37078. /**
  37079. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37080. */
  37081. url: string,
  37082. /**
  37083. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37084. */
  37085. extensions?: string[] | undefined,
  37086. /**
  37087. * Defines if mipmaps should not be generated (default is false)
  37088. */
  37089. noMipmap?: boolean | undefined,
  37090. /**
  37091. * Defines the explicit list of files (undefined by default)
  37092. */
  37093. files?: string[] | undefined);
  37094. /**
  37095. * Execute the current task
  37096. * @param scene defines the scene where you want your assets to be loaded
  37097. * @param onSuccess is a callback called when the task is successfully executed
  37098. * @param onError is a callback called if an error occurs
  37099. */
  37100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37101. }
  37102. /**
  37103. * Define a task used by AssetsManager to load HDR cube textures
  37104. */
  37105. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37106. /**
  37107. * Defines the name of the task
  37108. */
  37109. name: string;
  37110. /**
  37111. * Defines the location of the file to load
  37112. */
  37113. url: string;
  37114. /**
  37115. * Defines the desired size (the more it increases the longer the generation will be)
  37116. */
  37117. size: number;
  37118. /**
  37119. * Defines if mipmaps should not be generated (default is false)
  37120. */
  37121. noMipmap: boolean;
  37122. /**
  37123. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37124. */
  37125. generateHarmonics: boolean;
  37126. /**
  37127. * 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)
  37128. */
  37129. gammaSpace: boolean;
  37130. /**
  37131. * Internal Use Only
  37132. */
  37133. reserved: boolean;
  37134. /**
  37135. * Gets the loaded texture
  37136. */
  37137. texture: HDRCubeTexture;
  37138. /**
  37139. * Callback called when the task is successful
  37140. */
  37141. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37142. /**
  37143. * Callback called when the task is successful
  37144. */
  37145. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37146. /**
  37147. * Creates a new HDRCubeTextureAssetTask object
  37148. * @param name defines the name of the task
  37149. * @param url defines the location of the file to load
  37150. * @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.
  37151. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37152. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37153. * @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)
  37154. * @param reserved Internal use only
  37155. */
  37156. constructor(
  37157. /**
  37158. * Defines the name of the task
  37159. */
  37160. name: string,
  37161. /**
  37162. * Defines the location of the file to load
  37163. */
  37164. url: string,
  37165. /**
  37166. * Defines the desired size (the more it increases the longer the generation will be)
  37167. */
  37168. size: number,
  37169. /**
  37170. * Defines if mipmaps should not be generated (default is false)
  37171. */
  37172. noMipmap?: boolean,
  37173. /**
  37174. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37175. */
  37176. generateHarmonics?: boolean,
  37177. /**
  37178. * 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)
  37179. */
  37180. gammaSpace?: boolean,
  37181. /**
  37182. * Internal Use Only
  37183. */
  37184. reserved?: boolean);
  37185. /**
  37186. * Execute the current task
  37187. * @param scene defines the scene where you want your assets to be loaded
  37188. * @param onSuccess is a callback called when the task is successfully executed
  37189. * @param onError is a callback called if an error occurs
  37190. */
  37191. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37192. }
  37193. /**
  37194. * This class can be used to easily import assets into a scene
  37195. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37196. */
  37197. class AssetsManager {
  37198. private _scene;
  37199. private _isLoading;
  37200. protected _tasks: AbstractAssetTask[];
  37201. protected _waitingTasksCount: number;
  37202. protected _totalTasksCount: number;
  37203. /**
  37204. * Callback called when all tasks are processed
  37205. */
  37206. onFinish: (tasks: AbstractAssetTask[]) => void;
  37207. /**
  37208. * Callback called when a task is successful
  37209. */
  37210. onTaskSuccess: (task: AbstractAssetTask) => void;
  37211. /**
  37212. * Callback called when a task had an error
  37213. */
  37214. onTaskError: (task: AbstractAssetTask) => void;
  37215. /**
  37216. * Callback called when a task is done (whatever the result is)
  37217. */
  37218. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37219. /**
  37220. * Observable called when all tasks are processed
  37221. */
  37222. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37223. /**
  37224. * Observable called when a task had an error
  37225. */
  37226. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37227. /**
  37228. * Observable called when a task is successful
  37229. */
  37230. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37231. /**
  37232. * Observable called when a task is done (whatever the result is)
  37233. */
  37234. onProgressObservable: Observable<IAssetsProgressEvent>;
  37235. /**
  37236. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37237. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37238. */
  37239. useDefaultLoadingScreen: boolean;
  37240. /**
  37241. * Creates a new AssetsManager
  37242. * @param scene defines the scene to work on
  37243. */
  37244. constructor(scene: Scene);
  37245. /**
  37246. * Add a MeshAssetTask to the list of active tasks
  37247. * @param taskName defines the name of the new task
  37248. * @param meshesNames defines the name of meshes to load
  37249. * @param rootUrl defines the root url to use to locate files
  37250. * @param sceneFilename defines the filename of the scene file
  37251. * @returns a new MeshAssetTask object
  37252. */
  37253. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37254. /**
  37255. * Add a TextFileAssetTask to the list of active tasks
  37256. * @param taskName defines the name of the new task
  37257. * @param url defines the url of the file to load
  37258. * @returns a new TextFileAssetTask object
  37259. */
  37260. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37261. /**
  37262. * Add a BinaryFileAssetTask to the list of active tasks
  37263. * @param taskName defines the name of the new task
  37264. * @param url defines the url of the file to load
  37265. * @returns a new BinaryFileAssetTask object
  37266. */
  37267. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37268. /**
  37269. * Add a ImageAssetTask to the list of active tasks
  37270. * @param taskName defines the name of the new task
  37271. * @param url defines the url of the file to load
  37272. * @returns a new ImageAssetTask object
  37273. */
  37274. addImageTask(taskName: string, url: string): ImageAssetTask;
  37275. /**
  37276. * Add a TextureAssetTask to the list of active tasks
  37277. * @param taskName defines the name of the new task
  37278. * @param url defines the url of the file to load
  37279. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37280. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37281. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37282. * @returns a new TextureAssetTask object
  37283. */
  37284. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37285. /**
  37286. * Add a CubeTextureAssetTask to the list of active tasks
  37287. * @param taskName defines the name of the new task
  37288. * @param url defines the url of the file to load
  37289. * @param extensions defines the extension to use to load the cube map (can be null)
  37290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37291. * @param files defines the list of files to load (can be null)
  37292. * @returns a new CubeTextureAssetTask object
  37293. */
  37294. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37295. /**
  37296. *
  37297. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37298. * @param taskName defines the name of the new task
  37299. * @param url defines the url of the file to load
  37300. * @param size defines the size you want for the cubemap (can be null)
  37301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37302. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37303. * @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)
  37304. * @param reserved Internal use only
  37305. * @returns a new HDRCubeTextureAssetTask object
  37306. */
  37307. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37308. /**
  37309. * Remove a task from the assets manager.
  37310. * @param task the task to remove
  37311. */
  37312. removeTask(task: AbstractAssetTask): void;
  37313. private _decreaseWaitingTasksCount;
  37314. private _runTask;
  37315. /**
  37316. * Reset the AssetsManager and remove all tasks
  37317. * @return the current instance of the AssetsManager
  37318. */
  37319. reset(): AssetsManager;
  37320. /**
  37321. * Start the loading process
  37322. * @return the current instance of the AssetsManager
  37323. */
  37324. load(): AssetsManager;
  37325. }
  37326. }
  37327. declare module BABYLON {
  37328. /**
  37329. * Direct draw surface info
  37330. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37331. */
  37332. interface DDSInfo {
  37333. /**
  37334. * Width of the texture
  37335. */
  37336. width: number;
  37337. /**
  37338. * Width of the texture
  37339. */
  37340. height: number;
  37341. /**
  37342. * Number of Mipmaps for the texture
  37343. * @see https://en.wikipedia.org/wiki/Mipmap
  37344. */
  37345. mipmapCount: number;
  37346. /**
  37347. * If the textures format is a known fourCC format
  37348. * @see https://www.fourcc.org/
  37349. */
  37350. isFourCC: boolean;
  37351. /**
  37352. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37353. */
  37354. isRGB: boolean;
  37355. /**
  37356. * If the texture is a lumincance format
  37357. */
  37358. isLuminance: boolean;
  37359. /**
  37360. * If this is a cube texture
  37361. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37362. */
  37363. isCube: boolean;
  37364. /**
  37365. * If the texture is a compressed format eg. FOURCC_DXT1
  37366. */
  37367. isCompressed: boolean;
  37368. /**
  37369. * The dxgiFormat of the texture
  37370. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37371. */
  37372. dxgiFormat: number;
  37373. /**
  37374. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37375. */
  37376. textureType: number;
  37377. /**
  37378. * Sphericle polynomial created for the dds texture
  37379. */
  37380. sphericalPolynomial?: SphericalPolynomial;
  37381. }
  37382. /**
  37383. * Class used to provide DDS decompression tools
  37384. */
  37385. class DDSTools {
  37386. /**
  37387. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37388. */
  37389. static StoreLODInAlphaChannel: boolean;
  37390. /**
  37391. * Gets DDS information from an array buffer
  37392. * @param arrayBuffer defines the array buffer to read data from
  37393. * @returns the DDS information
  37394. */
  37395. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37396. private static _FloatView;
  37397. private static _Int32View;
  37398. private static _ToHalfFloat;
  37399. private static _FromHalfFloat;
  37400. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37401. private static _GetHalfFloatRGBAArrayBuffer;
  37402. private static _GetFloatRGBAArrayBuffer;
  37403. private static _GetFloatAsUIntRGBAArrayBuffer;
  37404. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37405. private static _GetRGBAArrayBuffer;
  37406. private static _ExtractLongWordOrder;
  37407. private static _GetRGBArrayBuffer;
  37408. private static _GetLuminanceArrayBuffer;
  37409. /**
  37410. * Uploads DDS Levels to a Babylon Texture
  37411. * @hidden
  37412. */
  37413. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37414. }
  37415. }
  37416. declare module BABYLON {
  37417. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37418. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37419. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37420. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37421. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37422. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37423. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37424. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37425. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37426. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37427. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37428. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37429. /**
  37430. * Decorator used to define property that can be serialized as reference to a camera
  37431. * @param sourceName defines the name of the property to decorate
  37432. */
  37433. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37434. /**
  37435. * Class used to help serialization objects
  37436. */
  37437. class SerializationHelper {
  37438. /**
  37439. * Static function used to serialized a specific entity
  37440. * @param entity defines the entity to serialize
  37441. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37442. * @returns a JSON compatible object representing the serialization of the entity
  37443. */
  37444. static Serialize<T>(entity: T, serializationObject?: any): any;
  37445. /**
  37446. * Creates a new entity from a serialization data object
  37447. * @param creationFunction defines a function used to instanciated the new entity
  37448. * @param source defines the source serialization data
  37449. * @param scene defines the hosting scene
  37450. * @param rootUrl defines the root url for resources
  37451. * @returns a new entity
  37452. */
  37453. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37454. /**
  37455. * Clones an object
  37456. * @param creationFunction defines the function used to instanciate the new object
  37457. * @param source defines the source object
  37458. * @returns the cloned object
  37459. */
  37460. static Clone<T>(creationFunction: () => T, source: T): T;
  37461. /**
  37462. * Instanciates a new object based on a source one (some data will be shared between both object)
  37463. * @param creationFunction defines the function used to instanciate the new object
  37464. * @param source defines the source object
  37465. * @returns the new object
  37466. */
  37467. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37468. }
  37469. }
  37470. declare module BABYLON {
  37471. /**
  37472. * Wrapper class for promise with external resolve and reject.
  37473. */
  37474. class Deferred<T> {
  37475. /**
  37476. * The promise associated with this deferred object.
  37477. */
  37478. readonly promise: Promise<T>;
  37479. private _resolve;
  37480. private _reject;
  37481. /**
  37482. * The resolve method of the promise associated with this deferred object.
  37483. */
  37484. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37485. /**
  37486. * The reject method of the promise associated with this deferred object.
  37487. */
  37488. readonly reject: (reason?: any) => void;
  37489. /**
  37490. * Constructor for this deferred object.
  37491. */
  37492. constructor();
  37493. }
  37494. }
  37495. declare module BABYLON {
  37496. /**
  37497. * Raw texture data and descriptor sufficient for WebGL texture upload
  37498. */
  37499. interface EnvironmentTextureInfo {
  37500. /**
  37501. * Version of the environment map
  37502. */
  37503. version: number;
  37504. /**
  37505. * Width of image
  37506. */
  37507. width: number;
  37508. /**
  37509. * Irradiance information stored in the file.
  37510. */
  37511. irradiance: any;
  37512. /**
  37513. * Specular information stored in the file.
  37514. */
  37515. specular: any;
  37516. }
  37517. /**
  37518. * Sets of helpers addressing the serialization and deserialization of environment texture
  37519. * stored in a BabylonJS env file.
  37520. * Those files are usually stored as .env files.
  37521. */
  37522. class EnvironmentTextureTools {
  37523. /**
  37524. * Magic number identifying the env file.
  37525. */
  37526. private static _MagicBytes;
  37527. /**
  37528. * Gets the environment info from an env file.
  37529. * @param data The array buffer containing the .env bytes.
  37530. * @returns the environment file info (the json header) if successfully parsed.
  37531. */
  37532. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37533. /**
  37534. * Creates an environment texture from a loaded cube texture.
  37535. * @param texture defines the cube texture to convert in env file
  37536. * @return a promise containing the environment data if succesfull.
  37537. */
  37538. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37539. /**
  37540. * Creates a JSON representation of the spherical data.
  37541. * @param texture defines the texture containing the polynomials
  37542. * @return the JSON representation of the spherical info
  37543. */
  37544. private static _CreateEnvTextureIrradiance;
  37545. /**
  37546. * Uploads the texture info contained in the env file to the GPU.
  37547. * @param texture defines the internal texture to upload to
  37548. * @param arrayBuffer defines the buffer cotaining the data to load
  37549. * @param info defines the texture info retrieved through the GetEnvInfo method
  37550. * @returns a promise
  37551. */
  37552. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37553. /**
  37554. * Uploads the levels of image data to the GPU.
  37555. * @param texture defines the internal texture to upload to
  37556. * @param imageData defines the array buffer views of image data [mipmap][face]
  37557. * @returns a promise
  37558. */
  37559. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37560. /**
  37561. * Uploads spherical polynomials information to the texture.
  37562. * @param texture defines the texture we are trying to upload the information to
  37563. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37564. */
  37565. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37566. }
  37567. }
  37568. declare module BABYLON {
  37569. /**
  37570. * Class used to help managing file picking and drag'n'drop
  37571. */
  37572. class FilesInput {
  37573. /**
  37574. * List of files ready to be loaded
  37575. */
  37576. static FilesToLoad: {
  37577. [key: string]: File;
  37578. };
  37579. /**
  37580. * Callback called when a file is processed
  37581. */
  37582. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37583. private _engine;
  37584. private _currentScene;
  37585. private _sceneLoadedCallback;
  37586. private _progressCallback;
  37587. private _additionalRenderLoopLogicCallback;
  37588. private _textureLoadingCallback;
  37589. private _startingProcessingFilesCallback;
  37590. private _onReloadCallback;
  37591. private _errorCallback;
  37592. private _elementToMonitor;
  37593. private _sceneFileToLoad;
  37594. private _filesToLoad;
  37595. /**
  37596. * Creates a new FilesInput
  37597. * @param engine defines the rendering engine
  37598. * @param scene defines the hosting scene
  37599. * @param sceneLoadedCallback callback called when scene is loaded
  37600. * @param progressCallback callback called to track progress
  37601. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37602. * @param textureLoadingCallback callback called when a texture is loading
  37603. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37604. * @param onReloadCallback callback called when a reload is requested
  37605. * @param errorCallback callback call if an error occurs
  37606. */
  37607. 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);
  37608. private _dragEnterHandler;
  37609. private _dragOverHandler;
  37610. private _dropHandler;
  37611. /**
  37612. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37613. * @param elementToMonitor defines the DOM element to track
  37614. */
  37615. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37616. /**
  37617. * Release all associated resources
  37618. */
  37619. dispose(): void;
  37620. private renderFunction;
  37621. private drag;
  37622. private drop;
  37623. private _traverseFolder;
  37624. private _processFiles;
  37625. /**
  37626. * Load files from a drop event
  37627. * @param event defines the drop event to use as source
  37628. */
  37629. loadFiles(event: any): void;
  37630. private _processReload;
  37631. /**
  37632. * Reload the current scene from the loaded files
  37633. */
  37634. reload(): void;
  37635. }
  37636. }
  37637. declare module BABYLON {
  37638. /**
  37639. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37640. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37641. */
  37642. class KhronosTextureContainer {
  37643. /** contents of the KTX container file */
  37644. arrayBuffer: any;
  37645. private static HEADER_LEN;
  37646. private static COMPRESSED_2D;
  37647. private static COMPRESSED_3D;
  37648. private static TEX_2D;
  37649. private static TEX_3D;
  37650. /**
  37651. * Gets the openGL type
  37652. */
  37653. glType: number;
  37654. /**
  37655. * Gets the openGL type size
  37656. */
  37657. glTypeSize: number;
  37658. /**
  37659. * Gets the openGL format
  37660. */
  37661. glFormat: number;
  37662. /**
  37663. * Gets the openGL internal format
  37664. */
  37665. glInternalFormat: number;
  37666. /**
  37667. * Gets the base internal format
  37668. */
  37669. glBaseInternalFormat: number;
  37670. /**
  37671. * Gets image width in pixel
  37672. */
  37673. pixelWidth: number;
  37674. /**
  37675. * Gets image height in pixel
  37676. */
  37677. pixelHeight: number;
  37678. /**
  37679. * Gets image depth in pixels
  37680. */
  37681. pixelDepth: number;
  37682. /**
  37683. * Gets the number of array elements
  37684. */
  37685. numberOfArrayElements: number;
  37686. /**
  37687. * Gets the number of faces
  37688. */
  37689. numberOfFaces: number;
  37690. /**
  37691. * Gets the number of mipmap levels
  37692. */
  37693. numberOfMipmapLevels: number;
  37694. /**
  37695. * Gets the bytes of key value data
  37696. */
  37697. bytesOfKeyValueData: number;
  37698. /**
  37699. * Gets the load type
  37700. */
  37701. loadType: number;
  37702. /**
  37703. * Creates a new KhronosTextureContainer
  37704. * @param arrayBuffer contents of the KTX container file
  37705. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37706. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37707. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37708. */
  37709. constructor(
  37710. /** contents of the KTX container file */
  37711. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37712. /**
  37713. * Revert the endianness of a value.
  37714. * Not as fast hardware based, but will probably never need to use
  37715. * @param val defines the value to convert
  37716. * @returns the new value
  37717. */
  37718. switchEndianness(val: number): number;
  37719. /**
  37720. * Uploads KTX content to a Babylon Texture.
  37721. * It is assumed that the texture has already been created & is currently bound
  37722. * @hidden
  37723. */
  37724. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37725. private _upload2DCompressedLevels;
  37726. }
  37727. }
  37728. declare module BABYLON {
  37729. /**
  37730. * A class serves as a medium between the observable and its observers
  37731. */
  37732. class EventState {
  37733. /**
  37734. * Create a new EventState
  37735. * @param mask defines the mask associated with this state
  37736. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37737. * @param target defines the original target of the state
  37738. * @param currentTarget defines the current target of the state
  37739. */
  37740. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37741. /**
  37742. * Initialize the current event state
  37743. * @param mask defines the mask associated with this state
  37744. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37745. * @param target defines the original target of the state
  37746. * @param currentTarget defines the current target of the state
  37747. * @returns the current event state
  37748. */
  37749. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37750. /**
  37751. * An Observer can set this property to true to prevent subsequent observers of being notified
  37752. */
  37753. skipNextObservers: boolean;
  37754. /**
  37755. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37756. */
  37757. mask: number;
  37758. /**
  37759. * The object that originally notified the event
  37760. */
  37761. target?: any;
  37762. /**
  37763. * The current object in the bubbling phase
  37764. */
  37765. currentTarget?: any;
  37766. /**
  37767. * This will be populated with the return value of the last function that was executed.
  37768. * If it is the first function in the callback chain it will be the event data.
  37769. */
  37770. lastReturnValue?: any;
  37771. }
  37772. /**
  37773. * Represent an Observer registered to a given Observable object.
  37774. */
  37775. class Observer<T> {
  37776. /**
  37777. * Defines the callback to call when the observer is notified
  37778. */
  37779. callback: (eventData: T, eventState: EventState) => void;
  37780. /**
  37781. * Defines the mask of the observer (used to filter notifications)
  37782. */
  37783. mask: number;
  37784. /**
  37785. * Defines the current scope used to restore the JS context
  37786. */
  37787. scope: any;
  37788. /** @hidden */
  37789. _willBeUnregistered: boolean;
  37790. /**
  37791. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37792. */
  37793. unregisterOnNextCall: boolean;
  37794. /**
  37795. * Creates a new observer
  37796. * @param callback defines the callback to call when the observer is notified
  37797. * @param mask defines the mask of the observer (used to filter notifications)
  37798. * @param scope defines the current scope used to restore the JS context
  37799. */
  37800. constructor(
  37801. /**
  37802. * Defines the callback to call when the observer is notified
  37803. */
  37804. callback: (eventData: T, eventState: EventState) => void,
  37805. /**
  37806. * Defines the mask of the observer (used to filter notifications)
  37807. */
  37808. mask: number,
  37809. /**
  37810. * Defines the current scope used to restore the JS context
  37811. */
  37812. scope?: any);
  37813. }
  37814. /**
  37815. * Represent a list of observers registered to multiple Observables object.
  37816. */
  37817. class MultiObserver<T> {
  37818. private _observers;
  37819. private _observables;
  37820. /**
  37821. * Release associated resources
  37822. */
  37823. dispose(): void;
  37824. /**
  37825. * Raise a callback when one of the observable will notify
  37826. * @param observables defines a list of observables to watch
  37827. * @param callback defines the callback to call on notification
  37828. * @param mask defines the mask used to filter notifications
  37829. * @param scope defines the current scope used to restore the JS context
  37830. * @returns the new MultiObserver
  37831. */
  37832. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37833. }
  37834. /**
  37835. * The Observable class is a simple implementation of the Observable pattern.
  37836. *
  37837. * 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.
  37838. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37839. * 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).
  37840. * 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.
  37841. */
  37842. class Observable<T> {
  37843. private _observers;
  37844. private _eventState;
  37845. private _onObserverAdded;
  37846. /**
  37847. * Creates a new observable
  37848. * @param onObserverAdded defines a callback to call when a new observer is added
  37849. */
  37850. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37851. /**
  37852. * Create a new Observer with the specified callback
  37853. * @param callback the callback that will be executed for that Observer
  37854. * @param mask the mask used to filter observers
  37855. * @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.
  37856. * @param scope optional scope for the callback to be called from
  37857. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37858. * @returns the new observer created for the callback
  37859. */
  37860. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37861. /**
  37862. * Create a new Observer with the specified callback and unregisters after the next notification
  37863. * @param callback the callback that will be executed for that Observer
  37864. * @returns the new observer created for the callback
  37865. */
  37866. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37867. /**
  37868. * Remove an Observer from the Observable object
  37869. * @param observer the instance of the Observer to remove
  37870. * @returns false if it doesn't belong to this Observable
  37871. */
  37872. remove(observer: Nullable<Observer<T>>): boolean;
  37873. /**
  37874. * Remove a callback from the Observable object
  37875. * @param callback the callback to remove
  37876. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37877. * @returns false if it doesn't belong to this Observable
  37878. */
  37879. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37880. private _deferUnregister;
  37881. private _remove;
  37882. /**
  37883. * Notify all Observers by calling their respective callback with the given data
  37884. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37885. * @param eventData defines the data to send to all observers
  37886. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37887. * @param target defines the original target of the state
  37888. * @param currentTarget defines the current target of the state
  37889. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37890. */
  37891. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37892. /**
  37893. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37894. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37895. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37896. * and it is crucial that all callbacks will be executed.
  37897. * The order of the callbacks is kept, callbacks are not executed parallel.
  37898. *
  37899. * @param eventData The data to be sent to each callback
  37900. * @param mask is used to filter observers defaults to -1
  37901. * @param target defines the callback target (see EventState)
  37902. * @param currentTarget defines he current object in the bubbling phase
  37903. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37904. */
  37905. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37906. /**
  37907. * Notify a specific observer
  37908. * @param observer defines the observer to notify
  37909. * @param eventData defines the data to be sent to each callback
  37910. * @param mask is used to filter observers defaults to -1
  37911. */
  37912. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37913. /**
  37914. * Gets a boolean indicating if the observable has at least one observer
  37915. * @returns true is the Observable has at least one Observer registered
  37916. */
  37917. hasObservers(): boolean;
  37918. /**
  37919. * Clear the list of observers
  37920. */
  37921. clear(): void;
  37922. /**
  37923. * Clone the current observable
  37924. * @returns a new observable
  37925. */
  37926. clone(): Observable<T>;
  37927. /**
  37928. * Does this observable handles observer registered with a given mask
  37929. * @param mask defines the mask to be tested
  37930. * @return whether or not one observer registered with the given mask is handeled
  37931. **/
  37932. hasSpecificMask(mask?: number): boolean;
  37933. }
  37934. }
  37935. declare module BABYLON {
  37936. /**
  37937. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37938. */
  37939. class PerformanceMonitor {
  37940. private _enabled;
  37941. private _rollingFrameTime;
  37942. private _lastFrameTimeMs;
  37943. /**
  37944. * constructor
  37945. * @param frameSampleSize The number of samples required to saturate the sliding window
  37946. */
  37947. constructor(frameSampleSize?: number);
  37948. /**
  37949. * Samples current frame
  37950. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37951. */
  37952. sampleFrame(timeMs?: number): void;
  37953. /**
  37954. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37955. */
  37956. readonly averageFrameTime: number;
  37957. /**
  37958. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37959. */
  37960. readonly averageFrameTimeVariance: number;
  37961. /**
  37962. * Returns the frame time of the most recent frame
  37963. */
  37964. readonly instantaneousFrameTime: number;
  37965. /**
  37966. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37967. */
  37968. readonly averageFPS: number;
  37969. /**
  37970. * Returns the average framerate in frames per second using the most recent frame time
  37971. */
  37972. readonly instantaneousFPS: number;
  37973. /**
  37974. * Returns true if enough samples have been taken to completely fill the sliding window
  37975. */
  37976. readonly isSaturated: boolean;
  37977. /**
  37978. * Enables contributions to the sliding window sample set
  37979. */
  37980. enable(): void;
  37981. /**
  37982. * Disables contributions to the sliding window sample set
  37983. * Samples will not be interpolated over the disabled period
  37984. */
  37985. disable(): void;
  37986. /**
  37987. * Returns true if sampling is enabled
  37988. */
  37989. readonly isEnabled: boolean;
  37990. /**
  37991. * Resets performance monitor
  37992. */
  37993. reset(): void;
  37994. }
  37995. /**
  37996. * RollingAverage
  37997. *
  37998. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37999. */
  38000. class RollingAverage {
  38001. /**
  38002. * Current average
  38003. */
  38004. average: number;
  38005. /**
  38006. * Current variance
  38007. */
  38008. variance: number;
  38009. protected _samples: Array<number>;
  38010. protected _sampleCount: number;
  38011. protected _pos: number;
  38012. protected _m2: number;
  38013. /**
  38014. * constructor
  38015. * @param length The number of samples required to saturate the sliding window
  38016. */
  38017. constructor(length: number);
  38018. /**
  38019. * Adds a sample to the sample set
  38020. * @param v The sample value
  38021. */
  38022. add(v: number): void;
  38023. /**
  38024. * Returns previously added values or null if outside of history or outside the sliding window domain
  38025. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38026. * @return Value previously recorded with add() or null if outside of range
  38027. */
  38028. history(i: number): number;
  38029. /**
  38030. * Returns true if enough samples have been taken to completely fill the sliding window
  38031. * @return true if sample-set saturated
  38032. */
  38033. isSaturated(): boolean;
  38034. /**
  38035. * Resets the rolling average (equivalent to 0 samples taken so far)
  38036. */
  38037. reset(): void;
  38038. /**
  38039. * Wraps a value around the sample range boundaries
  38040. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38041. * @return Wrapped position in sample range
  38042. */
  38043. protected _wrapPosition(i: number): number;
  38044. }
  38045. }
  38046. declare module BABYLON {
  38047. /**
  38048. * Helper class that provides a small promise polyfill
  38049. */
  38050. class PromisePolyfill {
  38051. /**
  38052. * Static function used to check if the polyfill is required
  38053. * If this is the case then the function will inject the polyfill to window.Promise
  38054. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38055. */
  38056. static Apply(force?: boolean): void;
  38057. }
  38058. }
  38059. declare module BABYLON {
  38060. /**
  38061. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38063. */
  38064. class SceneOptimization {
  38065. /**
  38066. * Defines the priority of this optimization (0 by default which means first in the list)
  38067. */
  38068. priority: number;
  38069. /**
  38070. * Gets a string describing the action executed by the current optimization
  38071. * @returns description string
  38072. */
  38073. getDescription(): string;
  38074. /**
  38075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38076. * @param scene defines the current scene where to apply this optimization
  38077. * @param optimizer defines the current optimizer
  38078. * @returns true if everything that can be done was applied
  38079. */
  38080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38081. /**
  38082. * Creates the SceneOptimization object
  38083. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38084. * @param desc defines the description associated with the optimization
  38085. */
  38086. constructor(
  38087. /**
  38088. * Defines the priority of this optimization (0 by default which means first in the list)
  38089. */
  38090. priority?: number);
  38091. }
  38092. /**
  38093. * Defines an optimization used to reduce the size of render target textures
  38094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38095. */
  38096. class TextureOptimization extends SceneOptimization {
  38097. /**
  38098. * Defines the priority of this optimization (0 by default which means first in the list)
  38099. */
  38100. priority: number;
  38101. /**
  38102. * 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
  38103. */
  38104. maximumSize: number;
  38105. /**
  38106. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38107. */
  38108. step: number;
  38109. /**
  38110. * Gets a string describing the action executed by the current optimization
  38111. * @returns description string
  38112. */
  38113. getDescription(): string;
  38114. /**
  38115. * Creates the TextureOptimization object
  38116. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38117. * @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
  38118. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38119. */
  38120. constructor(
  38121. /**
  38122. * Defines the priority of this optimization (0 by default which means first in the list)
  38123. */
  38124. priority?: number,
  38125. /**
  38126. * 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
  38127. */
  38128. maximumSize?: number,
  38129. /**
  38130. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38131. */
  38132. step?: number);
  38133. /**
  38134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38135. * @param scene defines the current scene where to apply this optimization
  38136. * @param optimizer defines the current optimizer
  38137. * @returns true if everything that can be done was applied
  38138. */
  38139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38140. }
  38141. /**
  38142. * Defines an optimization used to increase or decrease the rendering resolution
  38143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38144. */
  38145. class HardwareScalingOptimization extends SceneOptimization {
  38146. /**
  38147. * Defines the priority of this optimization (0 by default which means first in the list)
  38148. */
  38149. priority: number;
  38150. /**
  38151. * Defines the maximum scale to use (2 by default)
  38152. */
  38153. maximumScale: number;
  38154. /**
  38155. * Defines the step to use between two passes (0.5 by default)
  38156. */
  38157. step: number;
  38158. private _currentScale;
  38159. private _directionOffset;
  38160. /**
  38161. * Gets a string describing the action executed by the current optimization
  38162. * @return description string
  38163. */
  38164. getDescription(): string;
  38165. /**
  38166. * Creates the HardwareScalingOptimization object
  38167. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38168. * @param maximumScale defines the maximum scale to use (2 by default)
  38169. * @param step defines the step to use between two passes (0.5 by default)
  38170. */
  38171. constructor(
  38172. /**
  38173. * Defines the priority of this optimization (0 by default which means first in the list)
  38174. */
  38175. priority?: number,
  38176. /**
  38177. * Defines the maximum scale to use (2 by default)
  38178. */
  38179. maximumScale?: number,
  38180. /**
  38181. * Defines the step to use between two passes (0.5 by default)
  38182. */
  38183. step?: number);
  38184. /**
  38185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38186. * @param scene defines the current scene where to apply this optimization
  38187. * @param optimizer defines the current optimizer
  38188. * @returns true if everything that can be done was applied
  38189. */
  38190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38191. }
  38192. /**
  38193. * Defines an optimization used to remove shadows
  38194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38195. */
  38196. class ShadowsOptimization extends SceneOptimization {
  38197. /**
  38198. * Gets a string describing the action executed by the current optimization
  38199. * @return description string
  38200. */
  38201. getDescription(): string;
  38202. /**
  38203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38204. * @param scene defines the current scene where to apply this optimization
  38205. * @param optimizer defines the current optimizer
  38206. * @returns true if everything that can be done was applied
  38207. */
  38208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38209. }
  38210. /**
  38211. * Defines an optimization used to turn post-processes off
  38212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38213. */
  38214. class PostProcessesOptimization extends SceneOptimization {
  38215. /**
  38216. * Gets a string describing the action executed by the current optimization
  38217. * @return description string
  38218. */
  38219. getDescription(): string;
  38220. /**
  38221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38222. * @param scene defines the current scene where to apply this optimization
  38223. * @param optimizer defines the current optimizer
  38224. * @returns true if everything that can be done was applied
  38225. */
  38226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38227. }
  38228. /**
  38229. * Defines an optimization used to turn lens flares off
  38230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38231. */
  38232. class LensFlaresOptimization extends SceneOptimization {
  38233. /**
  38234. * Gets a string describing the action executed by the current optimization
  38235. * @return description string
  38236. */
  38237. getDescription(): string;
  38238. /**
  38239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38240. * @param scene defines the current scene where to apply this optimization
  38241. * @param optimizer defines the current optimizer
  38242. * @returns true if everything that can be done was applied
  38243. */
  38244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38245. }
  38246. /**
  38247. * Defines an optimization based on user defined callback.
  38248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38249. */
  38250. class CustomOptimization extends SceneOptimization {
  38251. /**
  38252. * Callback called to apply the custom optimization.
  38253. */
  38254. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38255. /**
  38256. * Callback called to get custom description
  38257. */
  38258. onGetDescription: () => string;
  38259. /**
  38260. * Gets a string describing the action executed by the current optimization
  38261. * @returns description string
  38262. */
  38263. getDescription(): string;
  38264. /**
  38265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38266. * @param scene defines the current scene where to apply this optimization
  38267. * @param optimizer defines the current optimizer
  38268. * @returns true if everything that can be done was applied
  38269. */
  38270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38271. }
  38272. /**
  38273. * Defines an optimization used to turn particles off
  38274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38275. */
  38276. class ParticlesOptimization extends SceneOptimization {
  38277. /**
  38278. * Gets a string describing the action executed by the current optimization
  38279. * @return description string
  38280. */
  38281. getDescription(): string;
  38282. /**
  38283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38284. * @param scene defines the current scene where to apply this optimization
  38285. * @param optimizer defines the current optimizer
  38286. * @returns true if everything that can be done was applied
  38287. */
  38288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38289. }
  38290. /**
  38291. * Defines an optimization used to turn render targets off
  38292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38293. */
  38294. class RenderTargetsOptimization extends SceneOptimization {
  38295. /**
  38296. * Gets a string describing the action executed by the current optimization
  38297. * @return description string
  38298. */
  38299. getDescription(): string;
  38300. /**
  38301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38302. * @param scene defines the current scene where to apply this optimization
  38303. * @param optimizer defines the current optimizer
  38304. * @returns true if everything that can be done was applied
  38305. */
  38306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38307. }
  38308. /**
  38309. * Defines an optimization used to merge meshes with compatible materials
  38310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38311. */
  38312. class MergeMeshesOptimization extends SceneOptimization {
  38313. private static _UpdateSelectionTree;
  38314. /**
  38315. * Gets or sets a boolean which defines if optimization octree has to be updated
  38316. */
  38317. /**
  38318. * Gets or sets a boolean which defines if optimization octree has to be updated
  38319. */
  38320. static UpdateSelectionTree: boolean;
  38321. /**
  38322. * Gets a string describing the action executed by the current optimization
  38323. * @return description string
  38324. */
  38325. getDescription(): string;
  38326. private _canBeMerged;
  38327. /**
  38328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38329. * @param scene defines the current scene where to apply this optimization
  38330. * @param optimizer defines the current optimizer
  38331. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38332. * @returns true if everything that can be done was applied
  38333. */
  38334. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38335. }
  38336. /**
  38337. * Defines a list of options used by SceneOptimizer
  38338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38339. */
  38340. class SceneOptimizerOptions {
  38341. /**
  38342. * Defines the target frame rate to reach (60 by default)
  38343. */
  38344. targetFrameRate: number;
  38345. /**
  38346. * Defines the interval between two checkes (2000ms by default)
  38347. */
  38348. trackerDuration: number;
  38349. /**
  38350. * Gets the list of optimizations to apply
  38351. */
  38352. optimizations: SceneOptimization[];
  38353. /**
  38354. * Creates a new list of options used by SceneOptimizer
  38355. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38356. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38357. */
  38358. constructor(
  38359. /**
  38360. * Defines the target frame rate to reach (60 by default)
  38361. */
  38362. targetFrameRate?: number,
  38363. /**
  38364. * Defines the interval between two checkes (2000ms by default)
  38365. */
  38366. trackerDuration?: number);
  38367. /**
  38368. * Add a new optimization
  38369. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38370. * @returns the current SceneOptimizerOptions
  38371. */
  38372. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38373. /**
  38374. * Add a new custom optimization
  38375. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38376. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38377. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38378. * @returns the current SceneOptimizerOptions
  38379. */
  38380. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38381. /**
  38382. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38383. * @param targetFrameRate defines the target frame rate (60 by default)
  38384. * @returns a SceneOptimizerOptions object
  38385. */
  38386. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38387. /**
  38388. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38389. * @param targetFrameRate defines the target frame rate (60 by default)
  38390. * @returns a SceneOptimizerOptions object
  38391. */
  38392. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38393. /**
  38394. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38395. * @param targetFrameRate defines the target frame rate (60 by default)
  38396. * @returns a SceneOptimizerOptions object
  38397. */
  38398. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38399. }
  38400. /**
  38401. * Class used to run optimizations in order to reach a target frame rate
  38402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38403. */
  38404. class SceneOptimizer implements IDisposable {
  38405. private _isRunning;
  38406. private _options;
  38407. private _scene;
  38408. private _currentPriorityLevel;
  38409. private _targetFrameRate;
  38410. private _trackerDuration;
  38411. private _currentFrameRate;
  38412. private _sceneDisposeObserver;
  38413. private _improvementMode;
  38414. /**
  38415. * Defines an observable called when the optimizer reaches the target frame rate
  38416. */
  38417. onSuccessObservable: Observable<SceneOptimizer>;
  38418. /**
  38419. * Defines an observable called when the optimizer enables an optimization
  38420. */
  38421. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38422. /**
  38423. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38424. */
  38425. onFailureObservable: Observable<SceneOptimizer>;
  38426. /**
  38427. * Gets a boolean indicating if the optimizer is in improvement mode
  38428. */
  38429. readonly isInImprovementMode: boolean;
  38430. /**
  38431. * Gets the current priority level (0 at start)
  38432. */
  38433. readonly currentPriorityLevel: number;
  38434. /**
  38435. * Gets the current frame rate checked by the SceneOptimizer
  38436. */
  38437. readonly currentFrameRate: number;
  38438. /**
  38439. * Gets or sets the current target frame rate (60 by default)
  38440. */
  38441. /**
  38442. * Gets or sets the current target frame rate (60 by default)
  38443. */
  38444. targetFrameRate: number;
  38445. /**
  38446. * Gets or sets the current interval between two checks (every 2000ms by default)
  38447. */
  38448. /**
  38449. * Gets or sets the current interval between two checks (every 2000ms by default)
  38450. */
  38451. trackerDuration: number;
  38452. /**
  38453. * Gets the list of active optimizations
  38454. */
  38455. readonly optimizations: SceneOptimization[];
  38456. /**
  38457. * Creates a new SceneOptimizer
  38458. * @param scene defines the scene to work on
  38459. * @param options defines the options to use with the SceneOptimizer
  38460. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38461. * @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)
  38462. */
  38463. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38464. /**
  38465. * Stops the current optimizer
  38466. */
  38467. stop(): void;
  38468. /**
  38469. * Reset the optimizer to initial step (current priority level = 0)
  38470. */
  38471. reset(): void;
  38472. /**
  38473. * Start the optimizer. By default it will try to reach a specific framerate
  38474. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38475. */
  38476. start(): void;
  38477. private _checkCurrentState;
  38478. /**
  38479. * Release all resources
  38480. */
  38481. dispose(): void;
  38482. /**
  38483. * Helper function to create a SceneOptimizer with one single line of code
  38484. * @param scene defines the scene to work on
  38485. * @param options defines the options to use with the SceneOptimizer
  38486. * @param onSuccess defines a callback to call on success
  38487. * @param onFailure defines a callback to call on failure
  38488. * @returns the new SceneOptimizer object
  38489. */
  38490. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /**
  38495. * Class used to serialize a scene into a string
  38496. */
  38497. class SceneSerializer {
  38498. /**
  38499. * Clear cache used by a previous serialization
  38500. */
  38501. static ClearCache(): void;
  38502. /**
  38503. * Serialize a scene into a JSON compatible object
  38504. * @param scene defines the scene to serialize
  38505. * @returns a JSON compatible object
  38506. */
  38507. static Serialize(scene: Scene): any;
  38508. /**
  38509. * Serialize a mesh into a JSON compatible object
  38510. * @param toSerialize defines the mesh to serialize
  38511. * @param withParents defines if parents must be serialized as well
  38512. * @param withChildren defines if children must be serialized as well
  38513. * @returns a JSON compatible object
  38514. */
  38515. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38516. }
  38517. }
  38518. declare module BABYLON {
  38519. /**
  38520. * Defines an array and its length.
  38521. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38522. */
  38523. interface ISmartArrayLike<T> {
  38524. /**
  38525. * The data of the array.
  38526. */
  38527. data: Array<T>;
  38528. /**
  38529. * The active length of the array.
  38530. */
  38531. length: number;
  38532. }
  38533. /**
  38534. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38535. */
  38536. class SmartArray<T> implements ISmartArrayLike<T> {
  38537. /**
  38538. * The full set of data from the array.
  38539. */
  38540. data: Array<T>;
  38541. /**
  38542. * The active length of the array.
  38543. */
  38544. length: number;
  38545. protected _id: number;
  38546. /**
  38547. * Instantiates a Smart Array.
  38548. * @param capacity defines the default capacity of the array.
  38549. */
  38550. constructor(capacity: number);
  38551. /**
  38552. * Pushes a value at the end of the active data.
  38553. * @param value defines the object to push in the array.
  38554. */
  38555. push(value: T): void;
  38556. /**
  38557. * Iterates over the active data and apply the lambda to them.
  38558. * @param func defines the action to apply on each value.
  38559. */
  38560. forEach(func: (content: T) => void): void;
  38561. /**
  38562. * Sorts the full sets of data.
  38563. * @param compareFn defines the comparison function to apply.
  38564. */
  38565. sort(compareFn: (a: T, b: T) => number): void;
  38566. /**
  38567. * Resets the active data to an empty array.
  38568. */
  38569. reset(): void;
  38570. /**
  38571. * Releases all the data from the array as well as the array.
  38572. */
  38573. dispose(): void;
  38574. /**
  38575. * Concats the active data with a given array.
  38576. * @param array defines the data to concatenate with.
  38577. */
  38578. concat(array: any): void;
  38579. /**
  38580. * Returns the position of a value in the active data.
  38581. * @param value defines the value to find the index for
  38582. * @returns the index if found in the active data otherwise -1
  38583. */
  38584. indexOf(value: T): number;
  38585. /**
  38586. * Returns whether an element is part of the active data.
  38587. * @param value defines the value to look for
  38588. * @returns true if found in the active data otherwise false
  38589. */
  38590. contains(value: T): boolean;
  38591. private static _GlobalId;
  38592. }
  38593. /**
  38594. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38595. * The data in this array can only be present once
  38596. */
  38597. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38598. private _duplicateId;
  38599. /**
  38600. * Pushes a value at the end of the active data.
  38601. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38602. * @param value defines the object to push in the array.
  38603. */
  38604. push(value: T): void;
  38605. /**
  38606. * Pushes a value at the end of the active data.
  38607. * If the data is already present, it won t be added again
  38608. * @param value defines the object to push in the array.
  38609. * @returns true if added false if it was already present
  38610. */
  38611. pushNoDuplicate(value: T): boolean;
  38612. /**
  38613. * Resets the active data to an empty array.
  38614. */
  38615. reset(): void;
  38616. /**
  38617. * Concats the active data with a given array.
  38618. * This ensures no dupplicate will be present in the result.
  38619. * @param array defines the data to concatenate with.
  38620. */
  38621. concatWithNoDuplicate(array: any): void;
  38622. }
  38623. }
  38624. declare module BABYLON {
  38625. /**
  38626. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38627. * The underlying implementation relies on an associative array to ensure the best performances.
  38628. * The value can be anything including 'null' but except 'undefined'
  38629. */
  38630. class StringDictionary<T> {
  38631. /**
  38632. * This will clear this dictionary and copy the content from the 'source' one.
  38633. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38634. * @param source the dictionary to take the content from and copy to this dictionary
  38635. */
  38636. copyFrom(source: StringDictionary<T>): void;
  38637. /**
  38638. * Get a value based from its key
  38639. * @param key the given key to get the matching value from
  38640. * @return the value if found, otherwise undefined is returned
  38641. */
  38642. get(key: string): T | undefined;
  38643. /**
  38644. * Get a value from its key or add it if it doesn't exist.
  38645. * This method will ensure you that a given key/data will be present in the dictionary.
  38646. * @param key the given key to get the matching value from
  38647. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38648. * The factory will only be invoked if there's no data for the given key.
  38649. * @return the value corresponding to the key.
  38650. */
  38651. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38652. /**
  38653. * Get a value from its key if present in the dictionary otherwise add it
  38654. * @param key the key to get the value from
  38655. * @param val if there's no such key/value pair in the dictionary add it with this value
  38656. * @return the value corresponding to the key
  38657. */
  38658. getOrAdd(key: string, val: T): T;
  38659. /**
  38660. * Check if there's a given key in the dictionary
  38661. * @param key the key to check for
  38662. * @return true if the key is present, false otherwise
  38663. */
  38664. contains(key: string): boolean;
  38665. /**
  38666. * Add a new key and its corresponding value
  38667. * @param key the key to add
  38668. * @param value the value corresponding to the key
  38669. * @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
  38670. */
  38671. add(key: string, value: T): boolean;
  38672. /**
  38673. * Update a specific value associated to a key
  38674. * @param key defines the key to use
  38675. * @param value defines the value to store
  38676. * @returns true if the value was updated (or false if the key was not found)
  38677. */
  38678. set(key: string, value: T): boolean;
  38679. /**
  38680. * Get the element of the given key and remove it from the dictionary
  38681. * @param key defines the key to search
  38682. * @returns the value associated with the key or null if not found
  38683. */
  38684. getAndRemove(key: string): Nullable<T>;
  38685. /**
  38686. * Remove a key/value from the dictionary.
  38687. * @param key the key to remove
  38688. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38689. */
  38690. remove(key: string): boolean;
  38691. /**
  38692. * Clear the whole content of the dictionary
  38693. */
  38694. clear(): void;
  38695. /**
  38696. * Gets the current count
  38697. */
  38698. readonly count: number;
  38699. /**
  38700. * Execute a callback on each key/val of the dictionary.
  38701. * Note that you can remove any element in this dictionary in the callback implementation
  38702. * @param callback the callback to execute on a given key/value pair
  38703. */
  38704. forEach(callback: (key: string, val: T) => void): void;
  38705. /**
  38706. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38707. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38708. * Note that you can remove any element in this dictionary in the callback implementation
  38709. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38710. * @returns the first item
  38711. */
  38712. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38713. private _count;
  38714. private _data;
  38715. }
  38716. }
  38717. declare module BABYLON {
  38718. /**
  38719. * Class used to store custom tags
  38720. */
  38721. class Tags {
  38722. /**
  38723. * Adds support for tags on the given object
  38724. * @param obj defines the object to use
  38725. */
  38726. static EnableFor(obj: any): void;
  38727. /**
  38728. * Removes tags support
  38729. * @param obj defines the object to use
  38730. */
  38731. static DisableFor(obj: any): void;
  38732. /**
  38733. * Gets a boolean indicating if the given object has tags
  38734. * @param obj defines the object to use
  38735. * @returns a boolean
  38736. */
  38737. static HasTags(obj: any): boolean;
  38738. /**
  38739. * Gets the tags available on a given object
  38740. * @param obj defines the object to use
  38741. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38742. * @returns the tags
  38743. */
  38744. static GetTags(obj: any, asString?: boolean): any;
  38745. /**
  38746. * Adds tags to an object
  38747. * @param obj defines the object to use
  38748. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38749. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38750. */
  38751. static AddTagsTo(obj: any, tagsString: string): void;
  38752. /**
  38753. * @hidden
  38754. */
  38755. static _AddTagTo(obj: any, tag: string): void;
  38756. /**
  38757. * Removes specific tags from a specific object
  38758. * @param obj defines the object to use
  38759. * @param tagsString defines the tags to remove
  38760. */
  38761. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38762. /**
  38763. * @hidden
  38764. */
  38765. static _RemoveTagFrom(obj: any, tag: string): void;
  38766. /**
  38767. * Defines if tags hosted on an object match a given query
  38768. * @param obj defines the object to use
  38769. * @param tagsQuery defines the tag query
  38770. * @returns a boolean
  38771. */
  38772. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38773. }
  38774. }
  38775. declare module BABYLON {
  38776. /**
  38777. * Class used to host texture specific utilities
  38778. */
  38779. class TextureTools {
  38780. /**
  38781. * Uses the GPU to create a copy texture rescaled at a given size
  38782. * @param texture Texture to copy from
  38783. * @param width defines the desired width
  38784. * @param height defines the desired height
  38785. * @param useBilinearMode defines if bilinear mode has to be used
  38786. * @return the generated texture
  38787. */
  38788. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38789. /**
  38790. * Gets an environment BRDF texture for a given scene
  38791. * @param scene defines the hosting scene
  38792. * @returns the environment BRDF texture
  38793. */
  38794. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38795. private static _environmentBRDFBase64Texture;
  38796. }
  38797. }
  38798. declare module BABYLON {
  38799. /**
  38800. * Based on jsTGALoader - Javascript loader for TGA file
  38801. * By Vincent Thibault
  38802. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38803. */
  38804. class TGATools {
  38805. private static _TYPE_INDEXED;
  38806. private static _TYPE_RGB;
  38807. private static _TYPE_GREY;
  38808. private static _TYPE_RLE_INDEXED;
  38809. private static _TYPE_RLE_RGB;
  38810. private static _TYPE_RLE_GREY;
  38811. private static _ORIGIN_MASK;
  38812. private static _ORIGIN_SHIFT;
  38813. private static _ORIGIN_BL;
  38814. private static _ORIGIN_BR;
  38815. private static _ORIGIN_UL;
  38816. private static _ORIGIN_UR;
  38817. /**
  38818. * Gets the header of a TGA file
  38819. * @param data defines the TGA data
  38820. * @returns the header
  38821. */
  38822. static GetTGAHeader(data: Uint8Array): any;
  38823. /**
  38824. * Uploads TGA content to a Babylon Texture
  38825. * @hidden
  38826. */
  38827. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38828. /** @hidden */
  38829. 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;
  38830. /** @hidden */
  38831. 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;
  38832. /** @hidden */
  38833. 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;
  38834. /** @hidden */
  38835. 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;
  38836. /** @hidden */
  38837. 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;
  38838. /** @hidden */
  38839. 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;
  38840. }
  38841. }
  38842. declare module BABYLON {
  38843. /**
  38844. * Interface for any object that can request an animation frame
  38845. */
  38846. interface ICustomAnimationFrameRequester {
  38847. /**
  38848. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38849. */
  38850. renderFunction?: Function;
  38851. /**
  38852. * Called to request the next frame to render to
  38853. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38854. */
  38855. requestAnimationFrame: Function;
  38856. /**
  38857. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38858. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38859. */
  38860. requestID?: number;
  38861. }
  38862. /**
  38863. * Interface containing an array of animations
  38864. */
  38865. interface IAnimatable {
  38866. /**
  38867. * Array of animations
  38868. */
  38869. animations: Array<Animation>;
  38870. }
  38871. /** Interface used by value gradients (color, factor, ...) */
  38872. interface IValueGradient {
  38873. /**
  38874. * Gets or sets the gradient value (between 0 and 1)
  38875. */
  38876. gradient: number;
  38877. }
  38878. /** Class used to store color4 gradient */
  38879. class ColorGradient implements IValueGradient {
  38880. /**
  38881. * Gets or sets the gradient value (between 0 and 1)
  38882. */
  38883. gradient: number;
  38884. /**
  38885. * Gets or sets first associated color
  38886. */
  38887. color1: Color4;
  38888. /**
  38889. * Gets or sets second associated color
  38890. */
  38891. color2?: Color4;
  38892. /**
  38893. * Will get a color picked randomly between color1 and color2.
  38894. * If color2 is undefined then color1 will be used
  38895. * @param result defines the target Color4 to store the result in
  38896. */
  38897. getColorToRef(result: Color4): void;
  38898. }
  38899. /** Class used to store color 3 gradient */
  38900. class Color3Gradient implements IValueGradient {
  38901. /**
  38902. * Gets or sets the gradient value (between 0 and 1)
  38903. */
  38904. gradient: number;
  38905. /**
  38906. * Gets or sets the associated color
  38907. */
  38908. color: Color3;
  38909. }
  38910. /** Class used to store factor gradient */
  38911. class FactorGradient implements IValueGradient {
  38912. /**
  38913. * Gets or sets the gradient value (between 0 and 1)
  38914. */
  38915. gradient: number;
  38916. /**
  38917. * Gets or sets first associated factor
  38918. */
  38919. factor1: number;
  38920. /**
  38921. * Gets or sets second associated factor
  38922. */
  38923. factor2?: number;
  38924. /**
  38925. * Will get a number picked randomly between factor1 and factor2.
  38926. * If factor2 is undefined then factor1 will be used
  38927. * @returns the picked number
  38928. */
  38929. getFactor(): number;
  38930. }
  38931. /**
  38932. * @ignore
  38933. * Application error to support additional information when loading a file
  38934. */
  38935. class LoadFileError extends Error {
  38936. /** defines the optional XHR request */
  38937. request?: XMLHttpRequest | undefined;
  38938. private static _setPrototypeOf;
  38939. /**
  38940. * Creates a new LoadFileError
  38941. * @param message defines the message of the error
  38942. * @param request defines the optional XHR request
  38943. */
  38944. constructor(message: string,
  38945. /** defines the optional XHR request */
  38946. request?: XMLHttpRequest | undefined);
  38947. }
  38948. /**
  38949. * Class used to define a retry strategy when error happens while loading assets
  38950. */
  38951. class RetryStrategy {
  38952. /**
  38953. * Function used to defines an exponential back off strategy
  38954. * @param maxRetries defines the maximum number of retries (3 by default)
  38955. * @param baseInterval defines the interval between retries
  38956. * @returns the strategy function to use
  38957. */
  38958. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38959. }
  38960. /**
  38961. * File request interface
  38962. */
  38963. interface IFileRequest {
  38964. /**
  38965. * Raised when the request is complete (success or error).
  38966. */
  38967. onCompleteObservable: Observable<IFileRequest>;
  38968. /**
  38969. * Aborts the request for a file.
  38970. */
  38971. abort: () => void;
  38972. }
  38973. /**
  38974. * Class containing a set of static utilities functions
  38975. */
  38976. class Tools {
  38977. /**
  38978. * Gets or sets the base URL to use to load assets
  38979. */
  38980. static BaseUrl: string;
  38981. /**
  38982. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38983. */
  38984. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  38985. /**
  38986. * Default behaviour for cors in the application.
  38987. * It can be a string if the expected behavior is identical in the entire app.
  38988. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38989. */
  38990. static CorsBehavior: string | ((url: string | string[]) => string);
  38991. /**
  38992. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38993. * @ignorenaming
  38994. */
  38995. static UseFallbackTexture: boolean;
  38996. /**
  38997. * Use this object to register external classes like custom textures or material
  38998. * to allow the laoders to instantiate them
  38999. */
  39000. static RegisteredExternalClasses: {
  39001. [key: string]: Object;
  39002. };
  39003. /**
  39004. * Texture content used if a texture cannot loaded
  39005. * @ignorenaming
  39006. */
  39007. static fallbackTexture: string;
  39008. /**
  39009. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39010. * @param u defines the coordinate on X axis
  39011. * @param v defines the coordinate on Y axis
  39012. * @param width defines the width of the source data
  39013. * @param height defines the height of the source data
  39014. * @param pixels defines the source byte array
  39015. * @param color defines the output color
  39016. */
  39017. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39018. /**
  39019. * Interpolates between a and b via alpha
  39020. * @param a The lower value (returned when alpha = 0)
  39021. * @param b The upper value (returned when alpha = 1)
  39022. * @param alpha The interpolation-factor
  39023. * @return The mixed value
  39024. */
  39025. static Mix(a: number, b: number, alpha: number): number;
  39026. /**
  39027. * Tries to instantiate a new object from a given class name
  39028. * @param className defines the class name to instantiate
  39029. * @returns the new object or null if the system was not able to do the instantiation
  39030. */
  39031. static Instantiate(className: string): any;
  39032. /**
  39033. * Provides a slice function that will work even on IE
  39034. * @param data defines the array to slice
  39035. * @param start defines the start of the data (optional)
  39036. * @param end defines the end of the data (optional)
  39037. * @returns the new sliced array
  39038. */
  39039. static Slice<T>(data: T, start?: number, end?: number): T;
  39040. /**
  39041. * Polyfill for setImmediate
  39042. * @param action defines the action to execute after the current execution block
  39043. */
  39044. static SetImmediate(action: () => void): void;
  39045. /**
  39046. * Function indicating if a number is an exponent of 2
  39047. * @param value defines the value to test
  39048. * @returns true if the value is an exponent of 2
  39049. */
  39050. static IsExponentOfTwo(value: number): boolean;
  39051. private static _tmpFloatArray;
  39052. /**
  39053. * Returns the nearest 32-bit single precision float representation of a Number
  39054. * @param value A Number. If the parameter is of a different type, it will get converted
  39055. * to a number or to NaN if it cannot be converted
  39056. * @returns number
  39057. */
  39058. static FloatRound(value: number): number;
  39059. /**
  39060. * Find the next highest power of two.
  39061. * @param x Number to start search from.
  39062. * @return Next highest power of two.
  39063. */
  39064. static CeilingPOT(x: number): number;
  39065. /**
  39066. * Find the next lowest power of two.
  39067. * @param x Number to start search from.
  39068. * @return Next lowest power of two.
  39069. */
  39070. static FloorPOT(x: number): number;
  39071. /**
  39072. * Find the nearest power of two.
  39073. * @param x Number to start search from.
  39074. * @return Next nearest power of two.
  39075. */
  39076. static NearestPOT(x: number): number;
  39077. /**
  39078. * Get the closest exponent of two
  39079. * @param value defines the value to approximate
  39080. * @param max defines the maximum value to return
  39081. * @param mode defines how to define the closest value
  39082. * @returns closest exponent of two of the given value
  39083. */
  39084. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39085. /**
  39086. * Extracts the filename from a path
  39087. * @param path defines the path to use
  39088. * @returns the filename
  39089. */
  39090. static GetFilename(path: string): string;
  39091. /**
  39092. * Extracts the "folder" part of a path (everything before the filename).
  39093. * @param uri The URI to extract the info from
  39094. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39095. * @returns The "folder" part of the path
  39096. */
  39097. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39098. /**
  39099. * Extracts text content from a DOM element hierarchy
  39100. * @param element defines the root element
  39101. * @returns a string
  39102. */
  39103. static GetDOMTextContent(element: HTMLElement): string;
  39104. /**
  39105. * Convert an angle in radians to degrees
  39106. * @param angle defines the angle to convert
  39107. * @returns the angle in degrees
  39108. */
  39109. static ToDegrees(angle: number): number;
  39110. /**
  39111. * Convert an angle in degrees to radians
  39112. * @param angle defines the angle to convert
  39113. * @returns the angle in radians
  39114. */
  39115. static ToRadians(angle: number): number;
  39116. /**
  39117. * Encode a buffer to a base64 string
  39118. * @param buffer defines the buffer to encode
  39119. * @returns the encoded string
  39120. */
  39121. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39122. /**
  39123. * Extracts minimum and maximum values from a list of indexed positions
  39124. * @param positions defines the positions to use
  39125. * @param indices defines the indices to the positions
  39126. * @param indexStart defines the start index
  39127. * @param indexCount defines the end index
  39128. * @param bias defines bias value to add to the result
  39129. * @return minimum and maximum values
  39130. */
  39131. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39132. minimum: Vector3;
  39133. maximum: Vector3;
  39134. };
  39135. /**
  39136. * Extracts minimum and maximum values from a list of positions
  39137. * @param positions defines the positions to use
  39138. * @param start defines the start index in the positions array
  39139. * @param count defines the number of positions to handle
  39140. * @param bias defines bias value to add to the result
  39141. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39142. * @return minimum and maximum values
  39143. */
  39144. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39145. minimum: Vector3;
  39146. maximum: Vector3;
  39147. };
  39148. /**
  39149. * Returns an array if obj is not an array
  39150. * @param obj defines the object to evaluate as an array
  39151. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39152. * @returns either obj directly if obj is an array or a new array containing obj
  39153. */
  39154. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39155. /**
  39156. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39157. * @param size the number of element to construct and put in the array
  39158. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39159. * @returns a new array filled with new objects
  39160. */
  39161. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39162. /**
  39163. * Gets the pointer prefix to use
  39164. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39165. */
  39166. static GetPointerPrefix(): string;
  39167. /**
  39168. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39169. * @param func - the function to be called
  39170. * @param requester - the object that will request the next frame. Falls back to window.
  39171. * @returns frame number
  39172. */
  39173. static QueueNewFrame(func: () => void, requester?: any): number;
  39174. /**
  39175. * Ask the browser to promote the current element to fullscreen rendering mode
  39176. * @param element defines the DOM element to promote
  39177. */
  39178. static RequestFullscreen(element: HTMLElement): void;
  39179. /**
  39180. * Asks the browser to exit fullscreen mode
  39181. */
  39182. static ExitFullscreen(): void;
  39183. /**
  39184. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39185. * @param url define the url we are trying
  39186. * @param element define the dom element where to configure the cors policy
  39187. */
  39188. static SetCorsBehavior(url: string | string[], element: {
  39189. crossOrigin: string | null;
  39190. }): void;
  39191. /**
  39192. * Removes unwanted characters from an url
  39193. * @param url defines the url to clean
  39194. * @returns the cleaned url
  39195. */
  39196. static CleanUrl(url: string): string;
  39197. /**
  39198. * Gets or sets a function used to pre-process url before using them to load assets
  39199. */
  39200. static PreprocessUrl: (url: string) => string;
  39201. /**
  39202. * Loads an image as an HTMLImageElement.
  39203. * @param input url string, ArrayBuffer, or Blob to load
  39204. * @param onLoad callback called when the image successfully loads
  39205. * @param onError callback called when the image fails to load
  39206. * @param offlineProvider offline provider for caching
  39207. * @returns the HTMLImageElement of the loaded image
  39208. */
  39209. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39210. /**
  39211. * Loads a file
  39212. * @param url url string, ArrayBuffer, or Blob to load
  39213. * @param onSuccess callback called when the file successfully loads
  39214. * @param onProgress callback called while file is loading (if the server supports this mode)
  39215. * @param offlineProvider defines the offline provider for caching
  39216. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39217. * @param onError callback called when the file fails to load
  39218. * @returns a file request object
  39219. */
  39220. 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;
  39221. /**
  39222. * Load a script (identified by an url). When the url returns, the
  39223. * content of this file is added into a new script element, attached to the DOM (body element)
  39224. * @param scriptUrl defines the url of the script to laod
  39225. * @param onSuccess defines the callback called when the script is loaded
  39226. * @param onError defines the callback to call if an error occurs
  39227. */
  39228. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39229. /**
  39230. * Loads a file from a blob
  39231. * @param fileToLoad defines the blob to use
  39232. * @param callback defines the callback to call when data is loaded
  39233. * @param progressCallback defines the callback to call during loading process
  39234. * @returns a file request object
  39235. */
  39236. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39237. /**
  39238. * Loads a file
  39239. * @param fileToLoad defines the file to load
  39240. * @param callback defines the callback to call when data is loaded
  39241. * @param progressCallBack defines the callback to call during loading process
  39242. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39243. * @returns a file request object
  39244. */
  39245. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39246. /**
  39247. * Creates a data url from a given string content
  39248. * @param content defines the content to convert
  39249. * @returns the new data url link
  39250. */
  39251. static FileAsURL(content: string): string;
  39252. /**
  39253. * Format the given number to a specific decimal format
  39254. * @param value defines the number to format
  39255. * @param decimals defines the number of decimals to use
  39256. * @returns the formatted string
  39257. */
  39258. static Format(value: number, decimals?: number): string;
  39259. /**
  39260. * Checks if a given vector is inside a specific range
  39261. * @param v defines the vector to test
  39262. * @param min defines the minimum range
  39263. * @param max defines the maximum range
  39264. */
  39265. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39266. /**
  39267. * Tries to copy an object by duplicating every property
  39268. * @param source defines the source object
  39269. * @param destination defines the target object
  39270. * @param doNotCopyList defines a list of properties to avoid
  39271. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39272. */
  39273. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39274. /**
  39275. * Gets a boolean indicating if the given object has no own property
  39276. * @param obj defines the object to test
  39277. * @returns true if object has no own property
  39278. */
  39279. static IsEmpty(obj: any): boolean;
  39280. /**
  39281. * Function used to register events at window level
  39282. * @param events defines the events to register
  39283. */
  39284. static RegisterTopRootEvents(events: {
  39285. name: string;
  39286. handler: Nullable<(e: FocusEvent) => any>;
  39287. }[]): void;
  39288. /**
  39289. * Function used to unregister events from window level
  39290. * @param events defines the events to unregister
  39291. */
  39292. static UnregisterTopRootEvents(events: {
  39293. name: string;
  39294. handler: Nullable<(e: FocusEvent) => any>;
  39295. }[]): void;
  39296. /**
  39297. * Dumps the current bound framebuffer
  39298. * @param width defines the rendering width
  39299. * @param height defines the rendering height
  39300. * @param engine defines the hosting engine
  39301. * @param successCallback defines the callback triggered once the data are available
  39302. * @param mimeType defines the mime type of the result
  39303. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39304. */
  39305. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39306. /**
  39307. * Converts the canvas data to blob.
  39308. * This acts as a polyfill for browsers not supporting the to blob function.
  39309. * @param canvas Defines the canvas to extract the data from
  39310. * @param successCallback Defines the callback triggered once the data are available
  39311. * @param mimeType Defines the mime type of the result
  39312. */
  39313. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39314. /**
  39315. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39316. * @param successCallback defines the callback triggered once the data are available
  39317. * @param mimeType defines the mime type of the result
  39318. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39319. */
  39320. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39321. /**
  39322. * Downloads a blob in the browser
  39323. * @param blob defines the blob to download
  39324. * @param fileName defines the name of the downloaded file
  39325. */
  39326. static Download(blob: Blob, fileName: string): void;
  39327. /**
  39328. * Captures a screenshot of the current rendering
  39329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39330. * @param engine defines the rendering engine
  39331. * @param camera defines the source camera
  39332. * @param size This parameter can be set to a single number or to an object with the
  39333. * following (optional) properties: precision, width, height. If a single number is passed,
  39334. * it will be used for both width and height. If an object is passed, the screenshot size
  39335. * will be derived from the parameters. The precision property is a multiplier allowing
  39336. * rendering at a higher or lower resolution
  39337. * @param successCallback defines the callback receives a single parameter which contains the
  39338. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39339. * src parameter of an <img> to display it
  39340. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39341. * Check your browser for supported MIME types
  39342. */
  39343. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39344. /**
  39345. * Generates an image screenshot from the specified camera.
  39346. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39347. * @param engine The engine to use for rendering
  39348. * @param camera The camera to use for rendering
  39349. * @param size This parameter can be set to a single number or to an object with the
  39350. * following (optional) properties: precision, width, height. If a single number is passed,
  39351. * it will be used for both width and height. If an object is passed, the screenshot size
  39352. * will be derived from the parameters. The precision property is a multiplier allowing
  39353. * rendering at a higher or lower resolution
  39354. * @param successCallback The callback receives a single parameter which contains the
  39355. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39356. * src parameter of an <img> to display it
  39357. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39358. * Check your browser for supported MIME types
  39359. * @param samples Texture samples (default: 1)
  39360. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39361. * @param fileName A name for for the downloaded file.
  39362. */
  39363. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39364. /**
  39365. * Validates if xhr data is correct
  39366. * @param xhr defines the request to validate
  39367. * @param dataType defines the expected data type
  39368. * @returns true if data is correct
  39369. */
  39370. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39371. /**
  39372. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39373. * Be aware Math.random() could cause collisions, but:
  39374. * "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"
  39375. * @returns a pseudo random id
  39376. */
  39377. static RandomId(): string;
  39378. /**
  39379. * Test if the given uri is a base64 string
  39380. * @param uri The uri to test
  39381. * @return True if the uri is a base64 string or false otherwise
  39382. */
  39383. static IsBase64(uri: string): boolean;
  39384. /**
  39385. * Decode the given base64 uri.
  39386. * @param uri The uri to decode
  39387. * @return The decoded base64 data.
  39388. */
  39389. static DecodeBase64(uri: string): ArrayBuffer;
  39390. /**
  39391. * No log
  39392. */
  39393. static readonly NoneLogLevel: number;
  39394. /**
  39395. * Only message logs
  39396. */
  39397. static readonly MessageLogLevel: number;
  39398. /**
  39399. * Only warning logs
  39400. */
  39401. static readonly WarningLogLevel: number;
  39402. /**
  39403. * Only error logs
  39404. */
  39405. static readonly ErrorLogLevel: number;
  39406. /**
  39407. * All logs
  39408. */
  39409. static readonly AllLogLevel: number;
  39410. private static _LogCache;
  39411. /**
  39412. * Gets a value indicating the number of loading errors
  39413. * @ignorenaming
  39414. */
  39415. static errorsCount: number;
  39416. /**
  39417. * Callback called when a new log is added
  39418. */
  39419. static OnNewCacheEntry: (entry: string) => void;
  39420. private static _AddLogEntry;
  39421. private static _FormatMessage;
  39422. private static _LogDisabled;
  39423. private static _LogEnabled;
  39424. private static _WarnDisabled;
  39425. private static _WarnEnabled;
  39426. private static _ErrorDisabled;
  39427. private static _ErrorEnabled;
  39428. /**
  39429. * Log a message to the console
  39430. */
  39431. static Log: (message: string) => void;
  39432. /**
  39433. * Write a warning message to the console
  39434. */
  39435. static Warn: (message: string) => void;
  39436. /**
  39437. * Write an error message to the console
  39438. */
  39439. static Error: (message: string) => void;
  39440. /**
  39441. * Gets current log cache (list of logs)
  39442. */
  39443. static readonly LogCache: string;
  39444. /**
  39445. * Clears the log cache
  39446. */
  39447. static ClearLogCache(): void;
  39448. /**
  39449. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39450. */
  39451. static LogLevels: number;
  39452. /**
  39453. * Checks if the loaded document was accessed via `file:`-Protocol.
  39454. * @returns boolean
  39455. */
  39456. static IsFileURL(): boolean;
  39457. /**
  39458. * Checks if the window object exists
  39459. * @returns true if the window object exists
  39460. */
  39461. static IsWindowObjectExist(): boolean;
  39462. /**
  39463. * No performance log
  39464. */
  39465. static readonly PerformanceNoneLogLevel: number;
  39466. /**
  39467. * Use user marks to log performance
  39468. */
  39469. static readonly PerformanceUserMarkLogLevel: number;
  39470. /**
  39471. * Log performance to the console
  39472. */
  39473. static readonly PerformanceConsoleLogLevel: number;
  39474. private static _performance;
  39475. /**
  39476. * Sets the current performance log level
  39477. */
  39478. static PerformanceLogLevel: number;
  39479. private static _StartPerformanceCounterDisabled;
  39480. private static _EndPerformanceCounterDisabled;
  39481. private static _StartUserMark;
  39482. private static _EndUserMark;
  39483. private static _StartPerformanceConsole;
  39484. private static _EndPerformanceConsole;
  39485. /**
  39486. * Starts a performance counter
  39487. */
  39488. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39489. /**
  39490. * Ends a specific performance coutner
  39491. */
  39492. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39493. /**
  39494. * Gets either window.performance.now() if supported or Date.now() else
  39495. */
  39496. static readonly Now: number;
  39497. /**
  39498. * This method will return the name of the class used to create the instance of the given object.
  39499. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39500. * @param object the object to get the class name from
  39501. * @param isType defines if the object is actually a type
  39502. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39503. */
  39504. static GetClassName(object: any, isType?: boolean): string;
  39505. /**
  39506. * Gets the first element of an array satisfying a given predicate
  39507. * @param array defines the array to browse
  39508. * @param predicate defines the predicate to use
  39509. * @returns null if not found or the element
  39510. */
  39511. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39512. /**
  39513. * This method will return the name of the full name of the class, including its owning module (if any).
  39514. * 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).
  39515. * @param object the object to get the class name from
  39516. * @param isType defines if the object is actually a type
  39517. * @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.
  39518. * @ignorenaming
  39519. */
  39520. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39521. /**
  39522. * Returns a promise that resolves after the given amount of time.
  39523. * @param delay Number of milliseconds to delay
  39524. * @returns Promise that resolves after the given amount of time
  39525. */
  39526. static DelayAsync(delay: number): Promise<void>;
  39527. /**
  39528. * Gets the current gradient from an array of IValueGradient
  39529. * @param ratio defines the current ratio to get
  39530. * @param gradients defines the array of IValueGradient
  39531. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39532. */
  39533. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39534. }
  39535. /**
  39536. * This class is used to track a performance counter which is number based.
  39537. * The user has access to many properties which give statistics of different nature.
  39538. *
  39539. * The implementer can track two kinds of Performance Counter: time and count.
  39540. * 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.
  39541. * 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.
  39542. */
  39543. class PerfCounter {
  39544. /**
  39545. * Gets or sets a global boolean to turn on and off all the counters
  39546. */
  39547. static Enabled: boolean;
  39548. /**
  39549. * Returns the smallest value ever
  39550. */
  39551. readonly min: number;
  39552. /**
  39553. * Returns the biggest value ever
  39554. */
  39555. readonly max: number;
  39556. /**
  39557. * Returns the average value since the performance counter is running
  39558. */
  39559. readonly average: number;
  39560. /**
  39561. * Returns the average value of the last second the counter was monitored
  39562. */
  39563. readonly lastSecAverage: number;
  39564. /**
  39565. * Returns the current value
  39566. */
  39567. readonly current: number;
  39568. /**
  39569. * Gets the accumulated total
  39570. */
  39571. readonly total: number;
  39572. /**
  39573. * Gets the total value count
  39574. */
  39575. readonly count: number;
  39576. /**
  39577. * Creates a new counter
  39578. */
  39579. constructor();
  39580. /**
  39581. * Call this method to start monitoring a new frame.
  39582. * 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.
  39583. */
  39584. fetchNewFrame(): void;
  39585. /**
  39586. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39587. * @param newCount the count value to add to the monitored count
  39588. * @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.
  39589. */
  39590. addCount(newCount: number, fetchResult: boolean): void;
  39591. /**
  39592. * Start monitoring this performance counter
  39593. */
  39594. beginMonitoring(): void;
  39595. /**
  39596. * Compute the time lapsed since the previous beginMonitoring() call.
  39597. * @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
  39598. */
  39599. endMonitoring(newFrame?: boolean): void;
  39600. private _fetchResult;
  39601. private _startMonitoringTime;
  39602. private _min;
  39603. private _max;
  39604. private _average;
  39605. private _current;
  39606. private _totalValueCount;
  39607. private _totalAccumulated;
  39608. private _lastSecAverage;
  39609. private _lastSecAccumulated;
  39610. private _lastSecTime;
  39611. private _lastSecValueCount;
  39612. }
  39613. /**
  39614. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39615. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39616. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39617. * @param name The name of the class, case should be preserved
  39618. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39619. */
  39620. function className(name: string, module?: string): (target: Object) => void;
  39621. /**
  39622. * An implementation of a loop for asynchronous functions.
  39623. */
  39624. class AsyncLoop {
  39625. /**
  39626. * Defines the number of iterations for the loop
  39627. */
  39628. iterations: number;
  39629. /**
  39630. * Defines the current index of the loop.
  39631. */
  39632. index: number;
  39633. private _done;
  39634. private _fn;
  39635. private _successCallback;
  39636. /**
  39637. * Constructor.
  39638. * @param iterations the number of iterations.
  39639. * @param func the function to run each iteration
  39640. * @param successCallback the callback that will be called upon succesful execution
  39641. * @param offset starting offset.
  39642. */
  39643. constructor(
  39644. /**
  39645. * Defines the number of iterations for the loop
  39646. */
  39647. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39648. /**
  39649. * Execute the next iteration. Must be called after the last iteration was finished.
  39650. */
  39651. executeNext(): void;
  39652. /**
  39653. * Break the loop and run the success callback.
  39654. */
  39655. breakLoop(): void;
  39656. /**
  39657. * Create and run an async loop.
  39658. * @param iterations the number of iterations.
  39659. * @param fn the function to run each iteration
  39660. * @param successCallback the callback that will be called upon succesful execution
  39661. * @param offset starting offset.
  39662. * @returns the created async loop object
  39663. */
  39664. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39665. /**
  39666. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39667. * @param iterations total number of iterations
  39668. * @param syncedIterations number of synchronous iterations in each async iteration.
  39669. * @param fn the function to call each iteration.
  39670. * @param callback a success call back that will be called when iterating stops.
  39671. * @param breakFunction a break condition (optional)
  39672. * @param timeout timeout settings for the setTimeout function. default - 0.
  39673. * @returns the created async loop object
  39674. */
  39675. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39676. }
  39677. }
  39678. interface HTMLCanvasElement {
  39679. /** Track wether a record is in progress */
  39680. isRecording: boolean;
  39681. /** Capture Stream method defined by some browsers */
  39682. captureStream(fps?: number): MediaStream;
  39683. }
  39684. interface MediaRecorder {
  39685. /** Starts recording */
  39686. start(timeSlice: number): void;
  39687. /** Stops recording */
  39688. stop(): void;
  39689. /** Event raised when an error arised. */
  39690. onerror: (event: ErrorEvent) => void;
  39691. /** Event raised when the recording stops. */
  39692. onstop: (event: Event) => void;
  39693. /** Event raised when a new chunk of data is available and should be tracked. */
  39694. ondataavailable: (event: Event) => void;
  39695. }
  39696. interface MediaRecorderOptions {
  39697. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39698. mimeType?: string;
  39699. /** The chosen bitrate for the audio component of the media. */
  39700. audioBitsPerSecond?: number;
  39701. /** The chosen bitrate for the video component of the media. */
  39702. videoBitsPerSecond?: number;
  39703. /** 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. */
  39704. bitsPerSecond?: number;
  39705. }
  39706. interface MediaRecorderConstructor {
  39707. /**
  39708. * A reference to the prototype.
  39709. */
  39710. readonly prototype: MediaRecorder;
  39711. /**
  39712. * Creates a new MediaRecorder.
  39713. * @param stream Defines the stream to record.
  39714. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39715. */
  39716. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39717. }
  39718. /**
  39719. * MediaRecoreder object available in some browsers.
  39720. */
  39721. declare var MediaRecorder: MediaRecorderConstructor;
  39722. declare module BABYLON {
  39723. /**
  39724. * This represents the different options avilable for the video capture.
  39725. */
  39726. interface VideoRecorderOptions {
  39727. /** Defines the mime type of the video */
  39728. mimeType: string;
  39729. /** Defines the video the video should be recorded at */
  39730. fps: number;
  39731. /** Defines the chunk size for the recording data */
  39732. recordChunckSize: number;
  39733. }
  39734. /**
  39735. * This can helps recording videos from BabylonJS.
  39736. * This is based on the available WebRTC functionalities of the browser.
  39737. *
  39738. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39739. */
  39740. class VideoRecorder {
  39741. private static readonly _defaultOptions;
  39742. /**
  39743. * Returns wehther or not the VideoRecorder is available in your browser.
  39744. * @param engine Defines the Babylon Engine to check the support for
  39745. * @returns true if supported otherwise false
  39746. */
  39747. static IsSupported(engine: Engine): boolean;
  39748. private readonly _options;
  39749. private _canvas;
  39750. private _mediaRecorder;
  39751. private _recordedChunks;
  39752. private _fileName;
  39753. private _resolve;
  39754. private _reject;
  39755. /**
  39756. * True wether a recording is already in progress.
  39757. */
  39758. readonly isRecording: boolean;
  39759. /**
  39760. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39761. * a video file.
  39762. * @param engine Defines the BabylonJS Engine you wish to record
  39763. * @param options Defines options that can be used to customized the capture
  39764. */
  39765. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39766. /**
  39767. * Stops the current recording before the default capture timeout passed in the startRecording
  39768. * functions.
  39769. */
  39770. stopRecording(): void;
  39771. /**
  39772. * Starts recording the canvas for a max duration specified in parameters.
  39773. * @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.
  39774. * @param maxDuration Defines the maximum recording time in seconds.
  39775. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39776. * @return a promise callback at the end of the recording with the video data in Blob.
  39777. */
  39778. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39779. /**
  39780. * Releases internal resources used during the recording.
  39781. */
  39782. dispose(): void;
  39783. private _handleDataAvailable;
  39784. private _handleError;
  39785. private _handleStop;
  39786. }
  39787. }
  39788. declare module BABYLON {
  39789. /**
  39790. * Defines the potential axis of a Joystick
  39791. */
  39792. enum JoystickAxis {
  39793. /** X axis */
  39794. X = 0,
  39795. /** Y axis */
  39796. Y = 1,
  39797. /** Z axis */
  39798. Z = 2
  39799. }
  39800. /**
  39801. * Class used to define virtual joystick (used in touch mode)
  39802. */
  39803. class VirtualJoystick {
  39804. /**
  39805. * Gets or sets a boolean indicating that left and right values must be inverted
  39806. */
  39807. reverseLeftRight: boolean;
  39808. /**
  39809. * Gets or sets a boolean indicating that up and down values must be inverted
  39810. */
  39811. reverseUpDown: boolean;
  39812. /**
  39813. * Gets the offset value for the position (ie. the change of the position value)
  39814. */
  39815. deltaPosition: Vector3;
  39816. /**
  39817. * Gets a boolean indicating if the virtual joystick was pressed
  39818. */
  39819. pressed: boolean;
  39820. private static _globalJoystickIndex;
  39821. private static vjCanvas;
  39822. private static vjCanvasContext;
  39823. private static vjCanvasWidth;
  39824. private static vjCanvasHeight;
  39825. private static halfWidth;
  39826. private _action;
  39827. private _axisTargetedByLeftAndRight;
  39828. private _axisTargetedByUpAndDown;
  39829. private _joystickSensibility;
  39830. private _inversedSensibility;
  39831. private _joystickPointerID;
  39832. private _joystickColor;
  39833. private _joystickPointerPos;
  39834. private _joystickPreviousPointerPos;
  39835. private _joystickPointerStartPos;
  39836. private _deltaJoystickVector;
  39837. private _leftJoystick;
  39838. private _touches;
  39839. private _onPointerDownHandlerRef;
  39840. private _onPointerMoveHandlerRef;
  39841. private _onPointerUpHandlerRef;
  39842. private _onResize;
  39843. /**
  39844. * Creates a new virtual joystick
  39845. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39846. */
  39847. constructor(leftJoystick?: boolean);
  39848. /**
  39849. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39850. * @param newJoystickSensibility defines the new sensibility
  39851. */
  39852. setJoystickSensibility(newJoystickSensibility: number): void;
  39853. private _onPointerDown;
  39854. private _onPointerMove;
  39855. private _onPointerUp;
  39856. /**
  39857. * Change the color of the virtual joystick
  39858. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39859. */
  39860. setJoystickColor(newColor: string): void;
  39861. /**
  39862. * Defines a callback to call when the joystick is touched
  39863. * @param action defines the callback
  39864. */
  39865. setActionOnTouch(action: () => any): void;
  39866. /**
  39867. * Defines which axis you'd like to control for left & right
  39868. * @param axis defines the axis to use
  39869. */
  39870. setAxisForLeftRight(axis: JoystickAxis): void;
  39871. /**
  39872. * Defines which axis you'd like to control for up & down
  39873. * @param axis defines the axis to use
  39874. */
  39875. setAxisForUpDown(axis: JoystickAxis): void;
  39876. private _drawVirtualJoystick;
  39877. /**
  39878. * Release internal HTML canvas
  39879. */
  39880. releaseCanvas(): void;
  39881. }
  39882. }
  39883. declare module BABYLON {
  39884. /**
  39885. * Helper class to push actions to a pool of workers.
  39886. */
  39887. class WorkerPool implements IDisposable {
  39888. private _workerInfos;
  39889. private _pendingActions;
  39890. /**
  39891. * Constructor
  39892. * @param workers Array of workers to use for actions
  39893. */
  39894. constructor(workers: Array<Worker>);
  39895. /**
  39896. * Terminates all workers and clears any pending actions.
  39897. */
  39898. dispose(): void;
  39899. /**
  39900. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39901. * pended until a worker has completed its action.
  39902. * @param action The action to perform. Call onComplete when the action is complete.
  39903. */
  39904. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39905. private _execute;
  39906. }
  39907. }
  39908. declare module BABYLON {
  39909. /**
  39910. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39911. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39912. */
  39913. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39914. /**
  39915. * Gets the name of the behavior.
  39916. */
  39917. readonly name: string;
  39918. private _zoomStopsAnimation;
  39919. private _idleRotationSpeed;
  39920. private _idleRotationWaitTime;
  39921. private _idleRotationSpinupTime;
  39922. /**
  39923. * Sets the flag that indicates if user zooming should stop animation.
  39924. */
  39925. /**
  39926. * Gets the flag that indicates if user zooming should stop animation.
  39927. */
  39928. zoomStopsAnimation: boolean;
  39929. /**
  39930. * Sets the default speed at which the camera rotates around the model.
  39931. */
  39932. /**
  39933. * Gets the default speed at which the camera rotates around the model.
  39934. */
  39935. idleRotationSpeed: number;
  39936. /**
  39937. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39938. */
  39939. /**
  39940. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39941. */
  39942. idleRotationWaitTime: number;
  39943. /**
  39944. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39945. */
  39946. /**
  39947. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39948. */
  39949. idleRotationSpinupTime: number;
  39950. /**
  39951. * Gets a value indicating if the camera is currently rotating because of this behavior
  39952. */
  39953. readonly rotationInProgress: boolean;
  39954. private _onPrePointerObservableObserver;
  39955. private _onAfterCheckInputsObserver;
  39956. private _attachedCamera;
  39957. private _isPointerDown;
  39958. private _lastFrameTime;
  39959. private _lastInteractionTime;
  39960. private _cameraRotationSpeed;
  39961. /**
  39962. * Initializes the behavior.
  39963. */
  39964. init(): void;
  39965. /**
  39966. * Attaches the behavior to its arc rotate camera.
  39967. * @param camera Defines the camera to attach the behavior to
  39968. */
  39969. attach(camera: ArcRotateCamera): void;
  39970. /**
  39971. * Detaches the behavior from its current arc rotate camera.
  39972. */
  39973. detach(): void;
  39974. /**
  39975. * Returns true if user is scrolling.
  39976. * @return true if user is scrolling.
  39977. */
  39978. private _userIsZooming;
  39979. private _lastFrameRadius;
  39980. private _shouldAnimationStopForInteraction;
  39981. /**
  39982. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39983. */
  39984. private _applyUserInteraction;
  39985. private _userIsMoving;
  39986. }
  39987. }
  39988. declare module BABYLON {
  39989. /**
  39990. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39991. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39992. */
  39993. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39994. /**
  39995. * Gets the name of the behavior.
  39996. */
  39997. readonly name: string;
  39998. /**
  39999. * The easing function used by animations
  40000. */
  40001. static EasingFunction: BackEase;
  40002. /**
  40003. * The easing mode used by animations
  40004. */
  40005. static EasingMode: number;
  40006. /**
  40007. * The duration of the animation, in milliseconds
  40008. */
  40009. transitionDuration: number;
  40010. /**
  40011. * Length of the distance animated by the transition when lower radius is reached
  40012. */
  40013. lowerRadiusTransitionRange: number;
  40014. /**
  40015. * Length of the distance animated by the transition when upper radius is reached
  40016. */
  40017. upperRadiusTransitionRange: number;
  40018. private _autoTransitionRange;
  40019. /**
  40020. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40021. */
  40022. /**
  40023. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40024. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40025. */
  40026. autoTransitionRange: boolean;
  40027. private _attachedCamera;
  40028. private _onAfterCheckInputsObserver;
  40029. private _onMeshTargetChangedObserver;
  40030. /**
  40031. * Initializes the behavior.
  40032. */
  40033. init(): void;
  40034. /**
  40035. * Attaches the behavior to its arc rotate camera.
  40036. * @param camera Defines the camera to attach the behavior to
  40037. */
  40038. attach(camera: ArcRotateCamera): void;
  40039. /**
  40040. * Detaches the behavior from its current arc rotate camera.
  40041. */
  40042. detach(): void;
  40043. private _radiusIsAnimating;
  40044. private _radiusBounceTransition;
  40045. private _animatables;
  40046. private _cachedWheelPrecision;
  40047. /**
  40048. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40049. * @param radiusLimit The limit to check against.
  40050. * @return Bool to indicate if at limit.
  40051. */
  40052. private _isRadiusAtLimit;
  40053. /**
  40054. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40055. * @param radiusDelta The delta by which to animate to. Can be negative.
  40056. */
  40057. private _applyBoundRadiusAnimation;
  40058. /**
  40059. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40060. */
  40061. protected _clearAnimationLocks(): void;
  40062. /**
  40063. * Stops and removes all animations that have been applied to the camera
  40064. */
  40065. stopAllAnimations(): void;
  40066. }
  40067. }
  40068. declare module BABYLON {
  40069. /**
  40070. * 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.
  40071. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40072. */
  40073. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40074. /**
  40075. * Gets the name of the behavior.
  40076. */
  40077. readonly name: string;
  40078. private _mode;
  40079. private _radiusScale;
  40080. private _positionScale;
  40081. private _defaultElevation;
  40082. private _elevationReturnTime;
  40083. private _elevationReturnWaitTime;
  40084. private _zoomStopsAnimation;
  40085. private _framingTime;
  40086. /**
  40087. * The easing function used by animations
  40088. */
  40089. static EasingFunction: ExponentialEase;
  40090. /**
  40091. * The easing mode used by animations
  40092. */
  40093. static EasingMode: number;
  40094. /**
  40095. * Sets the current mode used by the behavior
  40096. */
  40097. /**
  40098. * Gets current mode used by the behavior.
  40099. */
  40100. mode: number;
  40101. /**
  40102. * Sets the scale applied to the radius (1 by default)
  40103. */
  40104. /**
  40105. * Gets the scale applied to the radius
  40106. */
  40107. radiusScale: number;
  40108. /**
  40109. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40110. */
  40111. /**
  40112. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40113. */
  40114. positionScale: number;
  40115. /**
  40116. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40117. * behaviour is triggered, in radians.
  40118. */
  40119. /**
  40120. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40121. * behaviour is triggered, in radians.
  40122. */
  40123. defaultElevation: number;
  40124. /**
  40125. * Sets the time (in milliseconds) taken to return to the default beta position.
  40126. * Negative value indicates camera should not return to default.
  40127. */
  40128. /**
  40129. * Gets the time (in milliseconds) taken to return to the default beta position.
  40130. * Negative value indicates camera should not return to default.
  40131. */
  40132. elevationReturnTime: number;
  40133. /**
  40134. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40135. */
  40136. /**
  40137. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40138. */
  40139. elevationReturnWaitTime: number;
  40140. /**
  40141. * Sets the flag that indicates if user zooming should stop animation.
  40142. */
  40143. /**
  40144. * Gets the flag that indicates if user zooming should stop animation.
  40145. */
  40146. zoomStopsAnimation: boolean;
  40147. /**
  40148. * Sets the transition time when framing the mesh, in milliseconds
  40149. */
  40150. /**
  40151. * Gets the transition time when framing the mesh, in milliseconds
  40152. */
  40153. framingTime: number;
  40154. /**
  40155. * Define if the behavior should automatically change the configured
  40156. * camera limits and sensibilities.
  40157. */
  40158. autoCorrectCameraLimitsAndSensibility: boolean;
  40159. private _onPrePointerObservableObserver;
  40160. private _onAfterCheckInputsObserver;
  40161. private _onMeshTargetChangedObserver;
  40162. private _attachedCamera;
  40163. private _isPointerDown;
  40164. private _lastInteractionTime;
  40165. /**
  40166. * Initializes the behavior.
  40167. */
  40168. init(): void;
  40169. /**
  40170. * Attaches the behavior to its arc rotate camera.
  40171. * @param camera Defines the camera to attach the behavior to
  40172. */
  40173. attach(camera: ArcRotateCamera): void;
  40174. /**
  40175. * Detaches the behavior from its current arc rotate camera.
  40176. */
  40177. detach(): void;
  40178. private _animatables;
  40179. private _betaIsAnimating;
  40180. private _betaTransition;
  40181. private _radiusTransition;
  40182. private _vectorTransition;
  40183. /**
  40184. * Targets the given mesh and updates zoom level accordingly.
  40185. * @param mesh The mesh to target.
  40186. * @param radius Optional. If a cached radius position already exists, overrides default.
  40187. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40188. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40189. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40190. */
  40191. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40192. /**
  40193. * Targets the given mesh with its children and updates zoom level accordingly.
  40194. * @param mesh The mesh to target.
  40195. * @param radius Optional. If a cached radius position already exists, overrides default.
  40196. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40197. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40198. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40199. */
  40200. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40201. /**
  40202. * Targets the given meshes with their children and updates zoom level accordingly.
  40203. * @param meshes The mesh to target.
  40204. * @param radius Optional. If a cached radius position already exists, overrides default.
  40205. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40206. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40207. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40208. */
  40209. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40210. /**
  40211. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40212. * @param minimumWorld Determines the smaller position of the bounding box extend
  40213. * @param maximumWorld Determines the bigger position of the bounding box extend
  40214. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40215. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40216. */
  40217. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40218. /**
  40219. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40220. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40221. * frustum width.
  40222. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40223. * to fully enclose the mesh in the viewing frustum.
  40224. */
  40225. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40226. /**
  40227. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40228. * is automatically returned to its default position (expected to be above ground plane).
  40229. */
  40230. private _maintainCameraAboveGround;
  40231. /**
  40232. * Returns the frustum slope based on the canvas ratio and camera FOV
  40233. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40234. */
  40235. private _getFrustumSlope;
  40236. /**
  40237. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40238. */
  40239. private _clearAnimationLocks;
  40240. /**
  40241. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40242. */
  40243. private _applyUserInteraction;
  40244. /**
  40245. * Stops and removes all animations that have been applied to the camera
  40246. */
  40247. stopAllAnimations(): void;
  40248. /**
  40249. * Gets a value indicating if the user is moving the camera
  40250. */
  40251. readonly isUserIsMoving: boolean;
  40252. /**
  40253. * The camera can move all the way towards the mesh.
  40254. */
  40255. static IgnoreBoundsSizeMode: number;
  40256. /**
  40257. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40258. */
  40259. static FitFrustumSidesMode: number;
  40260. }
  40261. }
  40262. declare module BABYLON {
  40263. /**
  40264. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40265. */
  40266. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40267. private ui;
  40268. /**
  40269. * The name of the behavior
  40270. */
  40271. name: string;
  40272. /**
  40273. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40274. */
  40275. distanceAwayFromFace: number;
  40276. /**
  40277. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40278. */
  40279. distanceAwayFromBottomOfFace: number;
  40280. private _faceVectors;
  40281. private _target;
  40282. private _scene;
  40283. private _onRenderObserver;
  40284. private _tmpMatrix;
  40285. private _tmpVector;
  40286. /**
  40287. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40288. * @param ui The transform node that should be attched to the mesh
  40289. */
  40290. constructor(ui: BABYLON.TransformNode);
  40291. /**
  40292. * Initializes the behavior
  40293. */
  40294. init(): void;
  40295. private _closestFace;
  40296. private _zeroVector;
  40297. private _lookAtTmpMatrix;
  40298. private _lookAtToRef;
  40299. /**
  40300. * Attaches the AttachToBoxBehavior to the passed in mesh
  40301. * @param target The mesh that the specified node will be attached to
  40302. */
  40303. attach(target: BABYLON.Mesh): void;
  40304. /**
  40305. * Detaches the behavior from the mesh
  40306. */
  40307. detach(): void;
  40308. }
  40309. }
  40310. declare module BABYLON {
  40311. /**
  40312. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40313. */
  40314. class FadeInOutBehavior implements Behavior<Mesh> {
  40315. /**
  40316. * Time in milliseconds to delay before fading in (Default: 0)
  40317. */
  40318. delay: number;
  40319. /**
  40320. * Time in milliseconds for the mesh to fade in (Default: 300)
  40321. */
  40322. fadeInTime: number;
  40323. private _millisecondsPerFrame;
  40324. private _hovered;
  40325. private _hoverValue;
  40326. private _ownerNode;
  40327. /**
  40328. * Instatiates the FadeInOutBehavior
  40329. */
  40330. constructor();
  40331. /**
  40332. * The name of the behavior
  40333. */
  40334. readonly name: string;
  40335. /**
  40336. * Initializes the behavior
  40337. */
  40338. init(): void;
  40339. /**
  40340. * Attaches the fade behavior on the passed in mesh
  40341. * @param ownerNode The mesh that will be faded in/out once attached
  40342. */
  40343. attach(ownerNode: Mesh): void;
  40344. /**
  40345. * Detaches the behavior from the mesh
  40346. */
  40347. detach(): void;
  40348. /**
  40349. * Triggers the mesh to begin fading in or out
  40350. * @param value if the object should fade in or out (true to fade in)
  40351. */
  40352. fadeIn(value: boolean): void;
  40353. private _update;
  40354. private _setAllVisibility;
  40355. }
  40356. }
  40357. declare module BABYLON {
  40358. /**
  40359. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40360. */
  40361. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40362. private _dragBehaviorA;
  40363. private _dragBehaviorB;
  40364. private _startDistance;
  40365. private _initialScale;
  40366. private _targetScale;
  40367. private _ownerNode;
  40368. private _sceneRenderObserver;
  40369. /**
  40370. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40371. */
  40372. constructor();
  40373. /**
  40374. * The name of the behavior
  40375. */
  40376. readonly name: string;
  40377. /**
  40378. * Initializes the behavior
  40379. */
  40380. init(): void;
  40381. private _getCurrentDistance;
  40382. /**
  40383. * Attaches the scale behavior the passed in mesh
  40384. * @param ownerNode The mesh that will be scaled around once attached
  40385. */
  40386. attach(ownerNode: Mesh): void;
  40387. /**
  40388. * Detaches the behavior from the mesh
  40389. */
  40390. detach(): void;
  40391. }
  40392. }
  40393. declare module BABYLON {
  40394. /**
  40395. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40396. */
  40397. class PointerDragBehavior implements Behavior<Mesh> {
  40398. private static _AnyMouseID;
  40399. private _attachedNode;
  40400. private _dragPlane;
  40401. private _scene;
  40402. private _pointerObserver;
  40403. private _beforeRenderObserver;
  40404. private static _planeScene;
  40405. /**
  40406. * 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)
  40407. */
  40408. maxDragAngle: number;
  40409. /**
  40410. * @hidden
  40411. */
  40412. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40413. /**
  40414. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40415. */
  40416. currentDraggingPointerID: number;
  40417. /**
  40418. * The last position where the pointer hit the drag plane in world space
  40419. */
  40420. lastDragPosition: Vector3;
  40421. /**
  40422. * If the behavior is currently in a dragging state
  40423. */
  40424. dragging: boolean;
  40425. /**
  40426. * 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)
  40427. */
  40428. dragDeltaRatio: number;
  40429. /**
  40430. * If the drag plane orientation should be updated during the dragging (Default: true)
  40431. */
  40432. updateDragPlane: boolean;
  40433. private _debugMode;
  40434. private _moving;
  40435. /**
  40436. * Fires each time the attached mesh is dragged with the pointer
  40437. * * delta between last drag position and current drag position in world space
  40438. * * dragDistance along the drag axis
  40439. * * dragPlaneNormal normal of the current drag plane used during the drag
  40440. * * dragPlanePoint in world space where the drag intersects the drag plane
  40441. */
  40442. onDragObservable: Observable<{
  40443. delta: Vector3;
  40444. dragPlanePoint: Vector3;
  40445. dragPlaneNormal: Vector3;
  40446. dragDistance: number;
  40447. pointerId: number;
  40448. }>;
  40449. /**
  40450. * Fires each time a drag begins (eg. mouse down on mesh)
  40451. */
  40452. onDragStartObservable: Observable<{
  40453. dragPlanePoint: Vector3;
  40454. pointerId: number;
  40455. }>;
  40456. /**
  40457. * Fires each time a drag ends (eg. mouse release after drag)
  40458. */
  40459. onDragEndObservable: Observable<{
  40460. dragPlanePoint: Vector3;
  40461. pointerId: number;
  40462. }>;
  40463. /**
  40464. * If the attached mesh should be moved when dragged
  40465. */
  40466. moveAttached: boolean;
  40467. /**
  40468. * If the drag behavior will react to drag events (Default: true)
  40469. */
  40470. enabled: boolean;
  40471. /**
  40472. * If camera controls should be detached during the drag
  40473. */
  40474. detachCameraControls: boolean;
  40475. /**
  40476. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40477. */
  40478. useObjectOrienationForDragging: boolean;
  40479. private _options;
  40480. /**
  40481. * Creates a pointer drag behavior that can be attached to a mesh
  40482. * @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)
  40483. */
  40484. constructor(options?: {
  40485. dragAxis?: Vector3;
  40486. dragPlaneNormal?: Vector3;
  40487. });
  40488. /**
  40489. * The name of the behavior
  40490. */
  40491. readonly name: string;
  40492. /**
  40493. * Initializes the behavior
  40494. */
  40495. init(): void;
  40496. private _tmpVector;
  40497. private _alternatePickedPoint;
  40498. private _worldDragAxis;
  40499. private _targetPosition;
  40500. private _attachedElement;
  40501. /**
  40502. * Attaches the drag behavior the passed in mesh
  40503. * @param ownerNode The mesh that will be dragged around once attached
  40504. */
  40505. attach(ownerNode: Mesh): void;
  40506. /**
  40507. * Force relase the drag action by code.
  40508. */
  40509. releaseDrag(): void;
  40510. private _startDragRay;
  40511. private _lastPointerRay;
  40512. /**
  40513. * Simulates the start of a pointer drag event on the behavior
  40514. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40515. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40516. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40517. */
  40518. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40519. private _startDrag;
  40520. private _dragDelta;
  40521. private _moveDrag;
  40522. private _pickWithRayOnDragPlane;
  40523. private _pointA;
  40524. private _pointB;
  40525. private _pointC;
  40526. private _lineA;
  40527. private _lineB;
  40528. private _localAxis;
  40529. private _lookAt;
  40530. private _updateDragPlanePosition;
  40531. /**
  40532. * Detaches the behavior from the mesh
  40533. */
  40534. detach(): void;
  40535. }
  40536. }
  40537. declare module BABYLON {
  40538. /**
  40539. * 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
  40540. */
  40541. class SixDofDragBehavior implements Behavior<Mesh> {
  40542. private static _virtualScene;
  40543. private _ownerNode;
  40544. private _sceneRenderObserver;
  40545. private _scene;
  40546. private _targetPosition;
  40547. private _virtualOriginMesh;
  40548. private _virtualDragMesh;
  40549. private _pointerObserver;
  40550. private _moving;
  40551. private _startingOrientation;
  40552. /**
  40553. * 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)
  40554. */
  40555. private zDragFactor;
  40556. /**
  40557. * If the behavior is currently in a dragging state
  40558. */
  40559. dragging: boolean;
  40560. /**
  40561. * 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)
  40562. */
  40563. dragDeltaRatio: number;
  40564. /**
  40565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40566. */
  40567. currentDraggingPointerID: number;
  40568. /**
  40569. * If camera controls should be detached during the drag
  40570. */
  40571. detachCameraControls: boolean;
  40572. /**
  40573. * Fires each time a drag starts
  40574. */
  40575. onDragStartObservable: Observable<{}>;
  40576. /**
  40577. * Fires each time a drag ends (eg. mouse release after drag)
  40578. */
  40579. onDragEndObservable: Observable<{}>;
  40580. /**
  40581. * 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
  40582. */
  40583. constructor();
  40584. /**
  40585. * The name of the behavior
  40586. */
  40587. readonly name: string;
  40588. /**
  40589. * Initializes the behavior
  40590. */
  40591. init(): void;
  40592. /**
  40593. * Attaches the scale behavior the passed in mesh
  40594. * @param ownerNode The mesh that will be scaled around once attached
  40595. */
  40596. attach(ownerNode: Mesh): void;
  40597. /**
  40598. * Detaches the behavior from the mesh
  40599. */
  40600. detach(): void;
  40601. }
  40602. }
  40603. declare module BABYLON {
  40604. /**
  40605. * Contains an array of blocks representing the octree
  40606. */
  40607. interface IOctreeContainer<T> {
  40608. /**
  40609. * Blocks within the octree
  40610. */
  40611. blocks: Array<OctreeBlock<T>>;
  40612. }
  40613. /**
  40614. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40616. */
  40617. class Octree<T> {
  40618. /** 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.) */
  40619. maxDepth: number;
  40620. /**
  40621. * Blocks within the octree containing objects
  40622. */
  40623. blocks: Array<OctreeBlock<T>>;
  40624. /**
  40625. * Content stored in the octree
  40626. */
  40627. dynamicContent: T[];
  40628. private _maxBlockCapacity;
  40629. private _selectionContent;
  40630. private _creationFunc;
  40631. /**
  40632. * Creates a octree
  40633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40634. * @param creationFunc function to be used to instatiate the octree
  40635. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40636. * @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.)
  40637. */
  40638. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40639. /** 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.) */
  40640. maxDepth?: number);
  40641. /**
  40642. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40643. * @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);
  40644. * @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);
  40645. * @param entries meshes to be added to the octree blocks
  40646. */
  40647. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40648. /**
  40649. * Adds a mesh to the octree
  40650. * @param entry Mesh to add to the octree
  40651. */
  40652. addMesh(entry: T): void;
  40653. /**
  40654. * Selects an array of meshes within the frustum
  40655. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40656. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40657. * @returns array of meshes within the frustum
  40658. */
  40659. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40660. /**
  40661. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40662. * @param sphereCenter defines the bounding sphere center
  40663. * @param sphereRadius defines the bounding sphere radius
  40664. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40665. * @returns an array of objects that intersect the sphere
  40666. */
  40667. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40668. /**
  40669. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40670. * @param ray defines the ray to test with
  40671. * @returns array of intersected objects
  40672. */
  40673. intersectsRay(ray: Ray): SmartArray<T>;
  40674. /**
  40675. * @hidden
  40676. */
  40677. 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;
  40678. /**
  40679. * Adds a mesh into the octree block if it intersects the block
  40680. */
  40681. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40682. /**
  40683. * Adds a submesh into the octree block if it intersects the block
  40684. */
  40685. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40686. }
  40687. }
  40688. declare module BABYLON {
  40689. /**
  40690. * Class used to store a cell in an octree
  40691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40692. */
  40693. class OctreeBlock<T> {
  40694. /**
  40695. * Gets the content of the current block
  40696. */
  40697. entries: T[];
  40698. /**
  40699. * Gets the list of block children
  40700. */
  40701. blocks: Array<OctreeBlock<T>>;
  40702. private _depth;
  40703. private _maxDepth;
  40704. private _capacity;
  40705. private _minPoint;
  40706. private _maxPoint;
  40707. private _boundingVectors;
  40708. private _creationFunc;
  40709. /**
  40710. * Creates a new block
  40711. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40712. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40713. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40714. * @param depth defines the current depth of this block in the octree
  40715. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40716. * @param creationFunc defines a callback to call when an element is added to the block
  40717. */
  40718. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40719. /**
  40720. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40721. */
  40722. readonly capacity: number;
  40723. /**
  40724. * Gets the minimum vector (in world space) of the block's bounding box
  40725. */
  40726. readonly minPoint: Vector3;
  40727. /**
  40728. * Gets the maximum vector (in world space) of the block's bounding box
  40729. */
  40730. readonly maxPoint: Vector3;
  40731. /**
  40732. * Add a new element to this block
  40733. * @param entry defines the element to add
  40734. */
  40735. addEntry(entry: T): void;
  40736. /**
  40737. * Add an array of elements to this block
  40738. * @param entries defines the array of elements to add
  40739. */
  40740. addEntries(entries: T[]): void;
  40741. /**
  40742. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40743. * @param frustumPlanes defines the frustum planes to test
  40744. * @param selection defines the array to store current content if selection is positive
  40745. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40746. */
  40747. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40748. /**
  40749. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40750. * @param sphereCenter defines the bounding sphere center
  40751. * @param sphereRadius defines the bounding sphere radius
  40752. * @param selection defines the array to store current content if selection is positive
  40753. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40754. */
  40755. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40756. /**
  40757. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40758. * @param ray defines the ray to test with
  40759. * @param selection defines the array to store current content if selection is positive
  40760. */
  40761. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40762. /**
  40763. * Subdivide the content into child blocks (this block will then be empty)
  40764. */
  40765. createInnerBlocks(): void;
  40766. }
  40767. }
  40768. declare module BABYLON {
  40769. interface Scene {
  40770. /**
  40771. * @hidden
  40772. * Backing Filed
  40773. */
  40774. _selectionOctree: Octree<AbstractMesh>;
  40775. /**
  40776. * Gets the octree used to boost mesh selection (picking)
  40777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40778. */
  40779. selectionOctree: Octree<AbstractMesh>;
  40780. /**
  40781. * Creates or updates the octree used to boost selection (picking)
  40782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40783. * @param maxCapacity defines the maximum capacity per leaf
  40784. * @param maxDepth defines the maximum depth of the octree
  40785. * @returns an octree of AbstractMesh
  40786. */
  40787. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40788. }
  40789. interface AbstractMesh {
  40790. /**
  40791. * @hidden
  40792. * Backing Field
  40793. */
  40794. _submeshesOctree: Octree<SubMesh>;
  40795. /**
  40796. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40797. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40798. * @param maxCapacity defines the maximum size of each block (64 by default)
  40799. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40800. * @returns the new octree
  40801. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40803. */
  40804. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40805. }
  40806. /**
  40807. * Defines the octree scene component responsible to manage any octrees
  40808. * in a given scene.
  40809. */
  40810. class OctreeSceneComponent {
  40811. /**
  40812. * The component name helpfull to identify the component in the list of scene components.
  40813. */
  40814. readonly name: string;
  40815. /**
  40816. * The scene the component belongs to.
  40817. */
  40818. scene: Scene;
  40819. /**
  40820. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40821. */
  40822. readonly checksIsEnabled: boolean;
  40823. /**
  40824. * Creates a new instance of the component for the given scene
  40825. * @param scene Defines the scene to register the component in
  40826. */
  40827. constructor(scene: Scene);
  40828. /**
  40829. * Registers the component in a given scene
  40830. */
  40831. register(): void;
  40832. /**
  40833. * Return the list of active meshes
  40834. * @returns the list of active meshes
  40835. */
  40836. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40837. /**
  40838. * Return the list of active sub meshes
  40839. * @param mesh The mesh to get the candidates sub meshes from
  40840. * @returns the list of active sub meshes
  40841. */
  40842. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40843. private _tempRay;
  40844. /**
  40845. * Return the list of sub meshes intersecting with a given local ray
  40846. * @param mesh defines the mesh to find the submesh for
  40847. * @param localRay defines the ray in local space
  40848. * @returns the list of intersecting sub meshes
  40849. */
  40850. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40851. /**
  40852. * Return the list of sub meshes colliding with a collider
  40853. * @param mesh defines the mesh to find the submesh for
  40854. * @param collider defines the collider to evaluate the collision against
  40855. * @returns the list of colliding sub meshes
  40856. */
  40857. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40858. /**
  40859. * Rebuilds the elements related to this component in case of
  40860. * context lost for instance.
  40861. */
  40862. rebuild(): void;
  40863. /**
  40864. * Disposes the component and the associated ressources.
  40865. */
  40866. dispose(): void;
  40867. }
  40868. }
  40869. declare module BABYLON {
  40870. /**
  40871. * Manage the gamepad inputs to control an arc rotate camera.
  40872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40873. */
  40874. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40875. /**
  40876. * Defines the camera the input is attached to.
  40877. */
  40878. camera: ArcRotateCamera;
  40879. /**
  40880. * Defines the gamepad the input is gathering event from.
  40881. */
  40882. gamepad: Nullable<Gamepad>;
  40883. /**
  40884. * Defines the gamepad rotation sensiblity.
  40885. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40886. */
  40887. gamepadRotationSensibility: number;
  40888. /**
  40889. * Defines the gamepad move sensiblity.
  40890. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40891. */
  40892. gamepadMoveSensibility: number;
  40893. private _onGamepadConnectedObserver;
  40894. private _onGamepadDisconnectedObserver;
  40895. /**
  40896. * Attach the input controls to a specific dom element to get the input from.
  40897. * @param element Defines the element the controls should be listened from
  40898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40899. */
  40900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40901. /**
  40902. * Detach the current controls from the specified dom element.
  40903. * @param element Defines the element to stop listening the inputs from
  40904. */
  40905. detachControl(element: Nullable<HTMLElement>): void;
  40906. /**
  40907. * Update the current camera state depending on the inputs that have been used this frame.
  40908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40909. */
  40910. checkInputs(): void;
  40911. /**
  40912. * Gets the class name of the current intput.
  40913. * @returns the class name
  40914. */
  40915. getClassName(): string;
  40916. /**
  40917. * Get the friendly name associated with the input class.
  40918. * @returns the input friendly name
  40919. */
  40920. getSimpleName(): string;
  40921. }
  40922. }
  40923. declare module BABYLON {
  40924. /**
  40925. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40927. */
  40928. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40929. /**
  40930. * Defines the camera the input is attached to.
  40931. */
  40932. camera: ArcRotateCamera;
  40933. /**
  40934. * Defines the list of key codes associated with the up action (increase alpha)
  40935. */
  40936. keysUp: number[];
  40937. /**
  40938. * Defines the list of key codes associated with the down action (decrease alpha)
  40939. */
  40940. keysDown: number[];
  40941. /**
  40942. * Defines the list of key codes associated with the left action (increase beta)
  40943. */
  40944. keysLeft: number[];
  40945. /**
  40946. * Defines the list of key codes associated with the right action (decrease beta)
  40947. */
  40948. keysRight: number[];
  40949. /**
  40950. * Defines the list of key codes associated with the reset action.
  40951. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40952. */
  40953. keysReset: number[];
  40954. /**
  40955. * Defines the panning sensibility of the inputs.
  40956. * (How fast is the camera paning)
  40957. */
  40958. panningSensibility: number;
  40959. /**
  40960. * Defines the zooming sensibility of the inputs.
  40961. * (How fast is the camera zooming)
  40962. */
  40963. zoomingSensibility: number;
  40964. /**
  40965. * Defines wether maintaining the alt key down switch the movement mode from
  40966. * orientation to zoom.
  40967. */
  40968. useAltToZoom: boolean;
  40969. /**
  40970. * Rotation speed of the camera
  40971. */
  40972. angularSpeed: number;
  40973. private _keys;
  40974. private _ctrlPressed;
  40975. private _altPressed;
  40976. private _onCanvasBlurObserver;
  40977. private _onKeyboardObserver;
  40978. private _engine;
  40979. private _scene;
  40980. /**
  40981. * Attach the input controls to a specific dom element to get the input from.
  40982. * @param element Defines the element the controls should be listened from
  40983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40984. */
  40985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40986. /**
  40987. * Detach the current controls from the specified dom element.
  40988. * @param element Defines the element to stop listening the inputs from
  40989. */
  40990. detachControl(element: Nullable<HTMLElement>): void;
  40991. /**
  40992. * Update the current camera state depending on the inputs that have been used this frame.
  40993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40994. */
  40995. checkInputs(): void;
  40996. /**
  40997. * Gets the class name of the current intput.
  40998. * @returns the class name
  40999. */
  41000. getClassName(): string;
  41001. /**
  41002. * Get the friendly name associated with the input class.
  41003. * @returns the input friendly name
  41004. */
  41005. getSimpleName(): string;
  41006. }
  41007. }
  41008. declare module BABYLON {
  41009. /**
  41010. * Manage the mouse wheel inputs to control an arc rotate camera.
  41011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41012. */
  41013. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41014. /**
  41015. * Defines the camera the input is attached to.
  41016. */
  41017. camera: ArcRotateCamera;
  41018. /**
  41019. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41020. */
  41021. wheelPrecision: number;
  41022. /**
  41023. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41024. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41025. */
  41026. wheelDeltaPercentage: number;
  41027. private _wheel;
  41028. private _observer;
  41029. /**
  41030. * Attach the input controls to a specific dom element to get the input from.
  41031. * @param element Defines the element the controls should be listened from
  41032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41033. */
  41034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41035. /**
  41036. * Detach the current controls from the specified dom element.
  41037. * @param element Defines the element to stop listening the inputs from
  41038. */
  41039. detachControl(element: Nullable<HTMLElement>): void;
  41040. /**
  41041. * Gets the class name of the current intput.
  41042. * @returns the class name
  41043. */
  41044. getClassName(): string;
  41045. /**
  41046. * Get the friendly name associated with the input class.
  41047. * @returns the input friendly name
  41048. */
  41049. getSimpleName(): string;
  41050. }
  41051. }
  41052. declare module BABYLON {
  41053. /**
  41054. * Manage the pointers inputs to control an arc rotate camera.
  41055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41056. */
  41057. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41058. /**
  41059. * Defines the camera the input is attached to.
  41060. */
  41061. camera: ArcRotateCamera;
  41062. /**
  41063. * Defines the buttons associated with the input to handle camera move.
  41064. */
  41065. buttons: number[];
  41066. /**
  41067. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41068. */
  41069. angularSensibilityX: number;
  41070. /**
  41071. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41072. */
  41073. angularSensibilityY: number;
  41074. /**
  41075. * Defines the pointer pinch precision or how fast is the camera zooming.
  41076. */
  41077. pinchPrecision: number;
  41078. /**
  41079. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41080. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41081. */
  41082. pinchDeltaPercentage: number;
  41083. /**
  41084. * Defines the pointer panning sensibility or how fast is the camera moving.
  41085. */
  41086. panningSensibility: number;
  41087. /**
  41088. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41089. */
  41090. multiTouchPanning: boolean;
  41091. /**
  41092. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41093. */
  41094. multiTouchPanAndZoom: boolean;
  41095. /**
  41096. * Revers pinch action direction.
  41097. */
  41098. pinchInwards: boolean;
  41099. private _isPanClick;
  41100. private _pointerInput;
  41101. private _observer;
  41102. private _onMouseMove;
  41103. private _onGestureStart;
  41104. private _onGesture;
  41105. private _MSGestureHandler;
  41106. private _onLostFocus;
  41107. private _onContextMenu;
  41108. /**
  41109. * Attach the input controls to a specific dom element to get the input from.
  41110. * @param element Defines the element the controls should be listened from
  41111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41112. */
  41113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41114. /**
  41115. * Detach the current controls from the specified dom element.
  41116. * @param element Defines the element to stop listening the inputs from
  41117. */
  41118. detachControl(element: Nullable<HTMLElement>): void;
  41119. /**
  41120. * Gets the class name of the current intput.
  41121. * @returns the class name
  41122. */
  41123. getClassName(): string;
  41124. /**
  41125. * Get the friendly name associated with the input class.
  41126. * @returns the input friendly name
  41127. */
  41128. getSimpleName(): string;
  41129. }
  41130. }
  41131. declare module BABYLON {
  41132. /**
  41133. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41135. */
  41136. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41137. /**
  41138. * Defines the camera the input is attached to.
  41139. */
  41140. camera: ArcRotateCamera;
  41141. /**
  41142. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41143. */
  41144. alphaCorrection: number;
  41145. /**
  41146. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  41147. */
  41148. betaCorrection: number;
  41149. /**
  41150. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41151. */
  41152. gammaCorrection: number;
  41153. private _alpha;
  41154. private _gamma;
  41155. private _dirty;
  41156. private _deviceOrientationHandler;
  41157. /**
  41158. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41159. */
  41160. constructor();
  41161. /**
  41162. * Attach the input controls to a specific dom element to get the input from.
  41163. * @param element Defines the element the controls should be listened from
  41164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41165. */
  41166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41167. /** @hidden */
  41168. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41169. /**
  41170. * Update the current camera state depending on the inputs that have been used this frame.
  41171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41172. */
  41173. checkInputs(): void;
  41174. /**
  41175. * Detach the current controls from the specified dom element.
  41176. * @param element Defines the element to stop listening the inputs from
  41177. */
  41178. detachControl(element: Nullable<HTMLElement>): void;
  41179. /**
  41180. * Gets the class name of the current intput.
  41181. * @returns the class name
  41182. */
  41183. getClassName(): string;
  41184. /**
  41185. * Get the friendly name associated with the input class.
  41186. * @returns the input friendly name
  41187. */
  41188. getSimpleName(): string;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. /**
  41193. * Listen to keyboard events to control the camera.
  41194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41195. */
  41196. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41197. /**
  41198. * Defines the camera the input is attached to.
  41199. */
  41200. camera: FlyCamera;
  41201. /**
  41202. * The list of keyboard keys used to control the forward move of the camera.
  41203. */
  41204. keysForward: number[];
  41205. /**
  41206. * The list of keyboard keys used to control the backward move of the camera.
  41207. */
  41208. keysBackward: number[];
  41209. /**
  41210. * The list of keyboard keys used to control the forward move of the camera.
  41211. */
  41212. keysUp: number[];
  41213. /**
  41214. * The list of keyboard keys used to control the backward move of the camera.
  41215. */
  41216. keysDown: number[];
  41217. /**
  41218. * The list of keyboard keys used to control the right strafe move of the camera.
  41219. */
  41220. keysRight: number[];
  41221. /**
  41222. * The list of keyboard keys used to control the left strafe move of the camera.
  41223. */
  41224. keysLeft: number[];
  41225. private _keys;
  41226. private _onCanvasBlurObserver;
  41227. private _onKeyboardObserver;
  41228. private _engine;
  41229. private _scene;
  41230. /**
  41231. * Attach the input controls to a specific dom element to get the input from.
  41232. * @param element Defines the element the controls should be listened from
  41233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41234. */
  41235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41236. /**
  41237. * Detach the current controls from the specified dom element.
  41238. * @param element Defines the element to stop listening the inputs from
  41239. */
  41240. detachControl(element: Nullable<HTMLElement>): void;
  41241. /**
  41242. * Gets the class name of the current intput.
  41243. * @returns the class name
  41244. */
  41245. getClassName(): string;
  41246. /** @hidden */
  41247. _onLostFocus(e: FocusEvent): void;
  41248. /**
  41249. * Get the friendly name associated with the input class.
  41250. * @returns the input friendly name
  41251. */
  41252. getSimpleName(): string;
  41253. /**
  41254. * Update the current camera state depending on the inputs that have been used this frame.
  41255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41256. */
  41257. checkInputs(): void;
  41258. }
  41259. }
  41260. declare module BABYLON {
  41261. /**
  41262. * Listen to mouse events to control the camera.
  41263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41264. */
  41265. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41266. /**
  41267. * Defines the camera the input is attached to.
  41268. */
  41269. camera: FlyCamera;
  41270. /**
  41271. * Defines if touch is enabled. (Default is true.)
  41272. */
  41273. touchEnabled: boolean;
  41274. /**
  41275. * Defines the buttons associated with the input to handle camera rotation.
  41276. */
  41277. buttons: number[];
  41278. /**
  41279. * Assign buttons for Yaw control.
  41280. */
  41281. buttonsYaw: number[];
  41282. /**
  41283. * Assign buttons for Pitch control.
  41284. */
  41285. buttonsPitch: number[];
  41286. /**
  41287. * Assign buttons for Roll control.
  41288. */
  41289. buttonsRoll: number[];
  41290. /**
  41291. * Detect if any button is being pressed while mouse is moved.
  41292. * -1 = Mouse locked.
  41293. * 0 = Left button.
  41294. * 1 = Middle Button.
  41295. * 2 = Right Button.
  41296. */
  41297. activeButton: number;
  41298. /**
  41299. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41300. * Higher values reduce its sensitivity.
  41301. */
  41302. angularSensibility: number;
  41303. private _mousemoveCallback;
  41304. private _observer;
  41305. private _rollObserver;
  41306. private previousPosition;
  41307. private noPreventDefault;
  41308. private element;
  41309. /**
  41310. * Listen to mouse events to control the camera.
  41311. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41313. */
  41314. constructor(touchEnabled?: boolean);
  41315. /**
  41316. * Attach the mouse control to the HTML DOM element.
  41317. * @param element Defines the element that listens to the input events.
  41318. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41319. */
  41320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41321. /**
  41322. * Detach the current controls from the specified dom element.
  41323. * @param element Defines the element to stop listening the inputs from
  41324. */
  41325. detachControl(element: Nullable<HTMLElement>): void;
  41326. /**
  41327. * Gets the class name of the current input.
  41328. * @returns the class name.
  41329. */
  41330. getClassName(): string;
  41331. /**
  41332. * Get the friendly name associated with the input class.
  41333. * @returns the input's friendly name.
  41334. */
  41335. getSimpleName(): string;
  41336. private _pointerInput;
  41337. private _onMouseMove;
  41338. /**
  41339. * Rotate camera by mouse offset.
  41340. */
  41341. private rotateCamera;
  41342. }
  41343. }
  41344. declare module BABYLON {
  41345. /**
  41346. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41347. * Screen rotation is taken into account.
  41348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41349. */
  41350. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41351. private _camera;
  41352. private _screenOrientationAngle;
  41353. private _constantTranform;
  41354. private _screenQuaternion;
  41355. private _alpha;
  41356. private _beta;
  41357. private _gamma;
  41358. /**
  41359. * Instantiates a new input
  41360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41361. */
  41362. constructor();
  41363. /**
  41364. * Define the camera controlled by the input.
  41365. */
  41366. camera: FreeCamera;
  41367. /**
  41368. * Attach the input controls to a specific dom element to get the input from.
  41369. * @param element Defines the element the controls should be listened from
  41370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41371. */
  41372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41373. private _orientationChanged;
  41374. private _deviceOrientation;
  41375. /**
  41376. * Detach the current controls from the specified dom element.
  41377. * @param element Defines the element to stop listening the inputs from
  41378. */
  41379. detachControl(element: Nullable<HTMLElement>): void;
  41380. /**
  41381. * Update the current camera state depending on the inputs that have been used this frame.
  41382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41383. */
  41384. checkInputs(): void;
  41385. /**
  41386. * Gets the class name of the current intput.
  41387. * @returns the class name
  41388. */
  41389. getClassName(): string;
  41390. /**
  41391. * Get the friendly name associated with the input class.
  41392. * @returns the input friendly name
  41393. */
  41394. getSimpleName(): string;
  41395. }
  41396. }
  41397. declare module BABYLON {
  41398. /**
  41399. * Manage the gamepad inputs to control a free camera.
  41400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41401. */
  41402. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41403. /**
  41404. * Define the camera the input is attached to.
  41405. */
  41406. camera: FreeCamera;
  41407. /**
  41408. * Define the Gamepad controlling the input
  41409. */
  41410. gamepad: Nullable<Gamepad>;
  41411. /**
  41412. * Defines the gamepad rotation sensiblity.
  41413. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41414. */
  41415. gamepadAngularSensibility: number;
  41416. /**
  41417. * Defines the gamepad move sensiblity.
  41418. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41419. */
  41420. gamepadMoveSensibility: number;
  41421. private _onGamepadConnectedObserver;
  41422. private _onGamepadDisconnectedObserver;
  41423. private _cameraTransform;
  41424. private _deltaTransform;
  41425. private _vector3;
  41426. private _vector2;
  41427. /**
  41428. * Attach the input controls to a specific dom element to get the input from.
  41429. * @param element Defines the element the controls should be listened from
  41430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41431. */
  41432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41433. /**
  41434. * Detach the current controls from the specified dom element.
  41435. * @param element Defines the element to stop listening the inputs from
  41436. */
  41437. detachControl(element: Nullable<HTMLElement>): void;
  41438. /**
  41439. * Update the current camera state depending on the inputs that have been used this frame.
  41440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41441. */
  41442. checkInputs(): void;
  41443. /**
  41444. * Gets the class name of the current intput.
  41445. * @returns the class name
  41446. */
  41447. getClassName(): string;
  41448. /**
  41449. * Get the friendly name associated with the input class.
  41450. * @returns the input friendly name
  41451. */
  41452. getSimpleName(): string;
  41453. }
  41454. }
  41455. declare module BABYLON {
  41456. /**
  41457. * Manage the keyboard inputs to control the movement of a free camera.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41461. /**
  41462. * Defines the camera the input is attached to.
  41463. */
  41464. camera: FreeCamera;
  41465. /**
  41466. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41467. */
  41468. keysUp: number[];
  41469. /**
  41470. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41471. */
  41472. keysDown: number[];
  41473. /**
  41474. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41475. */
  41476. keysLeft: number[];
  41477. /**
  41478. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41479. */
  41480. keysRight: number[];
  41481. private _keys;
  41482. private _onCanvasBlurObserver;
  41483. private _onKeyboardObserver;
  41484. private _engine;
  41485. private _scene;
  41486. /**
  41487. * Attach the input controls to a specific dom element to get the input from.
  41488. * @param element Defines the element the controls should be listened from
  41489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41490. */
  41491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41492. /**
  41493. * Detach the current controls from the specified dom element.
  41494. * @param element Defines the element to stop listening the inputs from
  41495. */
  41496. detachControl(element: Nullable<HTMLElement>): void;
  41497. /**
  41498. * Update the current camera state depending on the inputs that have been used this frame.
  41499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41500. */
  41501. checkInputs(): void;
  41502. /**
  41503. * Gets the class name of the current intput.
  41504. * @returns the class name
  41505. */
  41506. getClassName(): string;
  41507. /** @hidden */
  41508. _onLostFocus(e: FocusEvent): void;
  41509. /**
  41510. * Get the friendly name associated with the input class.
  41511. * @returns the input friendly name
  41512. */
  41513. getSimpleName(): string;
  41514. }
  41515. }
  41516. declare module BABYLON {
  41517. /**
  41518. * Manage the mouse inputs to control the movement of a free camera.
  41519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41520. */
  41521. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41522. /**
  41523. * Define if touch is enabled in the mouse input
  41524. */
  41525. touchEnabled: boolean;
  41526. /**
  41527. * Defines the camera the input is attached to.
  41528. */
  41529. camera: FreeCamera;
  41530. /**
  41531. * Defines the buttons associated with the input to handle camera move.
  41532. */
  41533. buttons: number[];
  41534. /**
  41535. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41536. */
  41537. angularSensibility: number;
  41538. private _pointerInput;
  41539. private _onMouseMove;
  41540. private _observer;
  41541. private previousPosition;
  41542. /**
  41543. * Manage the mouse inputs to control the movement of a free camera.
  41544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41545. * @param touchEnabled Defines if touch is enabled or not
  41546. */
  41547. constructor(
  41548. /**
  41549. * Define if touch is enabled in the mouse input
  41550. */
  41551. touchEnabled?: boolean);
  41552. /**
  41553. * Attach the input controls to a specific dom element to get the input from.
  41554. * @param element Defines the element the controls should be listened from
  41555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41556. */
  41557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41558. /**
  41559. * Detach the current controls from the specified dom element.
  41560. * @param element Defines the element to stop listening the inputs from
  41561. */
  41562. detachControl(element: Nullable<HTMLElement>): void;
  41563. /**
  41564. * Gets the class name of the current intput.
  41565. * @returns the class name
  41566. */
  41567. getClassName(): string;
  41568. /**
  41569. * Get the friendly name associated with the input class.
  41570. * @returns the input friendly name
  41571. */
  41572. getSimpleName(): string;
  41573. }
  41574. }
  41575. declare module BABYLON {
  41576. /**
  41577. * Manage the touch inputs to control the movement of a free camera.
  41578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41579. */
  41580. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41581. /**
  41582. * Defines the camera the input is attached to.
  41583. */
  41584. camera: FreeCamera;
  41585. /**
  41586. * Defines the touch sensibility for rotation.
  41587. * The higher the faster.
  41588. */
  41589. touchAngularSensibility: number;
  41590. /**
  41591. * Defines the touch sensibility for move.
  41592. * The higher the faster.
  41593. */
  41594. touchMoveSensibility: number;
  41595. private _offsetX;
  41596. private _offsetY;
  41597. private _pointerPressed;
  41598. private _pointerInput;
  41599. private _observer;
  41600. private _onLostFocus;
  41601. /**
  41602. * Attach the input controls to a specific dom element to get the input from.
  41603. * @param element Defines the element the controls should be listened from
  41604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41605. */
  41606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41607. /**
  41608. * Detach the current controls from the specified dom element.
  41609. * @param element Defines the element to stop listening the inputs from
  41610. */
  41611. detachControl(element: Nullable<HTMLElement>): void;
  41612. /**
  41613. * Update the current camera state depending on the inputs that have been used this frame.
  41614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41615. */
  41616. checkInputs(): void;
  41617. /**
  41618. * Gets the class name of the current intput.
  41619. * @returns the class name
  41620. */
  41621. getClassName(): string;
  41622. /**
  41623. * Get the friendly name associated with the input class.
  41624. * @returns the input friendly name
  41625. */
  41626. getSimpleName(): string;
  41627. }
  41628. }
  41629. declare module BABYLON {
  41630. /**
  41631. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41633. */
  41634. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41635. /**
  41636. * Defines the camera the input is attached to.
  41637. */
  41638. camera: FreeCamera;
  41639. private _leftjoystick;
  41640. private _rightjoystick;
  41641. /**
  41642. * Gets the left stick of the virtual joystick.
  41643. * @returns The virtual Joystick
  41644. */
  41645. getLeftJoystick(): VirtualJoystick;
  41646. /**
  41647. * Gets the right stick of the virtual joystick.
  41648. * @returns The virtual Joystick
  41649. */
  41650. getRightJoystick(): VirtualJoystick;
  41651. /**
  41652. * Update the current camera state depending on the inputs that have been used this frame.
  41653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41654. */
  41655. checkInputs(): void;
  41656. /**
  41657. * Attach the input controls to a specific dom element to get the input from.
  41658. * @param element Defines the element the controls should be listened from
  41659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41660. */
  41661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41662. /**
  41663. * Detach the current controls from the specified dom element.
  41664. * @param element Defines the element to stop listening the inputs from
  41665. */
  41666. detachControl(element: Nullable<HTMLElement>): void;
  41667. /**
  41668. * Gets the class name of the current intput.
  41669. * @returns the class name
  41670. */
  41671. getClassName(): string;
  41672. /**
  41673. * Get the friendly name associated with the input class.
  41674. * @returns the input friendly name
  41675. */
  41676. getSimpleName(): string;
  41677. }
  41678. }
  41679. declare module BABYLON {
  41680. /**
  41681. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41682. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41683. */
  41684. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41685. /**
  41686. * Creates a new AnaglyphArcRotateCamera
  41687. * @param name defines camera name
  41688. * @param alpha defines alpha angle (in radians)
  41689. * @param beta defines beta angle (in radians)
  41690. * @param radius defines radius
  41691. * @param target defines camera target
  41692. * @param interaxialDistance defines distance between each color axis
  41693. * @param scene defines the hosting scene
  41694. */
  41695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41696. /**
  41697. * Gets camera class name
  41698. * @returns AnaglyphArcRotateCamera
  41699. */
  41700. getClassName(): string;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41706. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41707. */
  41708. class AnaglyphFreeCamera extends FreeCamera {
  41709. /**
  41710. * Creates a new AnaglyphFreeCamera
  41711. * @param name defines camera name
  41712. * @param position defines initial position
  41713. * @param interaxialDistance defines distance between each color axis
  41714. * @param scene defines the hosting scene
  41715. */
  41716. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41717. /**
  41718. * Gets camera class name
  41719. * @returns AnaglyphFreeCamera
  41720. */
  41721. getClassName(): string;
  41722. }
  41723. }
  41724. declare module BABYLON {
  41725. /**
  41726. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41727. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41728. */
  41729. class AnaglyphGamepadCamera extends GamepadCamera {
  41730. /**
  41731. * Creates a new AnaglyphGamepadCamera
  41732. * @param name defines camera name
  41733. * @param position defines initial position
  41734. * @param interaxialDistance defines distance between each color axis
  41735. * @param scene defines the hosting scene
  41736. */
  41737. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41738. /**
  41739. * Gets camera class name
  41740. * @returns AnaglyphGamepadCamera
  41741. */
  41742. getClassName(): string;
  41743. }
  41744. }
  41745. declare module BABYLON {
  41746. /**
  41747. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41748. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41749. */
  41750. class AnaglyphUniversalCamera extends UniversalCamera {
  41751. /**
  41752. * Creates a new AnaglyphUniversalCamera
  41753. * @param name defines camera name
  41754. * @param position defines initial position
  41755. * @param interaxialDistance defines distance between each color axis
  41756. * @param scene defines the hosting scene
  41757. */
  41758. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41759. /**
  41760. * Gets camera class name
  41761. * @returns AnaglyphUniversalCamera
  41762. */
  41763. getClassName(): string;
  41764. }
  41765. }
  41766. declare module BABYLON {
  41767. /**
  41768. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41769. * @see http://doc.babylonjs.com/features/cameras
  41770. */
  41771. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41772. /**
  41773. * Creates a new StereoscopicArcRotateCamera
  41774. * @param name defines camera name
  41775. * @param alpha defines alpha angle (in radians)
  41776. * @param beta defines beta angle (in radians)
  41777. * @param radius defines radius
  41778. * @param target defines camera target
  41779. * @param interaxialDistance defines distance between each color axis
  41780. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41781. * @param scene defines the hosting scene
  41782. */
  41783. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41784. /**
  41785. * Gets camera class name
  41786. * @returns StereoscopicArcRotateCamera
  41787. */
  41788. getClassName(): string;
  41789. }
  41790. }
  41791. declare module BABYLON {
  41792. /**
  41793. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41794. * @see http://doc.babylonjs.com/features/cameras
  41795. */
  41796. class StereoscopicFreeCamera extends FreeCamera {
  41797. /**
  41798. * Creates a new StereoscopicFreeCamera
  41799. * @param name defines camera name
  41800. * @param position defines initial position
  41801. * @param interaxialDistance defines distance between each color axis
  41802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41803. * @param scene defines the hosting scene
  41804. */
  41805. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41806. /**
  41807. * Gets camera class name
  41808. * @returns StereoscopicFreeCamera
  41809. */
  41810. getClassName(): string;
  41811. }
  41812. }
  41813. declare module BABYLON {
  41814. /**
  41815. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41816. * @see http://doc.babylonjs.com/features/cameras
  41817. */
  41818. class StereoscopicGamepadCamera extends GamepadCamera {
  41819. /**
  41820. * Creates a new StereoscopicGamepadCamera
  41821. * @param name defines camera name
  41822. * @param position defines initial position
  41823. * @param interaxialDistance defines distance between each color axis
  41824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41825. * @param scene defines the hosting scene
  41826. */
  41827. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41828. /**
  41829. * Gets camera class name
  41830. * @returns StereoscopicGamepadCamera
  41831. */
  41832. getClassName(): string;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41838. * @see http://doc.babylonjs.com/features/cameras
  41839. */
  41840. class StereoscopicUniversalCamera extends UniversalCamera {
  41841. /**
  41842. * Creates a new StereoscopicUniversalCamera
  41843. * @param name defines camera name
  41844. * @param position defines initial position
  41845. * @param interaxialDistance defines distance between each color axis
  41846. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41847. * @param scene defines the hosting scene
  41848. */
  41849. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41850. /**
  41851. * Gets camera class name
  41852. * @returns StereoscopicUniversalCamera
  41853. */
  41854. getClassName(): string;
  41855. }
  41856. }
  41857. declare module BABYLON {
  41858. /**
  41859. * This represents all the required metrics to create a VR camera.
  41860. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41861. */
  41862. class VRCameraMetrics {
  41863. /**
  41864. * Define the horizontal resolution off the screen.
  41865. */
  41866. hResolution: number;
  41867. /**
  41868. * Define the vertical resolution off the screen.
  41869. */
  41870. vResolution: number;
  41871. /**
  41872. * Define the horizontal screen size.
  41873. */
  41874. hScreenSize: number;
  41875. /**
  41876. * Define the vertical screen size.
  41877. */
  41878. vScreenSize: number;
  41879. /**
  41880. * Define the vertical screen center position.
  41881. */
  41882. vScreenCenter: number;
  41883. /**
  41884. * Define the distance of the eyes to the screen.
  41885. */
  41886. eyeToScreenDistance: number;
  41887. /**
  41888. * Define the distance between both lenses
  41889. */
  41890. lensSeparationDistance: number;
  41891. /**
  41892. * Define the distance between both viewer's eyes.
  41893. */
  41894. interpupillaryDistance: number;
  41895. /**
  41896. * Define the distortion factor of the VR postprocess.
  41897. * Please, touch with care.
  41898. */
  41899. distortionK: number[];
  41900. /**
  41901. * Define the chromatic aberration correction factors for the VR post process.
  41902. */
  41903. chromaAbCorrection: number[];
  41904. /**
  41905. * Define the scale factor of the post process.
  41906. * The smaller the better but the slower.
  41907. */
  41908. postProcessScaleFactor: number;
  41909. /**
  41910. * Define an offset for the lens center.
  41911. */
  41912. lensCenterOffset: number;
  41913. /**
  41914. * Define if the current vr camera should compensate the distortion of the lense or not.
  41915. */
  41916. compensateDistortion: boolean;
  41917. /**
  41918. * Gets the rendering aspect ratio based on the provided resolutions.
  41919. */
  41920. readonly aspectRatio: number;
  41921. /**
  41922. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41923. */
  41924. readonly aspectRatioFov: number;
  41925. /**
  41926. * @hidden
  41927. */
  41928. readonly leftHMatrix: Matrix;
  41929. /**
  41930. * @hidden
  41931. */
  41932. readonly rightHMatrix: Matrix;
  41933. /**
  41934. * @hidden
  41935. */
  41936. readonly leftPreViewMatrix: Matrix;
  41937. /**
  41938. * @hidden
  41939. */
  41940. readonly rightPreViewMatrix: Matrix;
  41941. /**
  41942. * Get the default VRMetrics based on the most generic setup.
  41943. * @returns the default vr metrics
  41944. */
  41945. static GetDefault(): VRCameraMetrics;
  41946. }
  41947. }
  41948. declare module BABYLON {
  41949. /**
  41950. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41951. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41952. */
  41953. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41954. /**
  41955. * Creates a new VRDeviceOrientationArcRotateCamera
  41956. * @param name defines camera name
  41957. * @param alpha defines the camera rotation along the logitudinal axis
  41958. * @param beta defines the camera rotation along the latitudinal axis
  41959. * @param radius defines the camera distance from its target
  41960. * @param target defines the camera target
  41961. * @param scene defines the scene the camera belongs to
  41962. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41963. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41964. */
  41965. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41966. /**
  41967. * Gets camera class name
  41968. * @returns VRDeviceOrientationArcRotateCamera
  41969. */
  41970. getClassName(): string;
  41971. }
  41972. }
  41973. declare module BABYLON {
  41974. /**
  41975. * Camera used to simulate VR rendering (based on FreeCamera)
  41976. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41977. */
  41978. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41979. /**
  41980. * Creates a new VRDeviceOrientationFreeCamera
  41981. * @param name defines camera name
  41982. * @param position defines the start position of the camera
  41983. * @param scene defines the scene the camera belongs to
  41984. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41985. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41986. */
  41987. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41988. /**
  41989. * Gets camera class name
  41990. * @returns VRDeviceOrientationFreeCamera
  41991. */
  41992. getClassName(): string;
  41993. }
  41994. }
  41995. declare module BABYLON {
  41996. /**
  41997. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41998. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41999. */
  42000. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42001. /**
  42002. * Creates a new VRDeviceOrientationGamepadCamera
  42003. * @param name defines camera name
  42004. * @param position defines the start position of the camera
  42005. * @param scene defines the scene the camera belongs to
  42006. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42007. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42008. */
  42009. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42010. /**
  42011. * Gets camera class name
  42012. * @returns VRDeviceOrientationGamepadCamera
  42013. */
  42014. getClassName(): string;
  42015. }
  42016. }
  42017. declare module BABYLON {
  42018. /**
  42019. * Options to modify the vr teleportation behavior.
  42020. */
  42021. interface VRTeleportationOptions {
  42022. /**
  42023. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42024. */
  42025. floorMeshName?: string;
  42026. /**
  42027. * A list of meshes to be used as the teleportation floor. (default: empty)
  42028. */
  42029. floorMeshes?: Mesh[];
  42030. }
  42031. /**
  42032. * Options to modify the vr experience helper's behavior.
  42033. */
  42034. interface VRExperienceHelperOptions extends WebVROptions {
  42035. /**
  42036. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42037. */
  42038. createDeviceOrientationCamera?: boolean;
  42039. /**
  42040. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42041. */
  42042. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42043. /**
  42044. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42045. */
  42046. laserToggle?: boolean;
  42047. /**
  42048. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42049. */
  42050. floorMeshes?: Mesh[];
  42051. }
  42052. /**
  42053. * Helps to quickly add VR support to an existing scene.
  42054. * See http://doc.babylonjs.com/how_to/webvr_helper
  42055. */
  42056. class VRExperienceHelper {
  42057. /** Options to modify the vr experience helper's behavior. */
  42058. webVROptions: VRExperienceHelperOptions;
  42059. private _scene;
  42060. private _position;
  42061. private _btnVR;
  42062. private _btnVRDisplayed;
  42063. private _webVRsupported;
  42064. private _webVRready;
  42065. private _webVRrequesting;
  42066. private _webVRpresenting;
  42067. private _hasEnteredVR;
  42068. private _fullscreenVRpresenting;
  42069. private _canvas;
  42070. private _webVRCamera;
  42071. private _vrDeviceOrientationCamera;
  42072. private _deviceOrientationCamera;
  42073. private _existingCamera;
  42074. private _onKeyDown;
  42075. private _onVrDisplayPresentChange;
  42076. private _onVRDisplayChanged;
  42077. private _onVRRequestPresentStart;
  42078. private _onVRRequestPresentComplete;
  42079. /**
  42080. * Observable raised when entering VR.
  42081. */
  42082. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42083. /**
  42084. * Observable raised when exiting VR.
  42085. */
  42086. onExitingVRObservable: Observable<VRExperienceHelper>;
  42087. /**
  42088. * Observable raised when controller mesh is loaded.
  42089. */
  42090. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42091. /** Return this.onEnteringVRObservable
  42092. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42093. */
  42094. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42095. /** Return this.onExitingVRObservable
  42096. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42097. */
  42098. readonly onExitingVR: Observable<VRExperienceHelper>;
  42099. /** Return this.onControllerMeshLoadedObservable
  42100. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42101. */
  42102. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42103. private _rayLength;
  42104. private _useCustomVRButton;
  42105. private _teleportationRequested;
  42106. private _teleportActive;
  42107. private _floorMeshName;
  42108. private _floorMeshesCollection;
  42109. private _rotationAllowed;
  42110. private _teleportBackwardsVector;
  42111. private _teleportationTarget;
  42112. private _isDefaultTeleportationTarget;
  42113. private _postProcessMove;
  42114. private _teleportationFillColor;
  42115. private _teleportationBorderColor;
  42116. private _rotationAngle;
  42117. private _haloCenter;
  42118. private _cameraGazer;
  42119. private _padSensibilityUp;
  42120. private _padSensibilityDown;
  42121. private _leftController;
  42122. private _rightController;
  42123. /**
  42124. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42125. */
  42126. onNewMeshSelected: Observable<AbstractMesh>;
  42127. /**
  42128. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42129. */
  42130. onNewMeshPicked: Observable<PickingInfo>;
  42131. private _circleEase;
  42132. /**
  42133. * Observable raised before camera teleportation
  42134. */
  42135. onBeforeCameraTeleport: Observable<Vector3>;
  42136. /**
  42137. * Observable raised after camera teleportation
  42138. */
  42139. onAfterCameraTeleport: Observable<Vector3>;
  42140. /**
  42141. * Observable raised when current selected mesh gets unselected
  42142. */
  42143. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42144. private _raySelectionPredicate;
  42145. /**
  42146. * To be optionaly changed by user to define custom ray selection
  42147. */
  42148. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42149. /**
  42150. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42151. */
  42152. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42153. /**
  42154. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42155. */
  42156. teleportationEnabled: boolean;
  42157. private _defaultHeight;
  42158. private _teleportationInitialized;
  42159. private _interactionsEnabled;
  42160. private _interactionsRequested;
  42161. private _displayGaze;
  42162. private _displayLaserPointer;
  42163. /**
  42164. * The mesh used to display where the user is going to teleport.
  42165. */
  42166. /**
  42167. * Sets the mesh to be used to display where the user is going to teleport.
  42168. */
  42169. teleportationTarget: Mesh;
  42170. /**
  42171. * 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
  42172. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42173. * See http://doc.babylonjs.com/resources/baking_transformations
  42174. */
  42175. gazeTrackerMesh: Mesh;
  42176. /**
  42177. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42178. */
  42179. updateGazeTrackerScale: boolean;
  42180. /**
  42181. * The gaze tracking mesh corresponding to the left controller
  42182. */
  42183. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42184. /**
  42185. * The gaze tracking mesh corresponding to the right controller
  42186. */
  42187. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42188. /**
  42189. * If the ray of the gaze should be displayed.
  42190. */
  42191. /**
  42192. * Sets if the ray of the gaze should be displayed.
  42193. */
  42194. displayGaze: boolean;
  42195. /**
  42196. * If the ray of the LaserPointer should be displayed.
  42197. */
  42198. /**
  42199. * Sets if the ray of the LaserPointer should be displayed.
  42200. */
  42201. displayLaserPointer: boolean;
  42202. /**
  42203. * The deviceOrientationCamera used as the camera when not in VR.
  42204. */
  42205. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42206. /**
  42207. * Based on the current WebVR support, returns the current VR camera used.
  42208. */
  42209. readonly currentVRCamera: Nullable<Camera>;
  42210. /**
  42211. * The webVRCamera which is used when in VR.
  42212. */
  42213. readonly webVRCamera: WebVRFreeCamera;
  42214. /**
  42215. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42216. */
  42217. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42218. private readonly _teleportationRequestInitiated;
  42219. /**
  42220. * Instantiates a VRExperienceHelper.
  42221. * Helps to quickly add VR support to an existing scene.
  42222. * @param scene The scene the VRExperienceHelper belongs to.
  42223. * @param webVROptions Options to modify the vr experience helper's behavior.
  42224. */
  42225. constructor(scene: Scene,
  42226. /** Options to modify the vr experience helper's behavior. */
  42227. webVROptions?: VRExperienceHelperOptions);
  42228. private _onDefaultMeshLoaded;
  42229. private _onResize;
  42230. private _onFullscreenChange;
  42231. /**
  42232. * Gets a value indicating if we are currently in VR mode.
  42233. */
  42234. readonly isInVRMode: boolean;
  42235. private onVrDisplayPresentChange;
  42236. private onVRDisplayChanged;
  42237. private moveButtonToBottomRight;
  42238. private displayVRButton;
  42239. private updateButtonVisibility;
  42240. /**
  42241. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42242. * Otherwise, will use the fullscreen API.
  42243. */
  42244. enterVR(): void;
  42245. /**
  42246. * Attempt to exit VR, or fullscreen.
  42247. */
  42248. exitVR(): void;
  42249. /**
  42250. * The position of the vr experience helper.
  42251. */
  42252. /**
  42253. * Sets the position of the vr experience helper.
  42254. */
  42255. position: Vector3;
  42256. /**
  42257. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42258. */
  42259. enableInteractions(): void;
  42260. private readonly _noControllerIsActive;
  42261. private beforeRender;
  42262. private _isTeleportationFloor;
  42263. /**
  42264. * Adds a floor mesh to be used for teleportation.
  42265. * @param floorMesh the mesh to be used for teleportation.
  42266. */
  42267. addFloorMesh(floorMesh: Mesh): void;
  42268. /**
  42269. * Removes a floor mesh from being used for teleportation.
  42270. * @param floorMesh the mesh to be removed.
  42271. */
  42272. removeFloorMesh(floorMesh: Mesh): void;
  42273. /**
  42274. * Enables interactions and teleportation using the VR controllers and gaze.
  42275. * @param vrTeleportationOptions options to modify teleportation behavior.
  42276. */
  42277. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42278. private _onNewGamepadConnected;
  42279. private _tryEnableInteractionOnController;
  42280. private _onNewGamepadDisconnected;
  42281. private _enableInteractionOnController;
  42282. private _checkTeleportWithRay;
  42283. private _checkRotate;
  42284. private _checkTeleportBackwards;
  42285. private _enableTeleportationOnController;
  42286. private _createTeleportationCircles;
  42287. private _displayTeleportationTarget;
  42288. private _hideTeleportationTarget;
  42289. private _rotateCamera;
  42290. private _moveTeleportationSelectorTo;
  42291. private _workingVector;
  42292. private _workingQuaternion;
  42293. private _workingMatrix;
  42294. /**
  42295. * Teleports the users feet to the desired location
  42296. * @param location The location where the user's feet should be placed
  42297. */
  42298. teleportCamera(location: Vector3): void;
  42299. private _convertNormalToDirectionOfRay;
  42300. private _castRayAndSelectObject;
  42301. private _notifySelectedMeshUnselected;
  42302. /**
  42303. * Sets the color of the laser ray from the vr controllers.
  42304. * @param color new color for the ray.
  42305. */
  42306. changeLaserColor(color: Color3): void;
  42307. /**
  42308. * Sets the color of the ray from the vr headsets gaze.
  42309. * @param color new color for the ray.
  42310. */
  42311. changeGazeColor(color: Color3): void;
  42312. /**
  42313. * Exits VR and disposes of the vr experience helper
  42314. */
  42315. dispose(): void;
  42316. /**
  42317. * Gets the name of the VRExperienceHelper class
  42318. * @returns "VRExperienceHelper"
  42319. */
  42320. getClassName(): string;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42326. * IMPORTANT!! The data is right-hand data.
  42327. * @export
  42328. * @interface DevicePose
  42329. */
  42330. interface DevicePose {
  42331. /**
  42332. * The position of the device, values in array are [x,y,z].
  42333. */
  42334. readonly position: Nullable<Float32Array>;
  42335. /**
  42336. * The linearVelocity of the device, values in array are [x,y,z].
  42337. */
  42338. readonly linearVelocity: Nullable<Float32Array>;
  42339. /**
  42340. * The linearAcceleration of the device, values in array are [x,y,z].
  42341. */
  42342. readonly linearAcceleration: Nullable<Float32Array>;
  42343. /**
  42344. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42345. */
  42346. readonly orientation: Nullable<Float32Array>;
  42347. /**
  42348. * The angularVelocity of the device, values in array are [x,y,z].
  42349. */
  42350. readonly angularVelocity: Nullable<Float32Array>;
  42351. /**
  42352. * The angularAcceleration of the device, values in array are [x,y,z].
  42353. */
  42354. readonly angularAcceleration: Nullable<Float32Array>;
  42355. }
  42356. /**
  42357. * Interface representing a pose controlled object in Babylon.
  42358. * A pose controlled object has both regular pose values as well as pose values
  42359. * from an external device such as a VR head mounted display
  42360. */
  42361. interface PoseControlled {
  42362. /**
  42363. * The position of the object in babylon space.
  42364. */
  42365. position: Vector3;
  42366. /**
  42367. * The rotation quaternion of the object in babylon space.
  42368. */
  42369. rotationQuaternion: Quaternion;
  42370. /**
  42371. * The position of the device in babylon space.
  42372. */
  42373. devicePosition?: Vector3;
  42374. /**
  42375. * The rotation quaternion of the device in babylon space.
  42376. */
  42377. deviceRotationQuaternion: Quaternion;
  42378. /**
  42379. * The raw pose coming from the device.
  42380. */
  42381. rawPose: Nullable<DevicePose>;
  42382. /**
  42383. * The scale of the device to be used when translating from device space to babylon space.
  42384. */
  42385. deviceScaleFactor: number;
  42386. /**
  42387. * Updates the poseControlled values based on the input device pose.
  42388. * @param poseData the pose data to update the object with
  42389. */
  42390. updateFromDevice(poseData: DevicePose): void;
  42391. }
  42392. /**
  42393. * Set of options to customize the webVRCamera
  42394. */
  42395. interface WebVROptions {
  42396. /**
  42397. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42398. */
  42399. trackPosition?: boolean;
  42400. /**
  42401. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42402. */
  42403. positionScale?: number;
  42404. /**
  42405. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42406. */
  42407. displayName?: string;
  42408. /**
  42409. * Should the native controller meshes be initialized. (default: true)
  42410. */
  42411. controllerMeshes?: boolean;
  42412. /**
  42413. * Creating a default HemiLight only on controllers. (default: true)
  42414. */
  42415. defaultLightingOnControllers?: boolean;
  42416. /**
  42417. * If you don't want to use the default VR button of the helper. (default: false)
  42418. */
  42419. useCustomVRButton?: boolean;
  42420. /**
  42421. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42422. */
  42423. customVRButton?: HTMLButtonElement;
  42424. /**
  42425. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42426. */
  42427. rayLength?: number;
  42428. /**
  42429. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42430. */
  42431. defaultHeight?: number;
  42432. }
  42433. /**
  42434. * This represents a WebVR camera.
  42435. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42436. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42437. */
  42438. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42439. private webVROptions;
  42440. /**
  42441. * @hidden
  42442. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42443. */
  42444. _vrDevice: any;
  42445. /**
  42446. * The rawPose of the vrDevice.
  42447. */
  42448. rawPose: Nullable<DevicePose>;
  42449. private _onVREnabled;
  42450. private _specsVersion;
  42451. private _attached;
  42452. private _frameData;
  42453. protected _descendants: Array<Node>;
  42454. private _deviceRoomPosition;
  42455. /** @hidden */
  42456. _deviceRoomRotationQuaternion: Quaternion;
  42457. private _standingMatrix;
  42458. /**
  42459. * Represents device position in babylon space.
  42460. */
  42461. devicePosition: Vector3;
  42462. /**
  42463. * Represents device rotation in babylon space.
  42464. */
  42465. deviceRotationQuaternion: Quaternion;
  42466. /**
  42467. * The scale of the device to be used when translating from device space to babylon space.
  42468. */
  42469. deviceScaleFactor: number;
  42470. private _deviceToWorld;
  42471. private _worldToDevice;
  42472. /**
  42473. * References to the webVR controllers for the vrDevice.
  42474. */
  42475. controllers: Array<WebVRController>;
  42476. /**
  42477. * Emits an event when a controller is attached.
  42478. */
  42479. onControllersAttachedObservable: Observable<WebVRController[]>;
  42480. /**
  42481. * Emits an event when a controller's mesh has been loaded;
  42482. */
  42483. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42484. /**
  42485. * Emits an event when the HMD's pose has been updated.
  42486. */
  42487. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42488. private _poseSet;
  42489. /**
  42490. * If the rig cameras be used as parent instead of this camera.
  42491. */
  42492. rigParenting: boolean;
  42493. private _lightOnControllers;
  42494. private _defaultHeight?;
  42495. /**
  42496. * Instantiates a WebVRFreeCamera.
  42497. * @param name The name of the WebVRFreeCamera
  42498. * @param position The starting anchor position for the camera
  42499. * @param scene The scene the camera belongs to
  42500. * @param webVROptions a set of customizable options for the webVRCamera
  42501. */
  42502. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42503. /**
  42504. * Gets the device distance from the ground in meters.
  42505. * @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.
  42506. */
  42507. deviceDistanceToRoomGround(): number;
  42508. /**
  42509. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42510. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42511. */
  42512. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42513. /**
  42514. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42515. * @returns A promise with a boolean set to if the standing matrix is supported.
  42516. */
  42517. useStandingMatrixAsync(): Promise<boolean>;
  42518. /**
  42519. * Disposes the camera
  42520. */
  42521. dispose(): void;
  42522. /**
  42523. * Gets a vrController by name.
  42524. * @param name The name of the controller to retreive
  42525. * @returns the controller matching the name specified or null if not found
  42526. */
  42527. getControllerByName(name: string): Nullable<WebVRController>;
  42528. private _leftController;
  42529. /**
  42530. * The controller corrisponding to the users left hand.
  42531. */
  42532. readonly leftController: Nullable<WebVRController>;
  42533. private _rightController;
  42534. /**
  42535. * The controller corrisponding to the users right hand.
  42536. */
  42537. readonly rightController: Nullable<WebVRController>;
  42538. /**
  42539. * Casts a ray forward from the vrCamera's gaze.
  42540. * @param length Length of the ray (default: 100)
  42541. * @returns the ray corrisponding to the gaze
  42542. */
  42543. getForwardRay(length?: number): Ray;
  42544. /**
  42545. * @hidden
  42546. * Updates the camera based on device's frame data
  42547. */
  42548. _checkInputs(): void;
  42549. /**
  42550. * Updates the poseControlled values based on the input device pose.
  42551. * @param poseData Pose coming from the device
  42552. */
  42553. updateFromDevice(poseData: DevicePose): void;
  42554. private _htmlElementAttached;
  42555. private _detachIfAttached;
  42556. /**
  42557. * WebVR's attach control will start broadcasting frames to the device.
  42558. * Note that in certain browsers (chrome for example) this function must be called
  42559. * within a user-interaction callback. Example:
  42560. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42561. *
  42562. * @param element html element to attach the vrDevice to
  42563. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42564. */
  42565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42566. /**
  42567. * Detaches the camera from the html element and disables VR
  42568. *
  42569. * @param element html element to detach from
  42570. */
  42571. detachControl(element: HTMLElement): void;
  42572. /**
  42573. * @returns the name of this class
  42574. */
  42575. getClassName(): string;
  42576. /**
  42577. * Calls resetPose on the vrDisplay
  42578. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42579. */
  42580. resetToCurrentRotation(): void;
  42581. /**
  42582. * @hidden
  42583. * Updates the rig cameras (left and right eye)
  42584. */
  42585. _updateRigCameras(): void;
  42586. private _workingVector;
  42587. private _oneVector;
  42588. private _workingMatrix;
  42589. private updateCacheCalled;
  42590. private _correctPositionIfNotTrackPosition;
  42591. /**
  42592. * @hidden
  42593. * Updates the cached values of the camera
  42594. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42595. */
  42596. _updateCache(ignoreParentClass?: boolean): void;
  42597. /**
  42598. * @hidden
  42599. * Get current device position in babylon world
  42600. */
  42601. _computeDevicePosition(): void;
  42602. /**
  42603. * Updates the current device position and rotation in the babylon world
  42604. */
  42605. update(): void;
  42606. /**
  42607. * @hidden
  42608. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42609. * @returns an identity matrix
  42610. */
  42611. _getViewMatrix(): Matrix;
  42612. private _tmpMatrix;
  42613. /**
  42614. * This function is called by the two RIG cameras.
  42615. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42616. */
  42617. protected _getWebVRViewMatrix(): Matrix;
  42618. protected _getWebVRProjectionMatrix(): Matrix;
  42619. private _onGamepadConnectedObserver;
  42620. private _onGamepadDisconnectedObserver;
  42621. private _updateCacheWhenTrackingDisabledObserver;
  42622. /**
  42623. * Initializes the controllers and their meshes
  42624. */
  42625. initControllers(): void;
  42626. }
  42627. }
  42628. declare module BABYLON {
  42629. /**
  42630. * WebXR Camera which holds the views for the xrSession
  42631. * @see https://doc.babylonjs.com/how_to/webxr
  42632. */
  42633. class WebXRCamera extends FreeCamera {
  42634. /**
  42635. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42636. * @param name the name of the camera
  42637. * @param scene the scene to add the camera to
  42638. */
  42639. constructor(name: string, scene: BABYLON.Scene);
  42640. private _updateNumberOfRigCameras;
  42641. /** @hidden */
  42642. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42643. }
  42644. }
  42645. declare module BABYLON {
  42646. /** @hidden */
  42647. class _OcclusionDataStorage {
  42648. /** @hidden */
  42649. occlusionInternalRetryCounter: number;
  42650. /** @hidden */
  42651. isOcclusionQueryInProgress: boolean;
  42652. /** @hidden */
  42653. isOccluded: boolean;
  42654. /** @hidden */
  42655. occlusionRetryCount: number;
  42656. /** @hidden */
  42657. occlusionType: number;
  42658. /** @hidden */
  42659. occlusionQueryAlgorithmType: number;
  42660. }
  42661. interface Engine {
  42662. /**
  42663. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42664. * @return the new query
  42665. */
  42666. createQuery(): WebGLQuery;
  42667. /**
  42668. * Delete and release a webGL query
  42669. * @param query defines the query to delete
  42670. * @return the current engine
  42671. */
  42672. deleteQuery(query: WebGLQuery): Engine;
  42673. /**
  42674. * Check if a given query has resolved and got its value
  42675. * @param query defines the query to check
  42676. * @returns true if the query got its value
  42677. */
  42678. isQueryResultAvailable(query: WebGLQuery): boolean;
  42679. /**
  42680. * Gets the value of a given query
  42681. * @param query defines the query to check
  42682. * @returns the value of the query
  42683. */
  42684. getQueryResult(query: WebGLQuery): number;
  42685. /**
  42686. * Initiates an occlusion query
  42687. * @param algorithmType defines the algorithm to use
  42688. * @param query defines the query to use
  42689. * @returns the current engine
  42690. * @see http://doc.babylonjs.com/features/occlusionquery
  42691. */
  42692. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42693. /**
  42694. * Ends an occlusion query
  42695. * @see http://doc.babylonjs.com/features/occlusionquery
  42696. * @param algorithmType defines the algorithm to use
  42697. * @returns the current engine
  42698. */
  42699. endOcclusionQuery(algorithmType: number): Engine;
  42700. /**
  42701. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42702. * Please note that only one query can be issued at a time
  42703. * @returns a time token used to track the time span
  42704. */
  42705. startTimeQuery(): Nullable<_TimeToken>;
  42706. /**
  42707. * Ends a time query
  42708. * @param token defines the token used to measure the time span
  42709. * @returns the time spent (in ns)
  42710. */
  42711. endTimeQuery(token: _TimeToken): int;
  42712. /** @hidden */
  42713. _currentNonTimestampToken: Nullable<_TimeToken>;
  42714. /** @hidden */
  42715. _createTimeQuery(): WebGLQuery;
  42716. /** @hidden */
  42717. _deleteTimeQuery(query: WebGLQuery): void;
  42718. /** @hidden */
  42719. _getGlAlgorithmType(algorithmType: number): number;
  42720. /** @hidden */
  42721. _getTimeQueryResult(query: WebGLQuery): any;
  42722. /** @hidden */
  42723. _getTimeQueryAvailability(query: WebGLQuery): any;
  42724. }
  42725. interface AbstractMesh {
  42726. /**
  42727. * Backing filed
  42728. * @hidden
  42729. */
  42730. __occlusionDataStorage: _OcclusionDataStorage;
  42731. /**
  42732. * Access property
  42733. * @hidden
  42734. */
  42735. _occlusionDataStorage: _OcclusionDataStorage;
  42736. /**
  42737. * 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.
  42738. * The default value is -1 which means don't break the query and wait till the result
  42739. * @see http://doc.babylonjs.com/features/occlusionquery
  42740. */
  42741. occlusionRetryCount: number;
  42742. /**
  42743. * 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:
  42744. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42745. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42746. * * 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.
  42747. * @see http://doc.babylonjs.com/features/occlusionquery
  42748. */
  42749. occlusionType: number;
  42750. /**
  42751. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42752. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42753. * * 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.
  42754. * @see http://doc.babylonjs.com/features/occlusionquery
  42755. */
  42756. occlusionQueryAlgorithmType: number;
  42757. /**
  42758. * 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
  42759. * @see http://doc.babylonjs.com/features/occlusionquery
  42760. */
  42761. isOccluded: boolean;
  42762. /**
  42763. * Flag to check the progress status of the query
  42764. * @see http://doc.babylonjs.com/features/occlusionquery
  42765. */
  42766. isOcclusionQueryInProgress: boolean;
  42767. }
  42768. }
  42769. declare module BABYLON {
  42770. interface Engine {
  42771. /**
  42772. * Creates a webGL transform feedback object
  42773. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42774. * @returns the webGL transform feedback object
  42775. */
  42776. createTransformFeedback(): WebGLTransformFeedback;
  42777. /**
  42778. * Delete a webGL transform feedback object
  42779. * @param value defines the webGL transform feedback object to delete
  42780. */
  42781. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42782. /**
  42783. * Bind a webGL transform feedback object to the webgl context
  42784. * @param value defines the webGL transform feedback object to bind
  42785. */
  42786. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42787. /**
  42788. * Begins a transform feedback operation
  42789. * @param usePoints defines if points or triangles must be used
  42790. */
  42791. beginTransformFeedback(usePoints: boolean): void;
  42792. /**
  42793. * Ends a transform feedback operation
  42794. */
  42795. endTransformFeedback(): void;
  42796. /**
  42797. * Specify the varyings to use with transform feedback
  42798. * @param program defines the associated webGL program
  42799. * @param value defines the list of strings representing the varying names
  42800. */
  42801. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42802. /**
  42803. * Bind a webGL buffer for a transform feedback operation
  42804. * @param value defines the webGL buffer to bind
  42805. */
  42806. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42807. }
  42808. }
  42809. declare module BABYLON {
  42810. /**
  42811. * Google Daydream controller
  42812. */
  42813. class DaydreamController extends WebVRController {
  42814. /**
  42815. * Base Url for the controller model.
  42816. */
  42817. static MODEL_BASE_URL: string;
  42818. /**
  42819. * File name for the controller model.
  42820. */
  42821. static MODEL_FILENAME: string;
  42822. /**
  42823. * Gamepad Id prefix used to identify Daydream Controller.
  42824. */
  42825. static readonly GAMEPAD_ID_PREFIX: string;
  42826. /**
  42827. * Creates a new DaydreamController from a gamepad
  42828. * @param vrGamepad the gamepad that the controller should be created from
  42829. */
  42830. constructor(vrGamepad: any);
  42831. /**
  42832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42833. * @param scene scene in which to add meshes
  42834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42835. */
  42836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42837. /**
  42838. * Called once for each button that changed state since the last frame
  42839. * @param buttonIdx Which button index changed
  42840. * @param state New state of the button
  42841. * @param changes Which properties on the state changed since last frame
  42842. */
  42843. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42844. }
  42845. }
  42846. declare module BABYLON {
  42847. /**
  42848. * Gear VR Controller
  42849. */
  42850. class GearVRController extends WebVRController {
  42851. /**
  42852. * Base Url for the controller model.
  42853. */
  42854. static MODEL_BASE_URL: string;
  42855. /**
  42856. * File name for the controller model.
  42857. */
  42858. static MODEL_FILENAME: string;
  42859. /**
  42860. * Gamepad Id prefix used to identify this controller.
  42861. */
  42862. static readonly GAMEPAD_ID_PREFIX: string;
  42863. private readonly _buttonIndexToObservableNameMap;
  42864. /**
  42865. * Creates a new GearVRController from a gamepad
  42866. * @param vrGamepad the gamepad that the controller should be created from
  42867. */
  42868. constructor(vrGamepad: any);
  42869. /**
  42870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42871. * @param scene scene in which to add meshes
  42872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42873. */
  42874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42875. /**
  42876. * Called once for each button that changed state since the last frame
  42877. * @param buttonIdx Which button index changed
  42878. * @param state New state of the button
  42879. * @param changes Which properties on the state changed since last frame
  42880. */
  42881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42882. }
  42883. }
  42884. declare module BABYLON {
  42885. /**
  42886. * Generic Controller
  42887. */
  42888. class GenericController extends WebVRController {
  42889. /**
  42890. * Base Url for the controller model.
  42891. */
  42892. static readonly MODEL_BASE_URL: string;
  42893. /**
  42894. * File name for the controller model.
  42895. */
  42896. static readonly MODEL_FILENAME: string;
  42897. /**
  42898. * Creates a new GenericController from a gamepad
  42899. * @param vrGamepad the gamepad that the controller should be created from
  42900. */
  42901. constructor(vrGamepad: any);
  42902. /**
  42903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42904. * @param scene scene in which to add meshes
  42905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42906. */
  42907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42908. /**
  42909. * Called once for each button that changed state since the last frame
  42910. * @param buttonIdx Which button index changed
  42911. * @param state New state of the button
  42912. * @param changes Which properties on the state changed since last frame
  42913. */
  42914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42915. }
  42916. }
  42917. declare module BABYLON {
  42918. /**
  42919. * Oculus Touch Controller
  42920. */
  42921. class OculusTouchController extends WebVRController {
  42922. /**
  42923. * Base Url for the controller model.
  42924. */
  42925. static MODEL_BASE_URL: string;
  42926. /**
  42927. * File name for the left controller model.
  42928. */
  42929. static MODEL_LEFT_FILENAME: string;
  42930. /**
  42931. * File name for the right controller model.
  42932. */
  42933. static MODEL_RIGHT_FILENAME: string;
  42934. /**
  42935. * Fired when the secondary trigger on this controller is modified
  42936. */
  42937. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42938. /**
  42939. * Fired when the thumb rest on this controller is modified
  42940. */
  42941. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42942. /**
  42943. * Creates a new OculusTouchController from a gamepad
  42944. * @param vrGamepad the gamepad that the controller should be created from
  42945. */
  42946. constructor(vrGamepad: any);
  42947. /**
  42948. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42949. * @param scene scene in which to add meshes
  42950. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42951. */
  42952. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42953. /**
  42954. * Fired when the A button on this controller is modified
  42955. */
  42956. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42957. /**
  42958. * Fired when the B button on this controller is modified
  42959. */
  42960. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42961. /**
  42962. * Fired when the X button on this controller is modified
  42963. */
  42964. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42965. /**
  42966. * Fired when the Y button on this controller is modified
  42967. */
  42968. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42969. /**
  42970. * Called once for each button that changed state since the last frame
  42971. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42972. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42973. * 2) secondary trigger (same)
  42974. * 3) A (right) X (left), touch, pressed = value
  42975. * 4) B / Y
  42976. * 5) thumb rest
  42977. * @param buttonIdx Which button index changed
  42978. * @param state New state of the button
  42979. * @param changes Which properties on the state changed since last frame
  42980. */
  42981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42982. }
  42983. }
  42984. declare module BABYLON {
  42985. /**
  42986. * Defines the types of pose enabled controllers that are supported
  42987. */
  42988. enum PoseEnabledControllerType {
  42989. /**
  42990. * HTC Vive
  42991. */
  42992. VIVE = 0,
  42993. /**
  42994. * Oculus Rift
  42995. */
  42996. OCULUS = 1,
  42997. /**
  42998. * Windows mixed reality
  42999. */
  43000. WINDOWS = 2,
  43001. /**
  43002. * Samsung gear VR
  43003. */
  43004. GEAR_VR = 3,
  43005. /**
  43006. * Google Daydream
  43007. */
  43008. DAYDREAM = 4,
  43009. /**
  43010. * Generic
  43011. */
  43012. GENERIC = 5
  43013. }
  43014. /**
  43015. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43016. */
  43017. interface MutableGamepadButton {
  43018. /**
  43019. * Value of the button/trigger
  43020. */
  43021. value: number;
  43022. /**
  43023. * If the button/trigger is currently touched
  43024. */
  43025. touched: boolean;
  43026. /**
  43027. * If the button/trigger is currently pressed
  43028. */
  43029. pressed: boolean;
  43030. }
  43031. /**
  43032. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43033. * @hidden
  43034. */
  43035. interface ExtendedGamepadButton extends GamepadButton {
  43036. /**
  43037. * If the button/trigger is currently pressed
  43038. */
  43039. readonly pressed: boolean;
  43040. /**
  43041. * If the button/trigger is currently touched
  43042. */
  43043. readonly touched: boolean;
  43044. /**
  43045. * Value of the button/trigger
  43046. */
  43047. readonly value: number;
  43048. }
  43049. /**
  43050. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43051. */
  43052. class PoseEnabledControllerHelper {
  43053. /**
  43054. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43055. * @param vrGamepad the gamepad to initialized
  43056. * @returns a vr controller of the type the gamepad identified as
  43057. */
  43058. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43059. }
  43060. /**
  43061. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43062. */
  43063. class PoseEnabledController extends Gamepad implements PoseControlled {
  43064. private _deviceRoomPosition;
  43065. private _deviceRoomRotationQuaternion;
  43066. /**
  43067. * The device position in babylon space
  43068. */
  43069. devicePosition: Vector3;
  43070. /**
  43071. * The device rotation in babylon space
  43072. */
  43073. deviceRotationQuaternion: Quaternion;
  43074. /**
  43075. * The scale factor of the device in babylon space
  43076. */
  43077. deviceScaleFactor: number;
  43078. /**
  43079. * (Likely devicePosition should be used instead) The device position in its room space
  43080. */
  43081. position: Vector3;
  43082. /**
  43083. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43084. */
  43085. rotationQuaternion: Quaternion;
  43086. /**
  43087. * The type of controller (Eg. Windows mixed reality)
  43088. */
  43089. controllerType: PoseEnabledControllerType;
  43090. protected _calculatedPosition: Vector3;
  43091. private _calculatedRotation;
  43092. /**
  43093. * The raw pose from the device
  43094. */
  43095. rawPose: DevicePose;
  43096. private _trackPosition;
  43097. private _maxRotationDistFromHeadset;
  43098. private _draggedRoomRotation;
  43099. /**
  43100. * @hidden
  43101. */
  43102. _disableTrackPosition(fixedPosition: Vector3): void;
  43103. /**
  43104. * Internal, the mesh attached to the controller
  43105. * @hidden
  43106. */
  43107. _mesh: Nullable<AbstractMesh>;
  43108. private _poseControlledCamera;
  43109. private _leftHandSystemQuaternion;
  43110. /**
  43111. * Internal, matrix used to convert room space to babylon space
  43112. * @hidden
  43113. */
  43114. _deviceToWorld: Matrix;
  43115. /**
  43116. * Node to be used when casting a ray from the controller
  43117. * @hidden
  43118. */
  43119. _pointingPoseNode: Nullable<AbstractMesh>;
  43120. /**
  43121. * Name of the child mesh that can be used to cast a ray from the controller
  43122. */
  43123. static readonly POINTING_POSE: string;
  43124. /**
  43125. * Creates a new PoseEnabledController from a gamepad
  43126. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43127. */
  43128. constructor(browserGamepad: any);
  43129. private _workingMatrix;
  43130. /**
  43131. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43132. */
  43133. update(): void;
  43134. /**
  43135. * Updates only the pose device and mesh without doing any button event checking
  43136. */
  43137. protected _updatePoseAndMesh(): void;
  43138. /**
  43139. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43140. * @param poseData raw pose fromthe device
  43141. */
  43142. updateFromDevice(poseData: DevicePose): void;
  43143. /**
  43144. * @hidden
  43145. */
  43146. _meshAttachedObservable: Observable<AbstractMesh>;
  43147. /**
  43148. * Attaches a mesh to the controller
  43149. * @param mesh the mesh to be attached
  43150. */
  43151. attachToMesh(mesh: AbstractMesh): void;
  43152. /**
  43153. * Attaches the controllers mesh to a camera
  43154. * @param camera the camera the mesh should be attached to
  43155. */
  43156. attachToPoseControlledCamera(camera: TargetCamera): void;
  43157. /**
  43158. * Disposes of the controller
  43159. */
  43160. dispose(): void;
  43161. /**
  43162. * The mesh that is attached to the controller
  43163. */
  43164. readonly mesh: Nullable<AbstractMesh>;
  43165. /**
  43166. * Gets the ray of the controller in the direction the controller is pointing
  43167. * @param length the length the resulting ray should be
  43168. * @returns a ray in the direction the controller is pointing
  43169. */
  43170. getForwardRay(length?: number): Ray;
  43171. }
  43172. }
  43173. declare module BABYLON {
  43174. /**
  43175. * Vive Controller
  43176. */
  43177. class ViveController extends WebVRController {
  43178. /**
  43179. * Base Url for the controller model.
  43180. */
  43181. static MODEL_BASE_URL: string;
  43182. /**
  43183. * File name for the controller model.
  43184. */
  43185. static MODEL_FILENAME: string;
  43186. /**
  43187. * Creates a new ViveController from a gamepad
  43188. * @param vrGamepad the gamepad that the controller should be created from
  43189. */
  43190. constructor(vrGamepad: any);
  43191. /**
  43192. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43193. * @param scene scene in which to add meshes
  43194. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43195. */
  43196. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43197. /**
  43198. * Fired when the left button on this controller is modified
  43199. */
  43200. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43201. /**
  43202. * Fired when the right button on this controller is modified
  43203. */
  43204. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43205. /**
  43206. * Fired when the menu button on this controller is modified
  43207. */
  43208. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43209. /**
  43210. * Called once for each button that changed state since the last frame
  43211. * Vive mapping:
  43212. * 0: touchpad
  43213. * 1: trigger
  43214. * 2: left AND right buttons
  43215. * 3: menu button
  43216. * @param buttonIdx Which button index changed
  43217. * @param state New state of the button
  43218. * @param changes Which properties on the state changed since last frame
  43219. */
  43220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43221. }
  43222. }
  43223. declare module BABYLON {
  43224. /**
  43225. * Defines the WebVRController object that represents controllers tracked in 3D space
  43226. */
  43227. abstract class WebVRController extends PoseEnabledController {
  43228. /**
  43229. * Internal, the default controller model for the controller
  43230. */
  43231. protected _defaultModel: AbstractMesh;
  43232. /**
  43233. * Fired when the trigger state has changed
  43234. */
  43235. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43236. /**
  43237. * Fired when the main button state has changed
  43238. */
  43239. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43240. /**
  43241. * Fired when the secondary button state has changed
  43242. */
  43243. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43244. /**
  43245. * Fired when the pad state has changed
  43246. */
  43247. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43248. /**
  43249. * Fired when controllers stick values have changed
  43250. */
  43251. onPadValuesChangedObservable: Observable<StickValues>;
  43252. /**
  43253. * Array of button availible on the controller
  43254. */
  43255. protected _buttons: Array<MutableGamepadButton>;
  43256. private _onButtonStateChange;
  43257. /**
  43258. * Fired when a controller button's state has changed
  43259. * @param callback the callback containing the button that was modified
  43260. */
  43261. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43262. /**
  43263. * X and Y axis corrisponding to the controllers joystick
  43264. */
  43265. pad: StickValues;
  43266. /**
  43267. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43268. */
  43269. hand: string;
  43270. /**
  43271. * The default controller model for the controller
  43272. */
  43273. readonly defaultModel: AbstractMesh;
  43274. /**
  43275. * Creates a new WebVRController from a gamepad
  43276. * @param vrGamepad the gamepad that the WebVRController should be created from
  43277. */
  43278. constructor(vrGamepad: any);
  43279. /**
  43280. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43281. */
  43282. update(): void;
  43283. /**
  43284. * Function to be called when a button is modified
  43285. */
  43286. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43287. /**
  43288. * Loads a mesh and attaches it to the controller
  43289. * @param scene the scene the mesh should be added to
  43290. * @param meshLoaded callback for when the mesh has been loaded
  43291. */
  43292. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43293. private _setButtonValue;
  43294. private _changes;
  43295. private _checkChanges;
  43296. /**
  43297. * Disposes of th webVRCOntroller
  43298. */
  43299. dispose(): void;
  43300. }
  43301. }
  43302. declare module BABYLON {
  43303. /**
  43304. * Defines the WindowsMotionController object that the state of the windows motion controller
  43305. */
  43306. class WindowsMotionController extends WebVRController {
  43307. /**
  43308. * The base url used to load the left and right controller models
  43309. */
  43310. static MODEL_BASE_URL: string;
  43311. /**
  43312. * The name of the left controller model file
  43313. */
  43314. static MODEL_LEFT_FILENAME: string;
  43315. /**
  43316. * The name of the right controller model file
  43317. */
  43318. static MODEL_RIGHT_FILENAME: string;
  43319. /**
  43320. * The controller name prefix for this controller type
  43321. */
  43322. static readonly GAMEPAD_ID_PREFIX: string;
  43323. /**
  43324. * The controller id pattern for this controller type
  43325. */
  43326. private static readonly GAMEPAD_ID_PATTERN;
  43327. private _loadedMeshInfo;
  43328. private readonly _mapping;
  43329. /**
  43330. * Fired when the trackpad on this controller is clicked
  43331. */
  43332. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43333. /**
  43334. * Fired when the trackpad on this controller is modified
  43335. */
  43336. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43337. /**
  43338. * The current x and y values of this controller's trackpad
  43339. */
  43340. trackpad: StickValues;
  43341. /**
  43342. * Creates a new WindowsMotionController from a gamepad
  43343. * @param vrGamepad the gamepad that the controller should be created from
  43344. */
  43345. constructor(vrGamepad: any);
  43346. /**
  43347. * Fired when the trigger on this controller is modified
  43348. */
  43349. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43350. /**
  43351. * Fired when the menu button on this controller is modified
  43352. */
  43353. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43354. /**
  43355. * Fired when the grip button on this controller is modified
  43356. */
  43357. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43358. /**
  43359. * Fired when the thumbstick button on this controller is modified
  43360. */
  43361. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43362. /**
  43363. * Fired when the touchpad button on this controller is modified
  43364. */
  43365. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43366. /**
  43367. * Fired when the touchpad values on this controller are modified
  43368. */
  43369. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43370. private _updateTrackpad;
  43371. /**
  43372. * Called once per frame by the engine.
  43373. */
  43374. update(): void;
  43375. /**
  43376. * Called once for each button that changed state since the last frame
  43377. * @param buttonIdx Which button index changed
  43378. * @param state New state of the button
  43379. * @param changes Which properties on the state changed since last frame
  43380. */
  43381. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43382. /**
  43383. * Moves the buttons on the controller mesh based on their current state
  43384. * @param buttonName the name of the button to move
  43385. * @param buttonValue the value of the button which determines the buttons new position
  43386. */
  43387. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43388. /**
  43389. * Moves the axis on the controller mesh based on its current state
  43390. * @param axis the index of the axis
  43391. * @param axisValue the value of the axis which determines the meshes new position
  43392. * @hidden
  43393. */
  43394. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43395. /**
  43396. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43397. * @param scene scene in which to add meshes
  43398. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43399. */
  43400. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43401. /**
  43402. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43403. * can be transformed by button presses and axes values, based on this._mapping.
  43404. *
  43405. * @param scene scene in which the meshes exist
  43406. * @param meshes list of meshes that make up the controller model to process
  43407. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43408. */
  43409. private processModel;
  43410. private createMeshInfo;
  43411. /**
  43412. * Gets the ray of the controller in the direction the controller is pointing
  43413. * @param length the length the resulting ray should be
  43414. * @returns a ray in the direction the controller is pointing
  43415. */
  43416. getForwardRay(length?: number): Ray;
  43417. /**
  43418. * Disposes of the controller
  43419. */
  43420. dispose(): void;
  43421. }
  43422. }
  43423. declare module BABYLON {
  43424. /**
  43425. * Interface to implement to create a shadow generator compatible with BJS.
  43426. */
  43427. interface IShadowGenerator {
  43428. /**
  43429. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43430. * @returns The render target texture if present otherwise, null
  43431. */
  43432. getShadowMap(): Nullable<RenderTargetTexture>;
  43433. /**
  43434. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43435. * @returns The render target texture if the shadow map is present otherwise, null
  43436. */
  43437. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43438. /**
  43439. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43440. * @param subMesh The submesh we want to render in the shadow map
  43441. * @param useInstances Defines wether will draw in the map using instances
  43442. * @returns true if ready otherwise, false
  43443. */
  43444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43445. /**
  43446. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43447. * @param defines Defines of the material we want to update
  43448. * @param lightIndex Index of the light in the enabled light list of the material
  43449. */
  43450. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43451. /**
  43452. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43453. * defined in the generator but impacting the effect).
  43454. * It implies the unifroms available on the materials are the standard BJS ones.
  43455. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43456. * @param effect The effect we are binfing the information for
  43457. */
  43458. bindShadowLight(lightIndex: string, effect: Effect): void;
  43459. /**
  43460. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43461. * (eq to shadow prjection matrix * light transform matrix)
  43462. * @returns The transform matrix used to create the shadow map
  43463. */
  43464. getTransformMatrix(): Matrix;
  43465. /**
  43466. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43467. * Cube and 2D textures for instance.
  43468. */
  43469. recreateShadowMap(): void;
  43470. /**
  43471. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43472. * @param onCompiled Callback triggered at the and of the effects compilation
  43473. * @param options Sets of optional options forcing the compilation with different modes
  43474. */
  43475. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43476. useInstances: boolean;
  43477. }>): void;
  43478. /**
  43479. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43480. * @param options Sets of optional options forcing the compilation with different modes
  43481. * @returns A promise that resolves when the compilation completes
  43482. */
  43483. forceCompilationAsync(options?: Partial<{
  43484. useInstances: boolean;
  43485. }>): Promise<void>;
  43486. /**
  43487. * Serializes the shadow generator setup to a json object.
  43488. * @returns The serialized JSON object
  43489. */
  43490. serialize(): any;
  43491. /**
  43492. * Disposes the Shadow map and related Textures and effects.
  43493. */
  43494. dispose(): void;
  43495. }
  43496. /**
  43497. * Default implementation IShadowGenerator.
  43498. * This is the main object responsible of generating shadows in the framework.
  43499. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43500. */
  43501. class ShadowGenerator implements IShadowGenerator {
  43502. /**
  43503. * Shadow generator mode None: no filtering applied.
  43504. */
  43505. static readonly FILTER_NONE: number;
  43506. /**
  43507. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43508. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43509. */
  43510. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43511. /**
  43512. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43513. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43514. */
  43515. static readonly FILTER_POISSONSAMPLING: number;
  43516. /**
  43517. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43519. */
  43520. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43521. /**
  43522. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43523. * edge artifacts on steep falloff.
  43524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43525. */
  43526. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43527. /**
  43528. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43529. * edge artifacts on steep falloff.
  43530. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43531. */
  43532. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43533. /**
  43534. * Shadow generator mode PCF: Percentage Closer Filtering
  43535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43536. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43537. */
  43538. static readonly FILTER_PCF: number;
  43539. /**
  43540. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43541. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43542. * Contact Hardening
  43543. */
  43544. static readonly FILTER_PCSS: number;
  43545. /**
  43546. * Reserved for PCF and PCSS
  43547. * Highest Quality.
  43548. *
  43549. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43550. *
  43551. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43552. */
  43553. static readonly QUALITY_HIGH: number;
  43554. /**
  43555. * Reserved for PCF and PCSS
  43556. * Good tradeoff for quality/perf cross devices
  43557. *
  43558. * Execute PCF on a 3*3 kernel.
  43559. *
  43560. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43561. */
  43562. static readonly QUALITY_MEDIUM: number;
  43563. /**
  43564. * Reserved for PCF and PCSS
  43565. * The lowest quality but the fastest.
  43566. *
  43567. * Execute PCF on a 1*1 kernel.
  43568. *
  43569. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43570. */
  43571. static readonly QUALITY_LOW: number;
  43572. private _bias;
  43573. /**
  43574. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43575. */
  43576. /**
  43577. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43578. */
  43579. bias: number;
  43580. private _normalBias;
  43581. /**
  43582. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43583. */
  43584. /**
  43585. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43586. */
  43587. normalBias: number;
  43588. private _blurBoxOffset;
  43589. /**
  43590. * Gets the blur box offset: offset applied during the blur pass.
  43591. * Only usefull if useKernelBlur = false
  43592. */
  43593. /**
  43594. * Sets the blur box offset: offset applied during the blur pass.
  43595. * Only usefull if useKernelBlur = false
  43596. */
  43597. blurBoxOffset: number;
  43598. private _blurScale;
  43599. /**
  43600. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43601. * 2 means half of the size.
  43602. */
  43603. /**
  43604. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43605. * 2 means half of the size.
  43606. */
  43607. blurScale: number;
  43608. private _blurKernel;
  43609. /**
  43610. * Gets the blur kernel: kernel size of the blur pass.
  43611. * Only usefull if useKernelBlur = true
  43612. */
  43613. /**
  43614. * Sets the blur kernel: kernel size of the blur pass.
  43615. * Only usefull if useKernelBlur = true
  43616. */
  43617. blurKernel: number;
  43618. private _useKernelBlur;
  43619. /**
  43620. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43621. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43622. */
  43623. /**
  43624. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43625. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43626. */
  43627. useKernelBlur: boolean;
  43628. private _depthScale;
  43629. /**
  43630. * Gets the depth scale used in ESM mode.
  43631. */
  43632. /**
  43633. * Sets the depth scale used in ESM mode.
  43634. * This can override the scale stored on the light.
  43635. */
  43636. depthScale: number;
  43637. private _filter;
  43638. /**
  43639. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43640. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43641. */
  43642. /**
  43643. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43644. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43645. */
  43646. filter: number;
  43647. /**
  43648. * Gets if the current filter is set to Poisson Sampling.
  43649. */
  43650. /**
  43651. * Sets the current filter to Poisson Sampling.
  43652. */
  43653. usePoissonSampling: boolean;
  43654. /**
  43655. * Gets if the current filter is set to VSM.
  43656. * DEPRECATED. Should use useExponentialShadowMap instead.
  43657. */
  43658. /**
  43659. * Sets the current filter is to VSM.
  43660. * DEPRECATED. Should use useExponentialShadowMap instead.
  43661. */
  43662. useVarianceShadowMap: boolean;
  43663. /**
  43664. * Gets if the current filter is set to blurred VSM.
  43665. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43666. */
  43667. /**
  43668. * Sets the current filter is to blurred VSM.
  43669. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43670. */
  43671. useBlurVarianceShadowMap: boolean;
  43672. /**
  43673. * Gets if the current filter is set to ESM.
  43674. */
  43675. /**
  43676. * Sets the current filter is to ESM.
  43677. */
  43678. useExponentialShadowMap: boolean;
  43679. /**
  43680. * Gets if the current filter is set to filtered ESM.
  43681. */
  43682. /**
  43683. * Gets if the current filter is set to filtered ESM.
  43684. */
  43685. useBlurExponentialShadowMap: boolean;
  43686. /**
  43687. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43688. * exponential to prevent steep falloff artifacts).
  43689. */
  43690. /**
  43691. * Sets the current filter to "close ESM" (using the inverse of the
  43692. * exponential to prevent steep falloff artifacts).
  43693. */
  43694. useCloseExponentialShadowMap: boolean;
  43695. /**
  43696. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43697. * exponential to prevent steep falloff artifacts).
  43698. */
  43699. /**
  43700. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43701. * exponential to prevent steep falloff artifacts).
  43702. */
  43703. useBlurCloseExponentialShadowMap: boolean;
  43704. /**
  43705. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43706. */
  43707. /**
  43708. * Sets the current filter to "PCF" (percentage closer filtering).
  43709. */
  43710. usePercentageCloserFiltering: boolean;
  43711. private _filteringQuality;
  43712. /**
  43713. * Gets the PCF or PCSS Quality.
  43714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43715. */
  43716. /**
  43717. * Sets the PCF or PCSS Quality.
  43718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43719. */
  43720. filteringQuality: number;
  43721. /**
  43722. * Gets if the current filter is set to "PCSS" (contact hardening).
  43723. */
  43724. /**
  43725. * Sets the current filter to "PCSS" (contact hardening).
  43726. */
  43727. useContactHardeningShadow: boolean;
  43728. private _contactHardeningLightSizeUVRatio;
  43729. /**
  43730. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43731. * Using a ratio helps keeping shape stability independently of the map size.
  43732. *
  43733. * It does not account for the light projection as it was having too much
  43734. * instability during the light setup or during light position changes.
  43735. *
  43736. * Only valid if useContactHardeningShadow is true.
  43737. */
  43738. /**
  43739. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43740. * Using a ratio helps keeping shape stability independently of the map size.
  43741. *
  43742. * It does not account for the light projection as it was having too much
  43743. * instability during the light setup or during light position changes.
  43744. *
  43745. * Only valid if useContactHardeningShadow is true.
  43746. */
  43747. contactHardeningLightSizeUVRatio: number;
  43748. private _darkness;
  43749. /**
  43750. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43751. * 0 means strongest and 1 would means no shadow.
  43752. * @returns the darkness.
  43753. */
  43754. getDarkness(): number;
  43755. /**
  43756. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43757. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43758. * @returns the shadow generator allowing fluent coding.
  43759. */
  43760. setDarkness(darkness: number): ShadowGenerator;
  43761. private _transparencyShadow;
  43762. /**
  43763. * Sets the ability to have transparent shadow (boolean).
  43764. * @param transparent True if transparent else False
  43765. * @returns the shadow generator allowing fluent coding
  43766. */
  43767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43768. private _shadowMap;
  43769. private _shadowMap2;
  43770. /**
  43771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43772. * @returns The render target texture if present otherwise, null
  43773. */
  43774. getShadowMap(): Nullable<RenderTargetTexture>;
  43775. /**
  43776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43777. * @returns The render target texture if the shadow map is present otherwise, null
  43778. */
  43779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43780. /**
  43781. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43782. * @param mesh Mesh to add
  43783. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43784. * @returns the Shadow Generator itself
  43785. */
  43786. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43787. /**
  43788. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43789. * @param mesh Mesh to remove
  43790. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43791. * @returns the Shadow Generator itself
  43792. */
  43793. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43794. /**
  43795. * Controls the extent to which the shadows fade out at the edge of the frustum
  43796. * Used only by directionals and spots
  43797. */
  43798. frustumEdgeFalloff: number;
  43799. private _light;
  43800. /**
  43801. * Returns the associated light object.
  43802. * @returns the light generating the shadow
  43803. */
  43804. getLight(): IShadowLight;
  43805. /**
  43806. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43807. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43808. * It might on the other hand introduce peter panning.
  43809. */
  43810. forceBackFacesOnly: boolean;
  43811. private _scene;
  43812. private _lightDirection;
  43813. private _effect;
  43814. private _viewMatrix;
  43815. private _projectionMatrix;
  43816. private _transformMatrix;
  43817. private _cachedPosition;
  43818. private _cachedDirection;
  43819. private _cachedDefines;
  43820. private _currentRenderID;
  43821. private _boxBlurPostprocess;
  43822. private _kernelBlurXPostprocess;
  43823. private _kernelBlurYPostprocess;
  43824. private _blurPostProcesses;
  43825. private _mapSize;
  43826. private _currentFaceIndex;
  43827. private _currentFaceIndexCache;
  43828. private _textureType;
  43829. private _defaultTextureMatrix;
  43830. /**
  43831. * Creates a ShadowGenerator object.
  43832. * A ShadowGenerator is the required tool to use the shadows.
  43833. * Each light casting shadows needs to use its own ShadowGenerator.
  43834. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43835. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43836. * @param light The light object generating the shadows.
  43837. * @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.
  43838. */
  43839. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43840. private _initializeGenerator;
  43841. private _initializeShadowMap;
  43842. private _initializeBlurRTTAndPostProcesses;
  43843. private _renderForShadowMap;
  43844. private _renderSubMeshForShadowMap;
  43845. private _applyFilterValues;
  43846. /**
  43847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43848. * @param onCompiled Callback triggered at the and of the effects compilation
  43849. * @param options Sets of optional options forcing the compilation with different modes
  43850. */
  43851. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43852. useInstances: boolean;
  43853. }>): void;
  43854. /**
  43855. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43856. * @param options Sets of optional options forcing the compilation with different modes
  43857. * @returns A promise that resolves when the compilation completes
  43858. */
  43859. forceCompilationAsync(options?: Partial<{
  43860. useInstances: boolean;
  43861. }>): Promise<void>;
  43862. /**
  43863. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43864. * @param subMesh The submesh we want to render in the shadow map
  43865. * @param useInstances Defines wether will draw in the map using instances
  43866. * @returns true if ready otherwise, false
  43867. */
  43868. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43869. /**
  43870. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43871. * @param defines Defines of the material we want to update
  43872. * @param lightIndex Index of the light in the enabled light list of the material
  43873. */
  43874. prepareDefines(defines: any, lightIndex: number): void;
  43875. /**
  43876. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43877. * defined in the generator but impacting the effect).
  43878. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43879. * @param effect The effect we are binfing the information for
  43880. */
  43881. bindShadowLight(lightIndex: string, effect: Effect): void;
  43882. /**
  43883. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43884. * (eq to shadow prjection matrix * light transform matrix)
  43885. * @returns The transform matrix used to create the shadow map
  43886. */
  43887. getTransformMatrix(): Matrix;
  43888. /**
  43889. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43890. * Cube and 2D textures for instance.
  43891. */
  43892. recreateShadowMap(): void;
  43893. private _disposeBlurPostProcesses;
  43894. private _disposeRTTandPostProcesses;
  43895. /**
  43896. * Disposes the ShadowGenerator.
  43897. * Returns nothing.
  43898. */
  43899. dispose(): void;
  43900. /**
  43901. * Serializes the shadow generator setup to a json object.
  43902. * @returns The serialized JSON object
  43903. */
  43904. serialize(): any;
  43905. /**
  43906. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43907. * @param parsedShadowGenerator The JSON object to parse
  43908. * @param scene The scene to create the shadow map for
  43909. * @returns The parsed shadow generator
  43910. */
  43911. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43912. }
  43913. }
  43914. declare module BABYLON {
  43915. /**
  43916. * Defines the shadow generator component responsible to manage any shadow generators
  43917. * in a given scene.
  43918. */
  43919. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43920. /**
  43921. * The component name helpfull to identify the component in the list of scene components.
  43922. */
  43923. readonly name: string;
  43924. /**
  43925. * The scene the component belongs to.
  43926. */
  43927. scene: Scene;
  43928. /**
  43929. * Creates a new instance of the component for the given scene
  43930. * @param scene Defines the scene to register the component in
  43931. */
  43932. constructor(scene: Scene);
  43933. /**
  43934. * Registers the component in a given scene
  43935. */
  43936. register(): void;
  43937. /**
  43938. * Rebuilds the elements related to this component in case of
  43939. * context lost for instance.
  43940. */
  43941. rebuild(): void;
  43942. /**
  43943. * Serializes the component data to the specified json object
  43944. * @param serializationObject The object to serialize to
  43945. */
  43946. serialize(serializationObject: any): void;
  43947. /**
  43948. * Adds all the element from the container to the scene
  43949. * @param container the container holding the elements
  43950. */
  43951. addFromContainer(container: AbstractScene): void;
  43952. /**
  43953. * Removes all the elements in the container from the scene
  43954. * @param container contains the elements to remove
  43955. */
  43956. removeFromContainer(container: AbstractScene): void;
  43957. /**
  43958. * Rebuilds the elements related to this component in case of
  43959. * context lost for instance.
  43960. */
  43961. dispose(): void;
  43962. private _gatherRenderTargets;
  43963. }
  43964. }
  43965. declare module BABYLON {
  43966. }
  43967. declare module BABYLON {
  43968. /**
  43969. * Background material used to create an efficient environement around your scene.
  43970. */
  43971. class BackgroundMaterial extends PushMaterial {
  43972. /**
  43973. * Standard reflectance value at parallel view angle.
  43974. */
  43975. static StandardReflectance0: number;
  43976. /**
  43977. * Standard reflectance value at grazing angle.
  43978. */
  43979. static StandardReflectance90: number;
  43980. protected _primaryColor: Color3;
  43981. /**
  43982. * Key light Color (multiply against the environement texture)
  43983. */
  43984. primaryColor: Color3;
  43985. protected __perceptualColor: Nullable<Color3>;
  43986. /**
  43987. * Experimental Internal Use Only.
  43988. *
  43989. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43990. * This acts as a helper to set the primary color to a more "human friendly" value.
  43991. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43992. * output color as close as possible from the chosen value.
  43993. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43994. * part of lighting setup.)
  43995. */
  43996. _perceptualColor: Nullable<Color3>;
  43997. protected _primaryColorShadowLevel: float;
  43998. /**
  43999. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44000. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44001. */
  44002. primaryColorShadowLevel: float;
  44003. protected _primaryColorHighlightLevel: float;
  44004. /**
  44005. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44006. * The primary color is used at the level chosen to define what the white area would look.
  44007. */
  44008. primaryColorHighlightLevel: float;
  44009. protected _reflectionTexture: Nullable<BaseTexture>;
  44010. /**
  44011. * Reflection Texture used in the material.
  44012. * Should be author in a specific way for the best result (refer to the documentation).
  44013. */
  44014. reflectionTexture: Nullable<BaseTexture>;
  44015. protected _reflectionBlur: float;
  44016. /**
  44017. * Reflection Texture level of blur.
  44018. *
  44019. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44020. * texture twice.
  44021. */
  44022. reflectionBlur: float;
  44023. protected _diffuseTexture: Nullable<BaseTexture>;
  44024. /**
  44025. * Diffuse Texture used in the material.
  44026. * Should be author in a specific way for the best result (refer to the documentation).
  44027. */
  44028. diffuseTexture: Nullable<BaseTexture>;
  44029. protected _shadowLights: Nullable<IShadowLight[]>;
  44030. /**
  44031. * Specify the list of lights casting shadow on the material.
  44032. * All scene shadow lights will be included if null.
  44033. */
  44034. shadowLights: Nullable<IShadowLight[]>;
  44035. protected _shadowLevel: float;
  44036. /**
  44037. * Helps adjusting the shadow to a softer level if required.
  44038. * 0 means black shadows and 1 means no shadows.
  44039. */
  44040. shadowLevel: float;
  44041. protected _sceneCenter: Vector3;
  44042. /**
  44043. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44044. * It is usually zero but might be interesting to modify according to your setup.
  44045. */
  44046. sceneCenter: Vector3;
  44047. protected _opacityFresnel: boolean;
  44048. /**
  44049. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44050. * This helps ensuring a nice transition when the camera goes under the ground.
  44051. */
  44052. opacityFresnel: boolean;
  44053. protected _reflectionFresnel: boolean;
  44054. /**
  44055. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44056. * This helps adding a mirror texture on the ground.
  44057. */
  44058. reflectionFresnel: boolean;
  44059. protected _reflectionFalloffDistance: number;
  44060. /**
  44061. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44062. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44063. */
  44064. reflectionFalloffDistance: number;
  44065. protected _reflectionAmount: number;
  44066. /**
  44067. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44068. */
  44069. reflectionAmount: number;
  44070. protected _reflectionReflectance0: number;
  44071. /**
  44072. * This specifies the weight of the reflection at grazing angle.
  44073. */
  44074. reflectionReflectance0: number;
  44075. protected _reflectionReflectance90: number;
  44076. /**
  44077. * This specifies the weight of the reflection at a perpendicular point of view.
  44078. */
  44079. reflectionReflectance90: number;
  44080. /**
  44081. * Sets the reflection reflectance fresnel values according to the default standard
  44082. * empirically know to work well :-)
  44083. */
  44084. reflectionStandardFresnelWeight: number;
  44085. protected _useRGBColor: boolean;
  44086. /**
  44087. * Helps to directly use the maps channels instead of their level.
  44088. */
  44089. useRGBColor: boolean;
  44090. protected _enableNoise: boolean;
  44091. /**
  44092. * This helps reducing the banding effect that could occur on the background.
  44093. */
  44094. enableNoise: boolean;
  44095. /**
  44096. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44097. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44098. * Recommended to be keep at 1.0 except for special cases.
  44099. */
  44100. fovMultiplier: number;
  44101. private _fovMultiplier;
  44102. /**
  44103. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44104. */
  44105. useEquirectangularFOV: boolean;
  44106. private _maxSimultaneousLights;
  44107. /**
  44108. * Number of Simultaneous lights allowed on the material.
  44109. */
  44110. maxSimultaneousLights: int;
  44111. /**
  44112. * Default configuration related to image processing available in the Background Material.
  44113. */
  44114. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44115. /**
  44116. * Keep track of the image processing observer to allow dispose and replace.
  44117. */
  44118. private _imageProcessingObserver;
  44119. /**
  44120. * Attaches a new image processing configuration to the PBR Material.
  44121. * @param configuration (if null the scene configuration will be use)
  44122. */
  44123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44124. /**
  44125. * Gets the image processing configuration used either in this material.
  44126. */
  44127. /**
  44128. * Sets the Default image processing configuration used either in the this material.
  44129. *
  44130. * If sets to null, the scene one is in use.
  44131. */
  44132. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44133. /**
  44134. * Gets wether the color curves effect is enabled.
  44135. */
  44136. /**
  44137. * Sets wether the color curves effect is enabled.
  44138. */
  44139. cameraColorCurvesEnabled: boolean;
  44140. /**
  44141. * Gets wether the color grading effect is enabled.
  44142. */
  44143. /**
  44144. * Gets wether the color grading effect is enabled.
  44145. */
  44146. cameraColorGradingEnabled: boolean;
  44147. /**
  44148. * Gets wether tonemapping is enabled or not.
  44149. */
  44150. /**
  44151. * Sets wether tonemapping is enabled or not
  44152. */
  44153. cameraToneMappingEnabled: boolean;
  44154. /**
  44155. * The camera exposure used on this material.
  44156. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44157. * This corresponds to a photographic exposure.
  44158. */
  44159. /**
  44160. * The camera exposure used on this material.
  44161. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44162. * This corresponds to a photographic exposure.
  44163. */
  44164. cameraExposure: float;
  44165. /**
  44166. * Gets The camera contrast used on this material.
  44167. */
  44168. /**
  44169. * Sets The camera contrast used on this material.
  44170. */
  44171. cameraContrast: float;
  44172. /**
  44173. * Gets the Color Grading 2D Lookup Texture.
  44174. */
  44175. /**
  44176. * Sets the Color Grading 2D Lookup Texture.
  44177. */
  44178. cameraColorGradingTexture: Nullable<BaseTexture>;
  44179. /**
  44180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44182. * 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;
  44183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44184. */
  44185. /**
  44186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44188. * 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;
  44189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44190. */
  44191. cameraColorCurves: Nullable<ColorCurves>;
  44192. /**
  44193. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44194. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44195. */
  44196. switchToBGR: boolean;
  44197. private _renderTargets;
  44198. private _reflectionControls;
  44199. private _white;
  44200. private _primaryShadowColor;
  44201. private _primaryHighlightColor;
  44202. /**
  44203. * Instantiates a Background Material in the given scene
  44204. * @param name The friendly name of the material
  44205. * @param scene The scene to add the material to
  44206. */
  44207. constructor(name: string, scene: Scene);
  44208. /**
  44209. * Gets a boolean indicating that current material needs to register RTT
  44210. */
  44211. readonly hasRenderTargetTextures: boolean;
  44212. /**
  44213. * The entire material has been created in order to prevent overdraw.
  44214. * @returns false
  44215. */
  44216. needAlphaTesting(): boolean;
  44217. /**
  44218. * The entire material has been created in order to prevent overdraw.
  44219. * @returns true if blending is enable
  44220. */
  44221. needAlphaBlending(): boolean;
  44222. /**
  44223. * Checks wether the material is ready to be rendered for a given mesh.
  44224. * @param mesh The mesh to render
  44225. * @param subMesh The submesh to check against
  44226. * @param useInstances Specify wether or not the material is used with instances
  44227. * @returns true if all the dependencies are ready (Textures, Effects...)
  44228. */
  44229. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44230. /**
  44231. * Compute the primary color according to the chosen perceptual color.
  44232. */
  44233. private _computePrimaryColorFromPerceptualColor;
  44234. /**
  44235. * Compute the highlights and shadow colors according to their chosen levels.
  44236. */
  44237. private _computePrimaryColors;
  44238. /**
  44239. * Build the uniform buffer used in the material.
  44240. */
  44241. buildUniformLayout(): void;
  44242. /**
  44243. * Unbind the material.
  44244. */
  44245. unbind(): void;
  44246. /**
  44247. * Bind only the world matrix to the material.
  44248. * @param world The world matrix to bind.
  44249. */
  44250. bindOnlyWorldMatrix(world: Matrix): void;
  44251. /**
  44252. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44253. * @param world The world matrix to bind.
  44254. * @param subMesh The submesh to bind for.
  44255. */
  44256. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44257. /**
  44258. * Dispose the material.
  44259. * @param forceDisposeEffect Force disposal of the associated effect.
  44260. * @param forceDisposeTextures Force disposal of the associated textures.
  44261. */
  44262. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44263. /**
  44264. * Clones the material.
  44265. * @param name The cloned name.
  44266. * @returns The cloned material.
  44267. */
  44268. clone(name: string): BackgroundMaterial;
  44269. /**
  44270. * Serializes the current material to its JSON representation.
  44271. * @returns The JSON representation.
  44272. */
  44273. serialize(): any;
  44274. /**
  44275. * Gets the class name of the material
  44276. * @returns "BackgroundMaterial"
  44277. */
  44278. getClassName(): string;
  44279. /**
  44280. * Parse a JSON input to create back a background material.
  44281. * @param source The JSON data to parse
  44282. * @param scene The scene to create the parsed material in
  44283. * @param rootUrl The root url of the assets the material depends upon
  44284. * @returns the instantiated BackgroundMaterial.
  44285. */
  44286. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44287. }
  44288. }
  44289. declare module BABYLON {
  44290. /**
  44291. * The Physically based material base class of BJS.
  44292. *
  44293. * This offers the main features of a standard PBR material.
  44294. * For more information, please refer to the documentation :
  44295. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44296. */
  44297. abstract class PBRBaseMaterial extends PushMaterial {
  44298. /**
  44299. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44300. */
  44301. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44302. /**
  44303. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44304. * to enhance interoperability with other engines.
  44305. */
  44306. static readonly LIGHTFALLOFF_GLTF: number;
  44307. /**
  44308. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44309. * to enhance interoperability with other materials.
  44310. */
  44311. static readonly LIGHTFALLOFF_STANDARD: number;
  44312. /**
  44313. * Intensity of the direct lights e.g. the four lights available in your scene.
  44314. * This impacts both the direct diffuse and specular highlights.
  44315. */
  44316. protected _directIntensity: number;
  44317. /**
  44318. * Intensity of the emissive part of the material.
  44319. * This helps controlling the emissive effect without modifying the emissive color.
  44320. */
  44321. protected _emissiveIntensity: number;
  44322. /**
  44323. * Intensity of the environment e.g. how much the environment will light the object
  44324. * either through harmonics for rough material or through the refelction for shiny ones.
  44325. */
  44326. protected _environmentIntensity: number;
  44327. /**
  44328. * This is a special control allowing the reduction of the specular highlights coming from the
  44329. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44330. */
  44331. protected _specularIntensity: number;
  44332. /**
  44333. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44334. */
  44335. private _lightingInfos;
  44336. /**
  44337. * Debug Control allowing disabling the bump map on this material.
  44338. */
  44339. protected _disableBumpMap: boolean;
  44340. /**
  44341. * AKA Diffuse Texture in standard nomenclature.
  44342. */
  44343. protected _albedoTexture: BaseTexture;
  44344. /**
  44345. * AKA Occlusion Texture in other nomenclature.
  44346. */
  44347. protected _ambientTexture: BaseTexture;
  44348. /**
  44349. * AKA Occlusion Texture Intensity in other nomenclature.
  44350. */
  44351. protected _ambientTextureStrength: number;
  44352. /**
  44353. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44354. * 1 means it completely occludes it
  44355. * 0 mean it has no impact
  44356. */
  44357. protected _ambientTextureImpactOnAnalyticalLights: number;
  44358. /**
  44359. * Stores the alpha values in a texture.
  44360. */
  44361. protected _opacityTexture: BaseTexture;
  44362. /**
  44363. * Stores the reflection values in a texture.
  44364. */
  44365. protected _reflectionTexture: BaseTexture;
  44366. /**
  44367. * Stores the refraction values in a texture.
  44368. */
  44369. protected _refractionTexture: BaseTexture;
  44370. /**
  44371. * Stores the emissive values in a texture.
  44372. */
  44373. protected _emissiveTexture: BaseTexture;
  44374. /**
  44375. * AKA Specular texture in other nomenclature.
  44376. */
  44377. protected _reflectivityTexture: BaseTexture;
  44378. /**
  44379. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44380. */
  44381. protected _metallicTexture: BaseTexture;
  44382. /**
  44383. * Specifies the metallic scalar of the metallic/roughness workflow.
  44384. * Can also be used to scale the metalness values of the metallic texture.
  44385. */
  44386. protected _metallic: Nullable<number>;
  44387. /**
  44388. * Specifies the roughness scalar of the metallic/roughness workflow.
  44389. * Can also be used to scale the roughness values of the metallic texture.
  44390. */
  44391. protected _roughness: Nullable<number>;
  44392. /**
  44393. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44394. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44395. */
  44396. protected _microSurfaceTexture: BaseTexture;
  44397. /**
  44398. * Stores surface normal data used to displace a mesh in a texture.
  44399. */
  44400. protected _bumpTexture: BaseTexture;
  44401. /**
  44402. * Stores the pre-calculated light information of a mesh in a texture.
  44403. */
  44404. protected _lightmapTexture: BaseTexture;
  44405. /**
  44406. * The color of a material in ambient lighting.
  44407. */
  44408. protected _ambientColor: Color3;
  44409. /**
  44410. * AKA Diffuse Color in other nomenclature.
  44411. */
  44412. protected _albedoColor: Color3;
  44413. /**
  44414. * AKA Specular Color in other nomenclature.
  44415. */
  44416. protected _reflectivityColor: Color3;
  44417. /**
  44418. * The color applied when light is reflected from a material.
  44419. */
  44420. protected _reflectionColor: Color3;
  44421. /**
  44422. * The color applied when light is emitted from a material.
  44423. */
  44424. protected _emissiveColor: Color3;
  44425. /**
  44426. * AKA Glossiness in other nomenclature.
  44427. */
  44428. protected _microSurface: number;
  44429. /**
  44430. * source material index of refraction (IOR)' / 'destination material IOR.
  44431. */
  44432. protected _indexOfRefraction: number;
  44433. /**
  44434. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44435. */
  44436. protected _invertRefractionY: boolean;
  44437. /**
  44438. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44439. * Materials half opaque for instance using refraction could benefit from this control.
  44440. */
  44441. protected _linkRefractionWithTransparency: boolean;
  44442. /**
  44443. * Specifies that the material will use the light map as a show map.
  44444. */
  44445. protected _useLightmapAsShadowmap: boolean;
  44446. /**
  44447. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44448. * makes the reflect vector face the model (under horizon).
  44449. */
  44450. protected _useHorizonOcclusion: boolean;
  44451. /**
  44452. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44453. * too much the area relying on ambient texture to define their ambient occlusion.
  44454. */
  44455. protected _useRadianceOcclusion: boolean;
  44456. /**
  44457. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44458. */
  44459. protected _useAlphaFromAlbedoTexture: boolean;
  44460. /**
  44461. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44462. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44463. */
  44464. protected _useSpecularOverAlpha: boolean;
  44465. /**
  44466. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44467. */
  44468. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44469. /**
  44470. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44471. */
  44472. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44473. /**
  44474. * Specifies if the metallic texture contains the roughness information in its green channel.
  44475. */
  44476. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44477. /**
  44478. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44479. */
  44480. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44481. /**
  44482. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44483. */
  44484. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44485. /**
  44486. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44487. */
  44488. protected _useAmbientInGrayScale: boolean;
  44489. /**
  44490. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44491. * The material will try to infer what glossiness each pixel should be.
  44492. */
  44493. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44494. /**
  44495. * Defines the falloff type used in this material.
  44496. * It by default is Physical.
  44497. */
  44498. protected _lightFalloff: number;
  44499. /**
  44500. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44501. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44502. */
  44503. protected _useRadianceOverAlpha: boolean;
  44504. /**
  44505. * Allows using an object space normal map (instead of tangent space).
  44506. */
  44507. protected _useObjectSpaceNormalMap: boolean;
  44508. /**
  44509. * Allows using the bump map in parallax mode.
  44510. */
  44511. protected _useParallax: boolean;
  44512. /**
  44513. * Allows using the bump map in parallax occlusion mode.
  44514. */
  44515. protected _useParallaxOcclusion: boolean;
  44516. /**
  44517. * Controls the scale bias of the parallax mode.
  44518. */
  44519. protected _parallaxScaleBias: number;
  44520. /**
  44521. * If sets to true, disables all the lights affecting the material.
  44522. */
  44523. protected _disableLighting: boolean;
  44524. /**
  44525. * Number of Simultaneous lights allowed on the material.
  44526. */
  44527. protected _maxSimultaneousLights: number;
  44528. /**
  44529. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44530. */
  44531. protected _invertNormalMapX: boolean;
  44532. /**
  44533. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44534. */
  44535. protected _invertNormalMapY: boolean;
  44536. /**
  44537. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44538. */
  44539. protected _twoSidedLighting: boolean;
  44540. /**
  44541. * Defines the alpha limits in alpha test mode.
  44542. */
  44543. protected _alphaCutOff: number;
  44544. /**
  44545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44546. */
  44547. protected _forceAlphaTest: boolean;
  44548. /**
  44549. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44550. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44551. */
  44552. protected _useAlphaFresnel: boolean;
  44553. /**
  44554. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44555. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44556. */
  44557. protected _useLinearAlphaFresnel: boolean;
  44558. /**
  44559. * The transparency mode of the material.
  44560. */
  44561. protected _transparencyMode: Nullable<number>;
  44562. /**
  44563. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44564. * from cos thetav and roughness:
  44565. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44566. */
  44567. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44568. /**
  44569. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44570. */
  44571. protected _forceIrradianceInFragment: boolean;
  44572. /**
  44573. * Force normal to face away from face.
  44574. */
  44575. protected _forceNormalForward: boolean;
  44576. /**
  44577. * Enables specular anti aliasing in the PBR shader.
  44578. * It will both interacts on the Geometry for analytical and IBL lighting.
  44579. * It also prefilter the roughness map based on the bump values.
  44580. */
  44581. protected _enableSpecularAntiAliasing: boolean;
  44582. /**
  44583. * Default configuration related to image processing available in the PBR Material.
  44584. */
  44585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44586. /**
  44587. * Keep track of the image processing observer to allow dispose and replace.
  44588. */
  44589. private _imageProcessingObserver;
  44590. /**
  44591. * Attaches a new image processing configuration to the PBR Material.
  44592. * @param configuration
  44593. */
  44594. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44595. /**
  44596. * Stores the available render targets.
  44597. */
  44598. private _renderTargets;
  44599. /**
  44600. * Sets the global ambient color for the material used in lighting calculations.
  44601. */
  44602. private _globalAmbientColor;
  44603. /**
  44604. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44605. */
  44606. private _useLogarithmicDepth;
  44607. /**
  44608. * If set to true, no lighting calculations will be applied.
  44609. */
  44610. private _unlit;
  44611. /**
  44612. * Instantiates a new PBRMaterial instance.
  44613. *
  44614. * @param name The material name
  44615. * @param scene The scene the material will be use in.
  44616. */
  44617. constructor(name: string, scene: Scene);
  44618. /**
  44619. * Gets a boolean indicating that current material needs to register RTT
  44620. */
  44621. readonly hasRenderTargetTextures: boolean;
  44622. /**
  44623. * Gets the name of the material class.
  44624. */
  44625. getClassName(): string;
  44626. /**
  44627. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44628. */
  44629. /**
  44630. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44631. */
  44632. useLogarithmicDepth: boolean;
  44633. /**
  44634. * Gets the current transparency mode.
  44635. */
  44636. /**
  44637. * Sets the transparency mode of the material.
  44638. *
  44639. * | Value | Type | Description |
  44640. * | ----- | ----------------------------------- | ----------- |
  44641. * | 0 | OPAQUE | |
  44642. * | 1 | ALPHATEST | |
  44643. * | 2 | ALPHABLEND | |
  44644. * | 3 | ALPHATESTANDBLEND | |
  44645. *
  44646. */
  44647. transparencyMode: Nullable<number>;
  44648. /**
  44649. * Returns true if alpha blending should be disabled.
  44650. */
  44651. private readonly _disableAlphaBlending;
  44652. /**
  44653. * Specifies whether or not this material should be rendered in alpha blend mode.
  44654. */
  44655. needAlphaBlending(): boolean;
  44656. /**
  44657. * Specifies if the mesh will require alpha blending.
  44658. * @param mesh - BJS mesh.
  44659. */
  44660. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44661. /**
  44662. * Specifies whether or not this material should be rendered in alpha test mode.
  44663. */
  44664. needAlphaTesting(): boolean;
  44665. /**
  44666. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44667. */
  44668. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44669. /**
  44670. * Gets the texture used for the alpha test.
  44671. */
  44672. getAlphaTestTexture(): BaseTexture;
  44673. /**
  44674. * Stores the reflectivity values based on metallic roughness workflow.
  44675. */
  44676. private static _scaledReflectivity;
  44677. /**
  44678. * Specifies that the submesh is ready to be used.
  44679. * @param mesh - BJS mesh.
  44680. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44681. * @param useInstances - Specifies that instances should be used.
  44682. * @returns - boolean indicating that the submesh is ready or not.
  44683. */
  44684. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44685. /**
  44686. * Specifies if the material uses metallic roughness workflow.
  44687. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44688. */
  44689. isMetallicWorkflow(): boolean;
  44690. private _prepareEffect;
  44691. private _prepareDefines;
  44692. /**
  44693. * Force shader compilation
  44694. */
  44695. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44696. clipPlane: boolean;
  44697. }>): void;
  44698. /**
  44699. * Initializes the uniform buffer layout for the shader.
  44700. */
  44701. buildUniformLayout(): void;
  44702. /**
  44703. * Unbinds the textures.
  44704. */
  44705. unbind(): void;
  44706. /**
  44707. * Binds the submesh data.
  44708. * @param world - The world matrix.
  44709. * @param mesh - The BJS mesh.
  44710. * @param subMesh - A submesh of the BJS mesh.
  44711. */
  44712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44713. /**
  44714. * Returns the animatable textures.
  44715. * @returns - Array of animatable textures.
  44716. */
  44717. getAnimatables(): IAnimatable[];
  44718. /**
  44719. * Returns the texture used for reflections.
  44720. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44721. */
  44722. private _getReflectionTexture;
  44723. /**
  44724. * Returns the texture used for refraction or null if none is used.
  44725. * @returns - Refection texture if present. If no refraction texture and refraction
  44726. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44727. */
  44728. private _getRefractionTexture;
  44729. /**
  44730. * Disposes the resources of the material.
  44731. * @param forceDisposeEffect - Forces the disposal of effects.
  44732. * @param forceDisposeTextures - Forces the disposal of all textures.
  44733. */
  44734. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /**
  44739. * The Physically based simple base material of BJS.
  44740. *
  44741. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44742. * It is used as the base class for both the specGloss and metalRough conventions.
  44743. */
  44744. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44745. /**
  44746. * Number of Simultaneous lights allowed on the material.
  44747. */
  44748. maxSimultaneousLights: number;
  44749. /**
  44750. * If sets to true, disables all the lights affecting the material.
  44751. */
  44752. disableLighting: boolean;
  44753. /**
  44754. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44755. */
  44756. environmentTexture: BaseTexture;
  44757. /**
  44758. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44759. */
  44760. invertNormalMapX: boolean;
  44761. /**
  44762. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44763. */
  44764. invertNormalMapY: boolean;
  44765. /**
  44766. * Normal map used in the model.
  44767. */
  44768. normalTexture: BaseTexture;
  44769. /**
  44770. * Emissivie color used to self-illuminate the model.
  44771. */
  44772. emissiveColor: Color3;
  44773. /**
  44774. * Emissivie texture used to self-illuminate the model.
  44775. */
  44776. emissiveTexture: BaseTexture;
  44777. /**
  44778. * Occlusion Channel Strenght.
  44779. */
  44780. occlusionStrength: number;
  44781. /**
  44782. * Occlusion Texture of the material (adding extra occlusion effects).
  44783. */
  44784. occlusionTexture: BaseTexture;
  44785. /**
  44786. * Defines the alpha limits in alpha test mode.
  44787. */
  44788. alphaCutOff: number;
  44789. /**
  44790. * Gets the current double sided mode.
  44791. */
  44792. /**
  44793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44794. */
  44795. doubleSided: boolean;
  44796. /**
  44797. * Stores the pre-calculated light information of a mesh in a texture.
  44798. */
  44799. lightmapTexture: BaseTexture;
  44800. /**
  44801. * If true, the light map contains occlusion information instead of lighting info.
  44802. */
  44803. useLightmapAsShadowmap: boolean;
  44804. /**
  44805. * Return the active textures of the material.
  44806. */
  44807. getActiveTextures(): BaseTexture[];
  44808. hasTexture(texture: BaseTexture): boolean;
  44809. /**
  44810. * Instantiates a new PBRMaterial instance.
  44811. *
  44812. * @param name The material name
  44813. * @param scene The scene the material will be use in.
  44814. */
  44815. constructor(name: string, scene: Scene);
  44816. getClassName(): string;
  44817. }
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * The Physically based material of BJS.
  44822. *
  44823. * This offers the main features of a standard PBR material.
  44824. * For more information, please refer to the documentation :
  44825. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44826. */
  44827. class PBRMaterial extends PBRBaseMaterial {
  44828. /**
  44829. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44830. */
  44831. static readonly PBRMATERIAL_OPAQUE: number;
  44832. /**
  44833. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44834. */
  44835. static readonly PBRMATERIAL_ALPHATEST: number;
  44836. /**
  44837. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44838. */
  44839. static readonly PBRMATERIAL_ALPHABLEND: number;
  44840. /**
  44841. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44842. * They are also discarded below the alpha cutoff threshold to improve performances.
  44843. */
  44844. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44845. /**
  44846. * Defines the default value of how much AO map is occluding the analytical lights
  44847. * (point spot...).
  44848. */
  44849. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44850. /**
  44851. * Intensity of the direct lights e.g. the four lights available in your scene.
  44852. * This impacts both the direct diffuse and specular highlights.
  44853. */
  44854. directIntensity: number;
  44855. /**
  44856. * Intensity of the emissive part of the material.
  44857. * This helps controlling the emissive effect without modifying the emissive color.
  44858. */
  44859. emissiveIntensity: number;
  44860. /**
  44861. * Intensity of the environment e.g. how much the environment will light the object
  44862. * either through harmonics for rough material or through the refelction for shiny ones.
  44863. */
  44864. environmentIntensity: number;
  44865. /**
  44866. * This is a special control allowing the reduction of the specular highlights coming from the
  44867. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44868. */
  44869. specularIntensity: number;
  44870. /**
  44871. * Debug Control allowing disabling the bump map on this material.
  44872. */
  44873. disableBumpMap: boolean;
  44874. /**
  44875. * AKA Diffuse Texture in standard nomenclature.
  44876. */
  44877. albedoTexture: BaseTexture;
  44878. /**
  44879. * AKA Occlusion Texture in other nomenclature.
  44880. */
  44881. ambientTexture: BaseTexture;
  44882. /**
  44883. * AKA Occlusion Texture Intensity in other nomenclature.
  44884. */
  44885. ambientTextureStrength: number;
  44886. /**
  44887. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44888. * 1 means it completely occludes it
  44889. * 0 mean it has no impact
  44890. */
  44891. ambientTextureImpactOnAnalyticalLights: number;
  44892. /**
  44893. * Stores the alpha values in a texture.
  44894. */
  44895. opacityTexture: BaseTexture;
  44896. /**
  44897. * Stores the reflection values in a texture.
  44898. */
  44899. reflectionTexture: Nullable<BaseTexture>;
  44900. /**
  44901. * Stores the emissive values in a texture.
  44902. */
  44903. emissiveTexture: BaseTexture;
  44904. /**
  44905. * AKA Specular texture in other nomenclature.
  44906. */
  44907. reflectivityTexture: BaseTexture;
  44908. /**
  44909. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44910. */
  44911. metallicTexture: BaseTexture;
  44912. /**
  44913. * Specifies the metallic scalar of the metallic/roughness workflow.
  44914. * Can also be used to scale the metalness values of the metallic texture.
  44915. */
  44916. metallic: Nullable<number>;
  44917. /**
  44918. * Specifies the roughness scalar of the metallic/roughness workflow.
  44919. * Can also be used to scale the roughness values of the metallic texture.
  44920. */
  44921. roughness: Nullable<number>;
  44922. /**
  44923. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44924. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44925. */
  44926. microSurfaceTexture: BaseTexture;
  44927. /**
  44928. * Stores surface normal data used to displace a mesh in a texture.
  44929. */
  44930. bumpTexture: BaseTexture;
  44931. /**
  44932. * Stores the pre-calculated light information of a mesh in a texture.
  44933. */
  44934. lightmapTexture: BaseTexture;
  44935. /**
  44936. * Stores the refracted light information in a texture.
  44937. */
  44938. refractionTexture: BaseTexture;
  44939. /**
  44940. * The color of a material in ambient lighting.
  44941. */
  44942. ambientColor: Color3;
  44943. /**
  44944. * AKA Diffuse Color in other nomenclature.
  44945. */
  44946. albedoColor: Color3;
  44947. /**
  44948. * AKA Specular Color in other nomenclature.
  44949. */
  44950. reflectivityColor: Color3;
  44951. /**
  44952. * The color reflected from the material.
  44953. */
  44954. reflectionColor: Color3;
  44955. /**
  44956. * The color emitted from the material.
  44957. */
  44958. emissiveColor: Color3;
  44959. /**
  44960. * AKA Glossiness in other nomenclature.
  44961. */
  44962. microSurface: number;
  44963. /**
  44964. * source material index of refraction (IOR)' / 'destination material IOR.
  44965. */
  44966. indexOfRefraction: number;
  44967. /**
  44968. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44969. */
  44970. invertRefractionY: boolean;
  44971. /**
  44972. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44973. * Materials half opaque for instance using refraction could benefit from this control.
  44974. */
  44975. linkRefractionWithTransparency: boolean;
  44976. /**
  44977. * If true, the light map contains occlusion information instead of lighting info.
  44978. */
  44979. useLightmapAsShadowmap: boolean;
  44980. /**
  44981. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44982. */
  44983. useAlphaFromAlbedoTexture: boolean;
  44984. /**
  44985. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44986. */
  44987. forceAlphaTest: boolean;
  44988. /**
  44989. * Defines the alpha limits in alpha test mode.
  44990. */
  44991. alphaCutOff: number;
  44992. /**
  44993. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44994. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44995. */
  44996. useSpecularOverAlpha: boolean;
  44997. /**
  44998. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44999. */
  45000. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45001. /**
  45002. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45003. */
  45004. useRoughnessFromMetallicTextureAlpha: boolean;
  45005. /**
  45006. * Specifies if the metallic texture contains the roughness information in its green channel.
  45007. */
  45008. useRoughnessFromMetallicTextureGreen: boolean;
  45009. /**
  45010. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45011. */
  45012. useMetallnessFromMetallicTextureBlue: boolean;
  45013. /**
  45014. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45015. */
  45016. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45017. /**
  45018. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45019. */
  45020. useAmbientInGrayScale: boolean;
  45021. /**
  45022. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45023. * The material will try to infer what glossiness each pixel should be.
  45024. */
  45025. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45026. /**
  45027. * BJS is using an harcoded light falloff based on a manually sets up range.
  45028. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45029. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45030. */
  45031. /**
  45032. * BJS is using an harcoded light falloff based on a manually sets up range.
  45033. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45034. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45035. */
  45036. usePhysicalLightFalloff: boolean;
  45037. /**
  45038. * In order to support the falloff compatibility with gltf, a special mode has been added
  45039. * to reproduce the gltf light falloff.
  45040. */
  45041. /**
  45042. * In order to support the falloff compatibility with gltf, a special mode has been added
  45043. * to reproduce the gltf light falloff.
  45044. */
  45045. useGLTFLightFalloff: boolean;
  45046. /**
  45047. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45048. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45049. */
  45050. useRadianceOverAlpha: boolean;
  45051. /**
  45052. * Allows using an object space normal map (instead of tangent space).
  45053. */
  45054. useObjectSpaceNormalMap: boolean;
  45055. /**
  45056. * Allows using the bump map in parallax mode.
  45057. */
  45058. useParallax: boolean;
  45059. /**
  45060. * Allows using the bump map in parallax occlusion mode.
  45061. */
  45062. useParallaxOcclusion: boolean;
  45063. /**
  45064. * Controls the scale bias of the parallax mode.
  45065. */
  45066. parallaxScaleBias: number;
  45067. /**
  45068. * If sets to true, disables all the lights affecting the material.
  45069. */
  45070. disableLighting: boolean;
  45071. /**
  45072. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45073. */
  45074. forceIrradianceInFragment: boolean;
  45075. /**
  45076. * Number of Simultaneous lights allowed on the material.
  45077. */
  45078. maxSimultaneousLights: number;
  45079. /**
  45080. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45081. */
  45082. invertNormalMapX: boolean;
  45083. /**
  45084. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45085. */
  45086. invertNormalMapY: boolean;
  45087. /**
  45088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45089. */
  45090. twoSidedLighting: boolean;
  45091. /**
  45092. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45093. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45094. */
  45095. useAlphaFresnel: boolean;
  45096. /**
  45097. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45098. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45099. */
  45100. useLinearAlphaFresnel: boolean;
  45101. /**
  45102. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45103. * And/Or occlude the blended part.
  45104. */
  45105. environmentBRDFTexture: Nullable<BaseTexture>;
  45106. /**
  45107. * Force normal to face away from face.
  45108. */
  45109. forceNormalForward: boolean;
  45110. /**
  45111. * Enables specular anti aliasing in the PBR shader.
  45112. * It will both interacts on the Geometry for analytical and IBL lighting.
  45113. * It also prefilter the roughness map based on the bump values.
  45114. */
  45115. enableSpecularAntiAliasing: boolean;
  45116. /**
  45117. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45118. * makes the reflect vector face the model (under horizon).
  45119. */
  45120. useHorizonOcclusion: boolean;
  45121. /**
  45122. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45123. * too much the area relying on ambient texture to define their ambient occlusion.
  45124. */
  45125. useRadianceOcclusion: boolean;
  45126. /**
  45127. * If set to true, no lighting calculations will be applied.
  45128. */
  45129. unlit: boolean;
  45130. /**
  45131. * Gets the image processing configuration used either in this material.
  45132. */
  45133. /**
  45134. * Sets the Default image processing configuration used either in the this material.
  45135. *
  45136. * If sets to null, the scene one is in use.
  45137. */
  45138. imageProcessingConfiguration: ImageProcessingConfiguration;
  45139. /**
  45140. * Gets wether the color curves effect is enabled.
  45141. */
  45142. /**
  45143. * Sets wether the color curves effect is enabled.
  45144. */
  45145. cameraColorCurvesEnabled: boolean;
  45146. /**
  45147. * Gets wether the color grading effect is enabled.
  45148. */
  45149. /**
  45150. * Gets wether the color grading effect is enabled.
  45151. */
  45152. cameraColorGradingEnabled: boolean;
  45153. /**
  45154. * Gets wether tonemapping is enabled or not.
  45155. */
  45156. /**
  45157. * Sets wether tonemapping is enabled or not
  45158. */
  45159. cameraToneMappingEnabled: boolean;
  45160. /**
  45161. * The camera exposure used on this material.
  45162. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45163. * This corresponds to a photographic exposure.
  45164. */
  45165. /**
  45166. * The camera exposure used on this material.
  45167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45168. * This corresponds to a photographic exposure.
  45169. */
  45170. cameraExposure: number;
  45171. /**
  45172. * Gets The camera contrast used on this material.
  45173. */
  45174. /**
  45175. * Sets The camera contrast used on this material.
  45176. */
  45177. cameraContrast: number;
  45178. /**
  45179. * Gets the Color Grading 2D Lookup Texture.
  45180. */
  45181. /**
  45182. * Sets the Color Grading 2D Lookup Texture.
  45183. */
  45184. cameraColorGradingTexture: Nullable<BaseTexture>;
  45185. /**
  45186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45188. * 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;
  45189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45190. */
  45191. /**
  45192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45194. * 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;
  45195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45196. */
  45197. cameraColorCurves: Nullable<ColorCurves>;
  45198. /**
  45199. * Instantiates a new PBRMaterial instance.
  45200. *
  45201. * @param name The material name
  45202. * @param scene The scene the material will be use in.
  45203. */
  45204. constructor(name: string, scene: Scene);
  45205. /**
  45206. * Returns the name of this material class.
  45207. */
  45208. getClassName(): string;
  45209. /**
  45210. * Returns an array of the actively used textures.
  45211. * @returns - Array of BaseTextures
  45212. */
  45213. getActiveTextures(): BaseTexture[];
  45214. /**
  45215. * Checks to see if a texture is used in the material.
  45216. * @param texture - Base texture to use.
  45217. * @returns - Boolean specifying if a texture is used in the material.
  45218. */
  45219. hasTexture(texture: BaseTexture): boolean;
  45220. /**
  45221. * Makes a duplicate of the current material.
  45222. * @param name - name to use for the new material.
  45223. */
  45224. clone(name: string): PBRMaterial;
  45225. /**
  45226. * Serializes this PBR Material.
  45227. * @returns - An object with the serialized material.
  45228. */
  45229. serialize(): any;
  45230. /**
  45231. * Parses a PBR Material from a serialized object.
  45232. * @param source - Serialized object.
  45233. * @param scene - BJS scene instance.
  45234. * @param rootUrl - url for the scene object
  45235. * @returns - PBRMaterial
  45236. */
  45237. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45238. }
  45239. }
  45240. declare module BABYLON {
  45241. /**
  45242. * The PBR material of BJS following the metal roughness convention.
  45243. *
  45244. * This fits to the PBR convention in the GLTF definition:
  45245. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45246. */
  45247. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45248. /**
  45249. * The base color has two different interpretations depending on the value of metalness.
  45250. * When the material is a metal, the base color is the specific measured reflectance value
  45251. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45252. * of the material.
  45253. */
  45254. baseColor: Color3;
  45255. /**
  45256. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45257. * well as opacity information in the alpha channel.
  45258. */
  45259. baseTexture: BaseTexture;
  45260. /**
  45261. * Specifies the metallic scalar value of the material.
  45262. * Can also be used to scale the metalness values of the metallic texture.
  45263. */
  45264. metallic: number;
  45265. /**
  45266. * Specifies the roughness scalar value of the material.
  45267. * Can also be used to scale the roughness values of the metallic texture.
  45268. */
  45269. roughness: number;
  45270. /**
  45271. * Texture containing both the metallic value in the B channel and the
  45272. * roughness value in the G channel to keep better precision.
  45273. */
  45274. metallicRoughnessTexture: BaseTexture;
  45275. /**
  45276. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45277. *
  45278. * @param name The material name
  45279. * @param scene The scene the material will be use in.
  45280. */
  45281. constructor(name: string, scene: Scene);
  45282. /**
  45283. * Return the currrent class name of the material.
  45284. */
  45285. getClassName(): string;
  45286. /**
  45287. * Return the active textures of the material.
  45288. */
  45289. getActiveTextures(): BaseTexture[];
  45290. /**
  45291. * Checks to see if a texture is used in the material.
  45292. * @param texture - Base texture to use.
  45293. * @returns - Boolean specifying if a texture is used in the material.
  45294. */
  45295. hasTexture(texture: BaseTexture): boolean;
  45296. /**
  45297. * Makes a duplicate of the current material.
  45298. * @param name - name to use for the new material.
  45299. */
  45300. clone(name: string): PBRMetallicRoughnessMaterial;
  45301. /**
  45302. * Serialize the material to a parsable JSON object.
  45303. */
  45304. serialize(): any;
  45305. /**
  45306. * Parses a JSON object correponding to the serialize function.
  45307. */
  45308. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45309. }
  45310. }
  45311. declare module BABYLON {
  45312. /**
  45313. * The PBR material of BJS following the specular glossiness convention.
  45314. *
  45315. * This fits to the PBR convention in the GLTF definition:
  45316. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45317. */
  45318. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45319. /**
  45320. * Specifies the diffuse color of the material.
  45321. */
  45322. diffuseColor: Color3;
  45323. /**
  45324. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45325. * channel.
  45326. */
  45327. diffuseTexture: BaseTexture;
  45328. /**
  45329. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45330. */
  45331. specularColor: Color3;
  45332. /**
  45333. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45334. */
  45335. glossiness: number;
  45336. /**
  45337. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45338. */
  45339. specularGlossinessTexture: BaseTexture;
  45340. /**
  45341. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45342. *
  45343. * @param name The material name
  45344. * @param scene The scene the material will be use in.
  45345. */
  45346. constructor(name: string, scene: Scene);
  45347. /**
  45348. * Return the currrent class name of the material.
  45349. */
  45350. getClassName(): string;
  45351. /**
  45352. * Return the active textures of the material.
  45353. */
  45354. getActiveTextures(): BaseTexture[];
  45355. /**
  45356. * Checks to see if a texture is used in the material.
  45357. * @param texture - Base texture to use.
  45358. * @returns - Boolean specifying if a texture is used in the material.
  45359. */
  45360. hasTexture(texture: BaseTexture): boolean;
  45361. /**
  45362. * Makes a duplicate of the current material.
  45363. * @param name - name to use for the new material.
  45364. */
  45365. clone(name: string): PBRSpecularGlossinessMaterial;
  45366. /**
  45367. * Serialize the material to a parsable JSON object.
  45368. */
  45369. serialize(): any;
  45370. /**
  45371. * Parses a JSON object correponding to the serialize function.
  45372. */
  45373. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45374. }
  45375. }
  45376. declare module BABYLON {
  45377. /**
  45378. * Base class of all the textures in babylon.
  45379. * It groups all the common properties the materials, post process, lights... might need
  45380. * in order to make a correct use of the texture.
  45381. */
  45382. class BaseTexture {
  45383. /**
  45384. * Default anisotropic filtering level for the application.
  45385. * It is set to 4 as a good tradeoff between perf and quality.
  45386. */
  45387. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45388. /**
  45389. * Define the name of the texture.
  45390. */
  45391. name: string;
  45392. private _hasAlpha;
  45393. /**
  45394. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45395. */
  45396. hasAlpha: boolean;
  45397. /**
  45398. * Defines if the alpha value should be determined via the rgb values.
  45399. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45400. */
  45401. getAlphaFromRGB: boolean;
  45402. /**
  45403. * Intensity or strength of the texture.
  45404. * It is commonly used by materials to fine tune the intensity of the texture
  45405. */
  45406. level: number;
  45407. /**
  45408. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45409. * This is part of the texture as textures usually maps to one uv set.
  45410. */
  45411. coordinatesIndex: number;
  45412. private _coordinatesMode;
  45413. /**
  45414. * How a texture is mapped.
  45415. *
  45416. * | Value | Type | Description |
  45417. * | ----- | ----------------------------------- | ----------- |
  45418. * | 0 | EXPLICIT_MODE | |
  45419. * | 1 | SPHERICAL_MODE | |
  45420. * | 2 | PLANAR_MODE | |
  45421. * | 3 | CUBIC_MODE | |
  45422. * | 4 | PROJECTION_MODE | |
  45423. * | 5 | SKYBOX_MODE | |
  45424. * | 6 | INVCUBIC_MODE | |
  45425. * | 7 | EQUIRECTANGULAR_MODE | |
  45426. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45427. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45428. */
  45429. coordinatesMode: number;
  45430. /**
  45431. * | Value | Type | Description |
  45432. * | ----- | ------------------ | ----------- |
  45433. * | 0 | CLAMP_ADDRESSMODE | |
  45434. * | 1 | WRAP_ADDRESSMODE | |
  45435. * | 2 | MIRROR_ADDRESSMODE | |
  45436. */
  45437. wrapU: number;
  45438. /**
  45439. * | Value | Type | Description |
  45440. * | ----- | ------------------ | ----------- |
  45441. * | 0 | CLAMP_ADDRESSMODE | |
  45442. * | 1 | WRAP_ADDRESSMODE | |
  45443. * | 2 | MIRROR_ADDRESSMODE | |
  45444. */
  45445. wrapV: number;
  45446. /**
  45447. * | Value | Type | Description |
  45448. * | ----- | ------------------ | ----------- |
  45449. * | 0 | CLAMP_ADDRESSMODE | |
  45450. * | 1 | WRAP_ADDRESSMODE | |
  45451. * | 2 | MIRROR_ADDRESSMODE | |
  45452. */
  45453. wrapR: number;
  45454. /**
  45455. * With compliant hardware and browser (supporting anisotropic filtering)
  45456. * this defines the level of anisotropic filtering in the texture.
  45457. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45458. */
  45459. anisotropicFilteringLevel: number;
  45460. /**
  45461. * Define if the texture is a cube texture or if false a 2d texture.
  45462. */
  45463. isCube: boolean;
  45464. /**
  45465. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45466. */
  45467. is3D: boolean;
  45468. /**
  45469. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45470. * HDR texture are usually stored in linear space.
  45471. * This only impacts the PBR and Background materials
  45472. */
  45473. gammaSpace: boolean;
  45474. /**
  45475. * Gets whether or not the texture contains RGBD data.
  45476. */
  45477. readonly isRGBD: boolean;
  45478. /**
  45479. * Is Z inverted in the texture (useful in a cube texture).
  45480. */
  45481. invertZ: boolean;
  45482. /**
  45483. * @hidden
  45484. */
  45485. lodLevelInAlpha: boolean;
  45486. /**
  45487. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45488. */
  45489. lodGenerationOffset: number;
  45490. /**
  45491. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45492. */
  45493. lodGenerationScale: number;
  45494. /**
  45495. * Define if the texture is a render target.
  45496. */
  45497. isRenderTarget: boolean;
  45498. /**
  45499. * Define the unique id of the texture in the scene.
  45500. */
  45501. readonly uid: string;
  45502. /**
  45503. * Return a string representation of the texture.
  45504. * @returns the texture as a string
  45505. */
  45506. toString(): string;
  45507. /**
  45508. * Get the class name of the texture.
  45509. * @returns "BaseTexture"
  45510. */
  45511. getClassName(): string;
  45512. /**
  45513. * Define the list of animation attached to the texture.
  45514. */
  45515. animations: Animation[];
  45516. /**
  45517. * An event triggered when the texture is disposed.
  45518. */
  45519. onDisposeObservable: Observable<BaseTexture>;
  45520. private _onDisposeObserver;
  45521. /**
  45522. * Callback triggered when the texture has been disposed.
  45523. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45524. */
  45525. onDispose: () => void;
  45526. /**
  45527. * Define the current state of the loading sequence when in delayed load mode.
  45528. */
  45529. delayLoadState: number;
  45530. private _scene;
  45531. /** @hidden */
  45532. _texture: Nullable<InternalTexture>;
  45533. private _uid;
  45534. /**
  45535. * Define if the texture is preventinga material to render or not.
  45536. * If not and the texture is not ready, the engine will use a default black texture instead.
  45537. */
  45538. readonly isBlocking: boolean;
  45539. /**
  45540. * Instantiates a new BaseTexture.
  45541. * Base class of all the textures in babylon.
  45542. * It groups all the common properties the materials, post process, lights... might need
  45543. * in order to make a correct use of the texture.
  45544. * @param scene Define the scene the texture blongs to
  45545. */
  45546. constructor(scene: Nullable<Scene>);
  45547. /**
  45548. * Get the scene the texture belongs to.
  45549. * @returns the scene or null if undefined
  45550. */
  45551. getScene(): Nullable<Scene>;
  45552. /**
  45553. * Get the texture transform matrix used to offset tile the texture for istance.
  45554. * @returns the transformation matrix
  45555. */
  45556. getTextureMatrix(): Matrix;
  45557. /**
  45558. * Get the texture reflection matrix used to rotate/transform the reflection.
  45559. * @returns the reflection matrix
  45560. */
  45561. getReflectionTextureMatrix(): Matrix;
  45562. /**
  45563. * Get the underlying lower level texture from Babylon.
  45564. * @returns the insternal texture
  45565. */
  45566. getInternalTexture(): Nullable<InternalTexture>;
  45567. /**
  45568. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45569. * @returns true if ready or not blocking
  45570. */
  45571. isReadyOrNotBlocking(): boolean;
  45572. /**
  45573. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45574. * @returns true if fully ready
  45575. */
  45576. isReady(): boolean;
  45577. private _cachedSize;
  45578. /**
  45579. * Get the size of the texture.
  45580. * @returns the texture size.
  45581. */
  45582. getSize(): ISize;
  45583. /**
  45584. * Get the base size of the texture.
  45585. * It can be different from the size if the texture has been resized for POT for instance
  45586. * @returns the base size
  45587. */
  45588. getBaseSize(): ISize;
  45589. /**
  45590. * Scales the texture if is `canRescale()`
  45591. * @param ratio the resize factor we want to use to rescale
  45592. */
  45593. scale(ratio: number): void;
  45594. /**
  45595. * Get if the texture can rescale.
  45596. */
  45597. readonly canRescale: boolean;
  45598. /** @hidden */
  45599. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45600. /** @hidden */
  45601. _rebuild(): void;
  45602. /**
  45603. * Triggers the load sequence in delayed load mode.
  45604. */
  45605. delayLoad(): void;
  45606. /**
  45607. * Clones the texture.
  45608. * @returns the cloned texture
  45609. */
  45610. clone(): Nullable<BaseTexture>;
  45611. /**
  45612. * Get the texture underlying type (INT, FLOAT...)
  45613. */
  45614. readonly textureType: number;
  45615. /**
  45616. * Get the texture underlying format (RGB, RGBA...)
  45617. */
  45618. readonly textureFormat: number;
  45619. /**
  45620. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45621. * This will returns an RGBA array buffer containing either in values (0-255) or
  45622. * float values (0-1) depending of the underlying buffer type.
  45623. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45624. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45625. * @param buffer defines a user defined buffer to fill with data (can be null)
  45626. * @returns The Array buffer containing the pixels data.
  45627. */
  45628. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45629. /**
  45630. * Release and destroy the underlying lower level texture aka internalTexture.
  45631. */
  45632. releaseInternalTexture(): void;
  45633. /**
  45634. * Get the polynomial representation of the texture data.
  45635. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45636. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45637. */
  45638. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45639. /** @hidden */
  45640. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45641. /** @hidden */
  45642. readonly _lodTextureMid: Nullable<BaseTexture>;
  45643. /** @hidden */
  45644. readonly _lodTextureLow: Nullable<BaseTexture>;
  45645. /**
  45646. * Dispose the texture and release its associated resources.
  45647. */
  45648. dispose(): void;
  45649. /**
  45650. * Serialize the texture into a JSON representation that can be parsed later on.
  45651. * @returns the JSON representation of the texture
  45652. */
  45653. serialize(): any;
  45654. /**
  45655. * Helper function to be called back once a list of texture contains only ready textures.
  45656. * @param textures Define the list of textures to wait for
  45657. * @param callback Define the callback triggered once the entire list will be ready
  45658. */
  45659. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45660. }
  45661. }
  45662. declare module BABYLON {
  45663. /**
  45664. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45665. * It can help converting any input color in a desired output one. This can then be used to create effects
  45666. * from sepia, black and white to sixties or futuristic rendering...
  45667. *
  45668. * The only supported format is currently 3dl.
  45669. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45670. */
  45671. class ColorGradingTexture extends BaseTexture {
  45672. /**
  45673. * The current texture matrix. (will always be identity in color grading texture)
  45674. */
  45675. private _textureMatrix;
  45676. /**
  45677. * The texture URL.
  45678. */
  45679. url: string;
  45680. /**
  45681. * Empty line regex stored for GC.
  45682. */
  45683. private static _noneEmptyLineRegex;
  45684. private _engine;
  45685. /**
  45686. * Instantiates a ColorGradingTexture from the following parameters.
  45687. *
  45688. * @param url The location of the color gradind data (currently only supporting 3dl)
  45689. * @param scene The scene the texture will be used in
  45690. */
  45691. constructor(url: string, scene: Scene);
  45692. /**
  45693. * Returns the texture matrix used in most of the material.
  45694. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45695. */
  45696. getTextureMatrix(): Matrix;
  45697. /**
  45698. * Occurs when the file being loaded is a .3dl LUT file.
  45699. */
  45700. private load3dlTexture;
  45701. /**
  45702. * Starts the loading process of the texture.
  45703. */
  45704. private loadTexture;
  45705. /**
  45706. * Clones the color gradind texture.
  45707. */
  45708. clone(): ColorGradingTexture;
  45709. /**
  45710. * Called during delayed load for textures.
  45711. */
  45712. delayLoad(): void;
  45713. /**
  45714. * Parses a color grading texture serialized by Babylon.
  45715. * @param parsedTexture The texture information being parsedTexture
  45716. * @param scene The scene to load the texture in
  45717. * @param rootUrl The root url of the data assets to load
  45718. * @return A color gradind texture
  45719. */
  45720. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45721. /**
  45722. * Serializes the LUT texture to json format.
  45723. */
  45724. serialize(): any;
  45725. }
  45726. }
  45727. declare module BABYLON {
  45728. /**
  45729. * Class for creating a cube texture
  45730. */
  45731. class CubeTexture extends BaseTexture {
  45732. /**
  45733. * The url of the texture
  45734. */
  45735. url: string;
  45736. /**
  45737. * Gets or sets the center of the bounding box associated with the cube texture.
  45738. * It must define where the camera used to render the texture was set
  45739. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45740. */
  45741. boundingBoxPosition: Vector3;
  45742. private _boundingBoxSize;
  45743. /**
  45744. * Gets or sets the size of the bounding box associated with the cube texture
  45745. * When defined, the cubemap will switch to local mode
  45746. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45747. * @example https://www.babylonjs-playground.com/#RNASML
  45748. */
  45749. /**
  45750. * Returns the bounding box size
  45751. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45752. */
  45753. boundingBoxSize: Vector3;
  45754. protected _rotationY: number;
  45755. /**
  45756. * Sets texture matrix rotation angle around Y axis in radians.
  45757. */
  45758. /**
  45759. * Gets texture matrix rotation angle around Y axis radians.
  45760. */
  45761. rotationY: number;
  45762. private _noMipmap;
  45763. private _files;
  45764. private _extensions;
  45765. private _textureMatrix;
  45766. private _format;
  45767. private _createPolynomials;
  45768. /** @hidden */
  45769. readonly _prefiltered: boolean;
  45770. /**
  45771. * Creates a cube texture from an array of image urls
  45772. * @param files defines an array of image urls
  45773. * @param scene defines the hosting scene
  45774. * @param noMipmap specifies if mip maps are not used
  45775. * @returns a cube texture
  45776. */
  45777. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45778. /**
  45779. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45780. * @param url defines the url of the prefiltered texture
  45781. * @param scene defines the scene the texture is attached to
  45782. * @param forcedExtension defines the extension of the file if different from the url
  45783. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45784. * @return the prefiltered texture
  45785. */
  45786. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45787. /**
  45788. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45789. * as prefiltered data.
  45790. * @param rootUrl defines the url of the texture or the root name of the six images
  45791. * @param scene defines the scene the texture is attached to
  45792. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45793. * @param noMipmap defines if mipmaps should be created or not
  45794. * @param files defines the six files to load for the different faces
  45795. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45796. * @param onError defines a callback triggered in case of error during load
  45797. * @param format defines the internal format to use for the texture once loaded
  45798. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45799. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45800. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45801. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45802. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45803. * @return the cube texture
  45804. */
  45805. 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);
  45806. /**
  45807. * Delays loading of the cube texture
  45808. */
  45809. delayLoad(): void;
  45810. /**
  45811. * Returns the reflection texture matrix
  45812. * @returns the reflection texture matrix
  45813. */
  45814. getReflectionTextureMatrix(): Matrix;
  45815. /**
  45816. * Sets the reflection texture matrix
  45817. * @param value Reflection texture matrix
  45818. */
  45819. setReflectionTextureMatrix(value: Matrix): void;
  45820. /**
  45821. * Parses text to create a cube texture
  45822. * @param parsedTexture define the serialized text to read from
  45823. * @param scene defines the hosting scene
  45824. * @param rootUrl defines the root url of the cube texture
  45825. * @returns a cube texture
  45826. */
  45827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45828. /**
  45829. * Makes a clone, or deep copy, of the cube texture
  45830. * @returns a new cube texture
  45831. */
  45832. clone(): CubeTexture;
  45833. }
  45834. }
  45835. declare module BABYLON {
  45836. /**
  45837. * A class extending Texture allowing drawing on a texture
  45838. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45839. */
  45840. class DynamicTexture extends Texture {
  45841. private _generateMipMaps;
  45842. private _canvas;
  45843. private _context;
  45844. private _engine;
  45845. /**
  45846. * Creates a DynamicTexture
  45847. * @param name defines the name of the texture
  45848. * @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
  45849. * @param scene defines the scene where you want the texture
  45850. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45851. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45852. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45853. */
  45854. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45855. /**
  45856. * Gets the current state of canRescale
  45857. */
  45858. readonly canRescale: boolean;
  45859. private _recreate;
  45860. /**
  45861. * Scales the texture
  45862. * @param ratio the scale factor to apply to both width and height
  45863. */
  45864. scale(ratio: number): void;
  45865. /**
  45866. * Resizes the texture
  45867. * @param width the new width
  45868. * @param height the new height
  45869. */
  45870. scaleTo(width: number, height: number): void;
  45871. /**
  45872. * Gets the context of the canvas used by the texture
  45873. * @returns the canvas context of the dynamic texture
  45874. */
  45875. getContext(): CanvasRenderingContext2D;
  45876. /**
  45877. * Clears the texture
  45878. */
  45879. clear(): void;
  45880. /**
  45881. * Updates the texture
  45882. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45883. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45884. */
  45885. update(invertY?: boolean, premulAlpha?: boolean): void;
  45886. /**
  45887. * Draws text onto the texture
  45888. * @param text defines the text to be drawn
  45889. * @param x defines the placement of the text from the left
  45890. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45891. * @param font defines the font to be used with font-style, font-size, font-name
  45892. * @param color defines the color used for the text
  45893. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45894. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45895. * @param update defines whether texture is immediately update (default is true)
  45896. */
  45897. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45898. /**
  45899. * Clones the texture
  45900. * @returns the clone of the texture.
  45901. */
  45902. clone(): DynamicTexture;
  45903. /**
  45904. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45905. * @returns a serialized dynamic texture object
  45906. */
  45907. serialize(): any;
  45908. /** @hidden */
  45909. _rebuild(): void;
  45910. }
  45911. }
  45912. declare module BABYLON {
  45913. /**
  45914. * This represents a texture coming from an HDR input.
  45915. *
  45916. * The only supported format is currently panorama picture stored in RGBE format.
  45917. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45918. */
  45919. class HDRCubeTexture extends BaseTexture {
  45920. private static _facesMapping;
  45921. private _generateHarmonics;
  45922. private _noMipmap;
  45923. private _textureMatrix;
  45924. private _size;
  45925. private _onLoad;
  45926. private _onError;
  45927. /**
  45928. * The texture URL.
  45929. */
  45930. url: string;
  45931. /**
  45932. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45933. */
  45934. coordinatesMode: number;
  45935. protected _isBlocking: boolean;
  45936. /**
  45937. * Sets wether or not the texture is blocking during loading.
  45938. */
  45939. /**
  45940. * Gets wether or not the texture is blocking during loading.
  45941. */
  45942. isBlocking: boolean;
  45943. protected _rotationY: number;
  45944. /**
  45945. * Sets texture matrix rotation angle around Y axis in radians.
  45946. */
  45947. /**
  45948. * Gets texture matrix rotation angle around Y axis radians.
  45949. */
  45950. rotationY: number;
  45951. /**
  45952. * Gets or sets the center of the bounding box associated with the cube texture
  45953. * It must define where the camera used to render the texture was set
  45954. */
  45955. boundingBoxPosition: Vector3;
  45956. private _boundingBoxSize;
  45957. /**
  45958. * Gets or sets the size of the bounding box associated with the cube texture
  45959. * When defined, the cubemap will switch to local mode
  45960. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45961. * @example https://www.babylonjs-playground.com/#RNASML
  45962. */
  45963. boundingBoxSize: Vector3;
  45964. /**
  45965. * Instantiates an HDRTexture from the following parameters.
  45966. *
  45967. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45968. * @param scene The scene the texture will be used in
  45969. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45970. * @param noMipmap Forces to not generate the mipmap if true
  45971. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45972. * @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)
  45973. * @param reserved Reserved flag for internal use.
  45974. */
  45975. 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>);
  45976. /**
  45977. * Occurs when the file is raw .hdr file.
  45978. */
  45979. private loadTexture;
  45980. clone(): HDRCubeTexture;
  45981. delayLoad(): void;
  45982. /**
  45983. * Get the texture reflection matrix used to rotate/transform the reflection.
  45984. * @returns the reflection matrix
  45985. */
  45986. getReflectionTextureMatrix(): Matrix;
  45987. /**
  45988. * Set the texture reflection matrix used to rotate/transform the reflection.
  45989. * @param value Define the reflection matrix to set
  45990. */
  45991. setReflectionTextureMatrix(value: Matrix): void;
  45992. /**
  45993. * Parses a JSON representation of an HDR Texture in order to create the texture
  45994. * @param parsedTexture Define the JSON representation
  45995. * @param scene Define the scene the texture should be created in
  45996. * @param rootUrl Define the root url in case we need to load relative dependencies
  45997. * @returns the newly created texture after parsing
  45998. */
  45999. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46000. serialize(): any;
  46001. }
  46002. }
  46003. declare module BABYLON {
  46004. /**
  46005. * Class used to store data associated with WebGL texture data for the engine
  46006. * This class should not be used directly
  46007. */
  46008. class InternalTexture implements IInternalTextureTracker {
  46009. /**
  46010. * The source of the texture data is unknown
  46011. */
  46012. static DATASOURCE_UNKNOWN: number;
  46013. /**
  46014. * Texture data comes from an URL
  46015. */
  46016. static DATASOURCE_URL: number;
  46017. /**
  46018. * Texture data is only used for temporary storage
  46019. */
  46020. static DATASOURCE_TEMP: number;
  46021. /**
  46022. * Texture data comes from raw data (ArrayBuffer)
  46023. */
  46024. static DATASOURCE_RAW: number;
  46025. /**
  46026. * Texture content is dynamic (video or dynamic texture)
  46027. */
  46028. static DATASOURCE_DYNAMIC: number;
  46029. /**
  46030. * Texture content is generated by rendering to it
  46031. */
  46032. static DATASOURCE_RENDERTARGET: number;
  46033. /**
  46034. * Texture content is part of a multi render target process
  46035. */
  46036. static DATASOURCE_MULTIRENDERTARGET: number;
  46037. /**
  46038. * Texture data comes from a cube data file
  46039. */
  46040. static DATASOURCE_CUBE: number;
  46041. /**
  46042. * Texture data comes from a raw cube data
  46043. */
  46044. static DATASOURCE_CUBERAW: number;
  46045. /**
  46046. * Texture data come from a prefiltered cube data file
  46047. */
  46048. static DATASOURCE_CUBEPREFILTERED: number;
  46049. /**
  46050. * Texture content is raw 3D data
  46051. */
  46052. static DATASOURCE_RAW3D: number;
  46053. /**
  46054. * Texture content is a depth texture
  46055. */
  46056. static DATASOURCE_DEPTHTEXTURE: number;
  46057. /**
  46058. * Texture data comes from a raw cube data encoded with RGBD
  46059. */
  46060. static DATASOURCE_CUBERAW_RGBD: number;
  46061. /**
  46062. * Defines if the texture is ready
  46063. */
  46064. isReady: boolean;
  46065. /**
  46066. * Defines if the texture is a cube texture
  46067. */
  46068. isCube: boolean;
  46069. /**
  46070. * Defines if the texture contains 3D data
  46071. */
  46072. is3D: boolean;
  46073. /**
  46074. * Gets the URL used to load this texture
  46075. */
  46076. url: string;
  46077. /**
  46078. * Gets the sampling mode of the texture
  46079. */
  46080. samplingMode: number;
  46081. /**
  46082. * Gets a boolean indicating if the texture needs mipmaps generation
  46083. */
  46084. generateMipMaps: boolean;
  46085. /**
  46086. * Gets the number of samples used by the texture (WebGL2+ only)
  46087. */
  46088. samples: number;
  46089. /**
  46090. * Gets the type of the texture (int, float...)
  46091. */
  46092. type: number;
  46093. /**
  46094. * Gets the format of the texture (RGB, RGBA...)
  46095. */
  46096. format: number;
  46097. /**
  46098. * Observable called when the texture is loaded
  46099. */
  46100. onLoadedObservable: Observable<InternalTexture>;
  46101. /**
  46102. * Gets the width of the texture
  46103. */
  46104. width: number;
  46105. /**
  46106. * Gets the height of the texture
  46107. */
  46108. height: number;
  46109. /**
  46110. * Gets the depth of the texture
  46111. */
  46112. depth: number;
  46113. /**
  46114. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46115. */
  46116. baseWidth: number;
  46117. /**
  46118. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46119. */
  46120. baseHeight: number;
  46121. /**
  46122. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46123. */
  46124. baseDepth: number;
  46125. /**
  46126. * Gets a boolean indicating if the texture is inverted on Y axis
  46127. */
  46128. invertY: boolean;
  46129. /**
  46130. * Gets or set the previous tracker in the list
  46131. */
  46132. previous: Nullable<IInternalTextureTracker>;
  46133. /**
  46134. * Gets or set the next tracker in the list
  46135. */
  46136. next: Nullable<IInternalTextureTracker>;
  46137. /** @hidden */
  46138. _initialSlot: number;
  46139. /** @hidden */
  46140. _designatedSlot: number;
  46141. /** @hidden */
  46142. _dataSource: number;
  46143. /** @hidden */
  46144. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46145. /** @hidden */
  46146. _bufferView: Nullable<ArrayBufferView>;
  46147. /** @hidden */
  46148. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46149. /** @hidden */
  46150. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46151. /** @hidden */
  46152. _size: number;
  46153. /** @hidden */
  46154. _extension: string;
  46155. /** @hidden */
  46156. _files: Nullable<string[]>;
  46157. /** @hidden */
  46158. _workingCanvas: HTMLCanvasElement;
  46159. /** @hidden */
  46160. _workingContext: CanvasRenderingContext2D;
  46161. /** @hidden */
  46162. _framebuffer: Nullable<WebGLFramebuffer>;
  46163. /** @hidden */
  46164. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46165. /** @hidden */
  46166. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46167. /** @hidden */
  46168. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46169. /** @hidden */
  46170. _attachments: Nullable<number[]>;
  46171. /** @hidden */
  46172. _cachedCoordinatesMode: Nullable<number>;
  46173. /** @hidden */
  46174. _cachedWrapU: Nullable<number>;
  46175. /** @hidden */
  46176. _cachedWrapV: Nullable<number>;
  46177. /** @hidden */
  46178. _cachedWrapR: Nullable<number>;
  46179. /** @hidden */
  46180. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46181. /** @hidden */
  46182. _isDisabled: boolean;
  46183. /** @hidden */
  46184. _compression: Nullable<string>;
  46185. /** @hidden */
  46186. _generateStencilBuffer: boolean;
  46187. /** @hidden */
  46188. _generateDepthBuffer: boolean;
  46189. /** @hidden */
  46190. _comparisonFunction: number;
  46191. /** @hidden */
  46192. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46193. /** @hidden */
  46194. _lodGenerationScale: number;
  46195. /** @hidden */
  46196. _lodGenerationOffset: number;
  46197. /** @hidden */
  46198. _lodTextureHigh: BaseTexture;
  46199. /** @hidden */
  46200. _lodTextureMid: BaseTexture;
  46201. /** @hidden */
  46202. _lodTextureLow: BaseTexture;
  46203. /** @hidden */
  46204. _isRGBD: boolean;
  46205. /** @hidden */
  46206. _webGLTexture: Nullable<WebGLTexture>;
  46207. /** @hidden */
  46208. _references: number;
  46209. private _engine;
  46210. /**
  46211. * Gets the Engine the texture belongs to.
  46212. * @returns The babylon engine
  46213. */
  46214. getEngine(): Engine;
  46215. /**
  46216. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46217. */
  46218. readonly dataSource: number;
  46219. /**
  46220. * Creates a new InternalTexture
  46221. * @param engine defines the engine to use
  46222. * @param dataSource defines the type of data that will be used
  46223. */
  46224. constructor(engine: Engine, dataSource: number);
  46225. /**
  46226. * Increments the number of references (ie. the number of Texture that point to it)
  46227. */
  46228. incrementReferences(): void;
  46229. /**
  46230. * Change the size of the texture (not the size of the content)
  46231. * @param width defines the new width
  46232. * @param height defines the new height
  46233. * @param depth defines the new depth (1 by default)
  46234. */
  46235. updateSize(width: int, height: int, depth?: int): void;
  46236. /** @hidden */
  46237. _rebuild(): void;
  46238. /** @hidden */
  46239. _swapAndDie(target: InternalTexture): void;
  46240. /**
  46241. * Dispose the current allocated resources
  46242. */
  46243. dispose(): void;
  46244. }
  46245. }
  46246. declare module BABYLON {
  46247. /**
  46248. * This represents the required contract to create a new type of texture loader.
  46249. */
  46250. interface IInternalTextureLoader {
  46251. /**
  46252. * Defines wether the loader supports cascade loading the different faces.
  46253. */
  46254. supportCascades: boolean;
  46255. /**
  46256. * This returns if the loader support the current file information.
  46257. * @param extension defines the file extension of the file being loaded
  46258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46259. * @param fallback defines the fallback internal texture if any
  46260. * @param isBase64 defines whether the texture is encoded as a base64
  46261. * @param isBuffer defines whether the texture data are stored as a buffer
  46262. * @returns true if the loader can load the specified file
  46263. */
  46264. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46265. /**
  46266. * Transform the url before loading if required.
  46267. * @param rootUrl the url of the texture
  46268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46269. * @returns the transformed texture
  46270. */
  46271. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46272. /**
  46273. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46274. * @param rootUrl the url of the texture
  46275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46276. * @returns the fallback texture
  46277. */
  46278. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46279. /**
  46280. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46281. * @param data contains the texture data
  46282. * @param texture defines the BabylonJS internal texture
  46283. * @param createPolynomials will be true if polynomials have been requested
  46284. * @param onLoad defines the callback to trigger once the texture is ready
  46285. * @param onError defines the callback to trigger in case of error
  46286. */
  46287. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46288. /**
  46289. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46290. * @param data contains the texture data
  46291. * @param texture defines the BabylonJS internal texture
  46292. * @param callback defines the method to call once ready to upload
  46293. */
  46294. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * Internal interface used to track InternalTexture already bound to the GL context
  46300. */
  46301. interface IInternalTextureTracker {
  46302. /**
  46303. * Gets or set the previous tracker in the list
  46304. */
  46305. previous: Nullable<IInternalTextureTracker>;
  46306. /**
  46307. * Gets or set the next tracker in the list
  46308. */
  46309. next: Nullable<IInternalTextureTracker>;
  46310. }
  46311. /**
  46312. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46313. */
  46314. class DummyInternalTextureTracker {
  46315. /**
  46316. * Gets or set the previous tracker in the list
  46317. */
  46318. previous: Nullable<IInternalTextureTracker>;
  46319. /**
  46320. * Gets or set the next tracker in the list
  46321. */
  46322. next: Nullable<IInternalTextureTracker>;
  46323. }
  46324. }
  46325. declare module BABYLON {
  46326. /**
  46327. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46328. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46329. * You can then easily use it as a reflectionTexture on a flat surface.
  46330. * In case the surface is not a plane, please consider relying on reflection probes.
  46331. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46332. */
  46333. class MirrorTexture extends RenderTargetTexture {
  46334. private scene;
  46335. /**
  46336. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46337. * 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.
  46338. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46339. */
  46340. mirrorPlane: Plane;
  46341. /**
  46342. * Define the blur ratio used to blur the reflection if needed.
  46343. */
  46344. blurRatio: number;
  46345. /**
  46346. * Define the adaptive blur kernel used to blur the reflection if needed.
  46347. * This will autocompute the closest best match for the `blurKernel`
  46348. */
  46349. adaptiveBlurKernel: number;
  46350. /**
  46351. * Define the blur kernel used to blur the reflection if needed.
  46352. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46353. */
  46354. blurKernel: number;
  46355. /**
  46356. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46357. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46358. */
  46359. blurKernelX: number;
  46360. /**
  46361. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46362. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46363. */
  46364. blurKernelY: number;
  46365. private _autoComputeBlurKernel;
  46366. protected _onRatioRescale(): void;
  46367. private _updateGammaSpace;
  46368. private _imageProcessingConfigChangeObserver;
  46369. private _transformMatrix;
  46370. private _mirrorMatrix;
  46371. private _savedViewMatrix;
  46372. private _blurX;
  46373. private _blurY;
  46374. private _adaptiveBlurKernel;
  46375. private _blurKernelX;
  46376. private _blurKernelY;
  46377. private _blurRatio;
  46378. /**
  46379. * Instantiates a Mirror Texture.
  46380. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46381. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46382. * You can then easily use it as a reflectionTexture on a flat surface.
  46383. * In case the surface is not a plane, please consider relying on reflection probes.
  46384. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46385. * @param name
  46386. * @param size
  46387. * @param scene
  46388. * @param generateMipMaps
  46389. * @param type
  46390. * @param samplingMode
  46391. * @param generateDepthBuffer
  46392. */
  46393. constructor(name: string, size: number | {
  46394. width: number;
  46395. height: number;
  46396. } | {
  46397. ratio: number;
  46398. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46399. private _preparePostProcesses;
  46400. /**
  46401. * Clone the mirror texture.
  46402. * @returns the cloned texture
  46403. */
  46404. clone(): MirrorTexture;
  46405. /**
  46406. * Serialize the texture to a JSON representation you could use in Parse later on
  46407. * @returns the serialized JSON representation
  46408. */
  46409. serialize(): any;
  46410. /**
  46411. * Dispose the texture and release its associated resources.
  46412. */
  46413. dispose(): void;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * Creation options of the multi render target texture.
  46419. */
  46420. interface IMultiRenderTargetOptions {
  46421. /**
  46422. * Define if the texture needs to create mip maps after render.
  46423. */
  46424. generateMipMaps?: boolean;
  46425. /**
  46426. * Define the types of all the draw buffers we want to create
  46427. */
  46428. types?: number[];
  46429. /**
  46430. * Define the sampling modes of all the draw buffers we want to create
  46431. */
  46432. samplingModes?: number[];
  46433. /**
  46434. * Define if a depth buffer is required
  46435. */
  46436. generateDepthBuffer?: boolean;
  46437. /**
  46438. * Define if a stencil buffer is required
  46439. */
  46440. generateStencilBuffer?: boolean;
  46441. /**
  46442. * Define if a depth texture is required instead of a depth buffer
  46443. */
  46444. generateDepthTexture?: boolean;
  46445. /**
  46446. * Define the number of desired draw buffers
  46447. */
  46448. textureCount?: number;
  46449. /**
  46450. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46451. */
  46452. doNotChangeAspectRatio?: boolean;
  46453. /**
  46454. * Define the default type of the buffers we are creating
  46455. */
  46456. defaultType?: number;
  46457. }
  46458. /**
  46459. * A multi render target, like a render target provides the ability to render to a texture.
  46460. * Unlike the render target, it can render to several draw buffers in one draw.
  46461. * This is specially interesting in deferred rendering or for any effects requiring more than
  46462. * just one color from a single pass.
  46463. */
  46464. class MultiRenderTarget extends RenderTargetTexture {
  46465. private _internalTextures;
  46466. private _textures;
  46467. private _multiRenderTargetOptions;
  46468. /**
  46469. * Get if draw buffers are currently supported by the used hardware and browser.
  46470. */
  46471. readonly isSupported: boolean;
  46472. /**
  46473. * Get the list of textures generated by the multi render target.
  46474. */
  46475. readonly textures: Texture[];
  46476. /**
  46477. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46478. */
  46479. readonly depthTexture: Texture;
  46480. /**
  46481. * Set the wrapping mode on U of all the textures we are rendering to.
  46482. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46483. */
  46484. wrapU: number;
  46485. /**
  46486. * Set the wrapping mode on V of all the textures we are rendering to.
  46487. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46488. */
  46489. wrapV: number;
  46490. /**
  46491. * Instantiate a new multi render target texture.
  46492. * A multi render target, like a render target provides the ability to render to a texture.
  46493. * Unlike the render target, it can render to several draw buffers in one draw.
  46494. * This is specially interesting in deferred rendering or for any effects requiring more than
  46495. * just one color from a single pass.
  46496. * @param name Define the name of the texture
  46497. * @param size Define the size of the buffers to render to
  46498. * @param count Define the number of target we are rendering into
  46499. * @param scene Define the scene the texture belongs to
  46500. * @param options Define the options used to create the multi render target
  46501. */
  46502. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46503. /** @hidden */
  46504. _rebuild(): void;
  46505. private _createInternalTextures;
  46506. private _createTextures;
  46507. /**
  46508. * Define the number of samples used if MSAA is enabled.
  46509. */
  46510. samples: number;
  46511. /**
  46512. * Resize all the textures in the multi render target.
  46513. * Be carrefull as it will recreate all the data in the new texture.
  46514. * @param size Define the new size
  46515. */
  46516. resize(size: any): void;
  46517. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46518. /**
  46519. * Dispose the render targets and their associated resources
  46520. */
  46521. dispose(): void;
  46522. /**
  46523. * Release all the underlying texture used as draw buffers.
  46524. */
  46525. releaseInternalTextures(): void;
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Raw cube texture where the raw buffers are passed in
  46531. */
  46532. class RawCubeTexture extends CubeTexture {
  46533. /**
  46534. * Creates a cube texture where the raw buffers are passed in.
  46535. * @param scene defines the scene the texture is attached to
  46536. * @param data defines the array of data to use to create each face
  46537. * @param size defines the size of the textures
  46538. * @param format defines the format of the data
  46539. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46540. * @param generateMipMaps defines if the engine should generate the mip levels
  46541. * @param invertY defines if data must be stored with Y axis inverted
  46542. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46543. * @param compression defines the compression used (null by default)
  46544. */
  46545. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46546. /**
  46547. * Updates the raw cube texture.
  46548. * @param data defines the data to store
  46549. * @param format defines the data format
  46550. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46551. * @param invertY defines if data must be stored with Y axis inverted
  46552. * @param compression defines the compression used (null by default)
  46553. * @param level defines which level of the texture to update
  46554. */
  46555. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46556. /**
  46557. * Updates a raw cube texture with RGBD encoded data.
  46558. * @param data defines the array of data [mipmap][face] to use to create each face
  46559. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46560. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46561. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46562. * @returns a promsie that resolves when the operation is complete
  46563. */
  46564. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46565. /**
  46566. * Clones the raw cube texture.
  46567. * @return a new cube texture
  46568. */
  46569. clone(): CubeTexture;
  46570. /** @hidden */
  46571. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46572. }
  46573. }
  46574. declare module BABYLON {
  46575. /**
  46576. * Raw texture can help creating a texture directly from an array of data.
  46577. * This can be super useful if you either get the data from an uncompressed source or
  46578. * if you wish to create your texture pixel by pixel.
  46579. */
  46580. class RawTexture extends Texture {
  46581. /**
  46582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46583. */
  46584. format: number;
  46585. private _engine;
  46586. /**
  46587. * Instantiates a new RawTexture.
  46588. * Raw texture can help creating a texture directly from an array of data.
  46589. * This can be super useful if you either get the data from an uncompressed source or
  46590. * if you wish to create your texture pixel by pixel.
  46591. * @param data define the array of data to use to create the texture
  46592. * @param width define the width of the texture
  46593. * @param height define the height of the texture
  46594. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46595. * @param scene define the scene the texture belongs to
  46596. * @param generateMipMaps define whether mip maps should be generated or not
  46597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46599. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46600. */
  46601. constructor(data: ArrayBufferView, width: number, height: number,
  46602. /**
  46603. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46604. */
  46605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46606. /**
  46607. * Updates the texture underlying data.
  46608. * @param data Define the new data of the texture
  46609. */
  46610. update(data: ArrayBufferView): void;
  46611. /**
  46612. * Creates a luminance texture from some data.
  46613. * @param data Define the texture data
  46614. * @param width Define the width of the texture
  46615. * @param height Define the height of the texture
  46616. * @param scene Define the scene the texture belongs to
  46617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46620. * @returns the luminance texture
  46621. */
  46622. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46623. /**
  46624. * Creates a luminance alpha texture from some data.
  46625. * @param data Define the texture data
  46626. * @param width Define the width of the texture
  46627. * @param height Define the height of the texture
  46628. * @param scene Define the scene the texture belongs to
  46629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46632. * @returns the luminance alpha texture
  46633. */
  46634. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46635. /**
  46636. * Creates an alpha texture from some data.
  46637. * @param data Define the texture data
  46638. * @param width Define the width of the texture
  46639. * @param height Define the height of the texture
  46640. * @param scene Define the scene the texture belongs to
  46641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46644. * @returns the alpha texture
  46645. */
  46646. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46647. /**
  46648. * Creates a RGB texture from some data.
  46649. * @param data Define the texture data
  46650. * @param width Define the width of the texture
  46651. * @param height Define the height of the texture
  46652. * @param scene Define the scene the texture belongs to
  46653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46657. * @returns the RGB alpha texture
  46658. */
  46659. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46660. /**
  46661. * Creates a RGBA texture from some data.
  46662. * @param data Define the texture data
  46663. * @param width Define the width of the texture
  46664. * @param height Define the height of the texture
  46665. * @param scene Define the scene the texture belongs to
  46666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46670. * @returns the RGBA texture
  46671. */
  46672. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46673. /**
  46674. * Creates a R texture from some data.
  46675. * @param data Define the texture data
  46676. * @param width Define the width of the texture
  46677. * @param height Define the height of the texture
  46678. * @param scene Define the scene the texture belongs to
  46679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46682. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46683. * @returns the R texture
  46684. */
  46685. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /**
  46690. * Class used to store 3D textures containing user data
  46691. */
  46692. class RawTexture3D extends Texture {
  46693. /** Gets or sets the texture format to use */
  46694. format: number;
  46695. private _engine;
  46696. /**
  46697. * Create a new RawTexture3D
  46698. * @param data defines the data of the texture
  46699. * @param width defines the width of the texture
  46700. * @param height defines the height of the texture
  46701. * @param depth defines the depth of the texture
  46702. * @param format defines the texture format to use
  46703. * @param scene defines the hosting scene
  46704. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46705. * @param invertY defines if texture must be stored with Y axis inverted
  46706. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46707. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46708. */
  46709. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46710. /** Gets or sets the texture format to use */
  46711. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46712. /**
  46713. * Update the texture with new data
  46714. * @param data defines the data to store in the texture
  46715. */
  46716. update(data: ArrayBufferView): void;
  46717. }
  46718. }
  46719. declare module BABYLON {
  46720. /**
  46721. * Creates a refraction texture used by refraction channel of the standard material.
  46722. * It is like a mirror but to see through a material.
  46723. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46724. */
  46725. class RefractionTexture extends RenderTargetTexture {
  46726. /**
  46727. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46728. * 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.
  46729. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46730. */
  46731. refractionPlane: Plane;
  46732. /**
  46733. * Define how deep under the surface we should see.
  46734. */
  46735. depth: number;
  46736. /**
  46737. * Creates a refraction texture used by refraction channel of the standard material.
  46738. * It is like a mirror but to see through a material.
  46739. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46740. * @param name Define the texture name
  46741. * @param size Define the size of the underlying texture
  46742. * @param scene Define the scene the refraction belongs to
  46743. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46744. */
  46745. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46746. /**
  46747. * Clone the refraction texture.
  46748. * @returns the cloned texture
  46749. */
  46750. clone(): RefractionTexture;
  46751. /**
  46752. * Serialize the texture to a JSON representation you could use in Parse later on
  46753. * @returns the serialized JSON representation
  46754. */
  46755. serialize(): any;
  46756. }
  46757. }
  46758. declare module BABYLON {
  46759. /**
  46760. * This Helps creating a texture that will be created from a camera in your scene.
  46761. * It is basically a dynamic texture that could be used to create special effects for instance.
  46762. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46763. */
  46764. class RenderTargetTexture extends Texture {
  46765. isCube: boolean;
  46766. /**
  46767. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46768. */
  46769. static readonly REFRESHRATE_RENDER_ONCE: number;
  46770. /**
  46771. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46772. */
  46773. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46774. /**
  46775. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46776. * the central point of your effect and can save a lot of performances.
  46777. */
  46778. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46779. /**
  46780. * Use this predicate to dynamically define the list of mesh you want to render.
  46781. * If set, the renderList property will be overwritten.
  46782. */
  46783. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46784. private _renderList;
  46785. /**
  46786. * Use this list to define the list of mesh you want to render.
  46787. */
  46788. renderList: Nullable<Array<AbstractMesh>>;
  46789. private _hookArray;
  46790. /**
  46791. * Define if particles should be rendered in your texture.
  46792. */
  46793. renderParticles: boolean;
  46794. /**
  46795. * Define if sprites should be rendered in your texture.
  46796. */
  46797. renderSprites: boolean;
  46798. /**
  46799. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46800. */
  46801. coordinatesMode: number;
  46802. /**
  46803. * Define the camera used to render the texture.
  46804. */
  46805. activeCamera: Nullable<Camera>;
  46806. /**
  46807. * Override the render function of the texture with your own one.
  46808. */
  46809. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46810. /**
  46811. * Define if camera post processes should be use while rendering the texture.
  46812. */
  46813. useCameraPostProcesses: boolean;
  46814. /**
  46815. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46816. */
  46817. ignoreCameraViewport: boolean;
  46818. private _postProcessManager;
  46819. private _postProcesses;
  46820. private _resizeObserver;
  46821. /**
  46822. * An event triggered when the texture is unbind.
  46823. */
  46824. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46825. /**
  46826. * An event triggered when the texture is unbind.
  46827. */
  46828. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46829. private _onAfterUnbindObserver;
  46830. /**
  46831. * Set a after unbind callback in the texture.
  46832. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46833. */
  46834. onAfterUnbind: () => void;
  46835. /**
  46836. * An event triggered before rendering the texture
  46837. */
  46838. onBeforeRenderObservable: Observable<number>;
  46839. private _onBeforeRenderObserver;
  46840. /**
  46841. * Set a before render callback in the texture.
  46842. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46843. */
  46844. onBeforeRender: (faceIndex: number) => void;
  46845. /**
  46846. * An event triggered after rendering the texture
  46847. */
  46848. onAfterRenderObservable: Observable<number>;
  46849. private _onAfterRenderObserver;
  46850. /**
  46851. * Set a after render callback in the texture.
  46852. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46853. */
  46854. onAfterRender: (faceIndex: number) => void;
  46855. /**
  46856. * An event triggered after the texture clear
  46857. */
  46858. onClearObservable: Observable<Engine>;
  46859. private _onClearObserver;
  46860. /**
  46861. * Set a clear callback in the texture.
  46862. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46863. */
  46864. onClear: (Engine: Engine) => void;
  46865. /**
  46866. * Define the clear color of the Render Target if it should be different from the scene.
  46867. */
  46868. clearColor: Color4;
  46869. protected _size: number | {
  46870. width: number;
  46871. height: number;
  46872. };
  46873. protected _initialSizeParameter: number | {
  46874. width: number;
  46875. height: number;
  46876. } | {
  46877. ratio: number;
  46878. };
  46879. protected _sizeRatio: Nullable<number>;
  46880. /** @hidden */
  46881. _generateMipMaps: boolean;
  46882. protected _renderingManager: RenderingManager;
  46883. /** @hidden */
  46884. _waitingRenderList: string[];
  46885. protected _doNotChangeAspectRatio: boolean;
  46886. protected _currentRefreshId: number;
  46887. protected _refreshRate: number;
  46888. protected _textureMatrix: Matrix;
  46889. protected _samples: number;
  46890. protected _renderTargetOptions: RenderTargetCreationOptions;
  46891. /**
  46892. * Gets render target creation options that were used.
  46893. */
  46894. readonly renderTargetOptions: RenderTargetCreationOptions;
  46895. protected _engine: Engine;
  46896. protected _onRatioRescale(): void;
  46897. /**
  46898. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46899. * It must define where the camera used to render the texture is set
  46900. */
  46901. boundingBoxPosition: Vector3;
  46902. private _boundingBoxSize;
  46903. /**
  46904. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46905. * When defined, the cubemap will switch to local mode
  46906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46907. * @example https://www.babylonjs-playground.com/#RNASML
  46908. */
  46909. boundingBoxSize: Vector3;
  46910. /**
  46911. * In case the RTT has been created with a depth texture, get the associated
  46912. * depth texture.
  46913. * Otherwise, return null.
  46914. */
  46915. depthStencilTexture: Nullable<InternalTexture>;
  46916. /**
  46917. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46918. * or used a shadow, depth texture...
  46919. * @param name The friendly name of the texture
  46920. * @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)
  46921. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46922. * @param generateMipMaps True if mip maps need to be generated after render.
  46923. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46924. * @param type The type of the buffer in the RTT (int, half float, float...)
  46925. * @param isCube True if a cube texture needs to be created
  46926. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46927. * @param generateDepthBuffer True to generate a depth buffer
  46928. * @param generateStencilBuffer True to generate a stencil buffer
  46929. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46930. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46931. */
  46932. constructor(name: string, size: number | {
  46933. width: number;
  46934. height: number;
  46935. } | {
  46936. ratio: number;
  46937. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46938. /**
  46939. * Creates a depth stencil texture.
  46940. * This is only available in WebGL 2 or with the depth texture extension available.
  46941. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46942. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46943. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46944. */
  46945. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46946. private _processSizeParameter;
  46947. /**
  46948. * Define the number of samples to use in case of MSAA.
  46949. * It defaults to one meaning no MSAA has been enabled.
  46950. */
  46951. samples: number;
  46952. /**
  46953. * Resets the refresh counter of the texture and start bak from scratch.
  46954. * Could be usefull to regenerate the texture if it is setup to render only once.
  46955. */
  46956. resetRefreshCounter(): void;
  46957. /**
  46958. * Define the refresh rate of the texture or the rendering frequency.
  46959. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  46960. */
  46961. refreshRate: number;
  46962. /**
  46963. * Adds a post process to the render target rendering passes.
  46964. * @param postProcess define the post process to add
  46965. */
  46966. addPostProcess(postProcess: PostProcess): void;
  46967. /**
  46968. * Clear all the post processes attached to the render target
  46969. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  46970. */
  46971. clearPostProcesses(dispose?: boolean): void;
  46972. /**
  46973. * Remove one of the post process from the list of attached post processes to the texture
  46974. * @param postProcess define the post process to remove from the list
  46975. */
  46976. removePostProcess(postProcess: PostProcess): void;
  46977. /** @hidden */
  46978. _shouldRender(): boolean;
  46979. /**
  46980. * Gets the actual render size of the texture.
  46981. * @returns the width of the render size
  46982. */
  46983. getRenderSize(): number;
  46984. /**
  46985. * Gets the actual render width of the texture.
  46986. * @returns the width of the render size
  46987. */
  46988. getRenderWidth(): number;
  46989. /**
  46990. * Gets the actual render height of the texture.
  46991. * @returns the height of the render size
  46992. */
  46993. getRenderHeight(): number;
  46994. /**
  46995. * Get if the texture can be rescaled or not.
  46996. */
  46997. readonly canRescale: boolean;
  46998. /**
  46999. * Resize the texture using a ratio.
  47000. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47001. */
  47002. scale(ratio: number): void;
  47003. /**
  47004. * Get the texture reflection matrix used to rotate/transform the reflection.
  47005. * @returns the reflection matrix
  47006. */
  47007. getReflectionTextureMatrix(): Matrix;
  47008. /**
  47009. * Resize the texture to a new desired size.
  47010. * Be carrefull as it will recreate all the data in the new texture.
  47011. * @param size Define the new size. It can be:
  47012. * - a number for squared texture,
  47013. * - an object containing { width: number, height: number }
  47014. * - or an object containing a ratio { ratio: number }
  47015. */
  47016. resize(size: number | {
  47017. width: number;
  47018. height: number;
  47019. } | {
  47020. ratio: number;
  47021. }): void;
  47022. /**
  47023. * Renders all the objects from the render list into the texture.
  47024. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47025. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47026. */
  47027. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47028. private _bestReflectionRenderTargetDimension;
  47029. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47030. private renderToTarget;
  47031. /**
  47032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47033. * This allowed control for front to back rendering or reversly depending of the special needs.
  47034. *
  47035. * @param renderingGroupId The rendering group id corresponding to its index
  47036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47039. */
  47040. 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;
  47041. /**
  47042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47043. *
  47044. * @param renderingGroupId The rendering group id corresponding to its index
  47045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47046. */
  47047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47048. /**
  47049. * Clones the texture.
  47050. * @returns the cloned texture
  47051. */
  47052. clone(): RenderTargetTexture;
  47053. /**
  47054. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47055. * @returns The JSON representation of the texture
  47056. */
  47057. serialize(): any;
  47058. /**
  47059. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47060. */
  47061. disposeFramebufferObjects(): void;
  47062. /**
  47063. * Dispose the texture and release its associated resources.
  47064. */
  47065. dispose(): void;
  47066. /** @hidden */
  47067. _rebuild(): void;
  47068. /**
  47069. * Clear the info related to rendering groups preventing retention point in material dispose.
  47070. */
  47071. freeRenderingGroups(): void;
  47072. }
  47073. }
  47074. declare module BABYLON {
  47075. /**
  47076. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47077. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47078. */
  47079. class Texture extends BaseTexture {
  47080. /** nearest is mag = nearest and min = nearest and mip = linear */
  47081. static readonly NEAREST_SAMPLINGMODE: number;
  47082. /** nearest is mag = nearest and min = nearest and mip = linear */
  47083. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47084. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47085. static readonly BILINEAR_SAMPLINGMODE: number;
  47086. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47087. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47088. /** Trilinear is mag = linear and min = linear and mip = linear */
  47089. static readonly TRILINEAR_SAMPLINGMODE: number;
  47090. /** Trilinear is mag = linear and min = linear and mip = linear */
  47091. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47092. /** mag = nearest and min = nearest and mip = nearest */
  47093. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47094. /** mag = nearest and min = linear and mip = nearest */
  47095. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47096. /** mag = nearest and min = linear and mip = linear */
  47097. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47098. /** mag = nearest and min = linear and mip = none */
  47099. static readonly NEAREST_LINEAR: number;
  47100. /** mag = nearest and min = nearest and mip = none */
  47101. static readonly NEAREST_NEAREST: number;
  47102. /** mag = linear and min = nearest and mip = nearest */
  47103. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47104. /** mag = linear and min = nearest and mip = linear */
  47105. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47106. /** mag = linear and min = linear and mip = none */
  47107. static readonly LINEAR_LINEAR: number;
  47108. /** mag = linear and min = nearest and mip = none */
  47109. static readonly LINEAR_NEAREST: number;
  47110. /** Explicit coordinates mode */
  47111. static readonly EXPLICIT_MODE: number;
  47112. /** Spherical coordinates mode */
  47113. static readonly SPHERICAL_MODE: number;
  47114. /** Planar coordinates mode */
  47115. static readonly PLANAR_MODE: number;
  47116. /** Cubic coordinates mode */
  47117. static readonly CUBIC_MODE: number;
  47118. /** Projection coordinates mode */
  47119. static readonly PROJECTION_MODE: number;
  47120. /** Inverse Cubic coordinates mode */
  47121. static readonly SKYBOX_MODE: number;
  47122. /** Inverse Cubic coordinates mode */
  47123. static readonly INVCUBIC_MODE: number;
  47124. /** Equirectangular coordinates mode */
  47125. static readonly EQUIRECTANGULAR_MODE: number;
  47126. /** Equirectangular Fixed coordinates mode */
  47127. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47128. /** Equirectangular Fixed Mirrored coordinates mode */
  47129. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47130. /** Texture is not repeating outside of 0..1 UVs */
  47131. static readonly CLAMP_ADDRESSMODE: number;
  47132. /** Texture is repeating outside of 0..1 UVs */
  47133. static readonly WRAP_ADDRESSMODE: number;
  47134. /** Texture is repeating and mirrored */
  47135. static readonly MIRROR_ADDRESSMODE: number;
  47136. /**
  47137. * 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
  47138. */
  47139. static UseSerializedUrlIfAny: boolean;
  47140. /**
  47141. * Define the url of the texture.
  47142. */
  47143. url: Nullable<string>;
  47144. /**
  47145. * Define an offset on the texture to offset the u coordinates of the UVs
  47146. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47147. */
  47148. uOffset: number;
  47149. /**
  47150. * Define an offset on the texture to offset the v coordinates of the UVs
  47151. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47152. */
  47153. vOffset: number;
  47154. /**
  47155. * Define an offset on the texture to scale the u coordinates of the UVs
  47156. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47157. */
  47158. uScale: number;
  47159. /**
  47160. * Define an offset on the texture to scale the v coordinates of the UVs
  47161. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47162. */
  47163. vScale: number;
  47164. /**
  47165. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47166. * @see http://doc.babylonjs.com/how_to/more_materials
  47167. */
  47168. uAng: number;
  47169. /**
  47170. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47171. * @see http://doc.babylonjs.com/how_to/more_materials
  47172. */
  47173. vAng: number;
  47174. /**
  47175. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47176. * @see http://doc.babylonjs.com/how_to/more_materials
  47177. */
  47178. wAng: number;
  47179. /**
  47180. * Defines the center of rotation (U)
  47181. */
  47182. uRotationCenter: number;
  47183. /**
  47184. * Defines the center of rotation (V)
  47185. */
  47186. vRotationCenter: number;
  47187. /**
  47188. * Defines the center of rotation (W)
  47189. */
  47190. wRotationCenter: number;
  47191. /**
  47192. * Are mip maps generated for this texture or not.
  47193. */
  47194. readonly noMipmap: boolean;
  47195. private _noMipmap;
  47196. /** @hidden */
  47197. _invertY: boolean;
  47198. private _rowGenerationMatrix;
  47199. private _cachedTextureMatrix;
  47200. private _projectionModeMatrix;
  47201. private _t0;
  47202. private _t1;
  47203. private _t2;
  47204. private _cachedUOffset;
  47205. private _cachedVOffset;
  47206. private _cachedUScale;
  47207. private _cachedVScale;
  47208. private _cachedUAng;
  47209. private _cachedVAng;
  47210. private _cachedWAng;
  47211. private _cachedProjectionMatrixId;
  47212. private _cachedCoordinatesMode;
  47213. /** @hidden */
  47214. _samplingMode: number;
  47215. /** @hidden */
  47216. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47217. private _deleteBuffer;
  47218. protected _format: Nullable<number>;
  47219. private _delayedOnLoad;
  47220. private _delayedOnError;
  47221. /**
  47222. * Observable triggered once the texture has been loaded.
  47223. */
  47224. onLoadObservable: Observable<Texture>;
  47225. protected _isBlocking: boolean;
  47226. /**
  47227. * Is the texture preventing material to render while loading.
  47228. * If false, a default texture will be used instead of the loading one during the preparation step.
  47229. */
  47230. isBlocking: boolean;
  47231. /**
  47232. * Get the current sampling mode associated with the texture.
  47233. */
  47234. readonly samplingMode: number;
  47235. /**
  47236. * Instantiates a new texture.
  47237. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47238. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47239. * @param url define the url of the picture to load as a texture
  47240. * @param scene define the scene the texture will belong to
  47241. * @param noMipmap define if the texture will require mip maps or not
  47242. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47243. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47244. * @param onLoad define a callback triggered when the texture has been loaded
  47245. * @param onError define a callback triggered when an error occurred during the loading session
  47246. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47247. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47248. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47249. */
  47250. 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);
  47251. /**
  47252. * Update the url (and optional buffer) of this texture if url was null during construction.
  47253. * @param url the url of the texture
  47254. * @param buffer the buffer of the texture (defaults to null)
  47255. */
  47256. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47257. /**
  47258. * Finish the loading sequence of a texture flagged as delayed load.
  47259. * @hidden
  47260. */
  47261. delayLoad(): void;
  47262. /**
  47263. * Update the sampling mode of the texture.
  47264. * Default is Trilinear mode.
  47265. *
  47266. * | Value | Type | Description |
  47267. * | ----- | ------------------ | ----------- |
  47268. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47269. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47270. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47271. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47272. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47273. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47274. * | 7 | NEAREST_LINEAR | |
  47275. * | 8 | NEAREST_NEAREST | |
  47276. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47277. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47278. * | 11 | LINEAR_LINEAR | |
  47279. * | 12 | LINEAR_NEAREST | |
  47280. *
  47281. * > _mag_: magnification filter (close to the viewer)
  47282. * > _min_: minification filter (far from the viewer)
  47283. * > _mip_: filter used between mip map levels
  47284. *@param samplingMode Define the new sampling mode of the texture
  47285. */
  47286. updateSamplingMode(samplingMode: number): void;
  47287. private _prepareRowForTextureGeneration;
  47288. /**
  47289. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47290. * @returns the transform matrix of the texture.
  47291. */
  47292. getTextureMatrix(): Matrix;
  47293. /**
  47294. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47295. * @returns The reflection texture transform
  47296. */
  47297. getReflectionTextureMatrix(): Matrix;
  47298. /**
  47299. * Clones the texture.
  47300. * @returns the cloned texture
  47301. */
  47302. clone(): Texture;
  47303. /**
  47304. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47305. * @returns The JSON representation of the texture
  47306. */
  47307. serialize(): any;
  47308. /**
  47309. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47310. * @returns "Texture"
  47311. */
  47312. getClassName(): string;
  47313. /**
  47314. * Dispose the texture and release its associated resources.
  47315. */
  47316. dispose(): void;
  47317. /**
  47318. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47319. * @param parsedTexture Define the JSON representation of the texture
  47320. * @param scene Define the scene the parsed texture should be instantiated in
  47321. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47322. * @returns The parsed texture if successful
  47323. */
  47324. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47325. /**
  47326. * Creates a texture from its base 64 representation.
  47327. * @param data Define the base64 payload without the data: prefix
  47328. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47329. * @param scene Define the scene the texture should belong to
  47330. * @param noMipmap Forces the texture to not create mip map information if true
  47331. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47332. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47333. * @param onLoad define a callback triggered when the texture has been loaded
  47334. * @param onError define a callback triggered when an error occurred during the loading session
  47335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47336. * @returns the created texture
  47337. */
  47338. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47339. /**
  47340. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47341. * @param data Define the base64 payload without the data: prefix
  47342. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47343. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47344. * @param scene Define the scene the texture should belong to
  47345. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47346. * @param noMipmap Forces the texture to not create mip map information if true
  47347. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47348. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47349. * @param onLoad define a callback triggered when the texture has been loaded
  47350. * @param onError define a callback triggered when an error occurred during the loading session
  47351. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47352. * @returns the created texture
  47353. */
  47354. 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;
  47355. }
  47356. }
  47357. declare module BABYLON {
  47358. /**
  47359. * Settings for finer control over video usage
  47360. */
  47361. interface VideoTextureSettings {
  47362. /**
  47363. * Applies `autoplay` to video, if specified
  47364. */
  47365. autoPlay?: boolean;
  47366. /**
  47367. * Applies `loop` to video, if specified
  47368. */
  47369. loop?: boolean;
  47370. /**
  47371. * Automatically updates internal texture from video at every frame in the render loop
  47372. */
  47373. autoUpdateTexture: boolean;
  47374. /**
  47375. * Image src displayed during the video loading or until the user interacts with the video.
  47376. */
  47377. poster?: string;
  47378. }
  47379. /**
  47380. * If you want to display a video in your scene, this is the special texture for that.
  47381. * This special texture works similar to other textures, with the exception of a few parameters.
  47382. * @see https://doc.babylonjs.com/how_to/video_texture
  47383. */
  47384. class VideoTexture extends Texture {
  47385. /**
  47386. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47387. */
  47388. readonly autoUpdateTexture: boolean;
  47389. /**
  47390. * The video instance used by the texture internally
  47391. */
  47392. readonly video: HTMLVideoElement;
  47393. private _onUserActionRequestedObservable;
  47394. /**
  47395. * Event triggerd when a dom action is required by the user to play the video.
  47396. * This happens due to recent changes in browser policies preventing video to auto start.
  47397. */
  47398. readonly onUserActionRequestedObservable: Observable<Texture>;
  47399. private _generateMipMaps;
  47400. private _engine;
  47401. private _stillImageCaptured;
  47402. private _poster;
  47403. /**
  47404. * Creates a video texture.
  47405. * If you want to display a video in your scene, this is the special texture for that.
  47406. * This special texture works similar to other textures, with the exception of a few parameters.
  47407. * @see https://doc.babylonjs.com/how_to/video_texture
  47408. * @param name optional name, will detect from video source, if not defined
  47409. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47410. * @param scene is obviously the current scene.
  47411. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47412. * @param invertY is false by default but can be used to invert video on Y axis
  47413. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47414. * @param settings allows finer control over video usage
  47415. */
  47416. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47417. private _getName;
  47418. private _getVideo;
  47419. private _createInternalTexture;
  47420. private reset;
  47421. /**
  47422. * @hidden Internal method to initiate `update`.
  47423. */
  47424. _rebuild(): void;
  47425. /**
  47426. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47427. */
  47428. update(): void;
  47429. /**
  47430. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47431. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47432. */
  47433. updateTexture(isVisible: boolean): void;
  47434. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47435. /**
  47436. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47437. * @param url New url.
  47438. */
  47439. updateURL(url: string): void;
  47440. /**
  47441. * Dispose the texture and release its associated resources.
  47442. */
  47443. dispose(): void;
  47444. /**
  47445. * Creates a video texture straight from your WebCam video feed.
  47446. * @param scene Define the scene the texture should be created in
  47447. * @param onReady Define a callback to triggered once the texture will be ready
  47448. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47449. */
  47450. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47451. minWidth: number;
  47452. maxWidth: number;
  47453. minHeight: number;
  47454. maxHeight: number;
  47455. deviceId: string;
  47456. }): void;
  47457. }
  47458. }
  47459. declare var DracoDecoderModule: any;
  47460. declare var WebAssembly: any;
  47461. declare module BABYLON {
  47462. /**
  47463. * Configuration for Draco compression
  47464. */
  47465. interface IDracoCompressionConfiguration {
  47466. /**
  47467. * Configuration for the decoder.
  47468. */
  47469. decoder?: {
  47470. /**
  47471. * The url to the WebAssembly module.
  47472. */
  47473. wasmUrl?: string;
  47474. /**
  47475. * The url to the WebAssembly binary.
  47476. */
  47477. wasmBinaryUrl?: string;
  47478. /**
  47479. * The url to the fallback JavaScript module.
  47480. */
  47481. fallbackUrl?: string;
  47482. };
  47483. }
  47484. /**
  47485. * Draco compression (https://google.github.io/draco/)
  47486. *
  47487. * This class wraps the Draco module.
  47488. *
  47489. * **Encoder**
  47490. *
  47491. * The encoder is not currently implemented.
  47492. *
  47493. * **Decoder**
  47494. *
  47495. * 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.
  47496. *
  47497. * To update the configuration, use the following code:
  47498. * ```javascript
  47499. * BABYLON.DracoCompression.Configuration = {
  47500. * decoder: {
  47501. * wasmUrl: "<url to the WebAssembly library>",
  47502. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47503. * fallbackUrl: "<url to the fallback JavaScript library>",
  47504. * }
  47505. * };
  47506. * ```
  47507. *
  47508. * 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.
  47509. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47510. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47511. *
  47512. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47513. * ```javascript
  47514. * var dracoCompression = new BABYLON.DracoCompression();
  47515. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47516. * [BABYLON.VertexBuffer.PositionKind]: 0
  47517. * });
  47518. * ```
  47519. *
  47520. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47521. */
  47522. class DracoCompression implements IDisposable {
  47523. private static _DecoderModulePromise;
  47524. /**
  47525. * The configuration. Defaults to the following urls:
  47526. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47527. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47528. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47529. */
  47530. static Configuration: IDracoCompressionConfiguration;
  47531. /**
  47532. * Returns true if the decoder is available.
  47533. */
  47534. static readonly DecoderAvailable: boolean;
  47535. /**
  47536. * Constructor
  47537. */
  47538. constructor();
  47539. /**
  47540. * Stop all async operations and release resources.
  47541. */
  47542. dispose(): void;
  47543. /**
  47544. * Decode Draco compressed mesh data to vertex data.
  47545. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47546. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47547. * @returns A promise that resolves with the decoded vertex data
  47548. */
  47549. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47550. [kind: string]: number;
  47551. }): Promise<VertexData>;
  47552. private static _GetDecoderModule;
  47553. private static _LoadScriptAsync;
  47554. private static _LoadFileAsync;
  47555. }
  47556. }
  47557. declare module BABYLON {
  47558. /**
  47559. * Particle emitter emitting particles from the inside of a box.
  47560. * It emits the particles randomly between 2 given directions.
  47561. */
  47562. class BoxParticleEmitter implements IParticleEmitterType {
  47563. /**
  47564. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47565. */
  47566. direction1: Vector3;
  47567. /**
  47568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47569. */
  47570. direction2: Vector3;
  47571. /**
  47572. * 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.
  47573. */
  47574. minEmitBox: Vector3;
  47575. /**
  47576. * 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.
  47577. */
  47578. maxEmitBox: Vector3;
  47579. /**
  47580. * Creates a new instance BoxParticleEmitter
  47581. */
  47582. constructor();
  47583. /**
  47584. * Called by the particle System when the direction is computed for the created particle.
  47585. * @param worldMatrix is the world matrix of the particle system
  47586. * @param directionToUpdate is the direction vector to update with the result
  47587. * @param particle is the particle we are computed the direction for
  47588. */
  47589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47590. /**
  47591. * Called by the particle System when the position is computed for the created particle.
  47592. * @param worldMatrix is the world matrix of the particle system
  47593. * @param positionToUpdate is the position vector to update with the result
  47594. * @param particle is the particle we are computed the position for
  47595. */
  47596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47597. /**
  47598. * Clones the current emitter and returns a copy of it
  47599. * @returns the new emitter
  47600. */
  47601. clone(): BoxParticleEmitter;
  47602. /**
  47603. * Called by the GPUParticleSystem to setup the update shader
  47604. * @param effect defines the update shader
  47605. */
  47606. applyToShader(effect: Effect): void;
  47607. /**
  47608. * Returns a string to use to update the GPU particles update shader
  47609. * @returns a string containng the defines string
  47610. */
  47611. getEffectDefines(): string;
  47612. /**
  47613. * Returns the string "BoxParticleEmitter"
  47614. * @returns a string containing the class name
  47615. */
  47616. getClassName(): string;
  47617. /**
  47618. * Serializes the particle system to a JSON object.
  47619. * @returns the JSON object
  47620. */
  47621. serialize(): any;
  47622. /**
  47623. * Parse properties from a JSON object
  47624. * @param serializationObject defines the JSON object
  47625. */
  47626. parse(serializationObject: any): void;
  47627. }
  47628. }
  47629. declare module BABYLON {
  47630. /**
  47631. * Particle emitter emitting particles from the inside of a cone.
  47632. * It emits the particles alongside the cone volume from the base to the particle.
  47633. * The emission direction might be randomized.
  47634. */
  47635. class ConeParticleEmitter implements IParticleEmitterType {
  47636. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47637. directionRandomizer: number;
  47638. private _radius;
  47639. private _angle;
  47640. private _height;
  47641. /**
  47642. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47643. */
  47644. radiusRange: number;
  47645. /**
  47646. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47647. */
  47648. heightRange: number;
  47649. /**
  47650. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47651. */
  47652. emitFromSpawnPointOnly: boolean;
  47653. /**
  47654. * Gets or sets the radius of the emission cone
  47655. */
  47656. radius: number;
  47657. /**
  47658. * Gets or sets the angle of the emission cone
  47659. */
  47660. angle: number;
  47661. private _buildHeight;
  47662. /**
  47663. * Creates a new instance ConeParticleEmitter
  47664. * @param radius the radius of the emission cone (1 by default)
  47665. * @param angles the cone base angle (PI by default)
  47666. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47667. */
  47668. constructor(radius?: number, angle?: number,
  47669. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47670. directionRandomizer?: number);
  47671. /**
  47672. * Called by the particle System when the direction is computed for the created particle.
  47673. * @param worldMatrix is the world matrix of the particle system
  47674. * @param directionToUpdate is the direction vector to update with the result
  47675. * @param particle is the particle we are computed the direction for
  47676. */
  47677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47678. /**
  47679. * Called by the particle System when the position is computed for the created particle.
  47680. * @param worldMatrix is the world matrix of the particle system
  47681. * @param positionToUpdate is the position vector to update with the result
  47682. * @param particle is the particle we are computed the position for
  47683. */
  47684. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47685. /**
  47686. * Clones the current emitter and returns a copy of it
  47687. * @returns the new emitter
  47688. */
  47689. clone(): ConeParticleEmitter;
  47690. /**
  47691. * Called by the GPUParticleSystem to setup the update shader
  47692. * @param effect defines the update shader
  47693. */
  47694. applyToShader(effect: Effect): void;
  47695. /**
  47696. * Returns a string to use to update the GPU particles update shader
  47697. * @returns a string containng the defines string
  47698. */
  47699. getEffectDefines(): string;
  47700. /**
  47701. * Returns the string "ConeParticleEmitter"
  47702. * @returns a string containing the class name
  47703. */
  47704. getClassName(): string;
  47705. /**
  47706. * Serializes the particle system to a JSON object.
  47707. * @returns the JSON object
  47708. */
  47709. serialize(): any;
  47710. /**
  47711. * Parse properties from a JSON object
  47712. * @param serializationObject defines the JSON object
  47713. */
  47714. parse(serializationObject: any): void;
  47715. }
  47716. }
  47717. declare module BABYLON {
  47718. /**
  47719. * Particle emitter emitting particles from the inside of a cylinder.
  47720. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47721. */
  47722. class CylinderParticleEmitter implements IParticleEmitterType {
  47723. /**
  47724. * The radius of the emission cylinder.
  47725. */
  47726. radius: number;
  47727. /**
  47728. * The height of the emission cylinder.
  47729. */
  47730. height: number;
  47731. /**
  47732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47733. */
  47734. radiusRange: number;
  47735. /**
  47736. * How much to randomize the particle direction [0-1].
  47737. */
  47738. directionRandomizer: number;
  47739. /**
  47740. * Creates a new instance CylinderParticleEmitter
  47741. * @param radius the radius of the emission cylinder (1 by default)
  47742. * @param height the height of the emission cylinder (1 by default)
  47743. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47744. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47745. */
  47746. constructor(
  47747. /**
  47748. * The radius of the emission cylinder.
  47749. */
  47750. radius?: number,
  47751. /**
  47752. * The height of the emission cylinder.
  47753. */
  47754. height?: number,
  47755. /**
  47756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47757. */
  47758. radiusRange?: number,
  47759. /**
  47760. * How much to randomize the particle direction [0-1].
  47761. */
  47762. directionRandomizer?: number);
  47763. /**
  47764. * Called by the particle System when the direction is computed for the created particle.
  47765. * @param worldMatrix is the world matrix of the particle system
  47766. * @param directionToUpdate is the direction vector to update with the result
  47767. * @param particle is the particle we are computed the direction for
  47768. */
  47769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47770. /**
  47771. * Called by the particle System when the position is computed for the created particle.
  47772. * @param worldMatrix is the world matrix of the particle system
  47773. * @param positionToUpdate is the position vector to update with the result
  47774. * @param particle is the particle we are computed the position for
  47775. */
  47776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47777. /**
  47778. * Clones the current emitter and returns a copy of it
  47779. * @returns the new emitter
  47780. */
  47781. clone(): CylinderParticleEmitter;
  47782. /**
  47783. * Called by the GPUParticleSystem to setup the update shader
  47784. * @param effect defines the update shader
  47785. */
  47786. applyToShader(effect: Effect): void;
  47787. /**
  47788. * Returns a string to use to update the GPU particles update shader
  47789. * @returns a string containng the defines string
  47790. */
  47791. getEffectDefines(): string;
  47792. /**
  47793. * Returns the string "CylinderParticleEmitter"
  47794. * @returns a string containing the class name
  47795. */
  47796. getClassName(): string;
  47797. /**
  47798. * Serializes the particle system to a JSON object.
  47799. * @returns the JSON object
  47800. */
  47801. serialize(): any;
  47802. /**
  47803. * Parse properties from a JSON object
  47804. * @param serializationObject defines the JSON object
  47805. */
  47806. parse(serializationObject: any): void;
  47807. }
  47808. /**
  47809. * Particle emitter emitting particles from the inside of a cylinder.
  47810. * It emits the particles randomly between two vectors.
  47811. */
  47812. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47813. /**
  47814. * The min limit of the emission direction.
  47815. */
  47816. direction1: Vector3;
  47817. /**
  47818. * The max limit of the emission direction.
  47819. */
  47820. direction2: Vector3;
  47821. /**
  47822. * Creates a new instance CylinderDirectedParticleEmitter
  47823. * @param radius the radius of the emission cylinder (1 by default)
  47824. * @param height the height of the emission cylinder (1 by default)
  47825. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47826. * @param direction1 the min limit of the emission direction (up vector by default)
  47827. * @param direction2 the max limit of the emission direction (up vector by default)
  47828. */
  47829. constructor(radius?: number, height?: number, radiusRange?: number,
  47830. /**
  47831. * The min limit of the emission direction.
  47832. */
  47833. direction1?: Vector3,
  47834. /**
  47835. * The max limit of the emission direction.
  47836. */
  47837. direction2?: Vector3);
  47838. /**
  47839. * Called by the particle System when the direction is computed for the created particle.
  47840. * @param worldMatrix is the world matrix of the particle system
  47841. * @param directionToUpdate is the direction vector to update with the result
  47842. * @param particle is the particle we are computed the direction for
  47843. */
  47844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47845. /**
  47846. * Clones the current emitter and returns a copy of it
  47847. * @returns the new emitter
  47848. */
  47849. clone(): CylinderDirectedParticleEmitter;
  47850. /**
  47851. * Called by the GPUParticleSystem to setup the update shader
  47852. * @param effect defines the update shader
  47853. */
  47854. applyToShader(effect: Effect): void;
  47855. /**
  47856. * Returns a string to use to update the GPU particles update shader
  47857. * @returns a string containng the defines string
  47858. */
  47859. getEffectDefines(): string;
  47860. /**
  47861. * Returns the string "CylinderDirectedParticleEmitter"
  47862. * @returns a string containing the class name
  47863. */
  47864. getClassName(): string;
  47865. /**
  47866. * Serializes the particle system to a JSON object.
  47867. * @returns the JSON object
  47868. */
  47869. serialize(): any;
  47870. /**
  47871. * Parse properties from a JSON object
  47872. * @param serializationObject defines the JSON object
  47873. */
  47874. parse(serializationObject: any): void;
  47875. }
  47876. }
  47877. declare module BABYLON {
  47878. /**
  47879. * Particle emitter emitting particles from the inside of a hemisphere.
  47880. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  47881. */
  47882. class HemisphericParticleEmitter implements IParticleEmitterType {
  47883. /**
  47884. * The radius of the emission hemisphere.
  47885. */
  47886. radius: number;
  47887. /**
  47888. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47889. */
  47890. radiusRange: number;
  47891. /**
  47892. * How much to randomize the particle direction [0-1].
  47893. */
  47894. directionRandomizer: number;
  47895. /**
  47896. * Creates a new instance HemisphericParticleEmitter
  47897. * @param radius the radius of the emission hemisphere (1 by default)
  47898. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47899. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47900. */
  47901. constructor(
  47902. /**
  47903. * The radius of the emission hemisphere.
  47904. */
  47905. radius?: number,
  47906. /**
  47907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47908. */
  47909. radiusRange?: number,
  47910. /**
  47911. * How much to randomize the particle direction [0-1].
  47912. */
  47913. directionRandomizer?: number);
  47914. /**
  47915. * Called by the particle System when the direction is computed for the created particle.
  47916. * @param worldMatrix is the world matrix of the particle system
  47917. * @param directionToUpdate is the direction vector to update with the result
  47918. * @param particle is the particle we are computed the direction for
  47919. */
  47920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47921. /**
  47922. * Called by the particle System when the position is computed for the created particle.
  47923. * @param worldMatrix is the world matrix of the particle system
  47924. * @param positionToUpdate is the position vector to update with the result
  47925. * @param particle is the particle we are computed the position for
  47926. */
  47927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47928. /**
  47929. * Clones the current emitter and returns a copy of it
  47930. * @returns the new emitter
  47931. */
  47932. clone(): HemisphericParticleEmitter;
  47933. /**
  47934. * Called by the GPUParticleSystem to setup the update shader
  47935. * @param effect defines the update shader
  47936. */
  47937. applyToShader(effect: Effect): void;
  47938. /**
  47939. * Returns a string to use to update the GPU particles update shader
  47940. * @returns a string containng the defines string
  47941. */
  47942. getEffectDefines(): string;
  47943. /**
  47944. * Returns the string "HemisphericParticleEmitter"
  47945. * @returns a string containing the class name
  47946. */
  47947. getClassName(): string;
  47948. /**
  47949. * Serializes the particle system to a JSON object.
  47950. * @returns the JSON object
  47951. */
  47952. serialize(): any;
  47953. /**
  47954. * Parse properties from a JSON object
  47955. * @param serializationObject defines the JSON object
  47956. */
  47957. parse(serializationObject: any): void;
  47958. }
  47959. }
  47960. declare module BABYLON {
  47961. /**
  47962. * Particle emitter represents a volume emitting particles.
  47963. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  47964. */
  47965. interface IParticleEmitterType {
  47966. /**
  47967. * Called by the particle System when the direction is computed for the created particle.
  47968. * @param worldMatrix is the world matrix of the particle system
  47969. * @param directionToUpdate is the direction vector to update with the result
  47970. * @param particle is the particle we are computed the direction for
  47971. */
  47972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47973. /**
  47974. * Called by the particle System when the position is computed for the created particle.
  47975. * @param worldMatrix is the world matrix of the particle system
  47976. * @param positionToUpdate is the position vector to update with the result
  47977. * @param particle is the particle we are computed the position for
  47978. */
  47979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47980. /**
  47981. * Clones the current emitter and returns a copy of it
  47982. * @returns the new emitter
  47983. */
  47984. clone(): IParticleEmitterType;
  47985. /**
  47986. * Called by the GPUParticleSystem to setup the update shader
  47987. * @param effect defines the update shader
  47988. */
  47989. applyToShader(effect: Effect): void;
  47990. /**
  47991. * Returns a string to use to update the GPU particles update shader
  47992. * @returns the effect defines string
  47993. */
  47994. getEffectDefines(): string;
  47995. /**
  47996. * Returns a string representing the class name
  47997. * @returns a string containing the class name
  47998. */
  47999. getClassName(): string;
  48000. /**
  48001. * Serializes the particle system to a JSON object.
  48002. * @returns the JSON object
  48003. */
  48004. serialize(): any;
  48005. /**
  48006. * Parse properties from a JSON object
  48007. * @param serializationObject defines the JSON object
  48008. */
  48009. parse(serializationObject: any): void;
  48010. }
  48011. }
  48012. declare module BABYLON {
  48013. /**
  48014. * Particle emitter emitting particles from a point.
  48015. * It emits the particles randomly between 2 given directions.
  48016. */
  48017. class PointParticleEmitter implements IParticleEmitterType {
  48018. /**
  48019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48020. */
  48021. direction1: Vector3;
  48022. /**
  48023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48024. */
  48025. direction2: Vector3;
  48026. /**
  48027. * Creates a new instance PointParticleEmitter
  48028. */
  48029. constructor();
  48030. /**
  48031. * Called by the particle System when the direction is computed for the created particle.
  48032. * @param worldMatrix is the world matrix of the particle system
  48033. * @param directionToUpdate is the direction vector to update with the result
  48034. * @param particle is the particle we are computed the direction for
  48035. */
  48036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48037. /**
  48038. * Called by the particle System when the position is computed for the created particle.
  48039. * @param worldMatrix is the world matrix of the particle system
  48040. * @param positionToUpdate is the position vector to update with the result
  48041. * @param particle is the particle we are computed the position for
  48042. */
  48043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48044. /**
  48045. * Clones the current emitter and returns a copy of it
  48046. * @returns the new emitter
  48047. */
  48048. clone(): PointParticleEmitter;
  48049. /**
  48050. * Called by the GPUParticleSystem to setup the update shader
  48051. * @param effect defines the update shader
  48052. */
  48053. applyToShader(effect: Effect): void;
  48054. /**
  48055. * Returns a string to use to update the GPU particles update shader
  48056. * @returns a string containng the defines string
  48057. */
  48058. getEffectDefines(): string;
  48059. /**
  48060. * Returns the string "PointParticleEmitter"
  48061. * @returns a string containing the class name
  48062. */
  48063. getClassName(): string;
  48064. /**
  48065. * Serializes the particle system to a JSON object.
  48066. * @returns the JSON object
  48067. */
  48068. serialize(): any;
  48069. /**
  48070. * Parse properties from a JSON object
  48071. * @param serializationObject defines the JSON object
  48072. */
  48073. parse(serializationObject: any): void;
  48074. }
  48075. }
  48076. declare module BABYLON {
  48077. /**
  48078. * Particle emitter emitting particles from the inside of a sphere.
  48079. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48080. */
  48081. class SphereParticleEmitter implements IParticleEmitterType {
  48082. /**
  48083. * The radius of the emission sphere.
  48084. */
  48085. radius: number;
  48086. /**
  48087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48088. */
  48089. radiusRange: number;
  48090. /**
  48091. * How much to randomize the particle direction [0-1].
  48092. */
  48093. directionRandomizer: number;
  48094. /**
  48095. * Creates a new instance SphereParticleEmitter
  48096. * @param radius the radius of the emission sphere (1 by default)
  48097. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48098. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48099. */
  48100. constructor(
  48101. /**
  48102. * The radius of the emission sphere.
  48103. */
  48104. radius?: number,
  48105. /**
  48106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48107. */
  48108. radiusRange?: number,
  48109. /**
  48110. * How much to randomize the particle direction [0-1].
  48111. */
  48112. directionRandomizer?: number);
  48113. /**
  48114. * Called by the particle System when the direction is computed for the created particle.
  48115. * @param worldMatrix is the world matrix of the particle system
  48116. * @param directionToUpdate is the direction vector to update with the result
  48117. * @param particle is the particle we are computed the direction for
  48118. */
  48119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48120. /**
  48121. * Called by the particle System when the position is computed for the created particle.
  48122. * @param worldMatrix is the world matrix of the particle system
  48123. * @param positionToUpdate is the position vector to update with the result
  48124. * @param particle is the particle we are computed the position for
  48125. */
  48126. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48127. /**
  48128. * Clones the current emitter and returns a copy of it
  48129. * @returns the new emitter
  48130. */
  48131. clone(): SphereParticleEmitter;
  48132. /**
  48133. * Called by the GPUParticleSystem to setup the update shader
  48134. * @param effect defines the update shader
  48135. */
  48136. applyToShader(effect: Effect): void;
  48137. /**
  48138. * Returns a string to use to update the GPU particles update shader
  48139. * @returns a string containng the defines string
  48140. */
  48141. getEffectDefines(): string;
  48142. /**
  48143. * Returns the string "SphereParticleEmitter"
  48144. * @returns a string containing the class name
  48145. */
  48146. getClassName(): string;
  48147. /**
  48148. * Serializes the particle system to a JSON object.
  48149. * @returns the JSON object
  48150. */
  48151. serialize(): any;
  48152. /**
  48153. * Parse properties from a JSON object
  48154. * @param serializationObject defines the JSON object
  48155. */
  48156. parse(serializationObject: any): void;
  48157. }
  48158. /**
  48159. * Particle emitter emitting particles from the inside of a sphere.
  48160. * It emits the particles randomly between two vectors.
  48161. */
  48162. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48163. /**
  48164. * The min limit of the emission direction.
  48165. */
  48166. direction1: Vector3;
  48167. /**
  48168. * The max limit of the emission direction.
  48169. */
  48170. direction2: Vector3;
  48171. /**
  48172. * Creates a new instance SphereDirectedParticleEmitter
  48173. * @param radius the radius of the emission sphere (1 by default)
  48174. * @param direction1 the min limit of the emission direction (up vector by default)
  48175. * @param direction2 the max limit of the emission direction (up vector by default)
  48176. */
  48177. constructor(radius?: number,
  48178. /**
  48179. * The min limit of the emission direction.
  48180. */
  48181. direction1?: Vector3,
  48182. /**
  48183. * The max limit of the emission direction.
  48184. */
  48185. direction2?: Vector3);
  48186. /**
  48187. * Called by the particle System when the direction is computed for the created particle.
  48188. * @param worldMatrix is the world matrix of the particle system
  48189. * @param directionToUpdate is the direction vector to update with the result
  48190. * @param particle is the particle we are computed the direction for
  48191. */
  48192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48193. /**
  48194. * Clones the current emitter and returns a copy of it
  48195. * @returns the new emitter
  48196. */
  48197. clone(): SphereDirectedParticleEmitter;
  48198. /**
  48199. * Called by the GPUParticleSystem to setup the update shader
  48200. * @param effect defines the update shader
  48201. */
  48202. applyToShader(effect: Effect): void;
  48203. /**
  48204. * Returns a string to use to update the GPU particles update shader
  48205. * @returns a string containng the defines string
  48206. */
  48207. getEffectDefines(): string;
  48208. /**
  48209. * Returns the string "SphereDirectedParticleEmitter"
  48210. * @returns a string containing the class name
  48211. */
  48212. getClassName(): string;
  48213. /**
  48214. * Serializes the particle system to a JSON object.
  48215. * @returns the JSON object
  48216. */
  48217. serialize(): any;
  48218. /**
  48219. * Parse properties from a JSON object
  48220. * @param serializationObject defines the JSON object
  48221. */
  48222. parse(serializationObject: any): void;
  48223. }
  48224. }
  48225. declare module BABYLON {
  48226. /** @hidden */
  48227. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48228. private _useDeltaForWorldStep;
  48229. world: any;
  48230. name: string;
  48231. private _physicsMaterials;
  48232. private _fixedTimeStep;
  48233. BJSCANNON: any;
  48234. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48235. setGravity(gravity: Vector3): void;
  48236. setTimeStep(timeStep: number): void;
  48237. getTimeStep(): number;
  48238. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48239. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48241. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48242. private _processChildMeshes;
  48243. removePhysicsBody(impostor: PhysicsImpostor): void;
  48244. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48245. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48246. private _addMaterial;
  48247. private _checkWithEpsilon;
  48248. private _createShape;
  48249. private _createHeightmap;
  48250. private _minus90X;
  48251. private _plus90X;
  48252. private _tmpPosition;
  48253. private _tmpDeltaPosition;
  48254. private _tmpUnityRotation;
  48255. private _updatePhysicsBodyTransformation;
  48256. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48257. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48258. isSupported(): boolean;
  48259. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48260. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48261. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48262. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48263. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48264. getBodyMass(impostor: PhysicsImpostor): number;
  48265. getBodyFriction(impostor: PhysicsImpostor): number;
  48266. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48267. getBodyRestitution(impostor: PhysicsImpostor): number;
  48268. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48269. sleepBody(impostor: PhysicsImpostor): void;
  48270. wakeUpBody(impostor: PhysicsImpostor): void;
  48271. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48272. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48273. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48274. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48275. getRadius(impostor: PhysicsImpostor): number;
  48276. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48277. dispose(): void;
  48278. private _extendNamespace;
  48279. }
  48280. }
  48281. declare module BABYLON {
  48282. /** @hidden */
  48283. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48284. world: any;
  48285. name: string;
  48286. BJSOIMO: any;
  48287. constructor(iterations?: number);
  48288. setGravity(gravity: Vector3): void;
  48289. setTimeStep(timeStep: number): void;
  48290. getTimeStep(): number;
  48291. private _tmpImpostorsArray;
  48292. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48293. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48294. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48295. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48296. private _tmpPositionVector;
  48297. removePhysicsBody(impostor: PhysicsImpostor): void;
  48298. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48299. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48300. isSupported(): boolean;
  48301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48302. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48303. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48304. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48305. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48306. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48307. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48308. getBodyMass(impostor: PhysicsImpostor): number;
  48309. getBodyFriction(impostor: PhysicsImpostor): number;
  48310. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48311. getBodyRestitution(impostor: PhysicsImpostor): number;
  48312. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48313. sleepBody(impostor: PhysicsImpostor): void;
  48314. wakeUpBody(impostor: PhysicsImpostor): void;
  48315. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48316. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48317. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48318. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48319. getRadius(impostor: PhysicsImpostor): number;
  48320. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48321. dispose(): void;
  48322. }
  48323. }
  48324. declare module BABYLON {
  48325. /**
  48326. * This represents a set of one or more post processes in Babylon.
  48327. * A post process can be used to apply a shader to a texture after it is rendered.
  48328. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48329. */
  48330. class PostProcessRenderEffect {
  48331. private _postProcesses;
  48332. private _getPostProcesses;
  48333. private _singleInstance;
  48334. private _cameras;
  48335. private _indicesForCamera;
  48336. /**
  48337. * Name of the effect
  48338. * @hidden
  48339. */
  48340. _name: string;
  48341. /**
  48342. * Instantiates a post process render effect.
  48343. * A post process can be used to apply a shader to a texture after it is rendered.
  48344. * @param engine The engine the effect is tied to
  48345. * @param name The name of the effect
  48346. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48347. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48348. */
  48349. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48350. /**
  48351. * Checks if all the post processes in the effect are supported.
  48352. */
  48353. readonly isSupported: boolean;
  48354. /**
  48355. * Updates the current state of the effect
  48356. * @hidden
  48357. */
  48358. _update(): void;
  48359. /**
  48360. * Attaches the effect on cameras
  48361. * @param cameras The camera to attach to.
  48362. * @hidden
  48363. */
  48364. _attachCameras(cameras: Camera): void;
  48365. /**
  48366. * Attaches the effect on cameras
  48367. * @param cameras The camera to attach to.
  48368. * @hidden
  48369. */
  48370. _attachCameras(cameras: Camera[]): void;
  48371. /**
  48372. * Detatches the effect on cameras
  48373. * @param cameras The camera to detatch from.
  48374. * @hidden
  48375. */
  48376. _detachCameras(cameras: Camera): void;
  48377. /**
  48378. * Detatches the effect on cameras
  48379. * @param cameras The camera to detatch from.
  48380. * @hidden
  48381. */
  48382. _detachCameras(cameras: Camera[]): void;
  48383. /**
  48384. * Enables the effect on given cameras
  48385. * @param cameras The camera to enable.
  48386. * @hidden
  48387. */
  48388. _enable(cameras: Camera): void;
  48389. /**
  48390. * Enables the effect on given cameras
  48391. * @param cameras The camera to enable.
  48392. * @hidden
  48393. */
  48394. _enable(cameras: Nullable<Camera[]>): void;
  48395. /**
  48396. * Disables the effect on the given cameras
  48397. * @param cameras The camera to disable.
  48398. * @hidden
  48399. */
  48400. _disable(cameras: Camera): void;
  48401. /**
  48402. * Disables the effect on the given cameras
  48403. * @param cameras The camera to disable.
  48404. * @hidden
  48405. */
  48406. _disable(cameras: Nullable<Camera[]>): void;
  48407. /**
  48408. * Gets a list of the post processes contained in the effect.
  48409. * @param camera The camera to get the post processes on.
  48410. * @returns The list of the post processes in the effect.
  48411. */
  48412. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48413. }
  48414. }
  48415. declare module BABYLON {
  48416. /**
  48417. * PostProcessRenderPipeline
  48418. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48419. */
  48420. class PostProcessRenderPipeline {
  48421. private engine;
  48422. private _renderEffects;
  48423. private _renderEffectsForIsolatedPass;
  48424. /**
  48425. * @hidden
  48426. */
  48427. protected _cameras: Camera[];
  48428. /** @hidden */
  48429. _name: string;
  48430. /**
  48431. * Initializes a PostProcessRenderPipeline
  48432. * @param engine engine to add the pipeline to
  48433. * @param name name of the pipeline
  48434. */
  48435. constructor(engine: Engine, name: string);
  48436. /**
  48437. * "PostProcessRenderPipeline"
  48438. * @returns "PostProcessRenderPipeline"
  48439. */
  48440. getClassName(): string;
  48441. /**
  48442. * If all the render effects in the pipeline are support
  48443. */
  48444. readonly isSupported: boolean;
  48445. /**
  48446. * Adds an effect to the pipeline
  48447. * @param renderEffect the effect to add
  48448. */
  48449. addEffect(renderEffect: PostProcessRenderEffect): void;
  48450. /** @hidden */
  48451. _rebuild(): void;
  48452. /** @hidden */
  48453. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48454. /** @hidden */
  48455. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48456. /** @hidden */
  48457. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48458. /** @hidden */
  48459. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48460. /** @hidden */
  48461. _attachCameras(cameras: Camera, unique: boolean): void;
  48462. /** @hidden */
  48463. _attachCameras(cameras: Camera[], unique: boolean): void;
  48464. /** @hidden */
  48465. _detachCameras(cameras: Camera): void;
  48466. /** @hidden */
  48467. _detachCameras(cameras: Nullable<Camera[]>): void;
  48468. /** @hidden */
  48469. _update(): void;
  48470. /** @hidden */
  48471. _reset(): void;
  48472. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48473. /**
  48474. * Disposes of the pipeline
  48475. */
  48476. dispose(): void;
  48477. }
  48478. }
  48479. declare module BABYLON {
  48480. /**
  48481. * PostProcessRenderPipelineManager class
  48482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48483. */
  48484. class PostProcessRenderPipelineManager {
  48485. private _renderPipelines;
  48486. /**
  48487. * Initializes a PostProcessRenderPipelineManager
  48488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48489. */
  48490. constructor();
  48491. /**
  48492. * Adds a pipeline to the manager
  48493. * @param renderPipeline The pipeline to add
  48494. */
  48495. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48496. /**
  48497. * Attaches a camera to the pipeline
  48498. * @param renderPipelineName The name of the pipeline to attach to
  48499. * @param cameras the camera to attach
  48500. * @param unique if the camera can be attached multiple times to the pipeline
  48501. */
  48502. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48503. /**
  48504. * Detaches a camera from the pipeline
  48505. * @param renderPipelineName The name of the pipeline to detach from
  48506. * @param cameras the camera to detach
  48507. */
  48508. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48509. /**
  48510. * Enables an effect by name on a pipeline
  48511. * @param renderPipelineName the name of the pipeline to enable the effect in
  48512. * @param renderEffectName the name of the effect to enable
  48513. * @param cameras the cameras that the effect should be enabled on
  48514. */
  48515. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48516. /**
  48517. * Disables an effect by name on a pipeline
  48518. * @param renderPipelineName the name of the pipeline to disable the effect in
  48519. * @param renderEffectName the name of the effect to disable
  48520. * @param cameras the cameras that the effect should be disabled on
  48521. */
  48522. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48523. /**
  48524. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48525. */
  48526. update(): void;
  48527. /** @hidden */
  48528. _rebuild(): void;
  48529. /**
  48530. * Disposes of the manager and pipelines
  48531. */
  48532. dispose(): void;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. interface Scene {
  48537. /** @hidden (Backing field) */
  48538. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48539. /**
  48540. * Gets the postprocess render pipeline manager
  48541. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48542. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48543. */
  48544. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48545. }
  48546. /**
  48547. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48548. */
  48549. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48550. /**
  48551. * The component name helpfull to identify the component in the list of scene components.
  48552. */
  48553. readonly name: string;
  48554. /**
  48555. * The scene the component belongs to.
  48556. */
  48557. scene: Scene;
  48558. /**
  48559. * Creates a new instance of the component for the given scene
  48560. * @param scene Defines the scene to register the component in
  48561. */
  48562. constructor(scene: Scene);
  48563. /**
  48564. * Registers the component in a given scene
  48565. */
  48566. register(): void;
  48567. /**
  48568. * Rebuilds the elements related to this component in case of
  48569. * context lost for instance.
  48570. */
  48571. rebuild(): void;
  48572. /**
  48573. * Disposes the component and the associated ressources
  48574. */
  48575. dispose(): void;
  48576. private _gatherRenderTargets;
  48577. }
  48578. }
  48579. declare module BABYLON {
  48580. /**
  48581. * Helper class dealing with the extraction of spherical polynomial dataArray
  48582. * from a cube map.
  48583. */
  48584. class CubeMapToSphericalPolynomialTools {
  48585. private static FileFaces;
  48586. /**
  48587. * Converts a texture to the according Spherical Polynomial data.
  48588. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48589. *
  48590. * @param texture The texture to extract the information from.
  48591. * @return The Spherical Polynomial data.
  48592. */
  48593. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48594. /**
  48595. * Converts a cubemap to the according Spherical Polynomial data.
  48596. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48597. *
  48598. * @param cubeInfo The Cube map to extract the information from.
  48599. * @return The Spherical Polynomial data.
  48600. */
  48601. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48602. }
  48603. }
  48604. declare module BABYLON {
  48605. /**
  48606. * Header information of HDR texture files.
  48607. */
  48608. interface HDRInfo {
  48609. /**
  48610. * The height of the texture in pixels.
  48611. */
  48612. height: number;
  48613. /**
  48614. * The width of the texture in pixels.
  48615. */
  48616. width: number;
  48617. /**
  48618. * The index of the beginning of the data in the binary file.
  48619. */
  48620. dataPosition: number;
  48621. }
  48622. /**
  48623. * This groups tools to convert HDR texture to native colors array.
  48624. */
  48625. class HDRTools {
  48626. private static Ldexp;
  48627. private static Rgbe2float;
  48628. private static readStringLine;
  48629. /**
  48630. * Reads header information from an RGBE texture stored in a native array.
  48631. * More information on this format are available here:
  48632. * https://en.wikipedia.org/wiki/RGBE_image_format
  48633. *
  48634. * @param uint8array The binary file stored in native array.
  48635. * @return The header information.
  48636. */
  48637. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48638. /**
  48639. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48640. * This RGBE texture needs to store the information as a panorama.
  48641. *
  48642. * More information on this format are available here:
  48643. * https://en.wikipedia.org/wiki/RGBE_image_format
  48644. *
  48645. * @param buffer The binary file stored in an array buffer.
  48646. * @param size The expected size of the extracted cubemap.
  48647. * @return The Cube Map information.
  48648. */
  48649. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48650. /**
  48651. * Returns the pixels data extracted from an RGBE texture.
  48652. * This pixels will be stored left to right up to down in the R G B order in one array.
  48653. *
  48654. * More information on this format are available here:
  48655. * https://en.wikipedia.org/wiki/RGBE_image_format
  48656. *
  48657. * @param uint8array The binary file stored in an array buffer.
  48658. * @param hdrInfo The header information of the file.
  48659. * @return The pixels data in RGB right to left up to down order.
  48660. */
  48661. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48662. private static RGBE_ReadPixels_RLE;
  48663. }
  48664. }
  48665. declare module BABYLON {
  48666. /**
  48667. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48668. */
  48669. interface CubeMapInfo {
  48670. /**
  48671. * The pixel array for the front face.
  48672. * This is stored in format, left to right, up to down format.
  48673. */
  48674. front: Nullable<ArrayBufferView>;
  48675. /**
  48676. * The pixel array for the back face.
  48677. * This is stored in format, left to right, up to down format.
  48678. */
  48679. back: Nullable<ArrayBufferView>;
  48680. /**
  48681. * The pixel array for the left face.
  48682. * This is stored in format, left to right, up to down format.
  48683. */
  48684. left: Nullable<ArrayBufferView>;
  48685. /**
  48686. * The pixel array for the right face.
  48687. * This is stored in format, left to right, up to down format.
  48688. */
  48689. right: Nullable<ArrayBufferView>;
  48690. /**
  48691. * The pixel array for the up face.
  48692. * This is stored in format, left to right, up to down format.
  48693. */
  48694. up: Nullable<ArrayBufferView>;
  48695. /**
  48696. * The pixel array for the down face.
  48697. * This is stored in format, left to right, up to down format.
  48698. */
  48699. down: Nullable<ArrayBufferView>;
  48700. /**
  48701. * The size of the cubemap stored.
  48702. *
  48703. * Each faces will be size * size pixels.
  48704. */
  48705. size: number;
  48706. /**
  48707. * The format of the texture.
  48708. *
  48709. * RGBA, RGB.
  48710. */
  48711. format: number;
  48712. /**
  48713. * The type of the texture data.
  48714. *
  48715. * UNSIGNED_INT, FLOAT.
  48716. */
  48717. type: number;
  48718. /**
  48719. * Specifies whether the texture is in gamma space.
  48720. */
  48721. gammaSpace: boolean;
  48722. }
  48723. /**
  48724. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48725. */
  48726. class PanoramaToCubeMapTools {
  48727. private static FACE_FRONT;
  48728. private static FACE_BACK;
  48729. private static FACE_RIGHT;
  48730. private static FACE_LEFT;
  48731. private static FACE_DOWN;
  48732. private static FACE_UP;
  48733. /**
  48734. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48735. *
  48736. * @param float32Array The source data.
  48737. * @param inputWidth The width of the input panorama.
  48738. * @param inputHeight The height of the input panorama.
  48739. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48740. * @return The cubemap data
  48741. */
  48742. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48743. private static CreateCubemapTexture;
  48744. private static CalcProjectionSpherical;
  48745. }
  48746. }
  48747. declare module BABYLON {
  48748. }
  48749. declare module BABYLON {
  48750. }
  48751. declare module BABYLON {
  48752. }
  48753. declare module BABYLON {
  48754. }
  48755. declare module BABYLON {
  48756. /**
  48757. * 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.
  48758. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48759. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48760. */
  48761. class CustomProceduralTexture extends ProceduralTexture {
  48762. private _animate;
  48763. private _time;
  48764. private _config;
  48765. private _texturePath;
  48766. /**
  48767. * Instantiates a new Custom Procedural Texture.
  48768. * 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.
  48769. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48770. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48771. * @param name Define the name of the texture
  48772. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48773. * @param size Define the size of the texture to create
  48774. * @param scene Define the scene the texture belongs to
  48775. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48776. * @param generateMipMaps Define if the texture should creates mip maps or not
  48777. */
  48778. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48779. private _loadJson;
  48780. /**
  48781. * Is the texture ready to be used ? (rendered at least once)
  48782. * @returns true if ready, otherwise, false.
  48783. */
  48784. isReady(): boolean;
  48785. /**
  48786. * Render the texture to its associated render target.
  48787. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48788. */
  48789. render(useCameraPostProcess?: boolean): void;
  48790. /**
  48791. * Update the list of dependant textures samplers in the shader.
  48792. */
  48793. updateTextures(): void;
  48794. /**
  48795. * Update the uniform values of the procedural texture in the shader.
  48796. */
  48797. updateShaderUniforms(): void;
  48798. /**
  48799. * Define if the texture animates or not.
  48800. */
  48801. animate: boolean;
  48802. }
  48803. }
  48804. declare module BABYLON {
  48805. /**
  48806. * Class used to generate noise procedural textures
  48807. */
  48808. class NoiseProceduralTexture extends ProceduralTexture {
  48809. private _time;
  48810. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48811. brightness: number;
  48812. /** Defines the number of octaves to process */
  48813. octaves: number;
  48814. /** Defines the level of persistence (0.8 by default) */
  48815. persistence: number;
  48816. /** Gets or sets animation speed factor (default is 1) */
  48817. animationSpeedFactor: number;
  48818. /**
  48819. * Creates a new NoiseProceduralTexture
  48820. * @param name defines the name fo the texture
  48821. * @param size defines the size of the texture (default is 256)
  48822. * @param scene defines the hosting scene
  48823. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48824. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48825. */
  48826. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48827. private _updateShaderUniforms;
  48828. protected _getDefines(): string;
  48829. /** Generate the current state of the procedural texture */
  48830. render(useCameraPostProcess?: boolean): void;
  48831. /**
  48832. * Serializes this noise procedural texture
  48833. * @returns a serialized noise procedural texture object
  48834. */
  48835. serialize(): any;
  48836. /**
  48837. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48838. * @param parsedTexture defines parsed texture data
  48839. * @param scene defines the current scene
  48840. * @param rootUrl defines the root URL containing noise procedural texture information
  48841. * @returns a parsed NoiseProceduralTexture
  48842. */
  48843. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48844. }
  48845. }
  48846. declare module BABYLON {
  48847. /**
  48848. * 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.
  48849. * This is the base class of any Procedural texture and contains most of the shareable code.
  48850. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48851. */
  48852. class ProceduralTexture extends Texture {
  48853. isCube: boolean;
  48854. /**
  48855. * Define if the texture is enabled or not (disabled texture will not render)
  48856. */
  48857. isEnabled: boolean;
  48858. /**
  48859. * Define if the texture must be cleared before rendering (default is true)
  48860. */
  48861. autoClear: boolean;
  48862. /**
  48863. * Callback called when the texture is generated
  48864. */
  48865. onGenerated: () => void;
  48866. /**
  48867. * Event raised when the texture is generated
  48868. */
  48869. onGeneratedObservable: Observable<ProceduralTexture>;
  48870. /** @hidden */
  48871. _generateMipMaps: boolean;
  48872. /** @hidden **/
  48873. _effect: Effect;
  48874. /** @hidden */
  48875. _textures: {
  48876. [key: string]: Texture;
  48877. };
  48878. private _size;
  48879. private _currentRefreshId;
  48880. private _refreshRate;
  48881. private _vertexBuffers;
  48882. private _indexBuffer;
  48883. private _uniforms;
  48884. private _samplers;
  48885. private _fragment;
  48886. private _floats;
  48887. private _ints;
  48888. private _floatsArrays;
  48889. private _colors3;
  48890. private _colors4;
  48891. private _vectors2;
  48892. private _vectors3;
  48893. private _matrices;
  48894. private _fallbackTexture;
  48895. private _fallbackTextureUsed;
  48896. private _engine;
  48897. private _cachedDefines;
  48898. private _contentUpdateId;
  48899. private _contentData;
  48900. /**
  48901. * Instantiates a new procedural texture.
  48902. * 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.
  48903. * This is the base class of any Procedural texture and contains most of the shareable code.
  48904. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48905. * @param name Define the name of the texture
  48906. * @param size Define the size of the texture to create
  48907. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48908. * @param scene Define the scene the texture belongs to
  48909. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48910. * @param generateMipMaps Define if the texture should creates mip maps or not
  48911. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48912. */
  48913. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48914. /**
  48915. * The effect that is created when initializing the post process.
  48916. * @returns The created effect corrisponding the the postprocess.
  48917. */
  48918. getEffect(): Effect;
  48919. /**
  48920. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48921. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48922. */
  48923. getContent(): Nullable<ArrayBufferView>;
  48924. private _createIndexBuffer;
  48925. /** @hidden */
  48926. _rebuild(): void;
  48927. /**
  48928. * Resets the texture in order to recreate its associated resources.
  48929. * This can be called in case of context loss
  48930. */
  48931. reset(): void;
  48932. protected _getDefines(): string;
  48933. /**
  48934. * Is the texture ready to be used ? (rendered at least once)
  48935. * @returns true if ready, otherwise, false.
  48936. */
  48937. isReady(): boolean;
  48938. /**
  48939. * Resets the refresh counter of the texture and start bak from scratch.
  48940. * Could be usefull to regenerate the texture if it is setup to render only once.
  48941. */
  48942. resetRefreshCounter(): void;
  48943. /**
  48944. * Set the fragment shader to use in order to render the texture.
  48945. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48946. */
  48947. setFragment(fragment: any): void;
  48948. /**
  48949. * Define the refresh rate of the texture or the rendering frequency.
  48950. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48951. */
  48952. refreshRate: number;
  48953. /** @hidden */
  48954. _shouldRender(): boolean;
  48955. /**
  48956. * Get the size the texture is rendering at.
  48957. * @returns the size (texture is always squared)
  48958. */
  48959. getRenderSize(): number;
  48960. /**
  48961. * Resize the texture to new value.
  48962. * @param size Define the new size the texture should have
  48963. * @param generateMipMaps Define whether the new texture should create mip maps
  48964. */
  48965. resize(size: number, generateMipMaps: boolean): void;
  48966. private _checkUniform;
  48967. /**
  48968. * Set a texture in the shader program used to render.
  48969. * @param name Define the name of the uniform samplers as defined in the shader
  48970. * @param texture Define the texture to bind to this sampler
  48971. * @return the texture itself allowing "fluent" like uniform updates
  48972. */
  48973. setTexture(name: string, texture: Texture): ProceduralTexture;
  48974. /**
  48975. * Set a float in the shader.
  48976. * @param name Define the name of the uniform as defined in the shader
  48977. * @param value Define the value to give to the uniform
  48978. * @return the texture itself allowing "fluent" like uniform updates
  48979. */
  48980. setFloat(name: string, value: number): ProceduralTexture;
  48981. /**
  48982. * Set a int in the shader.
  48983. * @param name Define the name of the uniform as defined in the shader
  48984. * @param value Define the value to give to the uniform
  48985. * @return the texture itself allowing "fluent" like uniform updates
  48986. */
  48987. setInt(name: string, value: number): ProceduralTexture;
  48988. /**
  48989. * Set an array of floats in the shader.
  48990. * @param name Define the name of the uniform as defined in the shader
  48991. * @param value Define the value to give to the uniform
  48992. * @return the texture itself allowing "fluent" like uniform updates
  48993. */
  48994. setFloats(name: string, value: number[]): ProceduralTexture;
  48995. /**
  48996. * Set a vec3 in the shader from a Color3.
  48997. * @param name Define the name of the uniform as defined in the shader
  48998. * @param value Define the value to give to the uniform
  48999. * @return the texture itself allowing "fluent" like uniform updates
  49000. */
  49001. setColor3(name: string, value: Color3): ProceduralTexture;
  49002. /**
  49003. * Set a vec4 in the shader from a Color4.
  49004. * @param name Define the name of the uniform as defined in the shader
  49005. * @param value Define the value to give to the uniform
  49006. * @return the texture itself allowing "fluent" like uniform updates
  49007. */
  49008. setColor4(name: string, value: Color4): ProceduralTexture;
  49009. /**
  49010. * Set a vec2 in the shader from a Vector2.
  49011. * @param name Define the name of the uniform as defined in the shader
  49012. * @param value Define the value to give to the uniform
  49013. * @return the texture itself allowing "fluent" like uniform updates
  49014. */
  49015. setVector2(name: string, value: Vector2): ProceduralTexture;
  49016. /**
  49017. * Set a vec3 in the shader from a Vector3.
  49018. * @param name Define the name of the uniform as defined in the shader
  49019. * @param value Define the value to give to the uniform
  49020. * @return the texture itself allowing "fluent" like uniform updates
  49021. */
  49022. setVector3(name: string, value: Vector3): ProceduralTexture;
  49023. /**
  49024. * Set a mat4 in the shader from a MAtrix.
  49025. * @param name Define the name of the uniform as defined in the shader
  49026. * @param value Define the value to give to the uniform
  49027. * @return the texture itself allowing "fluent" like uniform updates
  49028. */
  49029. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49030. /**
  49031. * Render the texture to its associated render target.
  49032. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49033. */
  49034. render(useCameraPostProcess?: boolean): void;
  49035. /**
  49036. * Clone the texture.
  49037. * @returns the cloned texture
  49038. */
  49039. clone(): ProceduralTexture;
  49040. /**
  49041. * Dispose the texture and release its asoociated resources.
  49042. */
  49043. dispose(): void;
  49044. }
  49045. }
  49046. declare module BABYLON {
  49047. interface AbstractScene {
  49048. /**
  49049. * The list of procedural textures added to the scene
  49050. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49051. */
  49052. proceduralTextures: Array<ProceduralTexture>;
  49053. }
  49054. /**
  49055. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49056. * in a given scene.
  49057. */
  49058. class ProceduralTextureSceneComponent implements ISceneComponent {
  49059. /**
  49060. * The component name helpfull to identify the component in the list of scene components.
  49061. */
  49062. readonly name: string;
  49063. /**
  49064. * The scene the component belongs to.
  49065. */
  49066. scene: Scene;
  49067. /**
  49068. * Creates a new instance of the component for the given scene
  49069. * @param scene Defines the scene to register the component in
  49070. */
  49071. constructor(scene: Scene);
  49072. /**
  49073. * Registers the component in a given scene
  49074. */
  49075. register(): void;
  49076. /**
  49077. * Rebuilds the elements related to this component in case of
  49078. * context lost for instance.
  49079. */
  49080. rebuild(): void;
  49081. /**
  49082. * Disposes the component and the associated ressources.
  49083. */
  49084. dispose(): void;
  49085. private _beforeClear;
  49086. }
  49087. }
  49088. declare module BABYLON {
  49089. /**
  49090. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49091. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49092. */
  49093. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49094. private _scene;
  49095. private _camerasToBeAttached;
  49096. /**
  49097. * ID of the sharpen post process,
  49098. */
  49099. private readonly SharpenPostProcessId;
  49100. /**
  49101. * @ignore
  49102. * ID of the image processing post process;
  49103. */
  49104. readonly ImageProcessingPostProcessId: string;
  49105. /**
  49106. * @ignore
  49107. * ID of the Fast Approximate Anti-Aliasing post process;
  49108. */
  49109. readonly FxaaPostProcessId: string;
  49110. /**
  49111. * ID of the chromatic aberration post process,
  49112. */
  49113. private readonly ChromaticAberrationPostProcessId;
  49114. /**
  49115. * ID of the grain post process
  49116. */
  49117. private readonly GrainPostProcessId;
  49118. /**
  49119. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49120. */
  49121. sharpen: SharpenPostProcess;
  49122. private _sharpenEffect;
  49123. private bloom;
  49124. /**
  49125. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49126. */
  49127. depthOfField: DepthOfFieldEffect;
  49128. /**
  49129. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49130. */
  49131. fxaa: FxaaPostProcess;
  49132. /**
  49133. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49134. */
  49135. imageProcessing: ImageProcessingPostProcess;
  49136. /**
  49137. * Chromatic aberration post process which will shift rgb colors in the image
  49138. */
  49139. chromaticAberration: ChromaticAberrationPostProcess;
  49140. private _chromaticAberrationEffect;
  49141. /**
  49142. * Grain post process which add noise to the image
  49143. */
  49144. grain: GrainPostProcess;
  49145. private _grainEffect;
  49146. /**
  49147. * Glow post process which adds a glow to emmisive areas of the image
  49148. */
  49149. private _glowLayer;
  49150. /**
  49151. * Animations which can be used to tweak settings over a period of time
  49152. */
  49153. animations: Animation[];
  49154. private _imageProcessingConfigurationObserver;
  49155. private _sharpenEnabled;
  49156. private _bloomEnabled;
  49157. private _depthOfFieldEnabled;
  49158. private _depthOfFieldBlurLevel;
  49159. private _fxaaEnabled;
  49160. private _imageProcessingEnabled;
  49161. private _defaultPipelineTextureType;
  49162. private _bloomScale;
  49163. private _chromaticAberrationEnabled;
  49164. private _grainEnabled;
  49165. private _buildAllowed;
  49166. /**
  49167. * Enable or disable the sharpen process from the pipeline
  49168. */
  49169. sharpenEnabled: boolean;
  49170. private _resizeObserver;
  49171. private _hardwareScaleLevel;
  49172. private _bloomKernel;
  49173. /**
  49174. * Specifies the size of the bloom blur kernel, relative to the final output size
  49175. */
  49176. bloomKernel: number;
  49177. /**
  49178. * Specifies the weight of the bloom in the final rendering
  49179. */
  49180. private _bloomWeight;
  49181. /**
  49182. * Specifies the luma threshold for the area that will be blurred by the bloom
  49183. */
  49184. private _bloomThreshold;
  49185. private _hdr;
  49186. /**
  49187. * The strength of the bloom.
  49188. */
  49189. bloomWeight: number;
  49190. /**
  49191. * The strength of the bloom.
  49192. */
  49193. bloomThreshold: number;
  49194. /**
  49195. * The scale of the bloom, lower value will provide better performance.
  49196. */
  49197. bloomScale: number;
  49198. /**
  49199. * Enable or disable the bloom from the pipeline
  49200. */
  49201. bloomEnabled: boolean;
  49202. private _rebuildBloom;
  49203. /**
  49204. * If the depth of field is enabled.
  49205. */
  49206. depthOfFieldEnabled: boolean;
  49207. /**
  49208. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49209. */
  49210. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49211. /**
  49212. * If the anti aliasing is enabled.
  49213. */
  49214. fxaaEnabled: boolean;
  49215. private _samples;
  49216. /**
  49217. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49218. */
  49219. samples: number;
  49220. /**
  49221. * If image processing is enabled.
  49222. */
  49223. imageProcessingEnabled: boolean;
  49224. /**
  49225. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49226. */
  49227. glowLayerEnabled: boolean;
  49228. /**
  49229. * Enable or disable the chromaticAberration process from the pipeline
  49230. */
  49231. chromaticAberrationEnabled: boolean;
  49232. /**
  49233. * Enable or disable the grain process from the pipeline
  49234. */
  49235. grainEnabled: boolean;
  49236. /**
  49237. * @constructor
  49238. * @param name - The rendering pipeline name (default: "")
  49239. * @param hdr - If high dynamic range textures should be used (default: true)
  49240. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49241. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49242. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49243. */
  49244. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49245. /**
  49246. * Force the compilation of the entire pipeline.
  49247. */
  49248. prepare(): void;
  49249. private _hasCleared;
  49250. private _prevPostProcess;
  49251. private _prevPrevPostProcess;
  49252. private _setAutoClearAndTextureSharing;
  49253. private _depthOfFieldSceneObserver;
  49254. private _buildPipeline;
  49255. private _disposePostProcesses;
  49256. /**
  49257. * Adds a camera to the pipeline
  49258. * @param camera the camera to be added
  49259. */
  49260. addCamera(camera: Camera): void;
  49261. /**
  49262. * Removes a camera from the pipeline
  49263. * @param camera the camera to remove
  49264. */
  49265. removeCamera(camera: Camera): void;
  49266. /**
  49267. * Dispose of the pipeline and stop all post processes
  49268. */
  49269. dispose(): void;
  49270. /**
  49271. * Serialize the rendering pipeline (Used when exporting)
  49272. * @returns the serialized object
  49273. */
  49274. serialize(): any;
  49275. /**
  49276. * Parse the serialized pipeline
  49277. * @param source Source pipeline.
  49278. * @param scene The scene to load the pipeline to.
  49279. * @param rootUrl The URL of the serialized pipeline.
  49280. * @returns An instantiated pipeline from the serialized object.
  49281. */
  49282. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49283. }
  49284. }
  49285. declare module BABYLON {
  49286. /**
  49287. * BABYLON.JS Chromatic Aberration GLSL Shader
  49288. * Author: Olivier Guyot
  49289. * Separates very slightly R, G and B colors on the edges of the screen
  49290. * Inspired by Francois Tarlier & Martins Upitis
  49291. */
  49292. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49293. /**
  49294. * @ignore
  49295. * The chromatic aberration PostProcess id in the pipeline
  49296. */
  49297. LensChromaticAberrationEffect: string;
  49298. /**
  49299. * @ignore
  49300. * The highlights enhancing PostProcess id in the pipeline
  49301. */
  49302. HighlightsEnhancingEffect: string;
  49303. /**
  49304. * @ignore
  49305. * The depth-of-field PostProcess id in the pipeline
  49306. */
  49307. LensDepthOfFieldEffect: string;
  49308. private _scene;
  49309. private _depthTexture;
  49310. private _grainTexture;
  49311. private _chromaticAberrationPostProcess;
  49312. private _highlightsPostProcess;
  49313. private _depthOfFieldPostProcess;
  49314. private _edgeBlur;
  49315. private _grainAmount;
  49316. private _chromaticAberration;
  49317. private _distortion;
  49318. private _highlightsGain;
  49319. private _highlightsThreshold;
  49320. private _dofDistance;
  49321. private _dofAperture;
  49322. private _dofDarken;
  49323. private _dofPentagon;
  49324. private _blurNoise;
  49325. /**
  49326. * @constructor
  49327. *
  49328. * Effect parameters are as follow:
  49329. * {
  49330. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49331. * edge_blur: number; // from 0 to x (1 for realism)
  49332. * distortion: number; // from 0 to x (1 for realism)
  49333. * grain_amount: number; // from 0 to 1
  49334. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49335. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49336. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49337. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49338. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49339. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49340. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49341. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49342. * }
  49343. * Note: if an effect parameter is unset, effect is disabled
  49344. *
  49345. * @param name The rendering pipeline name
  49346. * @param parameters - An object containing all parameters (see above)
  49347. * @param scene The scene linked to this pipeline
  49348. * @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)
  49349. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49350. */
  49351. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49352. /**
  49353. * Sets the amount of blur at the edges
  49354. * @param amount blur amount
  49355. */
  49356. setEdgeBlur(amount: number): void;
  49357. /**
  49358. * Sets edge blur to 0
  49359. */
  49360. disableEdgeBlur(): void;
  49361. /**
  49362. * Sets the amout of grain
  49363. * @param amount Amount of grain
  49364. */
  49365. setGrainAmount(amount: number): void;
  49366. /**
  49367. * Set grain amount to 0
  49368. */
  49369. disableGrain(): void;
  49370. /**
  49371. * Sets the chromatic aberration amount
  49372. * @param amount amount of chromatic aberration
  49373. */
  49374. setChromaticAberration(amount: number): void;
  49375. /**
  49376. * Sets chromatic aberration amount to 0
  49377. */
  49378. disableChromaticAberration(): void;
  49379. /**
  49380. * Sets the EdgeDistortion amount
  49381. * @param amount amount of EdgeDistortion
  49382. */
  49383. setEdgeDistortion(amount: number): void;
  49384. /**
  49385. * Sets edge distortion to 0
  49386. */
  49387. disableEdgeDistortion(): void;
  49388. /**
  49389. * Sets the FocusDistance amount
  49390. * @param amount amount of FocusDistance
  49391. */
  49392. setFocusDistance(amount: number): void;
  49393. /**
  49394. * Disables depth of field
  49395. */
  49396. disableDepthOfField(): void;
  49397. /**
  49398. * Sets the Aperture amount
  49399. * @param amount amount of Aperture
  49400. */
  49401. setAperture(amount: number): void;
  49402. /**
  49403. * Sets the DarkenOutOfFocus amount
  49404. * @param amount amount of DarkenOutOfFocus
  49405. */
  49406. setDarkenOutOfFocus(amount: number): void;
  49407. /**
  49408. * Creates a pentagon bokeh effect
  49409. */
  49410. enablePentagonBokeh(): void;
  49411. /**
  49412. * Disables the pentagon bokeh effect
  49413. */
  49414. disablePentagonBokeh(): void;
  49415. /**
  49416. * Enables noise blur
  49417. */
  49418. enableNoiseBlur(): void;
  49419. /**
  49420. * Disables noise blur
  49421. */
  49422. disableNoiseBlur(): void;
  49423. /**
  49424. * Sets the HighlightsGain amount
  49425. * @param amount amount of HighlightsGain
  49426. */
  49427. setHighlightsGain(amount: number): void;
  49428. /**
  49429. * Sets the HighlightsThreshold amount
  49430. * @param amount amount of HighlightsThreshold
  49431. */
  49432. setHighlightsThreshold(amount: number): void;
  49433. /**
  49434. * Disables highlights
  49435. */
  49436. disableHighlights(): void;
  49437. /**
  49438. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49439. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49440. */
  49441. dispose(disableDepthRender?: boolean): void;
  49442. private _createChromaticAberrationPostProcess;
  49443. private _createHighlightsPostProcess;
  49444. private _createDepthOfFieldPostProcess;
  49445. private _createGrainTexture;
  49446. }
  49447. }
  49448. declare module BABYLON {
  49449. /**
  49450. * Render pipeline to produce ssao effect
  49451. */
  49452. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49453. /**
  49454. * @ignore
  49455. * The PassPostProcess id in the pipeline that contains the original scene color
  49456. */
  49457. SSAOOriginalSceneColorEffect: string;
  49458. /**
  49459. * @ignore
  49460. * The SSAO PostProcess id in the pipeline
  49461. */
  49462. SSAORenderEffect: string;
  49463. /**
  49464. * @ignore
  49465. * The horizontal blur PostProcess id in the pipeline
  49466. */
  49467. SSAOBlurHRenderEffect: string;
  49468. /**
  49469. * @ignore
  49470. * The vertical blur PostProcess id in the pipeline
  49471. */
  49472. SSAOBlurVRenderEffect: string;
  49473. /**
  49474. * @ignore
  49475. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49476. */
  49477. SSAOCombineRenderEffect: string;
  49478. /**
  49479. * The output strength of the SSAO post-process. Default value is 1.0.
  49480. */
  49481. totalStrength: number;
  49482. /**
  49483. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49484. */
  49485. maxZ: number;
  49486. /**
  49487. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49488. */
  49489. minZAspect: number;
  49490. private _samples;
  49491. /**
  49492. * Number of samples used for the SSAO calculations. Default value is 8
  49493. */
  49494. samples: number;
  49495. private _textureSamples;
  49496. /**
  49497. * Number of samples to use for antialiasing
  49498. */
  49499. textureSamples: number;
  49500. /**
  49501. * Ratio object used for SSAO ratio and blur ratio
  49502. */
  49503. private _ratio;
  49504. /**
  49505. * Dynamically generated sphere sampler.
  49506. */
  49507. private _sampleSphere;
  49508. /**
  49509. * Blur filter offsets
  49510. */
  49511. private _samplerOffsets;
  49512. private _expensiveBlur;
  49513. /**
  49514. * If bilateral blur should be used
  49515. */
  49516. expensiveBlur: boolean;
  49517. /**
  49518. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49519. */
  49520. radius: number;
  49521. /**
  49522. * The base color of the SSAO post-process
  49523. * The final result is "base + ssao" between [0, 1]
  49524. */
  49525. base: number;
  49526. /**
  49527. * Support test.
  49528. */
  49529. static readonly IsSupported: boolean;
  49530. private _scene;
  49531. private _depthTexture;
  49532. private _normalTexture;
  49533. private _randomTexture;
  49534. private _originalColorPostProcess;
  49535. private _ssaoPostProcess;
  49536. private _blurHPostProcess;
  49537. private _blurVPostProcess;
  49538. private _ssaoCombinePostProcess;
  49539. private _firstUpdate;
  49540. /**
  49541. * @constructor
  49542. * @param name The rendering pipeline name
  49543. * @param scene The scene linked to this pipeline
  49544. * @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 }
  49545. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49546. */
  49547. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49548. /**
  49549. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49550. */
  49551. dispose(disableGeometryBufferRenderer?: boolean): void;
  49552. private _createBlurPostProcess;
  49553. /** @hidden */
  49554. _rebuild(): void;
  49555. private _bits;
  49556. private _radicalInverse_VdC;
  49557. private _hammersley;
  49558. private _hemisphereSample_uniform;
  49559. private _generateHemisphere;
  49560. private _createSSAOPostProcess;
  49561. private _createSSAOCombinePostProcess;
  49562. private _createRandomTexture;
  49563. /**
  49564. * Serialize the rendering pipeline (Used when exporting)
  49565. * @returns the serialized object
  49566. */
  49567. serialize(): any;
  49568. /**
  49569. * Parse the serialized pipeline
  49570. * @param source Source pipeline.
  49571. * @param scene The scene to load the pipeline to.
  49572. * @param rootUrl The URL of the serialized pipeline.
  49573. * @returns An instantiated pipeline from the serialized object.
  49574. */
  49575. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49576. }
  49577. }
  49578. declare module BABYLON {
  49579. /**
  49580. * Render pipeline to produce ssao effect
  49581. */
  49582. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49583. /**
  49584. * @ignore
  49585. * The PassPostProcess id in the pipeline that contains the original scene color
  49586. */
  49587. SSAOOriginalSceneColorEffect: string;
  49588. /**
  49589. * @ignore
  49590. * The SSAO PostProcess id in the pipeline
  49591. */
  49592. SSAORenderEffect: string;
  49593. /**
  49594. * @ignore
  49595. * The horizontal blur PostProcess id in the pipeline
  49596. */
  49597. SSAOBlurHRenderEffect: string;
  49598. /**
  49599. * @ignore
  49600. * The vertical blur PostProcess id in the pipeline
  49601. */
  49602. SSAOBlurVRenderEffect: string;
  49603. /**
  49604. * @ignore
  49605. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49606. */
  49607. SSAOCombineRenderEffect: string;
  49608. /**
  49609. * The output strength of the SSAO post-process. Default value is 1.0.
  49610. */
  49611. totalStrength: number;
  49612. /**
  49613. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49614. */
  49615. radius: number;
  49616. /**
  49617. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49618. * Must not be equal to fallOff and superior to fallOff.
  49619. * Default value is 0.975
  49620. */
  49621. area: number;
  49622. /**
  49623. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49624. * Must not be equal to area and inferior to area.
  49625. * Default value is 0.0
  49626. */
  49627. fallOff: number;
  49628. /**
  49629. * The base color of the SSAO post-process
  49630. * The final result is "base + ssao" between [0, 1]
  49631. */
  49632. base: number;
  49633. private _scene;
  49634. private _depthTexture;
  49635. private _randomTexture;
  49636. private _originalColorPostProcess;
  49637. private _ssaoPostProcess;
  49638. private _blurHPostProcess;
  49639. private _blurVPostProcess;
  49640. private _ssaoCombinePostProcess;
  49641. private _firstUpdate;
  49642. /**
  49643. * @constructor
  49644. * @param name - The rendering pipeline name
  49645. * @param scene - The scene linked to this pipeline
  49646. * @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 }
  49647. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49648. */
  49649. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49650. /**
  49651. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49652. */
  49653. dispose(disableDepthRender?: boolean): void;
  49654. private _createBlurPostProcess;
  49655. /** @hidden */
  49656. _rebuild(): void;
  49657. private _createSSAOPostProcess;
  49658. private _createSSAOCombinePostProcess;
  49659. private _createRandomTexture;
  49660. }
  49661. }
  49662. declare module BABYLON {
  49663. /**
  49664. * Standard rendering pipeline
  49665. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49666. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49667. */
  49668. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49669. /**
  49670. * Public members
  49671. */
  49672. /**
  49673. * Post-process which contains the original scene color before the pipeline applies all the effects
  49674. */
  49675. originalPostProcess: Nullable<PostProcess>;
  49676. /**
  49677. * Post-process used to down scale an image x4
  49678. */
  49679. downSampleX4PostProcess: Nullable<PostProcess>;
  49680. /**
  49681. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49682. */
  49683. brightPassPostProcess: Nullable<PostProcess>;
  49684. /**
  49685. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49686. */
  49687. blurHPostProcesses: PostProcess[];
  49688. /**
  49689. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49690. */
  49691. blurVPostProcesses: PostProcess[];
  49692. /**
  49693. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49694. */
  49695. textureAdderPostProcess: Nullable<PostProcess>;
  49696. /**
  49697. * Post-process used to create volumetric lighting effect
  49698. */
  49699. volumetricLightPostProcess: Nullable<PostProcess>;
  49700. /**
  49701. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49702. */
  49703. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49704. /**
  49705. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49706. */
  49707. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49708. /**
  49709. * Post-process used to merge the volumetric light effect and the real scene color
  49710. */
  49711. volumetricLightMergePostProces: Nullable<PostProcess>;
  49712. /**
  49713. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49714. */
  49715. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49716. /**
  49717. * Base post-process used to calculate the average luminance of the final image for HDR
  49718. */
  49719. luminancePostProcess: Nullable<PostProcess>;
  49720. /**
  49721. * Post-processes used to create down sample post-processes in order to get
  49722. * the average luminance of the final image for HDR
  49723. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49724. */
  49725. luminanceDownSamplePostProcesses: PostProcess[];
  49726. /**
  49727. * Post-process used to create a HDR effect (light adaptation)
  49728. */
  49729. hdrPostProcess: Nullable<PostProcess>;
  49730. /**
  49731. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49732. */
  49733. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49734. /**
  49735. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49736. */
  49737. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49738. /**
  49739. * Post-process used to merge the final HDR post-process and the real scene color
  49740. */
  49741. hdrFinalPostProcess: Nullable<PostProcess>;
  49742. /**
  49743. * Post-process used to create a lens flare effect
  49744. */
  49745. lensFlarePostProcess: Nullable<PostProcess>;
  49746. /**
  49747. * Post-process that merges the result of the lens flare post-process and the real scene color
  49748. */
  49749. lensFlareComposePostProcess: Nullable<PostProcess>;
  49750. /**
  49751. * Post-process used to create a motion blur effect
  49752. */
  49753. motionBlurPostProcess: Nullable<PostProcess>;
  49754. /**
  49755. * Post-process used to create a depth of field effect
  49756. */
  49757. depthOfFieldPostProcess: Nullable<PostProcess>;
  49758. /**
  49759. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49760. */
  49761. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49762. /**
  49763. * Represents the brightness threshold in order to configure the illuminated surfaces
  49764. */
  49765. brightThreshold: number;
  49766. /**
  49767. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49768. */
  49769. blurWidth: number;
  49770. /**
  49771. * Sets if the blur for highlighted surfaces must be only horizontal
  49772. */
  49773. horizontalBlur: boolean;
  49774. /**
  49775. * Sets the overall exposure used by the pipeline
  49776. */
  49777. exposure: number;
  49778. /**
  49779. * Texture used typically to simulate "dirty" on camera lens
  49780. */
  49781. lensTexture: Nullable<Texture>;
  49782. /**
  49783. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49784. */
  49785. volumetricLightCoefficient: number;
  49786. /**
  49787. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49788. */
  49789. volumetricLightPower: number;
  49790. /**
  49791. * Used the set the blur intensity to smooth the volumetric lights
  49792. */
  49793. volumetricLightBlurScale: number;
  49794. /**
  49795. * Light (spot or directional) used to generate the volumetric lights rays
  49796. * The source light must have a shadow generate so the pipeline can get its
  49797. * depth map
  49798. */
  49799. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49800. /**
  49801. * For eye adaptation, represents the minimum luminance the eye can see
  49802. */
  49803. hdrMinimumLuminance: number;
  49804. /**
  49805. * For eye adaptation, represents the decrease luminance speed
  49806. */
  49807. hdrDecreaseRate: number;
  49808. /**
  49809. * For eye adaptation, represents the increase luminance speed
  49810. */
  49811. hdrIncreaseRate: number;
  49812. /**
  49813. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49814. */
  49815. lensColorTexture: Nullable<Texture>;
  49816. /**
  49817. * The overall strengh for the lens flare effect
  49818. */
  49819. lensFlareStrength: number;
  49820. /**
  49821. * Dispersion coefficient for lens flare ghosts
  49822. */
  49823. lensFlareGhostDispersal: number;
  49824. /**
  49825. * Main lens flare halo width
  49826. */
  49827. lensFlareHaloWidth: number;
  49828. /**
  49829. * Based on the lens distortion effect, defines how much the lens flare result
  49830. * is distorted
  49831. */
  49832. lensFlareDistortionStrength: number;
  49833. /**
  49834. * Lens star texture must be used to simulate rays on the flares and is available
  49835. * in the documentation
  49836. */
  49837. lensStarTexture: Nullable<Texture>;
  49838. /**
  49839. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49840. * flare effect by taking account of the dirt texture
  49841. */
  49842. lensFlareDirtTexture: Nullable<Texture>;
  49843. /**
  49844. * Represents the focal length for the depth of field effect
  49845. */
  49846. depthOfFieldDistance: number;
  49847. /**
  49848. * Represents the blur intensity for the blurred part of the depth of field effect
  49849. */
  49850. depthOfFieldBlurWidth: number;
  49851. /**
  49852. * For motion blur, defines how much the image is blurred by the movement
  49853. */
  49854. motionStrength: number;
  49855. /**
  49856. * List of animations for the pipeline (IAnimatable implementation)
  49857. */
  49858. animations: Animation[];
  49859. /**
  49860. * Private members
  49861. */
  49862. private _scene;
  49863. private _currentDepthOfFieldSource;
  49864. private _basePostProcess;
  49865. private _hdrCurrentLuminance;
  49866. private _floatTextureType;
  49867. private _ratio;
  49868. private _bloomEnabled;
  49869. private _depthOfFieldEnabled;
  49870. private _vlsEnabled;
  49871. private _lensFlareEnabled;
  49872. private _hdrEnabled;
  49873. private _motionBlurEnabled;
  49874. private _fxaaEnabled;
  49875. private _motionBlurSamples;
  49876. private _volumetricLightStepsCount;
  49877. private _samples;
  49878. /**
  49879. * @ignore
  49880. * Specifies if the bloom pipeline is enabled
  49881. */
  49882. BloomEnabled: boolean;
  49883. /**
  49884. * @ignore
  49885. * Specifies if the depth of field pipeline is enabed
  49886. */
  49887. DepthOfFieldEnabled: boolean;
  49888. /**
  49889. * @ignore
  49890. * Specifies if the lens flare pipeline is enabed
  49891. */
  49892. LensFlareEnabled: boolean;
  49893. /**
  49894. * @ignore
  49895. * Specifies if the HDR pipeline is enabled
  49896. */
  49897. HDREnabled: boolean;
  49898. /**
  49899. * @ignore
  49900. * Specifies if the volumetric lights scattering effect is enabled
  49901. */
  49902. VLSEnabled: boolean;
  49903. /**
  49904. * @ignore
  49905. * Specifies if the motion blur effect is enabled
  49906. */
  49907. MotionBlurEnabled: boolean;
  49908. /**
  49909. * Specifies if anti-aliasing is enabled
  49910. */
  49911. fxaaEnabled: boolean;
  49912. /**
  49913. * Specifies the number of steps used to calculate the volumetric lights
  49914. * Typically in interval [50, 200]
  49915. */
  49916. volumetricLightStepsCount: number;
  49917. /**
  49918. * Specifies the number of samples used for the motion blur effect
  49919. * Typically in interval [16, 64]
  49920. */
  49921. motionBlurSamples: number;
  49922. /**
  49923. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49924. */
  49925. samples: number;
  49926. /**
  49927. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49928. * @constructor
  49929. * @param name The rendering pipeline name
  49930. * @param scene The scene linked to this pipeline
  49931. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  49932. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49933. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49934. */
  49935. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49936. private _buildPipeline;
  49937. private _createDownSampleX4PostProcess;
  49938. private _createBrightPassPostProcess;
  49939. private _createBlurPostProcesses;
  49940. private _createTextureAdderPostProcess;
  49941. private _createVolumetricLightPostProcess;
  49942. private _createLuminancePostProcesses;
  49943. private _createHdrPostProcess;
  49944. private _createLensFlarePostProcess;
  49945. private _createDepthOfFieldPostProcess;
  49946. private _createMotionBlurPostProcess;
  49947. private _getDepthTexture;
  49948. private _disposePostProcesses;
  49949. /**
  49950. * Dispose of the pipeline and stop all post processes
  49951. */
  49952. dispose(): void;
  49953. /**
  49954. * Serialize the rendering pipeline (Used when exporting)
  49955. * @returns the serialized object
  49956. */
  49957. serialize(): any;
  49958. /**
  49959. * Parse the serialized pipeline
  49960. * @param source Source pipeline.
  49961. * @param scene The scene to load the pipeline to.
  49962. * @param rootUrl The URL of the serialized pipeline.
  49963. * @returns An instantiated pipeline from the serialized object.
  49964. */
  49965. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  49966. /**
  49967. * Luminance steps
  49968. */
  49969. static LuminanceSteps: number;
  49970. }
  49971. }