babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. private _moveAssets;
  165. /**
  166. * Removes all the assets contained in the scene and adds them to the container.
  167. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  168. */
  169. moveAllFromScene(keepAssets?: KeepAssets): void;
  170. /**
  171. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  172. * @returns the root mesh
  173. */
  174. createRootMesh(): Mesh;
  175. }
  176. }
  177. interface Window {
  178. mozIndexedDB: IDBFactory;
  179. webkitIndexedDB: IDBFactory;
  180. msIndexedDB: IDBFactory;
  181. webkitURL: typeof URL;
  182. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  183. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  184. WebGLRenderingContext: WebGLRenderingContext;
  185. MSGesture: MSGesture;
  186. CANNON: any;
  187. AudioContext: AudioContext;
  188. webkitAudioContext: AudioContext;
  189. PointerEvent: any;
  190. Math: Math;
  191. Uint8Array: Uint8ArrayConstructor;
  192. Float32Array: Float32ArrayConstructor;
  193. mozURL: typeof URL;
  194. msURL: typeof URL;
  195. VRFrameData: any;
  196. DracoDecoderModule: any;
  197. setImmediate(handler: (...args: any[]) => void): number;
  198. }
  199. interface WebGLProgram {
  200. context?: WebGLRenderingContext;
  201. vertexShader?: WebGLShader;
  202. fragmentShader?: WebGLShader;
  203. isParallelCompiled: boolean;
  204. onCompiled?: () => void;
  205. }
  206. interface WebGLRenderingContext {
  207. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  208. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  209. vertexAttribDivisor(index: number, divisor: number): void;
  210. createVertexArray(): any;
  211. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  212. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  213. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  214. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  215. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  216. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  217. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  218. createQuery(): WebGLQuery;
  219. deleteQuery(query: WebGLQuery): void;
  220. beginQuery(target: number, query: WebGLQuery): void;
  221. endQuery(target: number): void;
  222. getQueryParameter(query: WebGLQuery, pname: number): any;
  223. getQuery(target: number, pname: number): any;
  224. MAX_SAMPLES: number;
  225. RGBA8: number;
  226. READ_FRAMEBUFFER: number;
  227. DRAW_FRAMEBUFFER: number;
  228. UNIFORM_BUFFER: number;
  229. HALF_FLOAT_OES: number;
  230. RGBA16F: number;
  231. RGBA32F: number;
  232. R32F: number;
  233. RG32F: number;
  234. RGB32F: number;
  235. R16F: number;
  236. RG16F: number;
  237. RGB16F: number;
  238. RED: number;
  239. RG: number;
  240. R8: number;
  241. RG8: number;
  242. UNSIGNED_INT_24_8: number;
  243. DEPTH24_STENCIL8: number;
  244. drawBuffers(buffers: number[]): void;
  245. readBuffer(src: number): void;
  246. readonly COLOR_ATTACHMENT0: number;
  247. readonly COLOR_ATTACHMENT1: number;
  248. readonly COLOR_ATTACHMENT2: number;
  249. readonly COLOR_ATTACHMENT3: number;
  250. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  251. ANY_SAMPLES_PASSED: number;
  252. QUERY_RESULT_AVAILABLE: number;
  253. QUERY_RESULT: number;
  254. }
  255. interface Document {
  256. mozCancelFullScreen(): void;
  257. msCancelFullScreen(): void;
  258. webkitCancelFullScreen(): void;
  259. requestPointerLock(): void;
  260. exitPointerLock(): void;
  261. fullscreen: boolean;
  262. mozFullScreen: boolean;
  263. msIsFullScreen: boolean;
  264. readonly webkitIsFullScreen: boolean;
  265. readonly pointerLockElement: Element;
  266. mozPointerLockElement: HTMLElement;
  267. msPointerLockElement: HTMLElement;
  268. webkitPointerLockElement: HTMLElement;
  269. }
  270. interface HTMLCanvasElement {
  271. requestPointerLock(): void;
  272. msRequestPointerLock?(): void;
  273. mozRequestPointerLock?(): void;
  274. webkitRequestPointerLock?(): void;
  275. }
  276. interface CanvasRenderingContext2D {
  277. msImageSmoothingEnabled: boolean;
  278. }
  279. interface WebGLBuffer {
  280. references: number;
  281. capacity: number;
  282. is32Bits: boolean;
  283. }
  284. interface WebGLProgram {
  285. transformFeedback?: WebGLTransformFeedback | null;
  286. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  287. }
  288. interface MouseEvent {
  289. mozMovementX: number;
  290. mozMovementY: number;
  291. webkitMovementX: number;
  292. webkitMovementY: number;
  293. msMovementX: number;
  294. msMovementY: number;
  295. }
  296. interface Navigator {
  297. mozGetVRDevices: (any: any) => any;
  298. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  299. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  300. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  301. webkitGetGamepads(): Gamepad[];
  302. msGetGamepads(): Gamepad[];
  303. webkitGamepads(): Gamepad[];
  304. }
  305. interface HTMLVideoElement {
  306. mozSrcObject: any;
  307. }
  308. interface Screen {
  309. readonly orientation: string;
  310. readonly mozOrientation: string;
  311. }
  312. interface Math {
  313. fround(x: number): number;
  314. imul(a: number, b: number): number;
  315. }
  316. interface EXT_disjoint_timer_query {
  317. QUERY_COUNTER_BITS_EXT: number;
  318. TIME_ELAPSED_EXT: number;
  319. TIMESTAMP_EXT: number;
  320. GPU_DISJOINT_EXT: number;
  321. QUERY_RESULT_EXT: number;
  322. QUERY_RESULT_AVAILABLE_EXT: number;
  323. queryCounterEXT(query: WebGLQuery, target: number): void;
  324. createQueryEXT(): WebGLQuery;
  325. beginQueryEXT(target: number, query: WebGLQuery): void;
  326. endQueryEXT(target: number): void;
  327. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  328. deleteQueryEXT(query: WebGLQuery): void;
  329. }
  330. interface WebGLUniformLocation {
  331. _currentState: any;
  332. }
  333. declare module BABYLON {
  334. /**
  335. * Defines how a node can be built from a string name.
  336. */
  337. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  338. /**
  339. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  340. */
  341. class Node implements IBehaviorAware<Node> {
  342. private static _NodeConstructors;
  343. /**
  344. * Add a new node constructor
  345. * @param type defines the type name of the node to construct
  346. * @param constructorFunc defines the constructor function
  347. */
  348. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  349. /**
  350. * Returns a node constructor based on type name
  351. * @param type defines the type name
  352. * @param name defines the new node name
  353. * @param scene defines the hosting scene
  354. * @param options defines optional options to transmit to constructors
  355. * @returns the new constructor or null
  356. */
  357. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  358. /**
  359. * Gets or sets the name of the node
  360. */
  361. name: string;
  362. /**
  363. * Gets or sets the id of the node
  364. */
  365. id: string;
  366. /**
  367. * Gets or sets the unique id of the node
  368. */
  369. uniqueId: number;
  370. /**
  371. * Gets or sets a string used to store user defined state for the node
  372. */
  373. state: string;
  374. /**
  375. * Gets or sets an object used to store user defined information for the node
  376. */
  377. metadata: any;
  378. /**
  379. * Gets or sets a boolean used to define if the node must be serialized
  380. */
  381. doNotSerialize: boolean;
  382. /** @hidden */
  383. _isDisposed: boolean;
  384. /**
  385. * Gets a list of Animations associated with the node
  386. */
  387. animations: Animation[];
  388. protected _ranges: {
  389. [name: string]: Nullable<AnimationRange>;
  390. };
  391. /**
  392. * Callback raised when the node is ready to be used
  393. */
  394. onReady: (node: Node) => void;
  395. private _isEnabled;
  396. private _isParentEnabled;
  397. private _isReady;
  398. /** @hidden */
  399. _currentRenderId: number;
  400. private _parentRenderId;
  401. protected _childRenderId: number;
  402. /** @hidden */
  403. _waitingParentId: Nullable<string>;
  404. /** @hidden */
  405. _scene: Scene;
  406. /** @hidden */
  407. _cache: any;
  408. private _parentNode;
  409. private _children;
  410. /** @hidden */
  411. _worldMatrix: Matrix;
  412. /** @hidden */
  413. _worldMatrixDeterminant: number;
  414. /** @hidden */
  415. private _sceneRootNodesIndex;
  416. /**
  417. * Gets a boolean indicating if the node has been disposed
  418. * @returns true if the node was disposed
  419. */
  420. isDisposed(): boolean;
  421. /**
  422. * Gets or sets the parent of the node
  423. */
  424. parent: Nullable<Node>;
  425. private addToSceneRootNodes;
  426. private removeFromSceneRootNodes;
  427. private _animationPropertiesOverride;
  428. /**
  429. * Gets or sets the animation properties override
  430. */
  431. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  432. /**
  433. * Gets a string idenfifying the name of the class
  434. * @returns "Node" string
  435. */
  436. getClassName(): string;
  437. /**
  438. * An event triggered when the mesh is disposed
  439. */
  440. onDisposeObservable: Observable<Node>;
  441. private _onDisposeObserver;
  442. /**
  443. * Sets a callback that will be raised when the node will be disposed
  444. */
  445. onDispose: () => void;
  446. /**
  447. * Creates a new Node
  448. * @param name the name and id to be given to this node
  449. * @param scene the scene this node will be added to
  450. */
  451. constructor(name: string, scene?: Nullable<Scene>);
  452. /**
  453. * Gets the scene of the node
  454. * @returns a scene
  455. */
  456. getScene(): Scene;
  457. /**
  458. * Gets the engine of the node
  459. * @returns a Engine
  460. */
  461. getEngine(): Engine;
  462. private _behaviors;
  463. /**
  464. * Attach a behavior to the node
  465. * @see http://doc.babylonjs.com/features/behaviour
  466. * @param behavior defines the behavior to attach
  467. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  468. * @returns the current Node
  469. */
  470. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  471. /**
  472. * Remove an attached behavior
  473. * @see http://doc.babylonjs.com/features/behaviour
  474. * @param behavior defines the behavior to attach
  475. * @returns the current Node
  476. */
  477. removeBehavior(behavior: Behavior<Node>): Node;
  478. /**
  479. * Gets the list of attached behaviors
  480. * @see http://doc.babylonjs.com/features/behaviour
  481. */
  482. readonly behaviors: Behavior<Node>[];
  483. /**
  484. * Gets an attached behavior by name
  485. * @param name defines the name of the behavior to look for
  486. * @see http://doc.babylonjs.com/features/behaviour
  487. * @returns null if behavior was not found else the requested behavior
  488. */
  489. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  490. /**
  491. * Returns the latest update of the World matrix
  492. * @returns a Matrix
  493. */
  494. getWorldMatrix(): Matrix;
  495. /** @hidden */
  496. _getWorldMatrixDeterminant(): number;
  497. /**
  498. * Returns directly the latest state of the mesh World matrix.
  499. * A Matrix is returned.
  500. */
  501. readonly worldMatrixFromCache: Matrix;
  502. /** @hidden */
  503. _initCache(): void;
  504. /** @hidden */
  505. updateCache(force?: boolean): void;
  506. /** @hidden */
  507. _updateCache(ignoreParentClass?: boolean): void;
  508. /** @hidden */
  509. _isSynchronized(): boolean;
  510. /** @hidden */
  511. _markSyncedWithParent(): void;
  512. /** @hidden */
  513. isSynchronizedWithParent(): boolean;
  514. /** @hidden */
  515. isSynchronized(): boolean;
  516. /**
  517. * Is this node ready to be used/rendered
  518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  519. * @return true if the node is ready
  520. */
  521. isReady(completeCheck?: boolean): boolean;
  522. /**
  523. * Is this node enabled?
  524. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  525. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  526. * @return whether this node (and its parent) is enabled
  527. */
  528. isEnabled(checkAncestors?: boolean): boolean;
  529. /** @hidden */
  530. protected _syncParentEnabledState(): void;
  531. /**
  532. * Set the enabled state of this node
  533. * @param value defines the new enabled state
  534. */
  535. setEnabled(value: boolean): void;
  536. /**
  537. * Is this node a descendant of the given node?
  538. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  539. * @param ancestor defines the parent node to inspect
  540. * @returns a boolean indicating if this node is a descendant of the given node
  541. */
  542. isDescendantOf(ancestor: Node): boolean;
  543. /** @hidden */
  544. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  545. /**
  546. * Will return all nodes that have this node as ascendant
  547. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  548. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  549. * @return all children nodes of all types
  550. */
  551. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  552. /**
  553. * Get all child-meshes of this node
  554. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  555. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  556. * @returns an array of AbstractMesh
  557. */
  558. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  559. /**
  560. * Get all child-transformNodes of this node
  561. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  562. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  563. * @returns an array of TransformNode
  564. */
  565. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  566. /**
  567. * Get all direct children of this node
  568. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  569. * @returns an array of Node
  570. */
  571. getChildren(predicate?: (node: Node) => boolean): Node[];
  572. /** @hidden */
  573. _setReady(state: boolean): void;
  574. /**
  575. * Get an animation by name
  576. * @param name defines the name of the animation to look for
  577. * @returns null if not found else the requested animation
  578. */
  579. getAnimationByName(name: string): Nullable<Animation>;
  580. /**
  581. * Creates an animation range for this node
  582. * @param name defines the name of the range
  583. * @param from defines the starting key
  584. * @param to defines the end key
  585. */
  586. createAnimationRange(name: string, from: number, to: number): void;
  587. /**
  588. * Delete a specific animation range
  589. * @param name defines the name of the range to delete
  590. * @param deleteFrames defines if animation frames from the range must be deleted as well
  591. */
  592. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  593. /**
  594. * Get an animation range by name
  595. * @param name defines the name of the animation range to look for
  596. * @returns null if not found else the requested animation range
  597. */
  598. getAnimationRange(name: string): Nullable<AnimationRange>;
  599. /**
  600. * Will start the animation sequence
  601. * @param name defines the range frames for animation sequence
  602. * @param loop defines if the animation should loop (false by default)
  603. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  604. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  605. * @returns the object created for this animation. If range does not exist, it will return null
  606. */
  607. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  608. /**
  609. * Serialize animation ranges into a JSON compatible object
  610. * @returns serialization object
  611. */
  612. serializeAnimationRanges(): any;
  613. /**
  614. * Computes the world matrix of the node
  615. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  616. * @returns the world matrix
  617. */
  618. computeWorldMatrix(force?: boolean): Matrix;
  619. /**
  620. * Releases resources associated with this node.
  621. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  622. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  623. */
  624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  625. /**
  626. * Parse animation range data from a serialization object and store them into a given node
  627. * @param node defines where to store the animation ranges
  628. * @param parsedNode defines the serialization object to read data from
  629. * @param scene defines the hosting scene
  630. */
  631. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  632. }
  633. }
  634. declare module BABYLON {
  635. /**
  636. * Define an interface for all classes that will hold resources
  637. */
  638. interface IDisposable {
  639. /**
  640. * Releases all held resources
  641. */
  642. dispose(): void;
  643. }
  644. /**
  645. * This class is used by the onRenderingGroupObservable
  646. */
  647. class RenderingGroupInfo {
  648. /**
  649. * The Scene that being rendered
  650. */
  651. scene: Scene;
  652. /**
  653. * The camera currently used for the rendering pass
  654. */
  655. camera: Nullable<Camera>;
  656. /**
  657. * The ID of the renderingGroup being processed
  658. */
  659. renderingGroupId: number;
  660. }
  661. /** Interface defining initialization parameters for Scene class */
  662. interface SceneOptions {
  663. /**
  664. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  665. * It will improve performance when the number of geometries becomes important.
  666. */
  667. useGeometryIdsMap?: boolean;
  668. /**
  669. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  670. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  671. */
  672. useMaterialMeshMap?: boolean;
  673. /**
  674. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  675. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  676. */
  677. useClonedMeshhMap?: boolean;
  678. }
  679. /**
  680. * Represents a scene to be rendered by the engine.
  681. * @see http://doc.babylonjs.com/features/scene
  682. */
  683. class Scene extends AbstractScene implements IAnimatable {
  684. private static _uniqueIdCounter;
  685. /** The fog is deactivated */
  686. static readonly FOGMODE_NONE: number;
  687. /** The fog density is following an exponential function */
  688. static readonly FOGMODE_EXP: number;
  689. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  690. static readonly FOGMODE_EXP2: number;
  691. /** The fog density is following a linear function. */
  692. static readonly FOGMODE_LINEAR: number;
  693. /**
  694. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  696. */
  697. static MinDeltaTime: number;
  698. /**
  699. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  701. */
  702. static MaxDeltaTime: number;
  703. /**
  704. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  705. */
  706. autoClear: boolean;
  707. /**
  708. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  709. */
  710. autoClearDepthAndStencil: boolean;
  711. /**
  712. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  713. */
  714. clearColor: Color4;
  715. /**
  716. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  717. */
  718. ambientColor: Color3;
  719. /** @hidden */
  720. _environmentBRDFTexture: BaseTexture;
  721. /** @hidden */
  722. protected _environmentTexture: BaseTexture;
  723. /**
  724. * Texture used in all pbr material as the reflection texture.
  725. * As in the majority of the scene they are the same (exception for multi room and so on),
  726. * this is easier to reference from here than from all the materials.
  727. */
  728. /**
  729. * Texture used in all pbr material as the reflection texture.
  730. * As in the majority of the scene they are the same (exception for multi room and so on),
  731. * this is easier to set here than in all the materials.
  732. */
  733. environmentTexture: BaseTexture;
  734. /** @hidden */
  735. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  736. /**
  737. * Default image processing configuration used either in the rendering
  738. * Forward main pass or through the imageProcessingPostProcess if present.
  739. * As in the majority of the scene they are the same (exception for multi camera),
  740. * this is easier to reference from here than from all the materials and post process.
  741. *
  742. * No setter as we it is a shared configuration, you can set the values instead.
  743. */
  744. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  745. private _forceWireframe;
  746. /**
  747. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  748. */
  749. forceWireframe: boolean;
  750. private _forcePointsCloud;
  751. /**
  752. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  753. */
  754. forcePointsCloud: boolean;
  755. /**
  756. * Gets or sets the active clipplane 1
  757. */
  758. clipPlane: Nullable<Plane>;
  759. /**
  760. * Gets or sets the active clipplane 2
  761. */
  762. clipPlane2: Nullable<Plane>;
  763. /**
  764. * Gets or sets the active clipplane 3
  765. */
  766. clipPlane3: Nullable<Plane>;
  767. /**
  768. * Gets or sets the active clipplane 4
  769. */
  770. clipPlane4: Nullable<Plane>;
  771. /**
  772. * Gets or sets a boolean indicating if animations are enabled
  773. */
  774. animationsEnabled: boolean;
  775. private _animationPropertiesOverride;
  776. /**
  777. * Gets or sets the animation properties override
  778. */
  779. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  780. /**
  781. * Gets or sets a boolean indicating if a constant deltatime has to be used
  782. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  783. */
  784. useConstantAnimationDeltaTime: boolean;
  785. /**
  786. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  787. * Please note that it requires to run a ray cast through the scene on every frame
  788. */
  789. constantlyUpdateMeshUnderPointer: boolean;
  790. /**
  791. * Defines the HTML cursor to use when hovering over interactive elements
  792. */
  793. hoverCursor: string;
  794. /**
  795. * Defines the HTML default cursor to use (empty by default)
  796. */
  797. defaultCursor: string;
  798. /**
  799. * This is used to call preventDefault() on pointer down
  800. * in order to block unwanted artifacts like system double clicks
  801. */
  802. preventDefaultOnPointerDown: boolean;
  803. /**
  804. * This is used to call preventDefault() on pointer up
  805. * in order to block unwanted artifacts like system double clicks
  806. */
  807. preventDefaultOnPointerUp: boolean;
  808. /**
  809. * Gets or sets user defined metadata
  810. */
  811. metadata: any;
  812. /**
  813. * Gets the name of the plugin used to load this scene (null by default)
  814. */
  815. loadingPluginName: string;
  816. /**
  817. * Use this array to add regular expressions used to disable offline support for specific urls
  818. */
  819. disableOfflineSupportExceptionRules: RegExp[];
  820. /**
  821. * An event triggered when the scene is disposed.
  822. */
  823. onDisposeObservable: Observable<Scene>;
  824. private _onDisposeObserver;
  825. /** Sets a function to be executed when this scene is disposed. */
  826. onDispose: () => void;
  827. /**
  828. * An event triggered before rendering the scene (right after animations and physics)
  829. */
  830. onBeforeRenderObservable: Observable<Scene>;
  831. private _onBeforeRenderObserver;
  832. /** Sets a function to be executed before rendering this scene */
  833. beforeRender: Nullable<() => void>;
  834. /**
  835. * An event triggered after rendering the scene
  836. */
  837. onAfterRenderObservable: Observable<Scene>;
  838. private _onAfterRenderObserver;
  839. /** Sets a function to be executed after rendering this scene */
  840. afterRender: Nullable<() => void>;
  841. /**
  842. * An event triggered before animating the scene
  843. */
  844. onBeforeAnimationsObservable: Observable<Scene>;
  845. /**
  846. * An event triggered after animations processing
  847. */
  848. onAfterAnimationsObservable: Observable<Scene>;
  849. /**
  850. * An event triggered before draw calls are ready to be sent
  851. */
  852. onBeforeDrawPhaseObservable: Observable<Scene>;
  853. /**
  854. * An event triggered after draw calls have been sent
  855. */
  856. onAfterDrawPhaseObservable: Observable<Scene>;
  857. /**
  858. * An event triggered when the scene is ready
  859. */
  860. onReadyObservable: Observable<Scene>;
  861. /**
  862. * An event triggered before rendering a camera
  863. */
  864. onBeforeCameraRenderObservable: Observable<Camera>;
  865. private _onBeforeCameraRenderObserver;
  866. /** Sets a function to be executed before rendering a camera*/
  867. beforeCameraRender: () => void;
  868. /**
  869. * An event triggered after rendering a camera
  870. */
  871. onAfterCameraRenderObservable: Observable<Camera>;
  872. private _onAfterCameraRenderObserver;
  873. /** Sets a function to be executed after rendering a camera*/
  874. afterCameraRender: () => void;
  875. /**
  876. * An event triggered when active meshes evaluation is about to start
  877. */
  878. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  879. /**
  880. * An event triggered when active meshes evaluation is done
  881. */
  882. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  883. /**
  884. * An event triggered when particles rendering is about to start
  885. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  886. */
  887. onBeforeParticlesRenderingObservable: Observable<Scene>;
  888. /**
  889. * An event triggered when particles rendering is done
  890. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  891. */
  892. onAfterParticlesRenderingObservable: Observable<Scene>;
  893. /**
  894. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  895. */
  896. onDataLoadedObservable: Observable<Scene>;
  897. /**
  898. * An event triggered when a camera is created
  899. */
  900. onNewCameraAddedObservable: Observable<Camera>;
  901. /**
  902. * An event triggered when a camera is removed
  903. */
  904. onCameraRemovedObservable: Observable<Camera>;
  905. /**
  906. * An event triggered when a light is created
  907. */
  908. onNewLightAddedObservable: Observable<Light>;
  909. /**
  910. * An event triggered when a light is removed
  911. */
  912. onLightRemovedObservable: Observable<Light>;
  913. /**
  914. * An event triggered when a geometry is created
  915. */
  916. onNewGeometryAddedObservable: Observable<Geometry>;
  917. /**
  918. * An event triggered when a geometry is removed
  919. */
  920. onGeometryRemovedObservable: Observable<Geometry>;
  921. /**
  922. * An event triggered when a transform node is created
  923. */
  924. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  925. /**
  926. * An event triggered when a transform node is removed
  927. */
  928. onTransformNodeRemovedObservable: Observable<TransformNode>;
  929. /**
  930. * An event triggered when a mesh is created
  931. */
  932. onNewMeshAddedObservable: Observable<AbstractMesh>;
  933. /**
  934. * An event triggered when a mesh is removed
  935. */
  936. onMeshRemovedObservable: Observable<AbstractMesh>;
  937. /**
  938. * An event triggered when a material is created
  939. */
  940. onNewMaterialAddedObservable: Observable<Material>;
  941. /**
  942. * An event triggered when a material is removed
  943. */
  944. onMaterialRemovedObservable: Observable<Material>;
  945. /**
  946. * An event triggered when a texture is created
  947. */
  948. onNewTextureAddedObservable: Observable<BaseTexture>;
  949. /**
  950. * An event triggered when a texture is removed
  951. */
  952. onTextureRemovedObservable: Observable<BaseTexture>;
  953. /**
  954. * An event triggered when render targets are about to be rendered
  955. * Can happen multiple times per frame.
  956. */
  957. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  958. /**
  959. * An event triggered when render targets were rendered.
  960. * Can happen multiple times per frame.
  961. */
  962. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  963. /**
  964. * An event triggered before calculating deterministic simulation step
  965. */
  966. onBeforeStepObservable: Observable<Scene>;
  967. /**
  968. * An event triggered after calculating deterministic simulation step
  969. */
  970. onAfterStepObservable: Observable<Scene>;
  971. /**
  972. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  973. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  974. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  975. */
  976. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  977. /**
  978. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  979. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  980. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  981. */
  982. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  983. /**
  984. * This Observable will when a mesh has been imported into the scene.
  985. */
  986. onMeshImportedObservable: Observable<AbstractMesh>;
  987. private _registeredForLateAnimationBindings;
  988. /**
  989. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  990. */
  991. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  992. /**
  993. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  994. */
  995. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  996. /**
  997. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  998. */
  999. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1000. private _onPointerMove;
  1001. private _onPointerDown;
  1002. private _onPointerUp;
  1003. /** Deprecated. Use onPointerObservable instead */
  1004. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1005. /** Deprecated. Use onPointerObservable instead */
  1006. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1007. /** Deprecated. Use onPointerObservable instead */
  1008. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1009. /** Deprecated. Use onPointerObservable instead */
  1010. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1011. /**
  1012. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1013. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1014. */
  1015. onPrePointerObservable: Observable<PointerInfoPre>;
  1016. /**
  1017. * Observable event triggered each time an input event is received from the rendering canvas
  1018. */
  1019. onPointerObservable: Observable<PointerInfo>;
  1020. /**
  1021. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1022. */
  1023. readonly unTranslatedPointer: Vector2;
  1024. /** The distance in pixel that you have to move to prevent some events */
  1025. static DragMovementThreshold: number;
  1026. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1027. static LongPressDelay: number;
  1028. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1029. static DoubleClickDelay: number;
  1030. /** If you need to check double click without raising a single click at first click, enable this flag */
  1031. static ExclusiveDoubleClickMode: boolean;
  1032. private _initClickEvent;
  1033. private _initActionManager;
  1034. private _delayedSimpleClick;
  1035. private _delayedSimpleClickTimeout;
  1036. private _previousDelayedSimpleClickTimeout;
  1037. private _meshPickProceed;
  1038. private _previousButtonPressed;
  1039. private _currentPickResult;
  1040. private _previousPickResult;
  1041. private _totalPointersPressed;
  1042. private _doubleClickOccured;
  1043. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1044. cameraToUseForPointers: Nullable<Camera>;
  1045. private _pointerX;
  1046. private _pointerY;
  1047. private _unTranslatedPointerX;
  1048. private _unTranslatedPointerY;
  1049. private _startingPointerPosition;
  1050. private _previousStartingPointerPosition;
  1051. private _startingPointerTime;
  1052. private _previousStartingPointerTime;
  1053. private _pointerCaptures;
  1054. private _timeAccumulator;
  1055. private _currentStepId;
  1056. private _currentInternalStep;
  1057. /** @hidden */
  1058. _mirroredCameraPosition: Nullable<Vector3>;
  1059. /**
  1060. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1061. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1062. */
  1063. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1064. /**
  1065. * Observable event triggered each time an keyboard event is received from the hosting window
  1066. */
  1067. onKeyboardObservable: Observable<KeyboardInfo>;
  1068. private _onKeyDown;
  1069. private _onKeyUp;
  1070. private _onCanvasFocusObserver;
  1071. private _onCanvasBlurObserver;
  1072. private _useRightHandedSystem;
  1073. /**
  1074. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1075. */
  1076. useRightHandedSystem: boolean;
  1077. /**
  1078. * Sets the step Id used by deterministic lock step
  1079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1080. * @param newStepId defines the step Id
  1081. */
  1082. setStepId(newStepId: number): void;
  1083. /**
  1084. * Gets the step Id used by deterministic lock step
  1085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1086. * @returns the step Id
  1087. */
  1088. getStepId(): number;
  1089. /**
  1090. * Gets the internal step used by deterministic lock step
  1091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1092. * @returns the internal step
  1093. */
  1094. getInternalStep(): number;
  1095. private _fogEnabled;
  1096. /**
  1097. * Gets or sets a boolean indicating if fog is enabled on this scene
  1098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1099. * (Default is true)
  1100. */
  1101. fogEnabled: boolean;
  1102. private _fogMode;
  1103. /**
  1104. * Gets or sets the fog mode to use
  1105. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1106. * | mode | value |
  1107. * | --- | --- |
  1108. * | FOGMODE_NONE | 0 |
  1109. * | FOGMODE_EXP | 1 |
  1110. * | FOGMODE_EXP2 | 2 |
  1111. * | FOGMODE_LINEAR | 3 |
  1112. */
  1113. fogMode: number;
  1114. /**
  1115. * Gets or sets the fog color to use
  1116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1117. * (Default is Color3(0.2, 0.2, 0.3))
  1118. */
  1119. fogColor: Color3;
  1120. /**
  1121. * Gets or sets the fog density to use
  1122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1123. * (Default is 0.1)
  1124. */
  1125. fogDensity: number;
  1126. /**
  1127. * Gets or sets the fog start distance to use
  1128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1129. * (Default is 0)
  1130. */
  1131. fogStart: number;
  1132. /**
  1133. * Gets or sets the fog end distance to use
  1134. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1135. * (Default is 1000)
  1136. */
  1137. fogEnd: number;
  1138. private _shadowsEnabled;
  1139. /**
  1140. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1141. */
  1142. shadowsEnabled: boolean;
  1143. private _lightsEnabled;
  1144. /**
  1145. * Gets or sets a boolean indicating if lights are enabled on this scene
  1146. */
  1147. lightsEnabled: boolean;
  1148. /** All of the active cameras added to this scene. */
  1149. activeCameras: Camera[];
  1150. /** The current active camera */
  1151. activeCamera: Nullable<Camera>;
  1152. private _defaultMaterial;
  1153. /** The default material used on meshes when no material is affected */
  1154. /** The default material used on meshes when no material is affected */
  1155. defaultMaterial: Material;
  1156. private _texturesEnabled;
  1157. /**
  1158. * Gets or sets a boolean indicating if textures are enabled on this scene
  1159. */
  1160. texturesEnabled: boolean;
  1161. /**
  1162. * Gets or sets a boolean indicating if particles are enabled on this scene
  1163. */
  1164. particlesEnabled: boolean;
  1165. /**
  1166. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1167. */
  1168. spritesEnabled: boolean;
  1169. private _skeletonsEnabled;
  1170. /**
  1171. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1172. */
  1173. skeletonsEnabled: boolean;
  1174. /**
  1175. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1176. */
  1177. lensFlaresEnabled: boolean;
  1178. /**
  1179. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1181. */
  1182. collisionsEnabled: boolean;
  1183. private _workerCollisions;
  1184. /** @hidden */
  1185. collisionCoordinator: ICollisionCoordinator;
  1186. /**
  1187. * Defines the gravity applied to this scene (used only for collisions)
  1188. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1189. */
  1190. gravity: Vector3;
  1191. /**
  1192. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1193. */
  1194. postProcessesEnabled: boolean;
  1195. /**
  1196. * The list of postprocesses added to the scene
  1197. */
  1198. postProcesses: PostProcess[];
  1199. /**
  1200. * Gets the current postprocess manager
  1201. */
  1202. postProcessManager: PostProcessManager;
  1203. /**
  1204. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1205. */
  1206. renderTargetsEnabled: boolean;
  1207. /**
  1208. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1209. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1210. */
  1211. dumpNextRenderTargets: boolean;
  1212. /**
  1213. * The list of user defined render targets added to the scene
  1214. */
  1215. customRenderTargets: RenderTargetTexture[];
  1216. /**
  1217. * Defines if texture loading must be delayed
  1218. * If true, textures will only be loaded when they need to be rendered
  1219. */
  1220. useDelayedTextureLoading: boolean;
  1221. /**
  1222. * Gets the list of meshes imported to the scene through SceneLoader
  1223. */
  1224. importedMeshesFiles: String[];
  1225. /**
  1226. * Gets or sets a boolean indicating if probes are enabled on this scene
  1227. */
  1228. probesEnabled: boolean;
  1229. /**
  1230. * Gets or sets the current offline provider to use to store scene data
  1231. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1232. */
  1233. offlineProvider: IOfflineProvider;
  1234. /**
  1235. * Gets or sets the action manager associated with the scene
  1236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1237. */
  1238. actionManager: ActionManager;
  1239. private _meshesForIntersections;
  1240. /**
  1241. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1242. */
  1243. proceduralTexturesEnabled: boolean;
  1244. private _engine;
  1245. private _totalVertices;
  1246. /** @hidden */
  1247. _activeIndices: PerfCounter;
  1248. /** @hidden */
  1249. _activeParticles: PerfCounter;
  1250. /** @hidden */
  1251. _activeBones: PerfCounter;
  1252. private _animationRatio;
  1253. private _animationTimeLast;
  1254. private _animationTime;
  1255. /**
  1256. * Gets or sets a general scale for animation speed
  1257. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1258. */
  1259. animationTimeScale: number;
  1260. /** @hidden */
  1261. _cachedMaterial: Nullable<Material>;
  1262. /** @hidden */
  1263. _cachedEffect: Nullable<Effect>;
  1264. /** @hidden */
  1265. _cachedVisibility: Nullable<number>;
  1266. private _renderId;
  1267. private _frameId;
  1268. private _executeWhenReadyTimeoutId;
  1269. private _intermediateRendering;
  1270. private _viewUpdateFlag;
  1271. private _projectionUpdateFlag;
  1272. private _alternateViewUpdateFlag;
  1273. private _alternateProjectionUpdateFlag;
  1274. /** @hidden */
  1275. _toBeDisposed: Nullable<IDisposable>[];
  1276. private _activeRequests;
  1277. private _pendingData;
  1278. private _isDisposed;
  1279. /**
  1280. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1281. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1282. */
  1283. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1284. private _activeMeshes;
  1285. private _processedMaterials;
  1286. private _renderTargets;
  1287. /** @hidden */
  1288. _activeParticleSystems: SmartArray<IParticleSystem>;
  1289. private _activeSkeletons;
  1290. private _softwareSkinnedMeshes;
  1291. private _renderingManager;
  1292. /** @hidden */
  1293. _activeAnimatables: Animatable[];
  1294. private _transformMatrix;
  1295. private _sceneUbo;
  1296. private _alternateSceneUbo;
  1297. private _pickWithRayInverseMatrix;
  1298. private _viewMatrix;
  1299. private _projectionMatrix;
  1300. private _alternateViewMatrix;
  1301. private _alternateProjectionMatrix;
  1302. private _alternateTransformMatrix;
  1303. private _useAlternateCameraConfiguration;
  1304. private _alternateRendering;
  1305. /** @hidden */
  1306. _forcedViewPosition: Nullable<Vector3>;
  1307. /** @hidden */
  1308. readonly _isAlternateRenderingEnabled: boolean;
  1309. private _frustumPlanes;
  1310. /**
  1311. * Gets the list of frustum planes (built from the active camera)
  1312. */
  1313. readonly frustumPlanes: Plane[];
  1314. /**
  1315. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1316. * This is useful if there are more lights that the maximum simulteanous authorized
  1317. */
  1318. requireLightSorting: boolean;
  1319. /** @hidden */
  1320. readonly useMaterialMeshMap: boolean;
  1321. /** @hidden */
  1322. readonly useClonedMeshhMap: boolean;
  1323. private _pointerOverMesh;
  1324. private _pickedDownMesh;
  1325. private _pickedUpMesh;
  1326. private _externalData;
  1327. private _uid;
  1328. /**
  1329. * @hidden
  1330. * Backing store of defined scene components.
  1331. */
  1332. _components: ISceneComponent[];
  1333. /**
  1334. * @hidden
  1335. * Backing store of defined scene components.
  1336. */
  1337. _serializableComponents: ISceneSerializableComponent[];
  1338. /**
  1339. * List of components to register on the next registration step.
  1340. */
  1341. private _transientComponents;
  1342. /**
  1343. * Registers the transient components if needed.
  1344. */
  1345. private _registerTransientComponents;
  1346. /**
  1347. * @hidden
  1348. * Add a component to the scene.
  1349. * Note that the ccomponent could be registered on th next frame if this is called after
  1350. * the register component stage.
  1351. * @param component Defines the component to add to the scene
  1352. */
  1353. _addComponent(component: ISceneComponent): void;
  1354. /**
  1355. * @hidden
  1356. * Gets a component from the scene.
  1357. * @param name defines the name of the component to retrieve
  1358. * @returns the component or null if not present
  1359. */
  1360. _getComponent(name: string): Nullable<ISceneComponent>;
  1361. /**
  1362. * @hidden
  1363. * Defines the actions happening before camera updates.
  1364. */
  1365. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1366. /**
  1367. * @hidden
  1368. * Defines the actions happening before clear the canvas.
  1369. */
  1370. _beforeClearStage: Stage<SimpleStageAction>;
  1371. /**
  1372. * @hidden
  1373. * Defines the actions when collecting render targets for the frame.
  1374. */
  1375. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1376. /**
  1377. * @hidden
  1378. * Defines the actions happening for one camera in the frame.
  1379. */
  1380. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1381. /**
  1382. * @hidden
  1383. * Defines the actions happening during the per mesh ready checks.
  1384. */
  1385. _isReadyForMeshStage: Stage<MeshStageAction>;
  1386. /**
  1387. * @hidden
  1388. * Defines the actions happening before evaluate active mesh checks.
  1389. */
  1390. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1391. /**
  1392. * @hidden
  1393. * Defines the actions happening during the evaluate sub mesh checks.
  1394. */
  1395. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1396. /**
  1397. * @hidden
  1398. * Defines the actions happening during the active mesh stage.
  1399. */
  1400. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1401. /**
  1402. * @hidden
  1403. * Defines the actions happening during the per camera render target step.
  1404. */
  1405. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1406. /**
  1407. * @hidden
  1408. * Defines the actions happening just before the active camera is drawing.
  1409. */
  1410. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1411. /**
  1412. * @hidden
  1413. * Defines the actions happening just before a rendering group is drawing.
  1414. */
  1415. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1416. /**
  1417. * @hidden
  1418. * Defines the actions happening just before a mesh is drawing.
  1419. */
  1420. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1421. /**
  1422. * @hidden
  1423. * Defines the actions happening just after a mesh has been drawn.
  1424. */
  1425. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1426. /**
  1427. * @hidden
  1428. * Defines the actions happening just after a rendering group has been drawn.
  1429. */
  1430. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1431. /**
  1432. * @hidden
  1433. * Defines the actions happening just after the active camera has been drawn.
  1434. */
  1435. _afterCameraDrawStage: Stage<CameraStageAction>;
  1436. /**
  1437. * @hidden
  1438. * Defines the actions happening just after rendering all cameras and computing intersections.
  1439. */
  1440. _afterRenderStage: Stage<SimpleStageAction>;
  1441. /**
  1442. * @hidden
  1443. * Defines the actions happening when a pointer move event happens.
  1444. */
  1445. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1446. /**
  1447. * @hidden
  1448. * Defines the actions happening when a pointer down event happens.
  1449. */
  1450. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1451. /**
  1452. * @hidden
  1453. * Defines the actions happening when a pointer up event happens.
  1454. */
  1455. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1456. /**
  1457. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1458. */
  1459. private geometriesById;
  1460. /**
  1461. * Creates a new Scene
  1462. * @param engine defines the engine to use to render this scene
  1463. */
  1464. constructor(engine: Engine, options?: SceneOptions);
  1465. private _defaultMeshCandidates;
  1466. /**
  1467. * @hidden
  1468. */
  1469. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1470. private _defaultSubMeshCandidates;
  1471. /**
  1472. * @hidden
  1473. */
  1474. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1475. /**
  1476. * Sets the default candidate providers for the scene.
  1477. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1478. * and getCollidingSubMeshCandidates to their default function
  1479. */
  1480. setDefaultCandidateProviders(): void;
  1481. /**
  1482. * Gets a boolean indicating if collisions are processed on a web worker
  1483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1484. */
  1485. workerCollisions: boolean;
  1486. /**
  1487. * Gets the mesh that is currently under the pointer
  1488. */
  1489. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1490. /**
  1491. * Gets the current on-screen X position of the pointer
  1492. */
  1493. readonly pointerX: number;
  1494. /**
  1495. * Gets the current on-screen Y position of the pointer
  1496. */
  1497. readonly pointerY: number;
  1498. /**
  1499. * Gets the cached material (ie. the latest rendered one)
  1500. * @returns the cached material
  1501. */
  1502. getCachedMaterial(): Nullable<Material>;
  1503. /**
  1504. * Gets the cached effect (ie. the latest rendered one)
  1505. * @returns the cached effect
  1506. */
  1507. getCachedEffect(): Nullable<Effect>;
  1508. /**
  1509. * Gets the cached visibility state (ie. the latest rendered one)
  1510. * @returns the cached visibility state
  1511. */
  1512. getCachedVisibility(): Nullable<number>;
  1513. /**
  1514. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1515. * @param material defines the current material
  1516. * @param effect defines the current effect
  1517. * @param visibility defines the current visibility state
  1518. * @returns true if one parameter is not cached
  1519. */
  1520. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1521. /**
  1522. * Gets the engine associated with the scene
  1523. * @returns an Engine
  1524. */
  1525. getEngine(): Engine;
  1526. /**
  1527. * Gets the total number of vertices rendered per frame
  1528. * @returns the total number of vertices rendered per frame
  1529. */
  1530. getTotalVertices(): number;
  1531. /**
  1532. * Gets the performance counter for total vertices
  1533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1534. */
  1535. readonly totalVerticesPerfCounter: PerfCounter;
  1536. /**
  1537. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1538. * @returns the total number of active indices rendered per frame
  1539. */
  1540. getActiveIndices(): number;
  1541. /**
  1542. * Gets the performance counter for active indices
  1543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1544. */
  1545. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1546. /**
  1547. * Gets the total number of active particles rendered per frame
  1548. * @returns the total number of active particles rendered per frame
  1549. */
  1550. getActiveParticles(): number;
  1551. /**
  1552. * Gets the performance counter for active particles
  1553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1554. */
  1555. readonly activeParticlesPerfCounter: PerfCounter;
  1556. /**
  1557. * Gets the total number of active bones rendered per frame
  1558. * @returns the total number of active bones rendered per frame
  1559. */
  1560. getActiveBones(): number;
  1561. /**
  1562. * Gets the performance counter for active bones
  1563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1564. */
  1565. readonly activeBonesPerfCounter: PerfCounter;
  1566. /** @hidden */
  1567. getInterFramePerfCounter(): number;
  1568. /** @hidden */
  1569. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1570. /** @hidden */
  1571. getLastFrameDuration(): number;
  1572. /** @hidden */
  1573. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1574. /** @hidden */
  1575. getEvaluateActiveMeshesDuration(): number;
  1576. /** @hidden */
  1577. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1578. /**
  1579. * Gets the array of active meshes
  1580. * @returns an array of AbstractMesh
  1581. */
  1582. getActiveMeshes(): SmartArray<AbstractMesh>;
  1583. /** @hidden */
  1584. getRenderTargetsDuration(): number;
  1585. /** @hidden */
  1586. getRenderDuration(): number;
  1587. /** @hidden */
  1588. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1589. /** @hidden */
  1590. getParticlesDuration(): number;
  1591. /** @hidden */
  1592. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1593. /** @hidden */
  1594. getSpritesDuration(): number;
  1595. /** @hidden */
  1596. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1597. /**
  1598. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1599. * @returns a number
  1600. */
  1601. getAnimationRatio(): number;
  1602. /**
  1603. * Gets an unique Id for the current render phase
  1604. * @returns a number
  1605. */
  1606. getRenderId(): number;
  1607. /**
  1608. * Gets an unique Id for the current frame
  1609. * @returns a number
  1610. */
  1611. getFrameId(): number;
  1612. /** Call this function if you want to manually increment the render Id*/
  1613. incrementRenderId(): void;
  1614. private _updatePointerPosition;
  1615. private _createUbo;
  1616. private _createAlternateUbo;
  1617. private _setRayOnPointerInfo;
  1618. /**
  1619. * Use this method to simulate a pointer move on a mesh
  1620. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1621. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1622. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1623. * @returns the current scene
  1624. */
  1625. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1626. private _processPointerMove;
  1627. private _checkPrePointerObservable;
  1628. /**
  1629. * Use this method to simulate a pointer down on a mesh
  1630. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1631. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1632. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1633. * @returns the current scene
  1634. */
  1635. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1636. private _processPointerDown;
  1637. /**
  1638. * Use this method to simulate a pointer up on a mesh
  1639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1642. * @returns the current scene
  1643. */
  1644. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1645. private _processPointerUp;
  1646. /**
  1647. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1648. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1649. * @returns true if the pointer was captured
  1650. */
  1651. isPointerCaptured(pointerId?: number): boolean;
  1652. /** @hidden */
  1653. _isPointerSwiping(): boolean;
  1654. /**
  1655. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1656. * @param attachUp defines if you want to attach events to pointerup
  1657. * @param attachDown defines if you want to attach events to pointerdown
  1658. * @param attachMove defines if you want to attach events to pointermove
  1659. */
  1660. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1661. /** Detaches all event handlers*/
  1662. detachControl(): void;
  1663. /**
  1664. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1665. * Delay loaded resources are not taking in account
  1666. * @return true if all required resources are ready
  1667. */
  1668. isReady(): boolean;
  1669. /** Resets all cached information relative to material (including effect and visibility) */
  1670. resetCachedMaterial(): void;
  1671. /**
  1672. * Registers a function to be called before every frame render
  1673. * @param func defines the function to register
  1674. */
  1675. registerBeforeRender(func: () => void): void;
  1676. /**
  1677. * Unregisters a function called before every frame render
  1678. * @param func defines the function to unregister
  1679. */
  1680. unregisterBeforeRender(func: () => void): void;
  1681. /**
  1682. * Registers a function to be called after every frame render
  1683. * @param func defines the function to register
  1684. */
  1685. registerAfterRender(func: () => void): void;
  1686. /**
  1687. * Unregisters a function called after every frame render
  1688. * @param func defines the function to unregister
  1689. */
  1690. unregisterAfterRender(func: () => void): void;
  1691. private _executeOnceBeforeRender;
  1692. /**
  1693. * The provided function will run before render once and will be disposed afterwards.
  1694. * A timeout delay can be provided so that the function will be executed in N ms.
  1695. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1696. * @param func The function to be executed.
  1697. * @param timeout optional delay in ms
  1698. */
  1699. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1700. /** @hidden */
  1701. _addPendingData(data: any): void;
  1702. /** @hidden */
  1703. _removePendingData(data: any): void;
  1704. /**
  1705. * Returns the number of items waiting to be loaded
  1706. * @returns the number of items waiting to be loaded
  1707. */
  1708. getWaitingItemsCount(): number;
  1709. /**
  1710. * Returns a boolean indicating if the scene is still loading data
  1711. */
  1712. readonly isLoading: boolean;
  1713. /**
  1714. * Registers a function to be executed when the scene is ready
  1715. * @param {Function} func - the function to be executed
  1716. */
  1717. executeWhenReady(func: () => void): void;
  1718. /**
  1719. * Returns a promise that resolves when the scene is ready
  1720. * @returns A promise that resolves when the scene is ready
  1721. */
  1722. whenReadyAsync(): Promise<void>;
  1723. /** @hidden */
  1724. _checkIsReady(): void;
  1725. /**
  1726. * Will start the animation sequence of a given target
  1727. * @param target defines the target
  1728. * @param from defines from which frame should animation start
  1729. * @param to defines until which frame should animation run.
  1730. * @param weight defines the weight to apply to the animation (1.0 by default)
  1731. * @param loop defines if the animation loops
  1732. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1733. * @param onAnimationEnd defines the function to be executed when the animation ends
  1734. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1736. * @returns the animatable object created for this animation
  1737. */
  1738. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1739. /**
  1740. * Will start the animation sequence of a given target
  1741. * @param target defines the target
  1742. * @param from defines from which frame should animation start
  1743. * @param to defines until which frame should animation run.
  1744. * @param loop defines if the animation loops
  1745. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1746. * @param onAnimationEnd defines the function to be executed when the animation ends
  1747. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1748. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1749. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1750. * @returns the animatable object created for this animation
  1751. */
  1752. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1753. /**
  1754. * Begin a new animation on a given node
  1755. * @param target defines the target where the animation will take place
  1756. * @param animations defines the list of animations to start
  1757. * @param from defines the initial value
  1758. * @param to defines the final value
  1759. * @param loop defines if you want animation to loop (off by default)
  1760. * @param speedRatio defines the speed ratio to apply to all animations
  1761. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1762. * @returns the list of created animatables
  1763. */
  1764. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1765. /**
  1766. * Begin a new animation on a given node and its hierarchy
  1767. * @param target defines the root node where the animation will take place
  1768. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1769. * @param animations defines the list of animations to start
  1770. * @param from defines the initial value
  1771. * @param to defines the final value
  1772. * @param loop defines if you want animation to loop (off by default)
  1773. * @param speedRatio defines the speed ratio to apply to all animations
  1774. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1775. * @returns the list of animatables created for all nodes
  1776. */
  1777. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1778. /**
  1779. * Gets the animatable associated with a specific target
  1780. * @param target defines the target of the animatable
  1781. * @returns the required animatable if found
  1782. */
  1783. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1784. /**
  1785. * Gets all animatables associated with a given target
  1786. * @param target defines the target to look animatables for
  1787. * @returns an array of Animatables
  1788. */
  1789. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1790. /**
  1791. * Gets all animatable attached to the scene
  1792. */
  1793. readonly animatables: Animatable[];
  1794. /**
  1795. * Will stop the animation of the given target
  1796. * @param target - the target
  1797. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1798. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1799. */
  1800. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1801. /**
  1802. * Stops and removes all animations that have been applied to the scene
  1803. */
  1804. stopAllAnimations(): void;
  1805. private _animate;
  1806. /** @hidden */
  1807. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1808. private _processLateAnimationBindingsForMatrices;
  1809. private _processLateAnimationBindingsForQuaternions;
  1810. private _processLateAnimationBindings;
  1811. /** @hidden */
  1812. _switchToAlternateCameraConfiguration(active: boolean): void;
  1813. /**
  1814. * Gets the current view matrix
  1815. * @returns a Matrix
  1816. */
  1817. getViewMatrix(): Matrix;
  1818. /**
  1819. * Gets the current projection matrix
  1820. * @returns a Matrix
  1821. */
  1822. getProjectionMatrix(): Matrix;
  1823. /**
  1824. * Gets the current transform matrix
  1825. * @returns a Matrix made of View * Projection
  1826. */
  1827. getTransformMatrix(): Matrix;
  1828. /**
  1829. * Sets the current transform matrix
  1830. * @param view defines the View matrix to use
  1831. * @param projection defines the Projection matrix to use
  1832. */
  1833. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1834. /** @hidden */
  1835. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1836. /**
  1837. * Gets the uniform buffer used to store scene data
  1838. * @returns a UniformBuffer
  1839. */
  1840. getSceneUniformBuffer(): UniformBuffer;
  1841. /**
  1842. * Gets an unique (relatively to the current scene) Id
  1843. * @returns an unique number for the scene
  1844. */
  1845. getUniqueId(): number;
  1846. /**
  1847. * Add a mesh to the list of scene's meshes
  1848. * @param newMesh defines the mesh to add
  1849. * @param recursive if all child meshes should also be added to the scene
  1850. */
  1851. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1852. /**
  1853. * Remove a mesh for the list of scene's meshes
  1854. * @param toRemove defines the mesh to remove
  1855. * @param recursive if all child meshes should also be removed from the scene
  1856. * @returns the index where the mesh was in the mesh list
  1857. */
  1858. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1859. /**
  1860. * Add a transform node to the list of scene's transform nodes
  1861. * @param newTransformNode defines the transform node to add
  1862. */
  1863. addTransformNode(newTransformNode: TransformNode): void;
  1864. /**
  1865. * Remove a transform node for the list of scene's transform nodes
  1866. * @param toRemove defines the transform node to remove
  1867. * @returns the index where the transform node was in the transform node list
  1868. */
  1869. removeTransformNode(toRemove: TransformNode): number;
  1870. /**
  1871. * Remove a skeleton for the list of scene's skeletons
  1872. * @param toRemove defines the skeleton to remove
  1873. * @returns the index where the skeleton was in the skeleton list
  1874. */
  1875. removeSkeleton(toRemove: Skeleton): number;
  1876. /**
  1877. * Remove a morph target for the list of scene's morph targets
  1878. * @param toRemove defines the morph target to remove
  1879. * @returns the index where the morph target was in the morph target list
  1880. */
  1881. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1882. /**
  1883. * Remove a light for the list of scene's lights
  1884. * @param toRemove defines the light to remove
  1885. * @returns the index where the light was in the light list
  1886. */
  1887. removeLight(toRemove: Light): number;
  1888. /**
  1889. * Remove a camera for the list of scene's cameras
  1890. * @param toRemove defines the camera to remove
  1891. * @returns the index where the camera was in the camera list
  1892. */
  1893. removeCamera(toRemove: Camera): number;
  1894. /**
  1895. * Remove a particle system for the list of scene's particle systems
  1896. * @param toRemove defines the particle system to remove
  1897. * @returns the index where the particle system was in the particle system list
  1898. */
  1899. removeParticleSystem(toRemove: IParticleSystem): number;
  1900. /**
  1901. * Remove a animation for the list of scene's animations
  1902. * @param toRemove defines the animation to remove
  1903. * @returns the index where the animation was in the animation list
  1904. */
  1905. removeAnimation(toRemove: Animation): number;
  1906. /**
  1907. * Removes the given animation group from this scene.
  1908. * @param toRemove The animation group to remove
  1909. * @returns The index of the removed animation group
  1910. */
  1911. removeAnimationGroup(toRemove: AnimationGroup): number;
  1912. /**
  1913. * Removes the given multi-material from this scene.
  1914. * @param toRemove The multi-material to remove
  1915. * @returns The index of the removed multi-material
  1916. */
  1917. removeMultiMaterial(toRemove: MultiMaterial): number;
  1918. /**
  1919. * Removes the given material from this scene.
  1920. * @param toRemove The material to remove
  1921. * @returns The index of the removed material
  1922. */
  1923. removeMaterial(toRemove: Material): number;
  1924. /**
  1925. * Removes the given action manager from this scene.
  1926. * @param toRemove The action manager to remove
  1927. * @returns The index of the removed action manager
  1928. */
  1929. removeActionManager(toRemove: ActionManager): number;
  1930. /**
  1931. * Removes the given texture from this scene.
  1932. * @param toRemove The texture to remove
  1933. * @returns The index of the removed texture
  1934. */
  1935. removeTexture(toRemove: BaseTexture): number;
  1936. /**
  1937. * Adds the given light to this scene
  1938. * @param newLight The light to add
  1939. */
  1940. addLight(newLight: Light): void;
  1941. /**
  1942. * Sorts the list list based on light priorities
  1943. */
  1944. sortLightsByPriority(): void;
  1945. /**
  1946. * Adds the given camera to this scene
  1947. * @param newCamera The camera to add
  1948. */
  1949. addCamera(newCamera: Camera): void;
  1950. /**
  1951. * Adds the given skeleton to this scene
  1952. * @param newSkeleton The skeleton to add
  1953. */
  1954. addSkeleton(newSkeleton: Skeleton): void;
  1955. /**
  1956. * Adds the given particle system to this scene
  1957. * @param newParticleSystem The particle system to add
  1958. */
  1959. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1960. /**
  1961. * Adds the given animation to this scene
  1962. * @param newAnimation The animation to add
  1963. */
  1964. addAnimation(newAnimation: Animation): void;
  1965. /**
  1966. * Adds the given animation group to this scene.
  1967. * @param newAnimationGroup The animation group to add
  1968. */
  1969. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1970. /**
  1971. * Adds the given multi-material to this scene
  1972. * @param newMultiMaterial The multi-material to add
  1973. */
  1974. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1975. /**
  1976. * Adds the given material to this scene
  1977. * @param newMaterial The material to add
  1978. */
  1979. addMaterial(newMaterial: Material): void;
  1980. /**
  1981. * Adds the given morph target to this scene
  1982. * @param newMorphTargetManager The morph target to add
  1983. */
  1984. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1985. /**
  1986. * Adds the given geometry to this scene
  1987. * @param newGeometry The geometry to add
  1988. */
  1989. addGeometry(newGeometry: Geometry): void;
  1990. /**
  1991. * Adds the given action manager to this scene
  1992. * @param newActionManager The action manager to add
  1993. */
  1994. addActionManager(newActionManager: ActionManager): void;
  1995. /**
  1996. * Adds the given texture to this scene.
  1997. * @param newTexture The texture to add
  1998. */
  1999. addTexture(newTexture: BaseTexture): void;
  2000. /**
  2001. * Switch active camera
  2002. * @param newCamera defines the new active camera
  2003. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2004. */
  2005. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2006. /**
  2007. * sets the active camera of the scene using its ID
  2008. * @param id defines the camera's ID
  2009. * @return the new active camera or null if none found.
  2010. */
  2011. setActiveCameraByID(id: string): Nullable<Camera>;
  2012. /**
  2013. * sets the active camera of the scene using its name
  2014. * @param name defines the camera's name
  2015. * @returns the new active camera or null if none found.
  2016. */
  2017. setActiveCameraByName(name: string): Nullable<Camera>;
  2018. /**
  2019. * get an animation group using its name
  2020. * @param name defines the material's name
  2021. * @return the animation group or null if none found.
  2022. */
  2023. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2024. /**
  2025. * get a material using its id
  2026. * @param id defines the material's ID
  2027. * @return the material or null if none found.
  2028. */
  2029. getMaterialByID(id: string): Nullable<Material>;
  2030. /**
  2031. * Gets a material using its name
  2032. * @param name defines the material's name
  2033. * @return the material or null if none found.
  2034. */
  2035. getMaterialByName(name: string): Nullable<Material>;
  2036. /**
  2037. * Gets a camera using its id
  2038. * @param id defines the id to look for
  2039. * @returns the camera or null if not found
  2040. */
  2041. getCameraByID(id: string): Nullable<Camera>;
  2042. /**
  2043. * Gets a camera using its unique id
  2044. * @param uniqueId defines the unique id to look for
  2045. * @returns the camera or null if not found
  2046. */
  2047. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2048. /**
  2049. * Gets a camera using its name
  2050. * @param name defines the camera's name
  2051. * @return the camera or null if none found.
  2052. */
  2053. getCameraByName(name: string): Nullable<Camera>;
  2054. /**
  2055. * Gets a bone using its id
  2056. * @param id defines the bone's id
  2057. * @return the bone or null if not found
  2058. */
  2059. getBoneByID(id: string): Nullable<Bone>;
  2060. /**
  2061. * Gets a bone using its id
  2062. * @param name defines the bone's name
  2063. * @return the bone or null if not found
  2064. */
  2065. getBoneByName(name: string): Nullable<Bone>;
  2066. /**
  2067. * Gets a light node using its name
  2068. * @param name defines the the light's name
  2069. * @return the light or null if none found.
  2070. */
  2071. getLightByName(name: string): Nullable<Light>;
  2072. /**
  2073. * Gets a light node using its id
  2074. * @param id defines the light's id
  2075. * @return the light or null if none found.
  2076. */
  2077. getLightByID(id: string): Nullable<Light>;
  2078. /**
  2079. * Gets a light node using its scene-generated unique ID
  2080. * @param uniqueId defines the light's unique id
  2081. * @return the light or null if none found.
  2082. */
  2083. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2084. /**
  2085. * Gets a particle system by id
  2086. * @param id defines the particle system id
  2087. * @return the corresponding system or null if none found
  2088. */
  2089. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2090. /**
  2091. * Gets a geometry using its ID
  2092. * @param id defines the geometry's id
  2093. * @return the geometry or null if none found.
  2094. */
  2095. getGeometryByID(id: string): Nullable<Geometry>;
  2096. /**
  2097. * Add a new geometry to this scene
  2098. * @param geometry defines the geometry to be added to the scene.
  2099. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2100. * @return a boolean defining if the geometry was added or not
  2101. */
  2102. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2103. /**
  2104. * Removes an existing geometry
  2105. * @param geometry defines the geometry to be removed from the scene
  2106. * @return a boolean defining if the geometry was removed or not
  2107. */
  2108. removeGeometry(geometry: Geometry): boolean;
  2109. /**
  2110. * Gets the list of geometries attached to the scene
  2111. * @returns an array of Geometry
  2112. */
  2113. getGeometries(): Geometry[];
  2114. /**
  2115. * Gets the first added mesh found of a given ID
  2116. * @param id defines the id to search for
  2117. * @return the mesh found or null if not found at all
  2118. */
  2119. getMeshByID(id: string): Nullable<AbstractMesh>;
  2120. /**
  2121. * Gets a list of meshes using their id
  2122. * @param id defines the id to search for
  2123. * @returns a list of meshes
  2124. */
  2125. getMeshesByID(id: string): Array<AbstractMesh>;
  2126. /**
  2127. * Gets the first added transform node found of a given ID
  2128. * @param id defines the id to search for
  2129. * @return the found transform node or null if not found at all.
  2130. */
  2131. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2132. /**
  2133. * Gets a list of transform nodes using their id
  2134. * @param id defines the id to search for
  2135. * @returns a list of transform nodes
  2136. */
  2137. getTransformNodesByID(id: string): Array<TransformNode>;
  2138. /**
  2139. * Gets a mesh with its auto-generated unique id
  2140. * @param uniqueId defines the unique id to search for
  2141. * @return the found mesh or null if not found at all.
  2142. */
  2143. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2144. /**
  2145. * Gets a the last added mesh using a given id
  2146. * @param id defines the id to search for
  2147. * @return the found mesh or null if not found at all.
  2148. */
  2149. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2150. /**
  2151. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2152. * @param id defines the id to search for
  2153. * @return the found node or null if not found at all
  2154. */
  2155. getLastEntryByID(id: string): Nullable<Node>;
  2156. /**
  2157. * Gets a node (Mesh, Camera, Light) using a given id
  2158. * @param id defines the id to search for
  2159. * @return the found node or null if not found at all
  2160. */
  2161. getNodeByID(id: string): Nullable<Node>;
  2162. /**
  2163. * Gets a node (Mesh, Camera, Light) using a given name
  2164. * @param name defines the name to search for
  2165. * @return the found node or null if not found at all.
  2166. */
  2167. getNodeByName(name: string): Nullable<Node>;
  2168. /**
  2169. * Gets a mesh using a given name
  2170. * @param name defines the name to search for
  2171. * @return the found mesh or null if not found at all.
  2172. */
  2173. getMeshByName(name: string): Nullable<AbstractMesh>;
  2174. /**
  2175. * Gets a transform node using a given name
  2176. * @param name defines the name to search for
  2177. * @return the found transform node or null if not found at all.
  2178. */
  2179. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2180. /**
  2181. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2182. * @param id defines the id to search for
  2183. * @return the found skeleton or null if not found at all.
  2184. */
  2185. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2186. /**
  2187. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2188. * @param id defines the id to search for
  2189. * @return the found skeleton or null if not found at all.
  2190. */
  2191. getSkeletonById(id: string): Nullable<Skeleton>;
  2192. /**
  2193. * Gets a skeleton using a given name
  2194. * @param name defines the name to search for
  2195. * @return the found skeleton or null if not found at all.
  2196. */
  2197. getSkeletonByName(name: string): Nullable<Skeleton>;
  2198. /**
  2199. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2200. * @param id defines the id to search for
  2201. * @return the found morph target manager or null if not found at all.
  2202. */
  2203. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2204. /**
  2205. * Gets a boolean indicating if the given mesh is active
  2206. * @param mesh defines the mesh to look for
  2207. * @returns true if the mesh is in the active list
  2208. */
  2209. isActiveMesh(mesh: AbstractMesh): boolean;
  2210. /**
  2211. * Return a unique id as a string which can serve as an identifier for the scene
  2212. */
  2213. readonly uid: string;
  2214. /**
  2215. * Add an externaly attached data from its key.
  2216. * This method call will fail and return false, if such key already exists.
  2217. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2218. * @param key the unique key that identifies the data
  2219. * @param data the data object to associate to the key for this Engine instance
  2220. * @return true if no such key were already present and the data was added successfully, false otherwise
  2221. */
  2222. addExternalData<T>(key: string, data: T): boolean;
  2223. /**
  2224. * Get an externaly attached data from its key
  2225. * @param key the unique key that identifies the data
  2226. * @return the associated data, if present (can be null), or undefined if not present
  2227. */
  2228. getExternalData<T>(key: string): Nullable<T>;
  2229. /**
  2230. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2231. * @param key the unique key that identifies the data
  2232. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2233. * @return the associated data, can be null if the factory returned null.
  2234. */
  2235. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2236. /**
  2237. * Remove an externaly attached data from the Engine instance
  2238. * @param key the unique key that identifies the data
  2239. * @return true if the data was successfully removed, false if it doesn't exist
  2240. */
  2241. removeExternalData(key: string): boolean;
  2242. private _evaluateSubMesh;
  2243. /**
  2244. * Clear the processed materials smart array preventing retention point in material dispose.
  2245. */
  2246. freeProcessedMaterials(): void;
  2247. private _preventFreeActiveMeshesAndRenderingGroups;
  2248. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2249. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2250. * when disposing several meshes in a row or a hierarchy of meshes.
  2251. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2252. */
  2253. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2254. /**
  2255. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2256. */
  2257. freeActiveMeshes(): void;
  2258. /**
  2259. * Clear the info related to rendering groups preventing retention points during dispose.
  2260. */
  2261. freeRenderingGroups(): void;
  2262. /** @hidden */
  2263. _isInIntermediateRendering(): boolean;
  2264. /**
  2265. * Lambda returning the list of potentially active meshes.
  2266. */
  2267. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2268. /**
  2269. * Lambda returning the list of potentially active sub meshes.
  2270. */
  2271. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2272. /**
  2273. * Lambda returning the list of potentially intersecting sub meshes.
  2274. */
  2275. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2276. /**
  2277. * Lambda returning the list of potentially colliding sub meshes.
  2278. */
  2279. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2280. private _activeMeshesFrozen;
  2281. /**
  2282. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2283. * @returns the current scene
  2284. */
  2285. freezeActiveMeshes(): Scene;
  2286. /**
  2287. * Use this function to restart evaluating active meshes on every frame
  2288. * @returns the current scene
  2289. */
  2290. unfreezeActiveMeshes(): Scene;
  2291. private _evaluateActiveMeshes;
  2292. private _activeMesh;
  2293. /**
  2294. * Update the transform matrix to update from the current active camera
  2295. * @param force defines a boolean used to force the update even if cache is up to date
  2296. */
  2297. updateTransformMatrix(force?: boolean): void;
  2298. /**
  2299. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2300. * @param alternateCamera defines the camera to use
  2301. */
  2302. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2303. /** @hidden */
  2304. _allowPostProcessClearColor: boolean;
  2305. private _renderForCamera;
  2306. private _processSubCameras;
  2307. private _checkIntersections;
  2308. /** @hidden */
  2309. _advancePhysicsEngineStep(step: number): void;
  2310. /**
  2311. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2312. */
  2313. getDeterministicFrameTime: () => number;
  2314. /**
  2315. * Render the scene
  2316. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2317. */
  2318. render(updateCameras?: boolean): void;
  2319. /**
  2320. * Freeze all materials
  2321. * A frozen material will not be updatable but should be faster to render
  2322. */
  2323. freezeMaterials(): void;
  2324. /**
  2325. * Unfreeze all materials
  2326. * A frozen material will not be updatable but should be faster to render
  2327. */
  2328. unfreezeMaterials(): void;
  2329. /**
  2330. * Releases all held ressources
  2331. */
  2332. dispose(): void;
  2333. /**
  2334. * Gets if the scene is already disposed
  2335. */
  2336. readonly isDisposed: boolean;
  2337. /**
  2338. * Call this function to reduce memory footprint of the scene.
  2339. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2340. */
  2341. clearCachedVertexData(): void;
  2342. /**
  2343. * This function will remove the local cached buffer data from texture.
  2344. * It will save memory but will prevent the texture from being rebuilt
  2345. */
  2346. cleanCachedTextureBuffer(): void;
  2347. /**
  2348. * Get the world extend vectors with an optional filter
  2349. *
  2350. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2351. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2352. */
  2353. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2354. min: Vector3;
  2355. max: Vector3;
  2356. };
  2357. /**
  2358. * Creates a ray that can be used to pick in the scene
  2359. * @param x defines the x coordinate of the origin (on-screen)
  2360. * @param y defines the y coordinate of the origin (on-screen)
  2361. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2362. * @param camera defines the camera to use for the picking
  2363. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2364. * @returns a Ray
  2365. */
  2366. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2367. /**
  2368. * Creates a ray that can be used to pick in the scene
  2369. * @param x defines the x coordinate of the origin (on-screen)
  2370. * @param y defines the y coordinate of the origin (on-screen)
  2371. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2372. * @param result defines the ray where to store the picking ray
  2373. * @param camera defines the camera to use for the picking
  2374. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2375. * @returns the current scene
  2376. */
  2377. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2378. /**
  2379. * Creates a ray that can be used to pick in the scene
  2380. * @param x defines the x coordinate of the origin (on-screen)
  2381. * @param y defines the y coordinate of the origin (on-screen)
  2382. * @param camera defines the camera to use for the picking
  2383. * @returns a Ray
  2384. */
  2385. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2386. /**
  2387. * Creates a ray that can be used to pick in the scene
  2388. * @param x defines the x coordinate of the origin (on-screen)
  2389. * @param y defines the y coordinate of the origin (on-screen)
  2390. * @param result defines the ray where to store the picking ray
  2391. * @param camera defines the camera to use for the picking
  2392. * @returns the current scene
  2393. */
  2394. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2395. private _internalPick;
  2396. private _internalMultiPick;
  2397. private _tempPickingRay;
  2398. /** Launch a ray to try to pick a mesh in the scene
  2399. * @param x position on screen
  2400. * @param y position on screen
  2401. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2402. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2403. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2404. * @returns a PickingInfo
  2405. */
  2406. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2407. private _cachedRayForTransform;
  2408. /** Use the given ray to pick a mesh in the scene
  2409. * @param ray The ray to use to pick meshes
  2410. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2411. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2412. * @returns a PickingInfo
  2413. */
  2414. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2415. /**
  2416. * Launch a ray to try to pick a mesh in the scene
  2417. * @param x X position on screen
  2418. * @param y Y position on screen
  2419. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2421. * @returns an array of PickingInfo
  2422. */
  2423. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2424. /**
  2425. * Launch a ray to try to pick a mesh in the scene
  2426. * @param ray Ray to use
  2427. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2428. * @returns an array of PickingInfo
  2429. */
  2430. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2431. /**
  2432. * Force the value of meshUnderPointer
  2433. * @param mesh defines the mesh to use
  2434. */
  2435. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2436. /**
  2437. * Gets the mesh under the pointer
  2438. * @returns a Mesh or null if no mesh is under the pointer
  2439. */
  2440. getPointerOverMesh(): Nullable<AbstractMesh>;
  2441. /** @hidden */
  2442. _rebuildGeometries(): void;
  2443. /** @hidden */
  2444. _rebuildTextures(): void;
  2445. private _getByTags;
  2446. /**
  2447. * Get a list of meshes by tags
  2448. * @param tagsQuery defines the tags query to use
  2449. * @param forEach defines a predicate used to filter results
  2450. * @returns an array of Mesh
  2451. */
  2452. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2453. /**
  2454. * Get a list of cameras by tags
  2455. * @param tagsQuery defines the tags query to use
  2456. * @param forEach defines a predicate used to filter results
  2457. * @returns an array of Camera
  2458. */
  2459. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2460. /**
  2461. * Get a list of lights by tags
  2462. * @param tagsQuery defines the tags query to use
  2463. * @param forEach defines a predicate used to filter results
  2464. * @returns an array of Light
  2465. */
  2466. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2467. /**
  2468. * Get a list of materials by tags
  2469. * @param tagsQuery defines the tags query to use
  2470. * @param forEach defines a predicate used to filter results
  2471. * @returns an array of Material
  2472. */
  2473. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2474. /**
  2475. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2476. * This allowed control for front to back rendering or reversly depending of the special needs.
  2477. *
  2478. * @param renderingGroupId The rendering group id corresponding to its index
  2479. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2480. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2481. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2482. */
  2483. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2484. /**
  2485. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2486. *
  2487. * @param renderingGroupId The rendering group id corresponding to its index
  2488. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2489. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2490. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2491. */
  2492. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2493. /**
  2494. * Gets the current auto clear configuration for one rendering group of the rendering
  2495. * manager.
  2496. * @param index the rendering group index to get the information for
  2497. * @returns The auto clear setup for the requested rendering group
  2498. */
  2499. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2500. private _blockMaterialDirtyMechanism;
  2501. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2502. blockMaterialDirtyMechanism: boolean;
  2503. /**
  2504. * Will flag all materials as dirty to trigger new shader compilation
  2505. * @param flag defines the flag used to specify which material part must be marked as dirty
  2506. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2507. */
  2508. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2509. /** @hidden */
  2510. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2511. /** @hidden */
  2512. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2513. }
  2514. }
  2515. declare module BABYLON {
  2516. /**
  2517. * Groups all the scene component constants in one place to ease maintenance.
  2518. * @hidden
  2519. */
  2520. class SceneComponentConstants {
  2521. static readonly NAME_EFFECTLAYER: string;
  2522. static readonly NAME_LAYER: string;
  2523. static readonly NAME_LENSFLARESYSTEM: string;
  2524. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2525. static readonly NAME_PARTICLESYSTEM: string;
  2526. static readonly NAME_GAMEPAD: string;
  2527. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2528. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2529. static readonly NAME_DEPTHRENDERER: string;
  2530. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2531. static readonly NAME_SPRITE: string;
  2532. static readonly NAME_OUTLINERENDERER: string;
  2533. static readonly NAME_PROCEDURALTEXTURE: string;
  2534. static readonly NAME_SHADOWGENERATOR: string;
  2535. static readonly NAME_OCTREE: string;
  2536. static readonly NAME_PHYSICSENGINE: string;
  2537. static readonly NAME_AUDIO: string;
  2538. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2539. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2540. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2541. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2542. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2543. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2544. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2545. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2546. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2547. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2548. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2549. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2550. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2551. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2553. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2554. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2555. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2556. static readonly STEP_AFTERRENDER_AUDIO: number;
  2557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2558. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2559. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2560. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2561. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2562. static readonly STEP_POINTERMOVE_SPRITE: number;
  2563. static readonly STEP_POINTERDOWN_SPRITE: number;
  2564. static readonly STEP_POINTERUP_SPRITE: number;
  2565. }
  2566. /**
  2567. * This represents a scene component.
  2568. *
  2569. * This is used to decouple the dependency the scene is having on the different workloads like
  2570. * layers, post processes...
  2571. */
  2572. interface ISceneComponent {
  2573. /**
  2574. * The name of the component. Each component must have a unique name.
  2575. */
  2576. name: string;
  2577. /**
  2578. * The scene the component belongs to.
  2579. */
  2580. scene: Scene;
  2581. /**
  2582. * Register the component to one instance of a scene.
  2583. */
  2584. register(): void;
  2585. /**
  2586. * Rebuilds the elements related to this component in case of
  2587. * context lost for instance.
  2588. */
  2589. rebuild(): void;
  2590. /**
  2591. * Disposes the component and the associated ressources.
  2592. */
  2593. dispose(): void;
  2594. }
  2595. /**
  2596. * This represents a SERIALIZABLE scene component.
  2597. *
  2598. * This extends Scene Component to add Serialization methods on top.
  2599. */
  2600. interface ISceneSerializableComponent extends ISceneComponent {
  2601. /**
  2602. * Adds all the element from the container to the scene
  2603. * @param container the container holding the elements
  2604. */
  2605. addFromContainer(container: AbstractScene): void;
  2606. /**
  2607. * Removes all the elements in the container from the scene
  2608. * @param container contains the elements to remove
  2609. */
  2610. removeFromContainer(container: AbstractScene): void;
  2611. /**
  2612. * Serializes the component data to the specified json object
  2613. * @param serializationObject The object to serialize to
  2614. */
  2615. serialize(serializationObject: any): void;
  2616. }
  2617. /**
  2618. * Strong typing of a Mesh related stage step action
  2619. */
  2620. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2621. /**
  2622. * Strong typing of a Evaluate Sub Mesh related stage step action
  2623. */
  2624. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2625. /**
  2626. * Strong typing of a Active Mesh related stage step action
  2627. */
  2628. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2629. /**
  2630. * Strong typing of a Camera related stage step action
  2631. */
  2632. type CameraStageAction = (camera: Camera) => void;
  2633. /**
  2634. * Strong typing of a RenderingGroup related stage step action
  2635. */
  2636. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2637. /**
  2638. * Strong typing of a Mesh Render related stage step action
  2639. */
  2640. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2641. /**
  2642. * Strong typing of a simple stage step action
  2643. */
  2644. type SimpleStageAction = () => void;
  2645. /**
  2646. * Strong typing of a render target action.
  2647. */
  2648. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2649. /**
  2650. * Strong typing of a pointer move action.
  2651. */
  2652. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2653. /**
  2654. * Strong typing of a pointer up/down action.
  2655. */
  2656. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2657. /**
  2658. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2659. * @hidden
  2660. */
  2661. class Stage<T extends Function> extends Array<{
  2662. index: number;
  2663. component: ISceneComponent;
  2664. action: T;
  2665. }> {
  2666. /**
  2667. * Hide ctor from the rest of the world.
  2668. * @param items The items to add.
  2669. */
  2670. private constructor();
  2671. /**
  2672. * Creates a new Stage.
  2673. * @returns A new instance of a Stage
  2674. */
  2675. static Create<T extends Function>(): Stage<T>;
  2676. /**
  2677. * Registers a step in an ordered way in the targeted stage.
  2678. * @param index Defines the position to register the step in
  2679. * @param component Defines the component attached to the step
  2680. * @param action Defines the action to launch during the step
  2681. */
  2682. registerStep(index: number, component: ISceneComponent, action: T): void;
  2683. /**
  2684. * Clears all the steps from the stage.
  2685. */
  2686. clear(): void;
  2687. }
  2688. }
  2689. declare module BABYLON {
  2690. /** Alias type for value that can be null */
  2691. type Nullable<T> = T | null;
  2692. /**
  2693. * Alias type for number that are floats
  2694. * @ignorenaming
  2695. */
  2696. type float = number;
  2697. /**
  2698. * Alias type for number that are doubles.
  2699. * @ignorenaming
  2700. */
  2701. type double = number;
  2702. /**
  2703. * Alias type for number that are integer
  2704. * @ignorenaming
  2705. */
  2706. type int = number;
  2707. /** Alias type for number array or Float32Array */
  2708. type FloatArray = number[] | Float32Array;
  2709. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2710. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2711. /**
  2712. * Alias for types that can be used by a Buffer or VertexBuffer.
  2713. */
  2714. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2715. }
  2716. declare module BABYLON {
  2717. /**
  2718. * The action to be carried out following a trigger
  2719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2720. */
  2721. class Action {
  2722. /** the trigger, with or without parameters, for the action */
  2723. triggerOptions: any;
  2724. /**
  2725. * Trigger for the action
  2726. */
  2727. trigger: number;
  2728. /**
  2729. * Internal only - manager for action
  2730. * @hidden
  2731. */
  2732. _actionManager: ActionManager;
  2733. private _nextActiveAction;
  2734. private _child;
  2735. private _condition?;
  2736. private _triggerParameter;
  2737. /**
  2738. * An event triggered prior to action being executed.
  2739. */
  2740. onBeforeExecuteObservable: Observable<Action>;
  2741. /**
  2742. * Creates a new Action
  2743. * @param triggerOptions the trigger, with or without parameters, for the action
  2744. * @param condition an optional determinant of action
  2745. */
  2746. constructor(
  2747. /** the trigger, with or without parameters, for the action */
  2748. triggerOptions: any, condition?: Condition);
  2749. /**
  2750. * Internal only
  2751. * @hidden
  2752. */
  2753. _prepare(): void;
  2754. /**
  2755. * Gets the trigger parameters
  2756. * @returns the trigger parameters
  2757. */
  2758. getTriggerParameter(): any;
  2759. /**
  2760. * Internal only - executes current action event
  2761. * @hidden
  2762. */
  2763. _executeCurrent(evt?: ActionEvent): void;
  2764. /**
  2765. * Execute placeholder for child classes
  2766. * @param evt optional action event
  2767. */
  2768. execute(evt?: ActionEvent): void;
  2769. /**
  2770. * Skips to next active action
  2771. */
  2772. skipToNextActiveAction(): void;
  2773. /**
  2774. * Adds action to chain of actions, may be a DoNothingAction
  2775. * @param action defines the next action to execute
  2776. * @returns The action passed in
  2777. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2778. */
  2779. then(action: Action): Action;
  2780. /**
  2781. * Internal only
  2782. * @hidden
  2783. */
  2784. _getProperty(propertyPath: string): string;
  2785. /**
  2786. * Internal only
  2787. * @hidden
  2788. */
  2789. _getEffectiveTarget(target: any, propertyPath: string): any;
  2790. /**
  2791. * Serialize placeholder for child classes
  2792. * @param parent of child
  2793. * @returns the serialized object
  2794. */
  2795. serialize(parent: any): any;
  2796. /**
  2797. * Internal only called by serialize
  2798. * @hidden
  2799. */
  2800. protected _serialize(serializedAction: any, parent?: any): any;
  2801. /**
  2802. * Internal only
  2803. * @hidden
  2804. */
  2805. static _SerializeValueAsString: (value: any) => string;
  2806. /**
  2807. * Internal only
  2808. * @hidden
  2809. */
  2810. static _GetTargetProperty: (target: Scene | Node) => {
  2811. name: string;
  2812. targetType: string;
  2813. value: string;
  2814. };
  2815. }
  2816. }
  2817. declare module BABYLON {
  2818. /**
  2819. * ActionEvent is the event being sent when an action is triggered.
  2820. */
  2821. class ActionEvent {
  2822. /** The mesh or sprite that triggered the action */
  2823. source: any;
  2824. /** The X mouse cursor position at the time of the event */
  2825. pointerX: number;
  2826. /** The Y mouse cursor position at the time of the event */
  2827. pointerY: number;
  2828. /** The mesh that is currently pointed at (can be null) */
  2829. meshUnderPointer: Nullable<AbstractMesh>;
  2830. /** the original (browser) event that triggered the ActionEvent */
  2831. sourceEvent?: any;
  2832. /** additional data for the event */
  2833. additionalData?: any;
  2834. /**
  2835. * Creates a new ActionEvent
  2836. * @param source The mesh or sprite that triggered the action
  2837. * @param pointerX The X mouse cursor position at the time of the event
  2838. * @param pointerY The Y mouse cursor position at the time of the event
  2839. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2840. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2841. * @param additionalData additional data for the event
  2842. */
  2843. constructor(
  2844. /** The mesh or sprite that triggered the action */
  2845. source: any,
  2846. /** The X mouse cursor position at the time of the event */
  2847. pointerX: number,
  2848. /** The Y mouse cursor position at the time of the event */
  2849. pointerY: number,
  2850. /** The mesh that is currently pointed at (can be null) */
  2851. meshUnderPointer: Nullable<AbstractMesh>,
  2852. /** the original (browser) event that triggered the ActionEvent */
  2853. sourceEvent?: any,
  2854. /** additional data for the event */
  2855. additionalData?: any);
  2856. /**
  2857. * Helper function to auto-create an ActionEvent from a source mesh.
  2858. * @param source The source mesh that triggered the event
  2859. * @param evt The original (browser) event
  2860. * @param additionalData additional data for the event
  2861. * @returns the new ActionEvent
  2862. */
  2863. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2864. /**
  2865. * Helper function to auto-create an ActionEvent from a source sprite
  2866. * @param source The source sprite that triggered the event
  2867. * @param scene Scene associated with the sprite
  2868. * @param evt The original (browser) event
  2869. * @param additionalData additional data for the event
  2870. * @returns the new ActionEvent
  2871. */
  2872. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2873. /**
  2874. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2875. * @param scene the scene where the event occurred
  2876. * @param evt The original (browser) event
  2877. * @returns the new ActionEvent
  2878. */
  2879. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2880. /**
  2881. * Helper function to auto-create an ActionEvent from a primitive
  2882. * @param prim defines the target primitive
  2883. * @param pointerPos defines the pointer position
  2884. * @param evt The original (browser) event
  2885. * @param additionalData additional data for the event
  2886. * @returns the new ActionEvent
  2887. */
  2888. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2889. }
  2890. /**
  2891. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2892. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2894. */
  2895. class ActionManager {
  2896. /**
  2897. * Nothing
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly NothingTrigger: number;
  2901. /**
  2902. * On pick
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnPickTrigger: number;
  2906. /**
  2907. * On left pick
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnLeftPickTrigger: number;
  2911. /**
  2912. * On right pick
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnRightPickTrigger: number;
  2916. /**
  2917. * On center pick
  2918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2919. */
  2920. static readonly OnCenterPickTrigger: number;
  2921. /**
  2922. * On pick down
  2923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2924. */
  2925. static readonly OnPickDownTrigger: number;
  2926. /**
  2927. * On double pick
  2928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2929. */
  2930. static readonly OnDoublePickTrigger: number;
  2931. /**
  2932. * On pick up
  2933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2934. */
  2935. static readonly OnPickUpTrigger: number;
  2936. /**
  2937. * On pick out.
  2938. * This trigger will only be raised if you also declared a OnPickDown
  2939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2940. */
  2941. static readonly OnPickOutTrigger: number;
  2942. /**
  2943. * On long press
  2944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2945. */
  2946. static readonly OnLongPressTrigger: number;
  2947. /**
  2948. * On pointer over
  2949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2950. */
  2951. static readonly OnPointerOverTrigger: number;
  2952. /**
  2953. * On pointer out
  2954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2955. */
  2956. static readonly OnPointerOutTrigger: number;
  2957. /**
  2958. * On every frame
  2959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2960. */
  2961. static readonly OnEveryFrameTrigger: number;
  2962. /**
  2963. * On intersection enter
  2964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2965. */
  2966. static readonly OnIntersectionEnterTrigger: number;
  2967. /**
  2968. * On intersection exit
  2969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2970. */
  2971. static readonly OnIntersectionExitTrigger: number;
  2972. /**
  2973. * On key down
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2975. */
  2976. static readonly OnKeyDownTrigger: number;
  2977. /**
  2978. * On key up
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly OnKeyUpTrigger: number;
  2982. /** Gets the list of active triggers */
  2983. static Triggers: {
  2984. [key: string]: number;
  2985. };
  2986. /** Gets the list of actions */
  2987. actions: Action[];
  2988. /** Gets the cursor to use when hovering items */
  2989. hoverCursor: string;
  2990. private _scene;
  2991. /**
  2992. * Creates a new action manager
  2993. * @param scene defines the hosting scene
  2994. */
  2995. constructor(scene: Scene);
  2996. /**
  2997. * Releases all associated resources
  2998. */
  2999. dispose(): void;
  3000. /**
  3001. * Gets hosting scene
  3002. * @returns the hosting scene
  3003. */
  3004. getScene(): Scene;
  3005. /**
  3006. * Does this action manager handles actions of any of the given triggers
  3007. * @param triggers defines the triggers to be tested
  3008. * @return a boolean indicating whether one (or more) of the triggers is handled
  3009. */
  3010. hasSpecificTriggers(triggers: number[]): boolean;
  3011. /**
  3012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3013. * speed.
  3014. * @param triggerA defines the trigger to be tested
  3015. * @param triggerB defines the trigger to be tested
  3016. * @return a boolean indicating whether one (or more) of the triggers is handled
  3017. */
  3018. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3019. /**
  3020. * Does this action manager handles actions of a given trigger
  3021. * @param trigger defines the trigger to be tested
  3022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3023. * @return whether the trigger is handled
  3024. */
  3025. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3026. /**
  3027. * Does this action manager has pointer triggers
  3028. */
  3029. readonly hasPointerTriggers: boolean;
  3030. /**
  3031. * Does this action manager has pick triggers
  3032. */
  3033. readonly hasPickTriggers: boolean;
  3034. /**
  3035. * Does exist one action manager with at least one trigger
  3036. **/
  3037. static readonly HasTriggers: boolean;
  3038. /**
  3039. * Does exist one action manager with at least one pick trigger
  3040. **/
  3041. static readonly HasPickTriggers: boolean;
  3042. /**
  3043. * Does exist one action manager that handles actions of a given trigger
  3044. * @param trigger defines the trigger to be tested
  3045. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3046. **/
  3047. static HasSpecificTrigger(trigger: number): boolean;
  3048. /**
  3049. * Registers an action to this action manager
  3050. * @param action defines the action to be registered
  3051. * @return the action amended (prepared) after registration
  3052. */
  3053. registerAction(action: Action): Nullable<Action>;
  3054. /**
  3055. * Unregisters an action to this action manager
  3056. * @param action defines the action to be unregistered
  3057. * @return a boolean indicating whether the action has been unregistered
  3058. */
  3059. unregisterAction(action: Action): Boolean;
  3060. /**
  3061. * Process a specific trigger
  3062. * @param trigger defines the trigger to process
  3063. * @param evt defines the event details to be processed
  3064. */
  3065. processTrigger(trigger: number, evt?: ActionEvent): void;
  3066. /** @hidden */
  3067. _getEffectiveTarget(target: any, propertyPath: string): any;
  3068. /** @hidden */
  3069. _getProperty(propertyPath: string): string;
  3070. /**
  3071. * Serialize this manager to a JSON object
  3072. * @param name defines the property name to store this manager
  3073. * @returns a JSON representation of this manager
  3074. */
  3075. serialize(name: string): any;
  3076. /**
  3077. * Creates a new ActionManager from a JSON data
  3078. * @param parsedActions defines the JSON data to read from
  3079. * @param object defines the hosting mesh
  3080. * @param scene defines the hosting scene
  3081. */
  3082. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3083. /**
  3084. * Get a trigger name by index
  3085. * @param trigger defines the trigger index
  3086. * @returns a trigger name
  3087. */
  3088. static GetTriggerName(trigger: number): string;
  3089. }
  3090. }
  3091. declare module BABYLON {
  3092. /**
  3093. * A Condition applied to an Action
  3094. */
  3095. class Condition {
  3096. /**
  3097. * Internal only - manager for action
  3098. * @hidden
  3099. */
  3100. _actionManager: ActionManager;
  3101. /**
  3102. * Internal only
  3103. * @hidden
  3104. */
  3105. _evaluationId: number;
  3106. /**
  3107. * Internal only
  3108. * @hidden
  3109. */
  3110. _currentResult: boolean;
  3111. /**
  3112. * Creates a new Condition
  3113. * @param actionManager the manager of the action the condition is applied to
  3114. */
  3115. constructor(actionManager: ActionManager);
  3116. /**
  3117. * Check if the current condition is valid
  3118. * @returns a boolean
  3119. */
  3120. isValid(): boolean;
  3121. /**
  3122. * Internal only
  3123. * @hidden
  3124. */
  3125. _getProperty(propertyPath: string): string;
  3126. /**
  3127. * Internal only
  3128. * @hidden
  3129. */
  3130. _getEffectiveTarget(target: any, propertyPath: string): any;
  3131. /**
  3132. * Serialize placeholder for child classes
  3133. * @returns the serialized object
  3134. */
  3135. serialize(): any;
  3136. /**
  3137. * Internal only
  3138. * @hidden
  3139. */
  3140. protected _serialize(serializedCondition: any): any;
  3141. }
  3142. /**
  3143. * Defines specific conditional operators as extensions of Condition
  3144. */
  3145. class ValueCondition extends Condition {
  3146. /** path to specify the property of the target the conditional operator uses */
  3147. propertyPath: string;
  3148. /** the value compared by the conditional operator against the current value of the property */
  3149. value: any;
  3150. /** the conditional operator, default ValueCondition.IsEqual */
  3151. operator: number;
  3152. /**
  3153. * Internal only
  3154. * @hidden
  3155. */
  3156. private static _IsEqual;
  3157. /**
  3158. * Internal only
  3159. * @hidden
  3160. */
  3161. private static _IsDifferent;
  3162. /**
  3163. * Internal only
  3164. * @hidden
  3165. */
  3166. private static _IsGreater;
  3167. /**
  3168. * Internal only
  3169. * @hidden
  3170. */
  3171. private static _IsLesser;
  3172. /**
  3173. * returns the number for IsEqual
  3174. */
  3175. static readonly IsEqual: number;
  3176. /**
  3177. * Returns the number for IsDifferent
  3178. */
  3179. static readonly IsDifferent: number;
  3180. /**
  3181. * Returns the number for IsGreater
  3182. */
  3183. static readonly IsGreater: number;
  3184. /**
  3185. * Returns the number for IsLesser
  3186. */
  3187. static readonly IsLesser: number;
  3188. /**
  3189. * Internal only The action manager for the condition
  3190. * @hidden
  3191. */
  3192. _actionManager: ActionManager;
  3193. /**
  3194. * Internal only
  3195. * @hidden
  3196. */
  3197. private _target;
  3198. /**
  3199. * Internal only
  3200. * @hidden
  3201. */
  3202. private _effectiveTarget;
  3203. /**
  3204. * Internal only
  3205. * @hidden
  3206. */
  3207. private _property;
  3208. /**
  3209. * Creates a new ValueCondition
  3210. * @param actionManager manager for the action the condition applies to
  3211. * @param target for the action
  3212. * @param propertyPath path to specify the property of the target the conditional operator uses
  3213. * @param value the value compared by the conditional operator against the current value of the property
  3214. * @param operator the conditional operator, default ValueCondition.IsEqual
  3215. */
  3216. constructor(actionManager: ActionManager, target: any,
  3217. /** path to specify the property of the target the conditional operator uses */
  3218. propertyPath: string,
  3219. /** the value compared by the conditional operator against the current value of the property */
  3220. value: any,
  3221. /** the conditional operator, default ValueCondition.IsEqual */
  3222. operator?: number);
  3223. /**
  3224. * Compares the given value with the property value for the specified conditional operator
  3225. * @returns the result of the comparison
  3226. */
  3227. isValid(): boolean;
  3228. /**
  3229. * Serialize the ValueCondition into a JSON compatible object
  3230. * @returns serialization object
  3231. */
  3232. serialize(): any;
  3233. /**
  3234. * Gets the name of the conditional operator for the ValueCondition
  3235. * @param operator the conditional operator
  3236. * @returns the name
  3237. */
  3238. static GetOperatorName(operator: number): string;
  3239. }
  3240. /**
  3241. * Defines a predicate condition as an extension of Condition
  3242. */
  3243. class PredicateCondition extends Condition {
  3244. /** defines the predicate function used to validate the condition */
  3245. predicate: () => boolean;
  3246. /**
  3247. * Internal only - manager for action
  3248. * @hidden
  3249. */
  3250. _actionManager: ActionManager;
  3251. /**
  3252. * Creates a new PredicateCondition
  3253. * @param actionManager manager for the action the condition applies to
  3254. * @param predicate defines the predicate function used to validate the condition
  3255. */
  3256. constructor(actionManager: ActionManager,
  3257. /** defines the predicate function used to validate the condition */
  3258. predicate: () => boolean);
  3259. /**
  3260. * @returns the validity of the predicate condition
  3261. */
  3262. isValid(): boolean;
  3263. }
  3264. /**
  3265. * Defines a state condition as an extension of Condition
  3266. */
  3267. class StateCondition extends Condition {
  3268. /** Value to compare with target state */
  3269. value: string;
  3270. /**
  3271. * Internal only - manager for action
  3272. * @hidden
  3273. */
  3274. _actionManager: ActionManager;
  3275. /**
  3276. * Internal only
  3277. * @hidden
  3278. */
  3279. private _target;
  3280. /**
  3281. * Creates a new StateCondition
  3282. * @param actionManager manager for the action the condition applies to
  3283. * @param target of the condition
  3284. * @param value to compare with target state
  3285. */
  3286. constructor(actionManager: ActionManager, target: any,
  3287. /** Value to compare with target state */
  3288. value: string);
  3289. /**
  3290. * Gets a boolean indicating if the current condition is met
  3291. * @returns the validity of the state
  3292. */
  3293. isValid(): boolean;
  3294. /**
  3295. * Serialize the StateCondition into a JSON compatible object
  3296. * @returns serialization object
  3297. */
  3298. serialize(): any;
  3299. }
  3300. }
  3301. declare module BABYLON {
  3302. /**
  3303. * This defines an action responsible to toggle a boolean once triggered.
  3304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3305. */
  3306. class SwitchBooleanAction extends Action {
  3307. /**
  3308. * The path to the boolean property in the target object
  3309. */
  3310. propertyPath: string;
  3311. private _target;
  3312. private _effectiveTarget;
  3313. private _property;
  3314. /**
  3315. * Instantiate the action
  3316. * @param triggerOptions defines the trigger options
  3317. * @param target defines the object containing the boolean
  3318. * @param propertyPath defines the path to the boolean property in the target object
  3319. * @param condition defines the trigger related conditions
  3320. */
  3321. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3322. /** @hidden */
  3323. _prepare(): void;
  3324. /**
  3325. * Execute the action toggle the boolean value.
  3326. */
  3327. execute(): void;
  3328. /**
  3329. * Serializes the actions and its related information.
  3330. * @param parent defines the object to serialize in
  3331. * @returns the serialized object
  3332. */
  3333. serialize(parent: any): any;
  3334. }
  3335. /**
  3336. * This defines an action responsible to set a the state field of the target
  3337. * to a desired value once triggered.
  3338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3339. */
  3340. class SetStateAction extends Action {
  3341. /**
  3342. * The value to store in the state field.
  3343. */
  3344. value: string;
  3345. private _target;
  3346. /**
  3347. * Instantiate the action
  3348. * @param triggerOptions defines the trigger options
  3349. * @param target defines the object containing the state property
  3350. * @param value defines the value to store in the state field
  3351. * @param condition defines the trigger related conditions
  3352. */
  3353. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3354. /**
  3355. * Execute the action and store the value on the target state property.
  3356. */
  3357. execute(): void;
  3358. /**
  3359. * Serializes the actions and its related information.
  3360. * @param parent defines the object to serialize in
  3361. * @returns the serialized object
  3362. */
  3363. serialize(parent: any): any;
  3364. }
  3365. /**
  3366. * This defines an action responsible to set a property of the target
  3367. * to a desired value once triggered.
  3368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3369. */
  3370. class SetValueAction extends Action {
  3371. /**
  3372. * The path of the property to set in the target.
  3373. */
  3374. propertyPath: string;
  3375. /**
  3376. * The value to set in the property
  3377. */
  3378. value: any;
  3379. private _target;
  3380. private _effectiveTarget;
  3381. private _property;
  3382. /**
  3383. * Instantiate the action
  3384. * @param triggerOptions defines the trigger options
  3385. * @param target defines the object containing the property
  3386. * @param propertyPath defines the path of the property to set in the target
  3387. * @param value defines the value to set in the property
  3388. * @param condition defines the trigger related conditions
  3389. */
  3390. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3391. /** @hidden */
  3392. _prepare(): void;
  3393. /**
  3394. * Execute the action and set the targetted property to the desired value.
  3395. */
  3396. execute(): void;
  3397. /**
  3398. * Serializes the actions and its related information.
  3399. * @param parent defines the object to serialize in
  3400. * @returns the serialized object
  3401. */
  3402. serialize(parent: any): any;
  3403. }
  3404. /**
  3405. * This defines an action responsible to increment the target value
  3406. * to a desired value once triggered.
  3407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3408. */
  3409. class IncrementValueAction extends Action {
  3410. /**
  3411. * The path of the property to increment in the target.
  3412. */
  3413. propertyPath: string;
  3414. /**
  3415. * The value we should increment the property by.
  3416. */
  3417. value: any;
  3418. private _target;
  3419. private _effectiveTarget;
  3420. private _property;
  3421. /**
  3422. * Instantiate the action
  3423. * @param triggerOptions defines the trigger options
  3424. * @param target defines the object containing the property
  3425. * @param propertyPath defines the path of the property to increment in the target
  3426. * @param value defines the value value we should increment the property by
  3427. * @param condition defines the trigger related conditions
  3428. */
  3429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3430. /** @hidden */
  3431. _prepare(): void;
  3432. /**
  3433. * Execute the action and increment the target of the value amount.
  3434. */
  3435. execute(): void;
  3436. /**
  3437. * Serializes the actions and its related information.
  3438. * @param parent defines the object to serialize in
  3439. * @returns the serialized object
  3440. */
  3441. serialize(parent: any): any;
  3442. }
  3443. /**
  3444. * This defines an action responsible to start an animation once triggered.
  3445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3446. */
  3447. class PlayAnimationAction extends Action {
  3448. /**
  3449. * Where the animation should start (animation frame)
  3450. */
  3451. from: number;
  3452. /**
  3453. * Where the animation should stop (animation frame)
  3454. */
  3455. to: number;
  3456. /**
  3457. * Define if the animation should loop or stop after the first play.
  3458. */
  3459. loop?: boolean;
  3460. private _target;
  3461. /**
  3462. * Instantiate the action
  3463. * @param triggerOptions defines the trigger options
  3464. * @param target defines the target animation or animation name
  3465. * @param from defines from where the animation should start (animation frame)
  3466. * @param end defines where the animation should stop (animation frame)
  3467. * @param loop defines if the animation should loop or stop after the first play
  3468. * @param condition defines the trigger related conditions
  3469. */
  3470. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3471. /** @hidden */
  3472. _prepare(): void;
  3473. /**
  3474. * Execute the action and play the animation.
  3475. */
  3476. execute(): void;
  3477. /**
  3478. * Serializes the actions and its related information.
  3479. * @param parent defines the object to serialize in
  3480. * @returns the serialized object
  3481. */
  3482. serialize(parent: any): any;
  3483. }
  3484. /**
  3485. * This defines an action responsible to stop an animation once triggered.
  3486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3487. */
  3488. class StopAnimationAction extends Action {
  3489. private _target;
  3490. /**
  3491. * Instantiate the action
  3492. * @param triggerOptions defines the trigger options
  3493. * @param target defines the target animation or animation name
  3494. * @param condition defines the trigger related conditions
  3495. */
  3496. constructor(triggerOptions: any, target: any, condition?: Condition);
  3497. /** @hidden */
  3498. _prepare(): void;
  3499. /**
  3500. * Execute the action and stop the animation.
  3501. */
  3502. execute(): void;
  3503. /**
  3504. * Serializes the actions and its related information.
  3505. * @param parent defines the object to serialize in
  3506. * @returns the serialized object
  3507. */
  3508. serialize(parent: any): any;
  3509. }
  3510. /**
  3511. * This defines an action responsible that does nothing once triggered.
  3512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3513. */
  3514. class DoNothingAction extends Action {
  3515. /**
  3516. * Instantiate the action
  3517. * @param triggerOptions defines the trigger options
  3518. * @param condition defines the trigger related conditions
  3519. */
  3520. constructor(triggerOptions?: any, condition?: Condition);
  3521. /**
  3522. * Execute the action and do nothing.
  3523. */
  3524. execute(): void;
  3525. /**
  3526. * Serializes the actions and its related information.
  3527. * @param parent defines the object to serialize in
  3528. * @returns the serialized object
  3529. */
  3530. serialize(parent: any): any;
  3531. }
  3532. /**
  3533. * This defines an action responsible to trigger several actions once triggered.
  3534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3535. */
  3536. class CombineAction extends Action {
  3537. /**
  3538. * The list of aggregated animations to run.
  3539. */
  3540. children: Action[];
  3541. /**
  3542. * Instantiate the action
  3543. * @param triggerOptions defines the trigger options
  3544. * @param children defines the list of aggregated animations to run
  3545. * @param condition defines the trigger related conditions
  3546. */
  3547. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3548. /** @hidden */
  3549. _prepare(): void;
  3550. /**
  3551. * Execute the action and executes all the aggregated actions.
  3552. */
  3553. execute(evt: ActionEvent): void;
  3554. /**
  3555. * Serializes the actions and its related information.
  3556. * @param parent defines the object to serialize in
  3557. * @returns the serialized object
  3558. */
  3559. serialize(parent: any): any;
  3560. }
  3561. /**
  3562. * This defines an action responsible to run code (external event) once triggered.
  3563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3564. */
  3565. class ExecuteCodeAction extends Action {
  3566. /**
  3567. * The callback function to run.
  3568. */
  3569. func: (evt: ActionEvent) => void;
  3570. /**
  3571. * Instantiate the action
  3572. * @param triggerOptions defines the trigger options
  3573. * @param func defines the callback function to run
  3574. * @param condition defines the trigger related conditions
  3575. */
  3576. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3577. /**
  3578. * Execute the action and run the attached code.
  3579. */
  3580. execute(evt: ActionEvent): void;
  3581. }
  3582. /**
  3583. * This defines an action responsible to set the parent property of the target once triggered.
  3584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3585. */
  3586. class SetParentAction extends Action {
  3587. private _parent;
  3588. private _target;
  3589. /**
  3590. * Instantiate the action
  3591. * @param triggerOptions defines the trigger options
  3592. * @param target defines the target containing the parent property
  3593. * @param parent defines from where the animation should start (animation frame)
  3594. * @param condition defines the trigger related conditions
  3595. */
  3596. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3597. /** @hidden */
  3598. _prepare(): void;
  3599. /**
  3600. * Execute the action and set the parent property.
  3601. */
  3602. execute(): void;
  3603. /**
  3604. * Serializes the actions and its related information.
  3605. * @param parent defines the object to serialize in
  3606. * @returns the serialized object
  3607. */
  3608. serialize(parent: any): any;
  3609. }
  3610. }
  3611. declare module BABYLON {
  3612. /**
  3613. * This defines an action helpful to play a defined sound on a triggered action.
  3614. */
  3615. class PlaySoundAction extends Action {
  3616. private _sound;
  3617. /**
  3618. * Instantiate the action
  3619. * @param triggerOptions defines the trigger options
  3620. * @param sound defines the sound to play
  3621. * @param condition defines the trigger related conditions
  3622. */
  3623. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3624. /** @hidden */
  3625. _prepare(): void;
  3626. /**
  3627. * Execute the action and play the sound.
  3628. */
  3629. execute(): void;
  3630. /**
  3631. * Serializes the actions and its related information.
  3632. * @param parent defines the object to serialize in
  3633. * @returns the serialized object
  3634. */
  3635. serialize(parent: any): any;
  3636. }
  3637. /**
  3638. * This defines an action helpful to stop a defined sound on a triggered action.
  3639. */
  3640. class StopSoundAction extends Action {
  3641. private _sound;
  3642. /**
  3643. * Instantiate the action
  3644. * @param triggerOptions defines the trigger options
  3645. * @param sound defines the sound to stop
  3646. * @param condition defines the trigger related conditions
  3647. */
  3648. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3649. /** @hidden */
  3650. _prepare(): void;
  3651. /**
  3652. * Execute the action and stop the sound.
  3653. */
  3654. execute(): void;
  3655. /**
  3656. * Serializes the actions and its related information.
  3657. * @param parent defines the object to serialize in
  3658. * @returns the serialized object
  3659. */
  3660. serialize(parent: any): any;
  3661. }
  3662. }
  3663. declare module BABYLON {
  3664. /**
  3665. * This defines an action responsible to change the value of a property
  3666. * by interpolating between its current value and the newly set one once triggered.
  3667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3668. */
  3669. class InterpolateValueAction extends Action {
  3670. /**
  3671. * Defines the path of the property where the value should be interpolated
  3672. */
  3673. propertyPath: string;
  3674. /**
  3675. * Defines the target value at the end of the interpolation.
  3676. */
  3677. value: any;
  3678. /**
  3679. * Defines the time it will take for the property to interpolate to the value.
  3680. */
  3681. duration: number;
  3682. /**
  3683. * Defines if the other scene animations should be stopped when the action has been triggered
  3684. */
  3685. stopOtherAnimations?: boolean;
  3686. /**
  3687. * Defines a callback raised once the interpolation animation has been done.
  3688. */
  3689. onInterpolationDone?: () => void;
  3690. /**
  3691. * Observable triggered once the interpolation animation has been done.
  3692. */
  3693. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3694. private _target;
  3695. private _effectiveTarget;
  3696. private _property;
  3697. /**
  3698. * Instantiate the action
  3699. * @param triggerOptions defines the trigger options
  3700. * @param target defines the object containing the value to interpolate
  3701. * @param propertyPath defines the path to the property in the target object
  3702. * @param value defines the target value at the end of the interpolation
  3703. * @param duration deines the time it will take for the property to interpolate to the value.
  3704. * @param condition defines the trigger related conditions
  3705. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3706. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3707. */
  3708. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3709. /** @hidden */
  3710. _prepare(): void;
  3711. /**
  3712. * Execute the action starts the value interpolation.
  3713. */
  3714. execute(): void;
  3715. /**
  3716. * Serializes the actions and its related information.
  3717. * @param parent defines the object to serialize in
  3718. * @returns the serialized object
  3719. */
  3720. serialize(parent: any): any;
  3721. }
  3722. }
  3723. declare module BABYLON {
  3724. /**
  3725. * Class used to store an actual running animation
  3726. */
  3727. class Animatable {
  3728. /** defines the target object */
  3729. target: any;
  3730. /** defines the starting frame number (default is 0) */
  3731. fromFrame: number;
  3732. /** defines the ending frame number (default is 100) */
  3733. toFrame: number;
  3734. /** defines if the animation must loop (default is false) */
  3735. loopAnimation: boolean;
  3736. /** defines a callback to call when animation ends if it is not looping */
  3737. onAnimationEnd?: (() => void) | null | undefined;
  3738. private _localDelayOffset;
  3739. private _pausedDelay;
  3740. private _runtimeAnimations;
  3741. private _paused;
  3742. private _scene;
  3743. private _speedRatio;
  3744. private _weight;
  3745. private _syncRoot;
  3746. /**
  3747. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3748. * This will only apply for non looping animation (default is true)
  3749. */
  3750. disposeOnEnd: boolean;
  3751. /**
  3752. * Gets a boolean indicating if the animation has started
  3753. */
  3754. animationStarted: boolean;
  3755. /**
  3756. * Observer raised when the animation ends
  3757. */
  3758. onAnimationEndObservable: Observable<Animatable>;
  3759. /**
  3760. * Gets the root Animatable used to synchronize and normalize animations
  3761. */
  3762. readonly syncRoot: Animatable;
  3763. /**
  3764. * Gets the current frame of the first RuntimeAnimation
  3765. * Used to synchronize Animatables
  3766. */
  3767. readonly masterFrame: number;
  3768. /**
  3769. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3770. */
  3771. weight: number;
  3772. /**
  3773. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3774. */
  3775. speedRatio: number;
  3776. /**
  3777. * Creates a new Animatable
  3778. * @param scene defines the hosting scene
  3779. * @param target defines the target object
  3780. * @param fromFrame defines the starting frame number (default is 0)
  3781. * @param toFrame defines the ending frame number (default is 100)
  3782. * @param loopAnimation defines if the animation must loop (default is false)
  3783. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3784. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3785. * @param animations defines a group of animation to add to the new Animatable
  3786. */
  3787. constructor(scene: Scene,
  3788. /** defines the target object */
  3789. target: any,
  3790. /** defines the starting frame number (default is 0) */
  3791. fromFrame?: number,
  3792. /** defines the ending frame number (default is 100) */
  3793. toFrame?: number,
  3794. /** defines if the animation must loop (default is false) */
  3795. loopAnimation?: boolean, speedRatio?: number,
  3796. /** defines a callback to call when animation ends if it is not looping */
  3797. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3798. /**
  3799. * Synchronize and normalize current Animatable with a source Animatable
  3800. * This is useful when using animation weights and when animations are not of the same length
  3801. * @param root defines the root Animatable to synchronize with
  3802. * @returns the current Animatable
  3803. */
  3804. syncWith(root: Animatable): Animatable;
  3805. /**
  3806. * Gets the list of runtime animations
  3807. * @returns an array of RuntimeAnimation
  3808. */
  3809. getAnimations(): RuntimeAnimation[];
  3810. /**
  3811. * Adds more animations to the current animatable
  3812. * @param target defines the target of the animations
  3813. * @param animations defines the new animations to add
  3814. */
  3815. appendAnimations(target: any, animations: Animation[]): void;
  3816. /**
  3817. * Gets the source animation for a specific property
  3818. * @param property defines the propertyu to look for
  3819. * @returns null or the source animation for the given property
  3820. */
  3821. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3822. /**
  3823. * Gets the runtime animation for a specific property
  3824. * @param property defines the propertyu to look for
  3825. * @returns null or the runtime animation for the given property
  3826. */
  3827. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3828. /**
  3829. * Resets the animatable to its original state
  3830. */
  3831. reset(): void;
  3832. /**
  3833. * Allows the animatable to blend with current running animations
  3834. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3835. * @param blendingSpeed defines the blending speed to use
  3836. */
  3837. enableBlending(blendingSpeed: number): void;
  3838. /**
  3839. * Disable animation blending
  3840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3841. */
  3842. disableBlending(): void;
  3843. /**
  3844. * Jump directly to a given frame
  3845. * @param frame defines the frame to jump to
  3846. */
  3847. goToFrame(frame: number): void;
  3848. /**
  3849. * Pause the animation
  3850. */
  3851. pause(): void;
  3852. /**
  3853. * Restart the animation
  3854. */
  3855. restart(): void;
  3856. private _raiseOnAnimationEnd;
  3857. /**
  3858. * Stop and delete the current animation
  3859. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3860. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  3861. */
  3862. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3863. /**
  3864. * Wait asynchronously for the animation to end
  3865. * @returns a promise which will be fullfilled when the animation ends
  3866. */
  3867. waitAsync(): Promise<Animatable>;
  3868. /** @hidden */
  3869. _animate(delay: number): boolean;
  3870. }
  3871. }
  3872. declare module BABYLON {
  3873. /**
  3874. * Represents the range of an animation
  3875. */
  3876. class AnimationRange {
  3877. /**The name of the animation range**/
  3878. name: string;
  3879. /**The starting frame of the animation */
  3880. from: number;
  3881. /**The ending frame of the animation*/
  3882. to: number;
  3883. /**
  3884. * Initializes the range of an animation
  3885. * @param name The name of the animation range
  3886. * @param from The starting frame of the animation
  3887. * @param to The ending frame of the animation
  3888. */
  3889. constructor(
  3890. /**The name of the animation range**/
  3891. name: string,
  3892. /**The starting frame of the animation */
  3893. from: number,
  3894. /**The ending frame of the animation*/
  3895. to: number);
  3896. /**
  3897. * Makes a copy of the animation range
  3898. * @returns A copy of the animation range
  3899. */
  3900. clone(): AnimationRange;
  3901. }
  3902. /**
  3903. * Composed of a frame, and an action function
  3904. */
  3905. class AnimationEvent {
  3906. /** The frame for which the event is triggered **/
  3907. frame: number;
  3908. /** The event to perform when triggered **/
  3909. action: (currentFrame: number) => void;
  3910. /** Specifies if the event should be triggered only once**/
  3911. onlyOnce?: boolean | undefined;
  3912. /**
  3913. * Specifies if the animation event is done
  3914. */
  3915. isDone: boolean;
  3916. /**
  3917. * Initializes the animation event
  3918. * @param frame The frame for which the event is triggered
  3919. * @param action The event to perform when triggered
  3920. * @param onlyOnce Specifies if the event should be triggered only once
  3921. */
  3922. constructor(
  3923. /** The frame for which the event is triggered **/
  3924. frame: number,
  3925. /** The event to perform when triggered **/
  3926. action: (currentFrame: number) => void,
  3927. /** Specifies if the event should be triggered only once**/
  3928. onlyOnce?: boolean | undefined);
  3929. /** @hidden */
  3930. _clone(): AnimationEvent;
  3931. }
  3932. /**
  3933. * A cursor which tracks a point on a path
  3934. */
  3935. class PathCursor {
  3936. private path;
  3937. /**
  3938. * Stores path cursor callbacks for when an onchange event is triggered
  3939. */
  3940. private _onchange;
  3941. /**
  3942. * The value of the path cursor
  3943. */
  3944. value: number;
  3945. /**
  3946. * The animation array of the path cursor
  3947. */
  3948. animations: Animation[];
  3949. /**
  3950. * Initializes the path cursor
  3951. * @param path The path to track
  3952. */
  3953. constructor(path: Path2);
  3954. /**
  3955. * Gets the cursor point on the path
  3956. * @returns A point on the path cursor at the cursor location
  3957. */
  3958. getPoint(): Vector3;
  3959. /**
  3960. * Moves the cursor ahead by the step amount
  3961. * @param step The amount to move the cursor forward
  3962. * @returns This path cursor
  3963. */
  3964. moveAhead(step?: number): PathCursor;
  3965. /**
  3966. * Moves the cursor behind by the step amount
  3967. * @param step The amount to move the cursor back
  3968. * @returns This path cursor
  3969. */
  3970. moveBack(step?: number): PathCursor;
  3971. /**
  3972. * Moves the cursor by the step amount
  3973. * If the step amount is greater than one, an exception is thrown
  3974. * @param step The amount to move the cursor
  3975. * @returns This path cursor
  3976. */
  3977. move(step: number): PathCursor;
  3978. /**
  3979. * Ensures that the value is limited between zero and one
  3980. * @returns This path cursor
  3981. */
  3982. private ensureLimits;
  3983. /**
  3984. * Runs onchange callbacks on change (used by the animation engine)
  3985. * @returns This path cursor
  3986. */
  3987. private raiseOnChange;
  3988. /**
  3989. * Executes a function on change
  3990. * @param f A path cursor onchange callback
  3991. * @returns This path cursor
  3992. */
  3993. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3994. }
  3995. /**
  3996. * Defines an interface which represents an animation key frame
  3997. */
  3998. interface IAnimationKey {
  3999. /**
  4000. * Frame of the key frame
  4001. */
  4002. frame: number;
  4003. /**
  4004. * Value at the specifies key frame
  4005. */
  4006. value: any;
  4007. /**
  4008. * The input tangent for the cubic hermite spline
  4009. */
  4010. inTangent?: any;
  4011. /**
  4012. * The output tangent for the cubic hermite spline
  4013. */
  4014. outTangent?: any;
  4015. /**
  4016. * The animation interpolation type
  4017. */
  4018. interpolation?: AnimationKeyInterpolation;
  4019. }
  4020. /**
  4021. * Enum for the animation key frame interpolation type
  4022. */
  4023. enum AnimationKeyInterpolation {
  4024. /**
  4025. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4026. */
  4027. STEP = 1
  4028. }
  4029. /**
  4030. * Class used to store any kind of animation
  4031. */
  4032. class Animation {
  4033. /**Name of the animation */
  4034. name: string;
  4035. /**Property to animate */
  4036. targetProperty: string;
  4037. /**The frames per second of the animation */
  4038. framePerSecond: number;
  4039. /**The data type of the animation */
  4040. dataType: number;
  4041. /**The loop mode of the animation */
  4042. loopMode?: number | undefined;
  4043. /**Specifies if blending should be enabled */
  4044. enableBlending?: boolean | undefined;
  4045. /**
  4046. * Use matrix interpolation instead of using direct key value when animating matrices
  4047. */
  4048. static AllowMatricesInterpolation: boolean;
  4049. /**
  4050. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4051. */
  4052. static AllowMatrixDecomposeForInterpolation: boolean;
  4053. /**
  4054. * Stores the key frames of the animation
  4055. */
  4056. private _keys;
  4057. /**
  4058. * Stores the easing function of the animation
  4059. */
  4060. private _easingFunction;
  4061. /**
  4062. * @hidden Internal use only
  4063. */
  4064. _runtimeAnimations: RuntimeAnimation[];
  4065. /**
  4066. * The set of event that will be linked to this animation
  4067. */
  4068. private _events;
  4069. /**
  4070. * Stores an array of target property paths
  4071. */
  4072. targetPropertyPath: string[];
  4073. /**
  4074. * Stores the blending speed of the animation
  4075. */
  4076. blendingSpeed: number;
  4077. /**
  4078. * Stores the animation ranges for the animation
  4079. */
  4080. private _ranges;
  4081. /**
  4082. * @hidden Internal use
  4083. */
  4084. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4085. /**
  4086. * Sets up an animation
  4087. * @param property The property to animate
  4088. * @param animationType The animation type to apply
  4089. * @param framePerSecond The frames per second of the animation
  4090. * @param easingFunction The easing function used in the animation
  4091. * @returns The created animation
  4092. */
  4093. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4094. /**
  4095. * Create and start an animation on a node
  4096. * @param name defines the name of the global animation that will be run on all nodes
  4097. * @param node defines the root node where the animation will take place
  4098. * @param targetProperty defines property to animate
  4099. * @param framePerSecond defines the number of frame per second yo use
  4100. * @param totalFrame defines the number of frames in total
  4101. * @param from defines the initial value
  4102. * @param to defines the final value
  4103. * @param loopMode defines which loop mode you want to use (off by default)
  4104. * @param easingFunction defines the easing function to use (linear by default)
  4105. * @param onAnimationEnd defines the callback to call when animation end
  4106. * @returns the animatable created for this animation
  4107. */
  4108. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4109. /**
  4110. * Create and start an animation on a node and its descendants
  4111. * @param name defines the name of the global animation that will be run on all nodes
  4112. * @param node defines the root node where the animation will take place
  4113. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  4114. * @param targetProperty defines property to animate
  4115. * @param framePerSecond defines the number of frame per second to use
  4116. * @param totalFrame defines the number of frames in total
  4117. * @param from defines the initial value
  4118. * @param to defines the final value
  4119. * @param loopMode defines which loop mode you want to use (off by default)
  4120. * @param easingFunction defines the easing function to use (linear by default)
  4121. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4122. * @returns the list of animatables created for all nodes
  4123. * @example https://www.babylonjs-playground.com/#MH0VLI
  4124. */
  4125. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  4126. /**
  4127. * Creates a new animation, merges it with the existing animations and starts it
  4128. * @param name Name of the animation
  4129. * @param node Node which contains the scene that begins the animations
  4130. * @param targetProperty Specifies which property to animate
  4131. * @param framePerSecond The frames per second of the animation
  4132. * @param totalFrame The total number of frames
  4133. * @param from The frame at the beginning of the animation
  4134. * @param to The frame at the end of the animation
  4135. * @param loopMode Specifies the loop mode of the animation
  4136. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4137. * @param onAnimationEnd Callback to run once the animation is complete
  4138. * @returns Nullable animation
  4139. */
  4140. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4141. /**
  4142. * Transition property of an host to the target Value
  4143. * @param property The property to transition
  4144. * @param targetValue The target Value of the property
  4145. * @param host The object where the property to animate belongs
  4146. * @param scene Scene used to run the animation
  4147. * @param frameRate Framerate (in frame/s) to use
  4148. * @param transition The transition type we want to use
  4149. * @param duration The duration of the animation, in milliseconds
  4150. * @param onAnimationEnd Callback trigger at the end of the animation
  4151. * @returns Nullable animation
  4152. */
  4153. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4154. /**
  4155. * Return the array of runtime animations currently using this animation
  4156. */
  4157. readonly runtimeAnimations: RuntimeAnimation[];
  4158. /**
  4159. * Specifies if any of the runtime animations are currently running
  4160. */
  4161. readonly hasRunningRuntimeAnimations: boolean;
  4162. /**
  4163. * Initializes the animation
  4164. * @param name Name of the animation
  4165. * @param targetProperty Property to animate
  4166. * @param framePerSecond The frames per second of the animation
  4167. * @param dataType The data type of the animation
  4168. * @param loopMode The loop mode of the animation
  4169. * @param enableBlendings Specifies if blending should be enabled
  4170. */
  4171. constructor(
  4172. /**Name of the animation */
  4173. name: string,
  4174. /**Property to animate */
  4175. targetProperty: string,
  4176. /**The frames per second of the animation */
  4177. framePerSecond: number,
  4178. /**The data type of the animation */
  4179. dataType: number,
  4180. /**The loop mode of the animation */
  4181. loopMode?: number | undefined,
  4182. /**Specifies if blending should be enabled */
  4183. enableBlending?: boolean | undefined);
  4184. /**
  4185. * Converts the animation to a string
  4186. * @param fullDetails support for multiple levels of logging within scene loading
  4187. * @returns String form of the animation
  4188. */
  4189. toString(fullDetails?: boolean): string;
  4190. /**
  4191. * Add an event to this animation
  4192. * @param event Event to add
  4193. */
  4194. addEvent(event: AnimationEvent): void;
  4195. /**
  4196. * Remove all events found at the given frame
  4197. * @param frame The frame to remove events from
  4198. */
  4199. removeEvents(frame: number): void;
  4200. /**
  4201. * Retrieves all the events from the animation
  4202. * @returns Events from the animation
  4203. */
  4204. getEvents(): AnimationEvent[];
  4205. /**
  4206. * Creates an animation range
  4207. * @param name Name of the animation range
  4208. * @param from Starting frame of the animation range
  4209. * @param to Ending frame of the animation
  4210. */
  4211. createRange(name: string, from: number, to: number): void;
  4212. /**
  4213. * Deletes an animation range by name
  4214. * @param name Name of the animation range to delete
  4215. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4216. */
  4217. deleteRange(name: string, deleteFrames?: boolean): void;
  4218. /**
  4219. * Gets the animation range by name, or null if not defined
  4220. * @param name Name of the animation range
  4221. * @returns Nullable animation range
  4222. */
  4223. getRange(name: string): Nullable<AnimationRange>;
  4224. /**
  4225. * Gets the key frames from the animation
  4226. * @returns The key frames of the animation
  4227. */
  4228. getKeys(): Array<IAnimationKey>;
  4229. /**
  4230. * Gets the highest frame rate of the animation
  4231. * @returns Highest frame rate of the animation
  4232. */
  4233. getHighestFrame(): number;
  4234. /**
  4235. * Gets the easing function of the animation
  4236. * @returns Easing function of the animation
  4237. */
  4238. getEasingFunction(): IEasingFunction;
  4239. /**
  4240. * Sets the easing function of the animation
  4241. * @param easingFunction A custom mathematical formula for animation
  4242. */
  4243. setEasingFunction(easingFunction: EasingFunction): void;
  4244. /**
  4245. * Interpolates a scalar linearly
  4246. * @param startValue Start value of the animation curve
  4247. * @param endValue End value of the animation curve
  4248. * @param gradient Scalar amount to interpolate
  4249. * @returns Interpolated scalar value
  4250. */
  4251. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4252. /**
  4253. * Interpolates a scalar cubically
  4254. * @param startValue Start value of the animation curve
  4255. * @param outTangent End tangent of the animation
  4256. * @param endValue End value of the animation curve
  4257. * @param inTangent Start tangent of the animation curve
  4258. * @param gradient Scalar amount to interpolate
  4259. * @returns Interpolated scalar value
  4260. */
  4261. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4262. /**
  4263. * Interpolates a quaternion using a spherical linear interpolation
  4264. * @param startValue Start value of the animation curve
  4265. * @param endValue End value of the animation curve
  4266. * @param gradient Scalar amount to interpolate
  4267. * @returns Interpolated quaternion value
  4268. */
  4269. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4270. /**
  4271. * Interpolates a quaternion cubically
  4272. * @param startValue Start value of the animation curve
  4273. * @param outTangent End tangent of the animation curve
  4274. * @param endValue End value of the animation curve
  4275. * @param inTangent Start tangent of the animation curve
  4276. * @param gradient Scalar amount to interpolate
  4277. * @returns Interpolated quaternion value
  4278. */
  4279. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4280. /**
  4281. * Interpolates a Vector3 linearl
  4282. * @param startValue Start value of the animation curve
  4283. * @param endValue End value of the animation curve
  4284. * @param gradient Scalar amount to interpolate
  4285. * @returns Interpolated scalar value
  4286. */
  4287. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4288. /**
  4289. * Interpolates a Vector3 cubically
  4290. * @param startValue Start value of the animation curve
  4291. * @param outTangent End tangent of the animation
  4292. * @param endValue End value of the animation curve
  4293. * @param inTangent Start tangent of the animation curve
  4294. * @param gradient Scalar amount to interpolate
  4295. * @returns InterpolatedVector3 value
  4296. */
  4297. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4298. /**
  4299. * Interpolates a Vector2 linearly
  4300. * @param startValue Start value of the animation curve
  4301. * @param endValue End value of the animation curve
  4302. * @param gradient Scalar amount to interpolate
  4303. * @returns Interpolated Vector2 value
  4304. */
  4305. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4306. /**
  4307. * Interpolates a Vector2 cubically
  4308. * @param startValue Start value of the animation curve
  4309. * @param outTangent End tangent of the animation
  4310. * @param endValue End value of the animation curve
  4311. * @param inTangent Start tangent of the animation curve
  4312. * @param gradient Scalar amount to interpolate
  4313. * @returns Interpolated Vector2 value
  4314. */
  4315. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4316. /**
  4317. * Interpolates a size linearly
  4318. * @param startValue Start value of the animation curve
  4319. * @param endValue End value of the animation curve
  4320. * @param gradient Scalar amount to interpolate
  4321. * @returns Interpolated Size value
  4322. */
  4323. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4324. /**
  4325. * Interpolates a Color3 linearly
  4326. * @param startValue Start value of the animation curve
  4327. * @param endValue End value of the animation curve
  4328. * @param gradient Scalar amount to interpolate
  4329. * @returns Interpolated Color3 value
  4330. */
  4331. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4332. /**
  4333. * @hidden Internal use only
  4334. */
  4335. _getKeyValue(value: any): any;
  4336. /**
  4337. * @hidden Internal use only
  4338. */
  4339. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4340. /**
  4341. * Defines the function to use to interpolate matrices
  4342. * @param startValue defines the start matrix
  4343. * @param endValue defines the end matrix
  4344. * @param gradient defines the gradient between both matrices
  4345. * @param result defines an optional target matrix where to store the interpolation
  4346. * @returns the interpolated matrix
  4347. */
  4348. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4349. /**
  4350. * Makes a copy of the animation
  4351. * @returns Cloned animation
  4352. */
  4353. clone(): Animation;
  4354. /**
  4355. * Sets the key frames of the animation
  4356. * @param values The animation key frames to set
  4357. */
  4358. setKeys(values: Array<IAnimationKey>): void;
  4359. /**
  4360. * Serializes the animation to an object
  4361. * @returns Serialized object
  4362. */
  4363. serialize(): any;
  4364. /**
  4365. * Float animation type
  4366. */
  4367. private static _ANIMATIONTYPE_FLOAT;
  4368. /**
  4369. * Vector3 animation type
  4370. */
  4371. private static _ANIMATIONTYPE_VECTOR3;
  4372. /**
  4373. * Quaternion animation type
  4374. */
  4375. private static _ANIMATIONTYPE_QUATERNION;
  4376. /**
  4377. * Matrix animation type
  4378. */
  4379. private static _ANIMATIONTYPE_MATRIX;
  4380. /**
  4381. * Color3 animation type
  4382. */
  4383. private static _ANIMATIONTYPE_COLOR3;
  4384. /**
  4385. * Vector2 animation type
  4386. */
  4387. private static _ANIMATIONTYPE_VECTOR2;
  4388. /**
  4389. * Size animation type
  4390. */
  4391. private static _ANIMATIONTYPE_SIZE;
  4392. /**
  4393. * Relative Loop Mode
  4394. */
  4395. private static _ANIMATIONLOOPMODE_RELATIVE;
  4396. /**
  4397. * Cycle Loop Mode
  4398. */
  4399. private static _ANIMATIONLOOPMODE_CYCLE;
  4400. /**
  4401. * Constant Loop Mode
  4402. */
  4403. private static _ANIMATIONLOOPMODE_CONSTANT;
  4404. /**
  4405. * Get the float animation type
  4406. */
  4407. static readonly ANIMATIONTYPE_FLOAT: number;
  4408. /**
  4409. * Get the Vector3 animation type
  4410. */
  4411. static readonly ANIMATIONTYPE_VECTOR3: number;
  4412. /**
  4413. * Get the Vector2 animation type
  4414. */
  4415. static readonly ANIMATIONTYPE_VECTOR2: number;
  4416. /**
  4417. * Get the Size animation type
  4418. */
  4419. static readonly ANIMATIONTYPE_SIZE: number;
  4420. /**
  4421. * Get the Quaternion animation type
  4422. */
  4423. static readonly ANIMATIONTYPE_QUATERNION: number;
  4424. /**
  4425. * Get the Matrix animation type
  4426. */
  4427. static readonly ANIMATIONTYPE_MATRIX: number;
  4428. /**
  4429. * Get the Color3 animation type
  4430. */
  4431. static readonly ANIMATIONTYPE_COLOR3: number;
  4432. /**
  4433. * Get the Relative Loop Mode
  4434. */
  4435. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4436. /**
  4437. * Get the Cycle Loop Mode
  4438. */
  4439. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4440. /**
  4441. * Get the Constant Loop Mode
  4442. */
  4443. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4444. /** @hidden */
  4445. static _UniversalLerp(left: any, right: any, amount: number): any;
  4446. /**
  4447. * Parses an animation object and creates an animation
  4448. * @param parsedAnimation Parsed animation object
  4449. * @returns Animation object
  4450. */
  4451. static Parse(parsedAnimation: any): Animation;
  4452. /**
  4453. * Appends the serialized animations from the source animations
  4454. * @param source Source containing the animations
  4455. * @param destination Target to store the animations
  4456. */
  4457. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /**
  4462. * This class defines the direct association between an animation and a target
  4463. */
  4464. class TargetedAnimation {
  4465. /**
  4466. * Animation to perform
  4467. */
  4468. animation: Animation;
  4469. /**
  4470. * Target to animate
  4471. */
  4472. target: any;
  4473. }
  4474. /**
  4475. * Use this class to create coordinated animations on multiple targets
  4476. */
  4477. class AnimationGroup implements IDisposable {
  4478. /** The name of the animation group */
  4479. name: string;
  4480. private _scene;
  4481. private _targetedAnimations;
  4482. private _animatables;
  4483. private _from;
  4484. private _to;
  4485. private _isStarted;
  4486. private _speedRatio;
  4487. /**
  4488. * This observable will notify when one animation have ended.
  4489. */
  4490. onAnimationEndObservable: Observable<TargetedAnimation>;
  4491. /**
  4492. * This observable will notify when all animations have ended.
  4493. */
  4494. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4495. /**
  4496. * This observable will notify when all animations have paused.
  4497. */
  4498. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4499. /**
  4500. * Gets the first frame
  4501. */
  4502. readonly from: number;
  4503. /**
  4504. * Gets the last frame
  4505. */
  4506. readonly to: number;
  4507. /**
  4508. * Define if the animations are started
  4509. */
  4510. readonly isStarted: boolean;
  4511. /**
  4512. * Gets or sets the speed ratio to use for all animations
  4513. */
  4514. /**
  4515. * Gets or sets the speed ratio to use for all animations
  4516. */
  4517. speedRatio: number;
  4518. /**
  4519. * Gets the targeted animations for this animation group
  4520. */
  4521. readonly targetedAnimations: Array<TargetedAnimation>;
  4522. /**
  4523. * returning the list of animatables controlled by this animation group.
  4524. */
  4525. readonly animatables: Array<Animatable>;
  4526. /**
  4527. * Instantiates a new Animation Group.
  4528. * This helps managing several animations at once.
  4529. * @see http://doc.babylonjs.com/how_to/group
  4530. * @param name Defines the name of the group
  4531. * @param scene Defines the scene the group belongs to
  4532. */
  4533. constructor(
  4534. /** The name of the animation group */
  4535. name: string, scene?: Nullable<Scene>);
  4536. /**
  4537. * Add an animation (with its target) in the group
  4538. * @param animation defines the animation we want to add
  4539. * @param target defines the target of the animation
  4540. * @returns the TargetedAnimation object
  4541. */
  4542. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4543. /**
  4544. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4545. * It can add constant keys at begin or end
  4546. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4547. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4548. * @returns the animation group
  4549. */
  4550. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4551. /**
  4552. * Start all animations on given targets
  4553. * @param loop defines if animations must loop
  4554. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4555. * @param from defines the from key (optional)
  4556. * @param to defines the to key (optional)
  4557. * @returns the current animation group
  4558. */
  4559. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4560. /**
  4561. * Pause all animations
  4562. * @returns the animation group
  4563. */
  4564. pause(): AnimationGroup;
  4565. /**
  4566. * Play all animations to initial state
  4567. * This function will start() the animations if they were not started or will restart() them if they were paused
  4568. * @param loop defines if animations must loop
  4569. * @returns the animation group
  4570. */
  4571. play(loop?: boolean): AnimationGroup;
  4572. /**
  4573. * Reset all animations to initial state
  4574. * @returns the animation group
  4575. */
  4576. reset(): AnimationGroup;
  4577. /**
  4578. * Restart animations from key 0
  4579. * @returns the animation group
  4580. */
  4581. restart(): AnimationGroup;
  4582. /**
  4583. * Stop all animations
  4584. * @returns the animation group
  4585. */
  4586. stop(): AnimationGroup;
  4587. /**
  4588. * Set animation weight for all animatables
  4589. * @param weight defines the weight to use
  4590. * @return the animationGroup
  4591. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4592. */
  4593. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4594. /**
  4595. * Synchronize and normalize all animatables with a source animatable
  4596. * @param root defines the root animatable to synchronize with
  4597. * @return the animationGroup
  4598. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4599. */
  4600. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4601. /**
  4602. * Goes to a specific frame in this animation group
  4603. * @param frame the frame number to go to
  4604. * @return the animationGroup
  4605. */
  4606. goToFrame(frame: number): AnimationGroup;
  4607. /**
  4608. * Dispose all associated resources
  4609. */
  4610. dispose(): void;
  4611. private _checkAnimationGroupEnded;
  4612. /**
  4613. * Returns a new AnimationGroup object parsed from the source provided.
  4614. * @param parsedAnimationGroup defines the source
  4615. * @param scene defines the scene that will receive the animationGroup
  4616. * @returns a new AnimationGroup
  4617. */
  4618. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4619. /**
  4620. * Returns the string "AnimationGroup"
  4621. * @returns "AnimationGroup"
  4622. */
  4623. getClassName(): string;
  4624. /**
  4625. * Creates a detailled string about the object
  4626. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4627. * @returns a string representing the object
  4628. */
  4629. toString(fullDetails?: boolean): string;
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /**
  4634. * Class used to override all child animations of a given target
  4635. */
  4636. class AnimationPropertiesOverride {
  4637. /**
  4638. * Gets or sets a value indicating if animation blending must be used
  4639. */
  4640. enableBlending: boolean;
  4641. /**
  4642. * Gets or sets the blending speed to use when enableBlending is true
  4643. */
  4644. blendingSpeed: number;
  4645. /**
  4646. * Gets or sets the default loop mode to use
  4647. */
  4648. loopMode: number;
  4649. }
  4650. }
  4651. declare module BABYLON {
  4652. /**
  4653. * This represents the main contract an easing function should follow.
  4654. * Easing functions are used throughout the animation system.
  4655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4656. */
  4657. interface IEasingFunction {
  4658. /**
  4659. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4660. * of the easing function.
  4661. * The link below provides some of the most common examples of easing functions.
  4662. * @see https://easings.net/
  4663. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4664. * @returns the corresponding value on the curve defined by the easing function
  4665. */
  4666. ease(gradient: number): number;
  4667. }
  4668. /**
  4669. * Base class used for every default easing function.
  4670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4671. */
  4672. class EasingFunction implements IEasingFunction {
  4673. /**
  4674. * Interpolation follows the mathematical formula associated with the easing function.
  4675. */
  4676. static readonly EASINGMODE_EASEIN: number;
  4677. /**
  4678. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4679. */
  4680. static readonly EASINGMODE_EASEOUT: number;
  4681. /**
  4682. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4683. */
  4684. static readonly EASINGMODE_EASEINOUT: number;
  4685. private _easingMode;
  4686. /**
  4687. * Sets the easing mode of the current function.
  4688. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4689. */
  4690. setEasingMode(easingMode: number): void;
  4691. /**
  4692. * Gets the current easing mode.
  4693. * @returns the easing mode
  4694. */
  4695. getEasingMode(): number;
  4696. /**
  4697. * @hidden
  4698. */
  4699. easeInCore(gradient: number): number;
  4700. /**
  4701. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4702. * of the easing function.
  4703. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4704. * @returns the corresponding value on the curve defined by the easing function
  4705. */
  4706. ease(gradient: number): number;
  4707. }
  4708. /**
  4709. * Easing function with a circle shape (see link below).
  4710. * @see https://easings.net/#easeInCirc
  4711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4712. */
  4713. class CircleEase extends EasingFunction implements IEasingFunction {
  4714. /** @hidden */
  4715. easeInCore(gradient: number): number;
  4716. }
  4717. /**
  4718. * Easing function with a ease back shape (see link below).
  4719. * @see https://easings.net/#easeInBack
  4720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4721. */
  4722. class BackEase extends EasingFunction implements IEasingFunction {
  4723. /** Defines the amplitude of the function */
  4724. amplitude: number;
  4725. /**
  4726. * Instantiates a back ease easing
  4727. * @see https://easings.net/#easeInBack
  4728. * @param amplitude Defines the amplitude of the function
  4729. */
  4730. constructor(
  4731. /** Defines the amplitude of the function */
  4732. amplitude?: number);
  4733. /** @hidden */
  4734. easeInCore(gradient: number): number;
  4735. }
  4736. /**
  4737. * Easing function with a bouncing shape (see link below).
  4738. * @see https://easings.net/#easeInBounce
  4739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4740. */
  4741. class BounceEase extends EasingFunction implements IEasingFunction {
  4742. /** Defines the number of bounces */
  4743. bounces: number;
  4744. /** Defines the amplitude of the bounce */
  4745. bounciness: number;
  4746. /**
  4747. * Instantiates a bounce easing
  4748. * @see https://easings.net/#easeInBounce
  4749. * @param bounces Defines the number of bounces
  4750. * @param bounciness Defines the amplitude of the bounce
  4751. */
  4752. constructor(
  4753. /** Defines the number of bounces */
  4754. bounces?: number,
  4755. /** Defines the amplitude of the bounce */
  4756. bounciness?: number);
  4757. /** @hidden */
  4758. easeInCore(gradient: number): number;
  4759. }
  4760. /**
  4761. * Easing function with a power of 3 shape (see link below).
  4762. * @see https://easings.net/#easeInCubic
  4763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4764. */
  4765. class CubicEase extends EasingFunction implements IEasingFunction {
  4766. /** @hidden */
  4767. easeInCore(gradient: number): number;
  4768. }
  4769. /**
  4770. * Easing function with an elastic shape (see link below).
  4771. * @see https://easings.net/#easeInElastic
  4772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4773. */
  4774. class ElasticEase extends EasingFunction implements IEasingFunction {
  4775. /** Defines the number of oscillations*/
  4776. oscillations: number;
  4777. /** Defines the amplitude of the oscillations*/
  4778. springiness: number;
  4779. /**
  4780. * Instantiates an elastic easing function
  4781. * @see https://easings.net/#easeInElastic
  4782. * @param oscillations Defines the number of oscillations
  4783. * @param springiness Defines the amplitude of the oscillations
  4784. */
  4785. constructor(
  4786. /** Defines the number of oscillations*/
  4787. oscillations?: number,
  4788. /** Defines the amplitude of the oscillations*/
  4789. springiness?: number);
  4790. /** @hidden */
  4791. easeInCore(gradient: number): number;
  4792. }
  4793. /**
  4794. * Easing function with an exponential shape (see link below).
  4795. * @see https://easings.net/#easeInExpo
  4796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4797. */
  4798. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4799. /** Defines the exponent of the function */
  4800. exponent: number;
  4801. /**
  4802. * Instantiates an exponential easing function
  4803. * @see https://easings.net/#easeInExpo
  4804. * @param exponent Defines the exponent of the function
  4805. */
  4806. constructor(
  4807. /** Defines the exponent of the function */
  4808. exponent?: number);
  4809. /** @hidden */
  4810. easeInCore(gradient: number): number;
  4811. }
  4812. /**
  4813. * Easing function with a power shape (see link below).
  4814. * @see https://easings.net/#easeInQuad
  4815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4816. */
  4817. class PowerEase extends EasingFunction implements IEasingFunction {
  4818. /** Defines the power of the function */
  4819. power: number;
  4820. /**
  4821. * Instantiates an power base easing function
  4822. * @see https://easings.net/#easeInQuad
  4823. * @param power Defines the power of the function
  4824. */
  4825. constructor(
  4826. /** Defines the power of the function */
  4827. power?: number);
  4828. /** @hidden */
  4829. easeInCore(gradient: number): number;
  4830. }
  4831. /**
  4832. * Easing function with a power of 2 shape (see link below).
  4833. * @see https://easings.net/#easeInQuad
  4834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4835. */
  4836. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4837. /** @hidden */
  4838. easeInCore(gradient: number): number;
  4839. }
  4840. /**
  4841. * Easing function with a power of 4 shape (see link below).
  4842. * @see https://easings.net/#easeInQuart
  4843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4844. */
  4845. class QuarticEase extends EasingFunction implements IEasingFunction {
  4846. /** @hidden */
  4847. easeInCore(gradient: number): number;
  4848. }
  4849. /**
  4850. * Easing function with a power of 5 shape (see link below).
  4851. * @see https://easings.net/#easeInQuint
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. class QuinticEase extends EasingFunction implements IEasingFunction {
  4855. /** @hidden */
  4856. easeInCore(gradient: number): number;
  4857. }
  4858. /**
  4859. * Easing function with a sin shape (see link below).
  4860. * @see https://easings.net/#easeInSine
  4861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4862. */
  4863. class SineEase extends EasingFunction implements IEasingFunction {
  4864. /** @hidden */
  4865. easeInCore(gradient: number): number;
  4866. }
  4867. /**
  4868. * Easing function with a bezier shape (see link below).
  4869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4871. */
  4872. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4873. /** Defines the x component of the start tangent in the bezier curve */
  4874. x1: number;
  4875. /** Defines the y component of the start tangent in the bezier curve */
  4876. y1: number;
  4877. /** Defines the x component of the end tangent in the bezier curve */
  4878. x2: number;
  4879. /** Defines the y component of the end tangent in the bezier curve */
  4880. y2: number;
  4881. /**
  4882. * Instantiates a bezier function
  4883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4884. * @param x1 Defines the x component of the start tangent in the bezier curve
  4885. * @param y1 Defines the y component of the start tangent in the bezier curve
  4886. * @param x2 Defines the x component of the end tangent in the bezier curve
  4887. * @param y2 Defines the y component of the end tangent in the bezier curve
  4888. */
  4889. constructor(
  4890. /** Defines the x component of the start tangent in the bezier curve */
  4891. x1?: number,
  4892. /** Defines the y component of the start tangent in the bezier curve */
  4893. y1?: number,
  4894. /** Defines the x component of the end tangent in the bezier curve */
  4895. x2?: number,
  4896. /** Defines the y component of the end tangent in the bezier curve */
  4897. y2?: number);
  4898. /** @hidden */
  4899. easeInCore(gradient: number): number;
  4900. }
  4901. }
  4902. declare module BABYLON {
  4903. /**
  4904. * Defines a runtime animation
  4905. */
  4906. class RuntimeAnimation {
  4907. private _events;
  4908. /**
  4909. * The current frame of the runtime animation
  4910. */
  4911. private _currentFrame;
  4912. /**
  4913. * The animation used by the runtime animation
  4914. */
  4915. private _animation;
  4916. /**
  4917. * The target of the runtime animation
  4918. */
  4919. private _target;
  4920. /**
  4921. * The initiating animatable
  4922. */
  4923. private _host;
  4924. /**
  4925. * The original value of the runtime animation
  4926. */
  4927. private _originalValue;
  4928. /**
  4929. * The original blend value of the runtime animation
  4930. */
  4931. private _originalBlendValue;
  4932. /**
  4933. * The offsets cache of the runtime animation
  4934. */
  4935. private _offsetsCache;
  4936. /**
  4937. * The high limits cache of the runtime animation
  4938. */
  4939. private _highLimitsCache;
  4940. /**
  4941. * Specifies if the runtime animation has been stopped
  4942. */
  4943. private _stopped;
  4944. /**
  4945. * The blending factor of the runtime animation
  4946. */
  4947. private _blendingFactor;
  4948. /**
  4949. * The BabylonJS scene
  4950. */
  4951. private _scene;
  4952. /**
  4953. * The current value of the runtime animation
  4954. */
  4955. private _currentValue;
  4956. /** @hidden */
  4957. _workValue: any;
  4958. /**
  4959. * The active target of the runtime animation
  4960. */
  4961. private _activeTarget;
  4962. /**
  4963. * The target path of the runtime animation
  4964. */
  4965. private _targetPath;
  4966. /**
  4967. * The weight of the runtime animation
  4968. */
  4969. private _weight;
  4970. /**
  4971. * The ratio offset of the runtime animation
  4972. */
  4973. private _ratioOffset;
  4974. /**
  4975. * The previous delay of the runtime animation
  4976. */
  4977. private _previousDelay;
  4978. /**
  4979. * The previous ratio of the runtime animation
  4980. */
  4981. private _previousRatio;
  4982. /**
  4983. * Gets the current frame of the runtime animation
  4984. */
  4985. readonly currentFrame: number;
  4986. /**
  4987. * Gets the weight of the runtime animation
  4988. */
  4989. readonly weight: number;
  4990. /**
  4991. * Gets the current value of the runtime animation
  4992. */
  4993. readonly currentValue: any;
  4994. /**
  4995. * Gets the target path of the runtime animation
  4996. */
  4997. readonly targetPath: string;
  4998. /**
  4999. * Gets the actual target of the runtime animation
  5000. */
  5001. readonly target: any;
  5002. /**
  5003. * Create a new RuntimeAnimation object
  5004. * @param target defines the target of the animation
  5005. * @param animation defines the source animation object
  5006. * @param scene defines the hosting scene
  5007. * @param host defines the initiating Animatable
  5008. */
  5009. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5010. /**
  5011. * Gets the animation from the runtime animation
  5012. */
  5013. readonly animation: Animation;
  5014. /**
  5015. * Resets the runtime animation to the beginning
  5016. * @param restoreOriginal defines whether to restore the target property to the original value
  5017. */
  5018. reset(restoreOriginal?: boolean): void;
  5019. /**
  5020. * Specifies if the runtime animation is stopped
  5021. * @returns Boolean specifying if the runtime animation is stopped
  5022. */
  5023. isStopped(): boolean;
  5024. /**
  5025. * Disposes of the runtime animation
  5026. */
  5027. dispose(): void;
  5028. /**
  5029. * Interpolates the animation from the current frame
  5030. * @param currentFrame The frame to interpolate the animation to
  5031. * @param repeatCount The number of times that the animation should loop
  5032. * @param loopMode The type of looping mode to use
  5033. * @param offsetValue Animation offset value
  5034. * @param highLimitValue The high limit value
  5035. * @returns The interpolated value
  5036. */
  5037. private _interpolate;
  5038. /**
  5039. * Apply the interpolated value to the target
  5040. * @param currentValue defines the value computed by the animation
  5041. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5042. */
  5043. setValue(currentValue: any, weight?: number): void;
  5044. private _setValue;
  5045. /**
  5046. * Gets the loop pmode of the runtime animation
  5047. * @returns Loop Mode
  5048. */
  5049. private _getCorrectLoopMode;
  5050. /**
  5051. * Move the current animation to a given frame
  5052. * @param frame defines the frame to move to
  5053. */
  5054. goToFrame(frame: number): void;
  5055. /**
  5056. * @hidden Internal use only
  5057. */
  5058. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5059. /**
  5060. * Execute the current animation
  5061. * @param delay defines the delay to add to the current frame
  5062. * @param from defines the lower bound of the animation range
  5063. * @param to defines the upper bound of the animation range
  5064. * @param loop defines if the current animation must loop
  5065. * @param speedRatio defines the current speed ratio
  5066. * @param weight defines the weight of the animation (default is -1 so no weight)
  5067. * @returns a boolean indicating if the animation is running
  5068. */
  5069. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5070. }
  5071. }
  5072. declare module BABYLON {
  5073. /**
  5074. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5076. */
  5077. class Analyser {
  5078. /**
  5079. * Gets or sets the smoothing
  5080. * @ignorenaming
  5081. */
  5082. SMOOTHING: number;
  5083. /**
  5084. * Gets or sets the FFT table size
  5085. * @ignorenaming
  5086. */
  5087. FFT_SIZE: number;
  5088. /**
  5089. * Gets or sets the bar graph amplitude
  5090. * @ignorenaming
  5091. */
  5092. BARGRAPHAMPLITUDE: number;
  5093. /**
  5094. * Gets or sets the position of the debug canvas
  5095. * @ignorenaming
  5096. */
  5097. DEBUGCANVASPOS: {
  5098. x: number;
  5099. y: number;
  5100. };
  5101. /**
  5102. * Gets or sets the debug canvas size
  5103. * @ignorenaming
  5104. */
  5105. DEBUGCANVASSIZE: {
  5106. width: number;
  5107. height: number;
  5108. };
  5109. private _byteFreqs;
  5110. private _byteTime;
  5111. private _floatFreqs;
  5112. private _webAudioAnalyser;
  5113. private _debugCanvas;
  5114. private _debugCanvasContext;
  5115. private _scene;
  5116. private _registerFunc;
  5117. private _audioEngine;
  5118. /**
  5119. * Creates a new analyser
  5120. * @param scene defines hosting scene
  5121. */
  5122. constructor(scene: Scene);
  5123. /**
  5124. * Get the number of data values you will have to play with for the visualization
  5125. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5126. * @returns a number
  5127. */
  5128. getFrequencyBinCount(): number;
  5129. /**
  5130. * Gets the current frequency data as a byte array
  5131. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5132. * @returns a Uint8Array
  5133. */
  5134. getByteFrequencyData(): Uint8Array;
  5135. /**
  5136. * Gets the current waveform as a byte array
  5137. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5138. * @returns a Uint8Array
  5139. */
  5140. getByteTimeDomainData(): Uint8Array;
  5141. /**
  5142. * Gets the current frequency data as a float array
  5143. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5144. * @returns a Float32Array
  5145. */
  5146. getFloatFrequencyData(): Float32Array;
  5147. /**
  5148. * Renders the debug canvas
  5149. */
  5150. drawDebugCanvas(): void;
  5151. /**
  5152. * Stops rendering the debug canvas and removes it
  5153. */
  5154. stopDebugCanvas(): void;
  5155. /**
  5156. * Connects two audio nodes
  5157. * @param inputAudioNode defines first node to connect
  5158. * @param outputAudioNode defines second node to connect
  5159. */
  5160. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5161. /**
  5162. * Releases all associated resources
  5163. */
  5164. dispose(): void;
  5165. }
  5166. }
  5167. declare module BABYLON {
  5168. /**
  5169. * This represents an audio engine and it is responsible
  5170. * to play, synchronize and analyse sounds throughout the application.
  5171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5172. */
  5173. interface IAudioEngine extends IDisposable {
  5174. /**
  5175. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5176. */
  5177. readonly canUseWebAudio: boolean;
  5178. /**
  5179. * Gets the current AudioContext if available.
  5180. */
  5181. readonly audioContext: Nullable<AudioContext>;
  5182. /**
  5183. * The master gain node defines the global audio volume of your audio engine.
  5184. */
  5185. readonly masterGain: GainNode;
  5186. /**
  5187. * Gets whether or not mp3 are supported by your browser.
  5188. */
  5189. readonly isMP3supported: boolean;
  5190. /**
  5191. * Gets whether or not ogg are supported by your browser.
  5192. */
  5193. readonly isOGGsupported: boolean;
  5194. /**
  5195. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5196. * @ignoreNaming
  5197. */
  5198. WarnedWebAudioUnsupported: boolean;
  5199. /**
  5200. * Defines if the audio engine relies on a custom unlocked button.
  5201. * In this case, the embedded button will not be displayed.
  5202. */
  5203. useCustomUnlockedButton: boolean;
  5204. /**
  5205. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5206. */
  5207. readonly unlocked: boolean;
  5208. /**
  5209. * Event raised when audio has been unlocked on the browser.
  5210. */
  5211. onAudioUnlockedObservable: Observable<AudioEngine>;
  5212. /**
  5213. * Event raised when audio has been locked on the browser.
  5214. */
  5215. onAudioLockedObservable: Observable<AudioEngine>;
  5216. /**
  5217. * Flags the audio engine in Locked state.
  5218. * This happens due to new browser policies preventing audio to autoplay.
  5219. */
  5220. lock(): void;
  5221. /**
  5222. * Unlocks the audio engine once a user action has been done on the dom.
  5223. * This is helpful to resume play once browser policies have been satisfied.
  5224. */
  5225. unlock(): void;
  5226. }
  5227. /**
  5228. * This represents the default audio engine used in babylon.
  5229. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5231. */
  5232. class AudioEngine implements IAudioEngine {
  5233. private _audioContext;
  5234. private _audioContextInitialized;
  5235. private _muteButton;
  5236. private _hostElement;
  5237. /**
  5238. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5239. */
  5240. canUseWebAudio: boolean;
  5241. /**
  5242. * The master gain node defines the global audio volume of your audio engine.
  5243. */
  5244. masterGain: GainNode;
  5245. /**
  5246. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5247. * @ignoreNaming
  5248. */
  5249. WarnedWebAudioUnsupported: boolean;
  5250. /**
  5251. * Gets whether or not mp3 are supported by your browser.
  5252. */
  5253. isMP3supported: boolean;
  5254. /**
  5255. * Gets whether or not ogg are supported by your browser.
  5256. */
  5257. isOGGsupported: boolean;
  5258. /**
  5259. * Gets whether audio has been unlocked on the device.
  5260. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5261. * a user interaction has happened.
  5262. */
  5263. unlocked: boolean;
  5264. /**
  5265. * Defines if the audio engine relies on a custom unlocked button.
  5266. * In this case, the embedded button will not be displayed.
  5267. */
  5268. useCustomUnlockedButton: boolean;
  5269. /**
  5270. * Event raised when audio has been unlocked on the browser.
  5271. */
  5272. onAudioUnlockedObservable: Observable<AudioEngine>;
  5273. /**
  5274. * Event raised when audio has been locked on the browser.
  5275. */
  5276. onAudioLockedObservable: Observable<AudioEngine>;
  5277. /**
  5278. * Gets the current AudioContext if available.
  5279. */
  5280. readonly audioContext: Nullable<AudioContext>;
  5281. private _connectedAnalyser;
  5282. /**
  5283. * Instantiates a new audio engine.
  5284. *
  5285. * There should be only one per page as some browsers restrict the number
  5286. * of audio contexts you can create.
  5287. * @param hostElement defines the host element where to display the mute icon if necessary
  5288. */
  5289. constructor(hostElement?: Nullable<HTMLElement>);
  5290. /**
  5291. * Flags the audio engine in Locked state.
  5292. * This happens due to new browser policies preventing audio to autoplay.
  5293. */
  5294. lock(): void;
  5295. /**
  5296. * Unlocks the audio engine once a user action has been done on the dom.
  5297. * This is helpful to resume play once browser policies have been satisfied.
  5298. */
  5299. unlock(): void;
  5300. private _resumeAudioContext;
  5301. private _initializeAudioContext;
  5302. private _tryToRun;
  5303. private _triggerRunningState;
  5304. private _triggerSuspendedState;
  5305. private _displayMuteButton;
  5306. private _moveButtonToTopLeft;
  5307. private _onResize;
  5308. private _hideMuteButton;
  5309. /**
  5310. * Destroy and release the resources associated with the audio ccontext.
  5311. */
  5312. dispose(): void;
  5313. /**
  5314. * Gets the global volume sets on the master gain.
  5315. * @returns the global volume if set or -1 otherwise
  5316. */
  5317. getGlobalVolume(): number;
  5318. /**
  5319. * Sets the global volume of your experience (sets on the master gain).
  5320. * @param newVolume Defines the new global volume of the application
  5321. */
  5322. setGlobalVolume(newVolume: number): void;
  5323. /**
  5324. * Connect the audio engine to an audio analyser allowing some amazing
  5325. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5327. * @param analyser The analyser to connect to the engine
  5328. */
  5329. connectToAnalyser(analyser: Analyser): void;
  5330. }
  5331. }
  5332. declare module BABYLON {
  5333. interface AbstractScene {
  5334. /**
  5335. * The list of sounds used in the scene.
  5336. */
  5337. sounds: Nullable<Array<Sound>>;
  5338. }
  5339. interface Scene {
  5340. /**
  5341. * @hidden
  5342. * Backing field
  5343. */
  5344. _mainSoundTrack: SoundTrack;
  5345. /**
  5346. * The main sound track played by the scene.
  5347. * It cotains your primary collection of sounds.
  5348. */
  5349. mainSoundTrack: SoundTrack;
  5350. /**
  5351. * The list of sound tracks added to the scene
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. soundTracks: Nullable<Array<SoundTrack>>;
  5355. /**
  5356. * Gets a sound using a given name
  5357. * @param name defines the name to search for
  5358. * @return the found sound or null if not found at all.
  5359. */
  5360. getSoundByName(name: string): Nullable<Sound>;
  5361. /**
  5362. * Gets or sets if audio support is enabled
  5363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5364. */
  5365. audioEnabled: boolean;
  5366. /**
  5367. * Gets or sets if audio will be output to headphones
  5368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5369. */
  5370. headphone: boolean;
  5371. }
  5372. /**
  5373. * Defines the sound scene component responsible to manage any sounds
  5374. * in a given scene.
  5375. */
  5376. class AudioSceneComponent implements ISceneSerializableComponent {
  5377. /**
  5378. * The component name helpfull to identify the component in the list of scene components.
  5379. */
  5380. readonly name: string;
  5381. /**
  5382. * The scene the component belongs to.
  5383. */
  5384. scene: Scene;
  5385. private _audioEnabled;
  5386. /**
  5387. * Gets whether audio is enabled or not.
  5388. * Please use related enable/disable method to switch state.
  5389. */
  5390. readonly audioEnabled: boolean;
  5391. private _headphone;
  5392. /**
  5393. * Gets whether audio is outputing to headphone or not.
  5394. * Please use the according Switch methods to change output.
  5395. */
  5396. readonly headphone: boolean;
  5397. /**
  5398. * Creates a new instance of the component for the given scene
  5399. * @param scene Defines the scene to register the component in
  5400. */
  5401. constructor(scene: Scene);
  5402. /**
  5403. * Registers the component in a given scene
  5404. */
  5405. register(): void;
  5406. /**
  5407. * Rebuilds the elements related to this component in case of
  5408. * context lost for instance.
  5409. */
  5410. rebuild(): void;
  5411. /**
  5412. * Serializes the component data to the specified json object
  5413. * @param serializationObject The object to serialize to
  5414. */
  5415. serialize(serializationObject: any): void;
  5416. /**
  5417. * Adds all the element from the container to the scene
  5418. * @param container the container holding the elements
  5419. */
  5420. addFromContainer(container: AbstractScene): void;
  5421. /**
  5422. * Removes all the elements in the container from the scene
  5423. * @param container contains the elements to remove
  5424. */
  5425. removeFromContainer(container: AbstractScene): void;
  5426. /**
  5427. * Disposes the component and the associated ressources.
  5428. */
  5429. dispose(): void;
  5430. /**
  5431. * Disables audio in the associated scene.
  5432. */
  5433. disableAudio(): void;
  5434. /**
  5435. * Enables audio in the associated scene.
  5436. */
  5437. enableAudio(): void;
  5438. /**
  5439. * Switch audio to headphone output.
  5440. */
  5441. switchAudioModeForHeadphones(): void;
  5442. /**
  5443. * Switch audio to normal speakers.
  5444. */
  5445. switchAudioModeForNormalSpeakers(): void;
  5446. private _afterRender;
  5447. }
  5448. }
  5449. declare module BABYLON {
  5450. /**
  5451. * Defines a sound that can be played in the application.
  5452. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5454. */
  5455. class Sound {
  5456. /**
  5457. * The name of the sound in the scene.
  5458. */
  5459. name: string;
  5460. /**
  5461. * Does the sound autoplay once loaded.
  5462. */
  5463. autoplay: boolean;
  5464. /**
  5465. * Does the sound loop after it finishes playing once.
  5466. */
  5467. loop: boolean;
  5468. /**
  5469. * Does the sound use a custom attenuation curve to simulate the falloff
  5470. * happening when the source gets further away from the camera.
  5471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5472. */
  5473. useCustomAttenuation: boolean;
  5474. /**
  5475. * The sound track id this sound belongs to.
  5476. */
  5477. soundTrackId: number;
  5478. /**
  5479. * Is this sound currently played.
  5480. */
  5481. isPlaying: boolean;
  5482. /**
  5483. * Is this sound currently paused.
  5484. */
  5485. isPaused: boolean;
  5486. /**
  5487. * Does this sound enables spatial sound.
  5488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5489. */
  5490. spatialSound: boolean;
  5491. /**
  5492. * Define the reference distance the sound should be heard perfectly.
  5493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5494. */
  5495. refDistance: number;
  5496. /**
  5497. * Define the roll off factor of spatial sounds.
  5498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5499. */
  5500. rolloffFactor: number;
  5501. /**
  5502. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5504. */
  5505. maxDistance: number;
  5506. /**
  5507. * Define the distance attenuation model the sound will follow.
  5508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5509. */
  5510. distanceModel: string;
  5511. /**
  5512. * @hidden
  5513. * Back Compat
  5514. **/
  5515. onended: () => any;
  5516. /**
  5517. * Observable event when the current playing sound finishes.
  5518. */
  5519. onEndedObservable: Observable<Sound>;
  5520. private _panningModel;
  5521. private _playbackRate;
  5522. private _streaming;
  5523. private _startTime;
  5524. private _startOffset;
  5525. private _position;
  5526. /** @hidden */
  5527. _positionInEmitterSpace: boolean;
  5528. private _localDirection;
  5529. private _volume;
  5530. private _isReadyToPlay;
  5531. private _isDirectional;
  5532. private _readyToPlayCallback;
  5533. private _audioBuffer;
  5534. private _soundSource;
  5535. private _streamingSource;
  5536. private _soundPanner;
  5537. private _soundGain;
  5538. private _inputAudioNode;
  5539. private _outputAudioNode;
  5540. private _coneInnerAngle;
  5541. private _coneOuterAngle;
  5542. private _coneOuterGain;
  5543. private _scene;
  5544. private _connectedMesh;
  5545. private _customAttenuationFunction;
  5546. private _registerFunc;
  5547. private _isOutputConnected;
  5548. private _htmlAudioElement;
  5549. private _urlType;
  5550. /**
  5551. * Create a sound and attach it to a scene
  5552. * @param name Name of your sound
  5553. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5554. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5555. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5556. */
  5557. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5558. /**
  5559. * Release the sound and its associated resources
  5560. */
  5561. dispose(): void;
  5562. /**
  5563. * Gets if the sounds is ready to be played or not.
  5564. * @returns true if ready, otherwise false
  5565. */
  5566. isReady(): boolean;
  5567. private _soundLoaded;
  5568. /**
  5569. * Sets the data of the sound from an audiobuffer
  5570. * @param audioBuffer The audioBuffer containing the data
  5571. */
  5572. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5573. /**
  5574. * Updates the current sounds options such as maxdistance, loop...
  5575. * @param options A JSON object containing values named as the object properties
  5576. */
  5577. updateOptions(options: any): void;
  5578. private _createSpatialParameters;
  5579. private _updateSpatialParameters;
  5580. /**
  5581. * Switch the panning model to HRTF:
  5582. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5584. */
  5585. switchPanningModelToHRTF(): void;
  5586. /**
  5587. * Switch the panning model to Equal Power:
  5588. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5590. */
  5591. switchPanningModelToEqualPower(): void;
  5592. private _switchPanningModel;
  5593. /**
  5594. * Connect this sound to a sound track audio node like gain...
  5595. * @param soundTrackAudioNode the sound track audio node to connect to
  5596. */
  5597. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5598. /**
  5599. * Transform this sound into a directional source
  5600. * @param coneInnerAngle Size of the inner cone in degree
  5601. * @param coneOuterAngle Size of the outer cone in degree
  5602. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5603. */
  5604. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5605. /**
  5606. * Gets or sets the inner angle for the directional cone.
  5607. */
  5608. /**
  5609. * Gets or sets the inner angle for the directional cone.
  5610. */
  5611. directionalConeInnerAngle: number;
  5612. /**
  5613. * Gets or sets the outer angle for the directional cone.
  5614. */
  5615. /**
  5616. * Gets or sets the outer angle for the directional cone.
  5617. */
  5618. directionalConeOuterAngle: number;
  5619. /**
  5620. * Sets the position of the emitter if spatial sound is enabled
  5621. * @param newPosition Defines the new posisiton
  5622. */
  5623. setPosition(newPosition: Vector3): void;
  5624. /**
  5625. * Sets the local direction of the emitter if spatial sound is enabled
  5626. * @param newLocalDirection Defines the new local direction
  5627. */
  5628. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5629. private _updateDirection;
  5630. /** @hidden */
  5631. updateDistanceFromListener(): void;
  5632. /**
  5633. * Sets a new custom attenuation function for the sound.
  5634. * @param callback Defines the function used for the attenuation
  5635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5636. */
  5637. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5638. /**
  5639. * Play the sound
  5640. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5641. * @param offset (optional) Start the sound setting it at a specific time
  5642. */
  5643. play(time?: number, offset?: number): void;
  5644. private _onended;
  5645. /**
  5646. * Stop the sound
  5647. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5648. */
  5649. stop(time?: number): void;
  5650. /**
  5651. * Put the sound in pause
  5652. */
  5653. pause(): void;
  5654. /**
  5655. * Sets a dedicated volume for this sounds
  5656. * @param newVolume Define the new volume of the sound
  5657. * @param time Define in how long the sound should be at this value
  5658. */
  5659. setVolume(newVolume: number, time?: number): void;
  5660. /**
  5661. * Set the sound play back rate
  5662. * @param newPlaybackRate Define the playback rate the sound should be played at
  5663. */
  5664. setPlaybackRate(newPlaybackRate: number): void;
  5665. /**
  5666. * Gets the volume of the sound.
  5667. * @returns the volume of the sound
  5668. */
  5669. getVolume(): number;
  5670. /**
  5671. * Attach the sound to a dedicated mesh
  5672. * @param meshToConnectTo The mesh to connect the sound with
  5673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5674. */
  5675. attachToMesh(meshToConnectTo: AbstractMesh): void;
  5676. /**
  5677. * Detach the sound from the previously attached mesh
  5678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5679. */
  5680. detachFromMesh(): void;
  5681. private _onRegisterAfterWorldMatrixUpdate;
  5682. /**
  5683. * Clone the current sound in the scene.
  5684. * @returns the new sound clone
  5685. */
  5686. clone(): Nullable<Sound>;
  5687. /**
  5688. * Gets the current underlying audio buffer containing the data
  5689. * @returns the audio buffer
  5690. */
  5691. getAudioBuffer(): Nullable<AudioBuffer>;
  5692. /**
  5693. * Serializes the Sound in a JSON representation
  5694. * @returns the JSON representation of the sound
  5695. */
  5696. serialize(): any;
  5697. /**
  5698. * Parse a JSON representation of a sound to innstantiate in a given scene
  5699. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5700. * @param scene Define the scene the new parsed sound should be created in
  5701. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5702. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5703. * @returns the newly parsed sound
  5704. */
  5705. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5706. }
  5707. }
  5708. declare module BABYLON {
  5709. /**
  5710. * Options allowed during the creation of a sound track.
  5711. */
  5712. interface ISoundTrackOptions {
  5713. /**
  5714. * The volume the sound track should take during creation
  5715. */
  5716. volume?: number;
  5717. /**
  5718. * Define if the sound track is the main sound track of the scene
  5719. */
  5720. mainTrack?: boolean;
  5721. }
  5722. /**
  5723. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5724. * It will be also used in a future release to apply effects on a specific track.
  5725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5726. */
  5727. class SoundTrack {
  5728. /**
  5729. * The unique identifier of the sound track in the scene.
  5730. */
  5731. id: number;
  5732. /**
  5733. * The list of sounds included in the sound track.
  5734. */
  5735. soundCollection: Array<Sound>;
  5736. private _outputAudioNode;
  5737. private _scene;
  5738. private _isMainTrack;
  5739. private _connectedAnalyser;
  5740. private _options;
  5741. private _isInitialized;
  5742. /**
  5743. * Creates a new sound track.
  5744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5745. * @param scene Define the scene the sound track belongs to
  5746. * @param options
  5747. */
  5748. constructor(scene: Scene, options?: ISoundTrackOptions);
  5749. private _initializeSoundTrackAudioGraph;
  5750. /**
  5751. * Release the sound track and its associated resources
  5752. */
  5753. dispose(): void;
  5754. /**
  5755. * Adds a sound to this sound track
  5756. * @param sound define the cound to add
  5757. * @ignoreNaming
  5758. */
  5759. AddSound(sound: Sound): void;
  5760. /**
  5761. * Removes a sound to this sound track
  5762. * @param sound define the cound to remove
  5763. * @ignoreNaming
  5764. */
  5765. RemoveSound(sound: Sound): void;
  5766. /**
  5767. * Set a global volume for the full sound track.
  5768. * @param newVolume Define the new volume of the sound track
  5769. */
  5770. setVolume(newVolume: number): void;
  5771. /**
  5772. * Switch the panning model to HRTF:
  5773. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5775. */
  5776. switchPanningModelToHRTF(): void;
  5777. /**
  5778. * Switch the panning model to Equal Power:
  5779. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5781. */
  5782. switchPanningModelToEqualPower(): void;
  5783. /**
  5784. * Connect the sound track to an audio analyser allowing some amazing
  5785. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5787. * @param analyser The analyser to connect to the engine
  5788. */
  5789. connectToAnalyser(analyser: Analyser): void;
  5790. }
  5791. }
  5792. declare module BABYLON {
  5793. /**
  5794. * Wraps one or more Sound objects and selects one with random weight for playback.
  5795. */
  5796. class WeightedSound {
  5797. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5798. loop: boolean;
  5799. private _coneInnerAngle;
  5800. private _coneOuterAngle;
  5801. private _volume;
  5802. /** A Sound is currently playing. */
  5803. isPlaying: boolean;
  5804. /** A Sound is currently paused. */
  5805. isPaused: boolean;
  5806. private _sounds;
  5807. private _weights;
  5808. private _currentIndex?;
  5809. /**
  5810. * Creates a new WeightedSound from the list of sounds given.
  5811. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5812. * @param sounds Array of Sounds that will be selected from.
  5813. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5814. */
  5815. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5816. /**
  5817. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5818. */
  5819. /**
  5820. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5821. */
  5822. directionalConeInnerAngle: number;
  5823. /**
  5824. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5825. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5826. */
  5827. /**
  5828. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5829. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5830. */
  5831. directionalConeOuterAngle: number;
  5832. /**
  5833. * Playback volume.
  5834. */
  5835. /**
  5836. * Playback volume.
  5837. */
  5838. volume: number;
  5839. private _onended;
  5840. /**
  5841. * Suspend playback
  5842. */
  5843. pause(): void;
  5844. /**
  5845. * Stop playback
  5846. */
  5847. stop(): void;
  5848. /**
  5849. * Start playback.
  5850. * @param startOffset Position the clip head at a specific time in seconds.
  5851. */
  5852. play(startOffset?: number): void;
  5853. }
  5854. }
  5855. declare module BABYLON {
  5856. /**
  5857. * Interface used to define a behavior
  5858. */
  5859. interface Behavior<T> {
  5860. /** gets or sets behavior's name */
  5861. name: string;
  5862. /**
  5863. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5864. */
  5865. init(): void;
  5866. /**
  5867. * Called when the behavior is attached to a target
  5868. * @param target defines the target where the behavior is attached to
  5869. */
  5870. attach(target: T): void;
  5871. /**
  5872. * Called when the behavior is detached from its target
  5873. */
  5874. detach(): void;
  5875. }
  5876. /**
  5877. * Interface implemented by classes supporting behaviors
  5878. */
  5879. interface IBehaviorAware<T> {
  5880. /**
  5881. * Attach a behavior
  5882. * @param behavior defines the behavior to attach
  5883. * @returns the current host
  5884. */
  5885. addBehavior(behavior: Behavior<T>): T;
  5886. /**
  5887. * Remove a behavior from the current object
  5888. * @param behavior defines the behavior to detach
  5889. * @returns the current host
  5890. */
  5891. removeBehavior(behavior: Behavior<T>): T;
  5892. /**
  5893. * Gets a behavior using its name to search
  5894. * @param name defines the name to search
  5895. * @returns the behavior or null if not found
  5896. */
  5897. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5898. }
  5899. }
  5900. declare module BABYLON {
  5901. /**
  5902. * Class used to store bone information
  5903. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5904. */
  5905. class Bone extends Node {
  5906. /**
  5907. * defines the bone name
  5908. */
  5909. name: string;
  5910. private static _tmpVecs;
  5911. private static _tmpQuat;
  5912. private static _tmpMats;
  5913. /**
  5914. * Gets the list of child bones
  5915. */
  5916. children: Bone[];
  5917. /** Gets the animations associated with this bone */
  5918. animations: Animation[];
  5919. /**
  5920. * Gets or sets bone length
  5921. */
  5922. length: number;
  5923. /**
  5924. * @hidden Internal only
  5925. * Set this value to map this bone to a different index in the transform matrices
  5926. * Set this value to -1 to exclude the bone from the transform matrices
  5927. */
  5928. _index: Nullable<number>;
  5929. private _skeleton;
  5930. private _localMatrix;
  5931. private _restPose;
  5932. private _baseMatrix;
  5933. private _absoluteTransform;
  5934. private _invertedAbsoluteTransform;
  5935. private _parent;
  5936. private _scalingDeterminant;
  5937. private _worldTransform;
  5938. private _localScaling;
  5939. private _localRotation;
  5940. private _localPosition;
  5941. private _needToDecompose;
  5942. private _needToCompose;
  5943. /** @hidden */
  5944. /** @hidden */
  5945. _matrix: Matrix;
  5946. /**
  5947. * Create a new bone
  5948. * @param name defines the bone name
  5949. * @param skeleton defines the parent skeleton
  5950. * @param parentBone defines the parent (can be null if the bone is the root)
  5951. * @param localMatrix defines the local matrix
  5952. * @param restPose defines the rest pose matrix
  5953. * @param baseMatrix defines the base matrix
  5954. * @param index defines index of the bone in the hiearchy
  5955. */
  5956. constructor(
  5957. /**
  5958. * defines the bone name
  5959. */
  5960. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  5961. /**
  5962. * Gets the parent skeleton
  5963. * @returns a skeleton
  5964. */
  5965. getSkeleton(): Skeleton;
  5966. /**
  5967. * Gets parent bone
  5968. * @returns a bone or null if the bone is the root of the bone hierarchy
  5969. */
  5970. getParent(): Nullable<Bone>;
  5971. /**
  5972. * Sets the parent bone
  5973. * @param parent defines the parent (can be null if the bone is the root)
  5974. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  5975. */
  5976. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  5977. /**
  5978. * Gets the local matrix
  5979. * @returns a matrix
  5980. */
  5981. getLocalMatrix(): Matrix;
  5982. /**
  5983. * Gets the base matrix (initial matrix which remains unchanged)
  5984. * @returns a matrix
  5985. */
  5986. getBaseMatrix(): Matrix;
  5987. /**
  5988. * Gets the rest pose matrix
  5989. * @returns a matrix
  5990. */
  5991. getRestPose(): Matrix;
  5992. /**
  5993. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  5994. */
  5995. getWorldMatrix(): Matrix;
  5996. /**
  5997. * Sets the local matrix to rest pose matrix
  5998. */
  5999. returnToRest(): void;
  6000. /**
  6001. * Gets the inverse of the absolute transform matrix.
  6002. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6003. * @returns a matrix
  6004. */
  6005. getInvertedAbsoluteTransform(): Matrix;
  6006. /**
  6007. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6008. * @returns a matrix
  6009. */
  6010. getAbsoluteTransform(): Matrix;
  6011. /** Gets or sets current position (in local space) */
  6012. position: Vector3;
  6013. /** Gets or sets current rotation (in local space) */
  6014. rotation: Vector3;
  6015. /** Gets or sets current rotation quaternion (in local space) */
  6016. rotationQuaternion: Quaternion;
  6017. /** Gets or sets current scaling (in local space) */
  6018. scaling: Vector3;
  6019. /**
  6020. * Gets the animation properties override
  6021. */
  6022. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6023. private _decompose;
  6024. private _compose;
  6025. /**
  6026. * Update the base and local matrices
  6027. * @param matrix defines the new base or local matrix
  6028. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6029. * @param updateLocalMatrix defines if the local matrix should be updated
  6030. */
  6031. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6032. /** @hidden */
  6033. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6034. /**
  6035. * Flag the bone as dirty (Forcing it to update everything)
  6036. */
  6037. markAsDirty(): void;
  6038. private _markAsDirtyAndCompose;
  6039. private _markAsDirtyAndDecompose;
  6040. /**
  6041. * Copy an animation range from another bone
  6042. * @param source defines the source bone
  6043. * @param rangeName defines the range name to copy
  6044. * @param frameOffset defines the frame offset
  6045. * @param rescaleAsRequired defines if rescaling must be applied if required
  6046. * @param skelDimensionsRatio defines the scaling ratio
  6047. * @returns true if operation was successful
  6048. */
  6049. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6050. /**
  6051. * Translate the bone in local or world space
  6052. * @param vec The amount to translate the bone
  6053. * @param space The space that the translation is in
  6054. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6055. */
  6056. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6057. /**
  6058. * Set the postion of the bone in local or world space
  6059. * @param position The position to set the bone
  6060. * @param space The space that the position is in
  6061. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6062. */
  6063. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6064. /**
  6065. * Set the absolute position of the bone (world space)
  6066. * @param position The position to set the bone
  6067. * @param mesh The mesh that this bone is attached to
  6068. */
  6069. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6070. /**
  6071. * Scale the bone on the x, y and z axes (in local space)
  6072. * @param x The amount to scale the bone on the x axis
  6073. * @param y The amount to scale the bone on the y axis
  6074. * @param z The amount to scale the bone on the z axis
  6075. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6076. */
  6077. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6078. /**
  6079. * Set the bone scaling in local space
  6080. * @param scale defines the scaling vector
  6081. */
  6082. setScale(scale: Vector3): void;
  6083. /**
  6084. * Gets the current scaling in local space
  6085. * @returns the current scaling vector
  6086. */
  6087. getScale(): Vector3;
  6088. /**
  6089. * Gets the current scaling in local space and stores it in a target vector
  6090. * @param result defines the target vector
  6091. */
  6092. getScaleToRef(result: Vector3): void;
  6093. /**
  6094. * Set the yaw, pitch, and roll of the bone in local or world space
  6095. * @param yaw The rotation of the bone on the y axis
  6096. * @param pitch The rotation of the bone on the x axis
  6097. * @param roll The rotation of the bone on the z axis
  6098. * @param space The space that the axes of rotation are in
  6099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6100. */
  6101. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6102. /**
  6103. * Add a rotation to the bone on an axis in local or world space
  6104. * @param axis The axis to rotate the bone on
  6105. * @param amount The amount to rotate the bone
  6106. * @param space The space that the axis is in
  6107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6108. */
  6109. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6110. /**
  6111. * Set the rotation of the bone to a particular axis angle in local or world space
  6112. * @param axis The axis to rotate the bone on
  6113. * @param angle The angle that the bone should be rotated to
  6114. * @param space The space that the axis is in
  6115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6116. */
  6117. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6118. /**
  6119. * Set the euler rotation of the bone in local of world space
  6120. * @param rotation The euler rotation that the bone should be set to
  6121. * @param space The space that the rotation is in
  6122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6123. */
  6124. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6125. /**
  6126. * Set the quaternion rotation of the bone in local of world space
  6127. * @param quat The quaternion rotation that the bone should be set to
  6128. * @param space The space that the rotation is in
  6129. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6130. */
  6131. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6132. /**
  6133. * Set the rotation matrix of the bone in local of world space
  6134. * @param rotMat The rotation matrix that the bone should be set to
  6135. * @param space The space that the rotation is in
  6136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6137. */
  6138. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6139. private _rotateWithMatrix;
  6140. private _getNegativeRotationToRef;
  6141. /**
  6142. * Get the position of the bone in local or world space
  6143. * @param space The space that the returned position is in
  6144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6145. * @returns The position of the bone
  6146. */
  6147. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6148. /**
  6149. * Copy the position of the bone to a vector3 in local or world space
  6150. * @param space The space that the returned position is in
  6151. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6152. * @param result The vector3 to copy the position to
  6153. */
  6154. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6155. /**
  6156. * Get the absolute position of the bone (world space)
  6157. * @param mesh The mesh that this bone is attached to
  6158. * @returns The absolute position of the bone
  6159. */
  6160. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6161. /**
  6162. * Copy the absolute position of the bone (world space) to the result param
  6163. * @param mesh The mesh that this bone is attached to
  6164. * @param result The vector3 to copy the absolute position to
  6165. */
  6166. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6167. /**
  6168. * Compute the absolute transforms of this bone and its children
  6169. */
  6170. computeAbsoluteTransforms(): void;
  6171. /**
  6172. * Get the world direction from an axis that is in the local space of the bone
  6173. * @param localAxis The local direction that is used to compute the world direction
  6174. * @param mesh The mesh that this bone is attached to
  6175. * @returns The world direction
  6176. */
  6177. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6178. /**
  6179. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6180. * @param localAxis The local direction that is used to compute the world direction
  6181. * @param mesh The mesh that this bone is attached to
  6182. * @param result The vector3 that the world direction will be copied to
  6183. */
  6184. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6185. /**
  6186. * Get the euler rotation of the bone in local or world space
  6187. * @param space The space that the rotation should be in
  6188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6189. * @returns The euler rotation
  6190. */
  6191. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6192. /**
  6193. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6194. * @param space The space that the rotation should be in
  6195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6196. * @param result The vector3 that the rotation should be copied to
  6197. */
  6198. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6199. /**
  6200. * Get the quaternion rotation of the bone in either local or world space
  6201. * @param space The space that the rotation should be in
  6202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6203. * @returns The quaternion rotation
  6204. */
  6205. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6206. /**
  6207. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6208. * @param space The space that the rotation should be in
  6209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6210. * @param result The quaternion that the rotation should be copied to
  6211. */
  6212. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6213. /**
  6214. * Get the rotation matrix of the bone in local or world space
  6215. * @param space The space that the rotation should be in
  6216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6217. * @returns The rotation matrix
  6218. */
  6219. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6220. /**
  6221. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6222. * @param space The space that the rotation should be in
  6223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6224. * @param result The quaternion that the rotation should be copied to
  6225. */
  6226. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6227. /**
  6228. * Get the world position of a point that is in the local space of the bone
  6229. * @param position The local position
  6230. * @param mesh The mesh that this bone is attached to
  6231. * @returns The world position
  6232. */
  6233. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6234. /**
  6235. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6236. * @param position The local position
  6237. * @param mesh The mesh that this bone is attached to
  6238. * @param result The vector3 that the world position should be copied to
  6239. */
  6240. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6241. /**
  6242. * Get the local position of a point that is in world space
  6243. * @param position The world position
  6244. * @param mesh The mesh that this bone is attached to
  6245. * @returns The local position
  6246. */
  6247. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6248. /**
  6249. * Get the local position of a point that is in world space and copy it to the result param
  6250. * @param position The world position
  6251. * @param mesh The mesh that this bone is attached to
  6252. * @param result The vector3 that the local position should be copied to
  6253. */
  6254. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * Class used to apply inverse kinematics to bones
  6260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6261. */
  6262. class BoneIKController {
  6263. private static _tmpVecs;
  6264. private static _tmpQuat;
  6265. private static _tmpMats;
  6266. /**
  6267. * Gets or sets the target mesh
  6268. */
  6269. targetMesh: AbstractMesh;
  6270. /** Gets or sets the mesh used as pole */
  6271. poleTargetMesh: AbstractMesh;
  6272. /**
  6273. * Gets or sets the bone used as pole
  6274. */
  6275. poleTargetBone: Nullable<Bone>;
  6276. /**
  6277. * Gets or sets the target position
  6278. */
  6279. targetPosition: Vector3;
  6280. /**
  6281. * Gets or sets the pole target position
  6282. */
  6283. poleTargetPosition: Vector3;
  6284. /**
  6285. * Gets or sets the pole target local offset
  6286. */
  6287. poleTargetLocalOffset: Vector3;
  6288. /**
  6289. * Gets or sets the pole angle
  6290. */
  6291. poleAngle: number;
  6292. /**
  6293. * Gets or sets the mesh associated with the controller
  6294. */
  6295. mesh: AbstractMesh;
  6296. /**
  6297. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6298. */
  6299. slerpAmount: number;
  6300. private _bone1Quat;
  6301. private _bone1Mat;
  6302. private _bone2Ang;
  6303. private _bone1;
  6304. private _bone2;
  6305. private _bone1Length;
  6306. private _bone2Length;
  6307. private _maxAngle;
  6308. private _maxReach;
  6309. private _rightHandedSystem;
  6310. private _bendAxis;
  6311. private _slerping;
  6312. private _adjustRoll;
  6313. /**
  6314. * Gets or sets maximum allowed angle
  6315. */
  6316. maxAngle: number;
  6317. /**
  6318. * Creates a new BoneIKController
  6319. * @param mesh defines the mesh to control
  6320. * @param bone defines the bone to control
  6321. * @param options defines options to set up the controller
  6322. */
  6323. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6324. targetMesh?: AbstractMesh;
  6325. poleTargetMesh?: AbstractMesh;
  6326. poleTargetBone?: Bone;
  6327. poleTargetLocalOffset?: Vector3;
  6328. poleAngle?: number;
  6329. bendAxis?: Vector3;
  6330. maxAngle?: number;
  6331. slerpAmount?: number;
  6332. });
  6333. private _setMaxAngle;
  6334. /**
  6335. * Force the controller to update the bones
  6336. */
  6337. update(): void;
  6338. }
  6339. }
  6340. declare module BABYLON {
  6341. /**
  6342. * Class used to make a bone look toward a point in space
  6343. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6344. */
  6345. class BoneLookController {
  6346. private static _tmpVecs;
  6347. private static _tmpQuat;
  6348. private static _tmpMats;
  6349. /**
  6350. * The target Vector3 that the bone will look at
  6351. */
  6352. target: Vector3;
  6353. /**
  6354. * The mesh that the bone is attached to
  6355. */
  6356. mesh: AbstractMesh;
  6357. /**
  6358. * The bone that will be looking to the target
  6359. */
  6360. bone: Bone;
  6361. /**
  6362. * The up axis of the coordinate system that is used when the bone is rotated
  6363. */
  6364. upAxis: Vector3;
  6365. /**
  6366. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6367. */
  6368. upAxisSpace: Space;
  6369. /**
  6370. * Used to make an adjustment to the yaw of the bone
  6371. */
  6372. adjustYaw: number;
  6373. /**
  6374. * Used to make an adjustment to the pitch of the bone
  6375. */
  6376. adjustPitch: number;
  6377. /**
  6378. * Used to make an adjustment to the roll of the bone
  6379. */
  6380. adjustRoll: number;
  6381. /**
  6382. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6383. */
  6384. slerpAmount: number;
  6385. private _minYaw;
  6386. private _maxYaw;
  6387. private _minPitch;
  6388. private _maxPitch;
  6389. private _minYawSin;
  6390. private _minYawCos;
  6391. private _maxYawSin;
  6392. private _maxYawCos;
  6393. private _midYawConstraint;
  6394. private _minPitchTan;
  6395. private _maxPitchTan;
  6396. private _boneQuat;
  6397. private _slerping;
  6398. private _transformYawPitch;
  6399. private _transformYawPitchInv;
  6400. private _firstFrameSkipped;
  6401. private _yawRange;
  6402. private _fowardAxis;
  6403. /**
  6404. * Gets or sets the minimum yaw angle that the bone can look to
  6405. */
  6406. minYaw: number;
  6407. /**
  6408. * Gets or sets the maximum yaw angle that the bone can look to
  6409. */
  6410. maxYaw: number;
  6411. /**
  6412. * Gets or sets the minimum pitch angle that the bone can look to
  6413. */
  6414. minPitch: number;
  6415. /**
  6416. * Gets or sets the maximum pitch angle that the bone can look to
  6417. */
  6418. maxPitch: number;
  6419. /**
  6420. * Create a BoneLookController
  6421. * @param mesh the mesh that the bone belongs to
  6422. * @param bone the bone that will be looking to the target
  6423. * @param target the target Vector3 to look at
  6424. * @param settings optional settings:
  6425. * * maxYaw: the maximum angle the bone will yaw to
  6426. * * minYaw: the minimum angle the bone will yaw to
  6427. * * maxPitch: the maximum angle the bone will pitch to
  6428. * * minPitch: the minimum angle the bone will yaw to
  6429. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6430. * * upAxis: the up axis of the coordinate system
  6431. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6432. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6433. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6434. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6435. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6436. * * adjustRoll: used to make an adjustment to the roll of the bone
  6437. **/
  6438. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6439. maxYaw?: number;
  6440. minYaw?: number;
  6441. maxPitch?: number;
  6442. minPitch?: number;
  6443. slerpAmount?: number;
  6444. upAxis?: Vector3;
  6445. upAxisSpace?: Space;
  6446. yawAxis?: Vector3;
  6447. pitchAxis?: Vector3;
  6448. adjustYaw?: number;
  6449. adjustPitch?: number;
  6450. adjustRoll?: number;
  6451. });
  6452. /**
  6453. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6454. */
  6455. update(): void;
  6456. private _getAngleDiff;
  6457. private _getAngleBetween;
  6458. private _isAngleBetween;
  6459. }
  6460. }
  6461. declare module BABYLON {
  6462. /**
  6463. * Class used to handle skinning animations
  6464. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6465. */
  6466. class Skeleton implements IAnimatable {
  6467. /** defines the skeleton name */
  6468. name: string;
  6469. /** defines the skeleton Id */
  6470. id: string;
  6471. /**
  6472. * Gets the list of child bones
  6473. */
  6474. bones: Bone[];
  6475. /**
  6476. * Gets an estimate of the dimension of the skeleton at rest
  6477. */
  6478. dimensionsAtRest: Vector3;
  6479. /**
  6480. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6481. */
  6482. needInitialSkinMatrix: boolean;
  6483. /**
  6484. * Gets the list of animations attached to this skeleton
  6485. */
  6486. animations: Array<Animation>;
  6487. private _scene;
  6488. private _isDirty;
  6489. private _transformMatrices;
  6490. private _meshesWithPoseMatrix;
  6491. private _animatables;
  6492. private _identity;
  6493. private _synchronizedWithMesh;
  6494. private _ranges;
  6495. private _lastAbsoluteTransformsUpdateId;
  6496. /**
  6497. * Specifies if the skeleton should be serialized
  6498. */
  6499. doNotSerialize: boolean;
  6500. private _animationPropertiesOverride;
  6501. /**
  6502. * Gets or sets the animation properties override
  6503. */
  6504. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6505. /**
  6506. * An observable triggered before computing the skeleton's matrices
  6507. */
  6508. onBeforeComputeObservable: Observable<Skeleton>;
  6509. /**
  6510. * Creates a new skeleton
  6511. * @param name defines the skeleton name
  6512. * @param id defines the skeleton Id
  6513. * @param scene defines the hosting scene
  6514. */
  6515. constructor(
  6516. /** defines the skeleton name */
  6517. name: string,
  6518. /** defines the skeleton Id */
  6519. id: string, scene: Scene);
  6520. /**
  6521. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6522. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6523. * @returns a Float32Array containing matrices data
  6524. */
  6525. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6526. /**
  6527. * Gets the current hosting scene
  6528. * @returns a scene object
  6529. */
  6530. getScene(): Scene;
  6531. /**
  6532. * Gets a string representing the current skeleton data
  6533. * @param fullDetails defines a boolean indicating if we want a verbose version
  6534. * @returns a string representing the current skeleton data
  6535. */
  6536. toString(fullDetails?: boolean): string;
  6537. /**
  6538. * Get bone's index searching by name
  6539. * @param name defines bone's name to search for
  6540. * @return the indice of the bone. Returns -1 if not found
  6541. */
  6542. getBoneIndexByName(name: string): number;
  6543. /**
  6544. * Creater a new animation range
  6545. * @param name defines the name of the range
  6546. * @param from defines the start key
  6547. * @param to defines the end key
  6548. */
  6549. createAnimationRange(name: string, from: number, to: number): void;
  6550. /**
  6551. * Delete a specific animation range
  6552. * @param name defines the name of the range
  6553. * @param deleteFrames defines if frames must be removed as well
  6554. */
  6555. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6556. /**
  6557. * Gets a specific animation range
  6558. * @param name defines the name of the range to look for
  6559. * @returns the requested animation range or null if not found
  6560. */
  6561. getAnimationRange(name: string): Nullable<AnimationRange>;
  6562. /**
  6563. * Gets the list of all animation ranges defined on this skeleton
  6564. * @returns an array
  6565. */
  6566. getAnimationRanges(): Nullable<AnimationRange>[];
  6567. /**
  6568. * Copy animation range from a source skeleton.
  6569. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6570. * @param source defines the source skeleton
  6571. * @param name defines the name of the range to copy
  6572. * @param rescaleAsRequired defines if rescaling must be applied if required
  6573. * @returns true if operation was successful
  6574. */
  6575. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6576. /**
  6577. * Forces the skeleton to go to rest pose
  6578. */
  6579. returnToRest(): void;
  6580. private _getHighestAnimationFrame;
  6581. /**
  6582. * Begin a specific animation range
  6583. * @param name defines the name of the range to start
  6584. * @param loop defines if looping must be turned on (false by default)
  6585. * @param speedRatio defines the speed ratio to apply (1 by default)
  6586. * @param onAnimationEnd defines a callback which will be called when animation will end
  6587. * @returns a new animatable
  6588. */
  6589. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6590. /** @hidden */
  6591. _markAsDirty(): void;
  6592. /** @hidden */
  6593. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6594. /** @hidden */
  6595. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6596. /** @hidden */
  6597. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  6598. /**
  6599. * Build all resources required to render a skeleton
  6600. */
  6601. prepare(): void;
  6602. /**
  6603. * Gets the list of animatables currently running for this skeleton
  6604. * @returns an array of animatables
  6605. */
  6606. getAnimatables(): IAnimatable[];
  6607. /**
  6608. * Clone the current skeleton
  6609. * @param name defines the name of the new skeleton
  6610. * @param id defines the id of the enw skeleton
  6611. * @returns the new skeleton
  6612. */
  6613. clone(name: string, id: string): Skeleton;
  6614. /**
  6615. * Enable animation blending for this skeleton
  6616. * @param blendingSpeed defines the blending speed to apply
  6617. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6618. */
  6619. enableBlending(blendingSpeed?: number): void;
  6620. /**
  6621. * Releases all resources associated with the current skeleton
  6622. */
  6623. dispose(): void;
  6624. /**
  6625. * Serialize the skeleton in a JSON object
  6626. * @returns a JSON object
  6627. */
  6628. serialize(): any;
  6629. /**
  6630. * Creates a new skeleton from serialized data
  6631. * @param parsedSkeleton defines the serialized data
  6632. * @param scene defines the hosting scene
  6633. * @returns a new skeleton
  6634. */
  6635. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6636. /**
  6637. * Compute all node absolute transforms
  6638. * @param forceUpdate defines if computation must be done even if cache is up to date
  6639. */
  6640. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6641. /**
  6642. * Gets the root pose matrix
  6643. * @returns a matrix
  6644. */
  6645. getPoseMatrix(): Nullable<Matrix>;
  6646. /**
  6647. * Sorts bones per internal index
  6648. */
  6649. sortBones(): void;
  6650. private _sortBones;
  6651. }
  6652. }
  6653. declare module BABYLON {
  6654. /**
  6655. * This represents an orbital type of camera.
  6656. *
  6657. * 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.
  6658. * 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.
  6659. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  6660. */
  6661. class ArcRotateCamera extends TargetCamera {
  6662. /**
  6663. * Defines the rotation angle of the camera along the longitudinal axis.
  6664. */
  6665. alpha: number;
  6666. /**
  6667. * Defines the rotation angle of the camera along the latitudinal axis.
  6668. */
  6669. beta: number;
  6670. /**
  6671. * Defines the radius of the camera from it s target point.
  6672. */
  6673. radius: number;
  6674. protected _target: Vector3;
  6675. protected _targetHost: Nullable<AbstractMesh>;
  6676. /**
  6677. * Defines the target point of the camera.
  6678. * The camera looks towards it form the radius distance.
  6679. */
  6680. target: Vector3;
  6681. /**
  6682. * Current inertia value on the longitudinal axis.
  6683. * The bigger this number the longer it will take for the camera to stop.
  6684. */
  6685. inertialAlphaOffset: number;
  6686. /**
  6687. * Current inertia value on the latitudinal axis.
  6688. * The bigger this number the longer it will take for the camera to stop.
  6689. */
  6690. inertialBetaOffset: number;
  6691. /**
  6692. * Current inertia value on the radius axis.
  6693. * The bigger this number the longer it will take for the camera to stop.
  6694. */
  6695. inertialRadiusOffset: number;
  6696. /**
  6697. * Minimum allowed angle on the longitudinal axis.
  6698. * This can help limiting how the Camera is able to move in the scene.
  6699. */
  6700. lowerAlphaLimit: Nullable<number>;
  6701. /**
  6702. * Maximum allowed angle on the longitudinal axis.
  6703. * This can help limiting how the Camera is able to move in the scene.
  6704. */
  6705. upperAlphaLimit: Nullable<number>;
  6706. /**
  6707. * Minimum allowed angle on the latitudinal axis.
  6708. * This can help limiting how the Camera is able to move in the scene.
  6709. */
  6710. lowerBetaLimit: number;
  6711. /**
  6712. * Maximum allowed angle on the latitudinal axis.
  6713. * This can help limiting how the Camera is able to move in the scene.
  6714. */
  6715. upperBetaLimit: number;
  6716. /**
  6717. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  6718. * This can help limiting how the Camera is able to move in the scene.
  6719. */
  6720. lowerRadiusLimit: Nullable<number>;
  6721. /**
  6722. * Maximum allowed distance of the camera to the target (The camera can not get further).
  6723. * This can help limiting how the Camera is able to move in the scene.
  6724. */
  6725. upperRadiusLimit: Nullable<number>;
  6726. /**
  6727. * Defines the current inertia value used during panning of the camera along the X axis.
  6728. */
  6729. inertialPanningX: number;
  6730. /**
  6731. * Defines the current inertia value used during panning of the camera along the Y axis.
  6732. */
  6733. inertialPanningY: number;
  6734. /**
  6735. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  6736. * Basically if your fingers moves away from more than this distance you will be considered
  6737. * in pinch mode.
  6738. */
  6739. pinchToPanMaxDistance: number;
  6740. /**
  6741. * Defines the maximum distance the camera can pan.
  6742. * This could help keeping the cammera always in your scene.
  6743. */
  6744. panningDistanceLimit: Nullable<number>;
  6745. /**
  6746. * Defines the target of the camera before paning.
  6747. */
  6748. panningOriginTarget: Vector3;
  6749. /**
  6750. * Defines the value of the inertia used during panning.
  6751. * 0 would mean stop inertia and one would mean no decelleration at all.
  6752. */
  6753. panningInertia: number;
  6754. /**
  6755. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  6756. */
  6757. angularSensibilityX: number;
  6758. /**
  6759. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  6760. */
  6761. angularSensibilityY: number;
  6762. /**
  6763. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  6764. */
  6765. pinchPrecision: number;
  6766. /**
  6767. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  6768. * It will be used instead of pinchDeltaPrecision if different from 0.
  6769. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6770. */
  6771. pinchDeltaPercentage: number;
  6772. /**
  6773. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  6774. */
  6775. panningSensibility: number;
  6776. /**
  6777. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  6778. */
  6779. keysUp: number[];
  6780. /**
  6781. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  6782. */
  6783. keysDown: number[];
  6784. /**
  6785. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  6786. */
  6787. keysLeft: number[];
  6788. /**
  6789. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  6790. */
  6791. keysRight: number[];
  6792. /**
  6793. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  6794. */
  6795. wheelPrecision: number;
  6796. /**
  6797. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  6798. * It will be used instead of pinchDeltaPrecision if different from 0.
  6799. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  6800. */
  6801. wheelDeltaPercentage: number;
  6802. /**
  6803. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  6804. */
  6805. zoomOnFactor: number;
  6806. /**
  6807. * Defines a screen offset for the camera position.
  6808. */
  6809. targetScreenOffset: Vector2;
  6810. /**
  6811. * Allows the camera to be completely reversed.
  6812. * If false the camera can not arrive upside down.
  6813. */
  6814. allowUpsideDown: boolean;
  6815. /**
  6816. * Define if double tap/click is used to restore the previously saved state of the camera.
  6817. */
  6818. useInputToRestoreState: boolean;
  6819. /** @hidden */
  6820. _viewMatrix: Matrix;
  6821. /** @hidden */
  6822. _useCtrlForPanning: boolean;
  6823. /** @hidden */
  6824. _panningMouseButton: number;
  6825. /**
  6826. * Defines the inpute associated to the camera.
  6827. */
  6828. inputs: ArcRotateCameraInputsManager;
  6829. /** @hidden */
  6830. _reset: () => void;
  6831. /**
  6832. * Defines the allowed panning axis.
  6833. */
  6834. panningAxis: Vector3;
  6835. protected _localDirection: Vector3;
  6836. protected _transformedDirection: Vector3;
  6837. private _bouncingBehavior;
  6838. /**
  6839. * Gets the bouncing behavior of the camera if it has been enabled.
  6840. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6841. */
  6842. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6843. /**
  6844. * Defines if the bouncing behavior of the camera is enabled on the camera.
  6845. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  6846. */
  6847. useBouncingBehavior: boolean;
  6848. private _framingBehavior;
  6849. /**
  6850. * Gets the framing behavior of the camera if it has been enabled.
  6851. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6852. */
  6853. readonly framingBehavior: Nullable<FramingBehavior>;
  6854. /**
  6855. * Defines if the framing behavior of the camera is enabled on the camera.
  6856. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  6857. */
  6858. useFramingBehavior: boolean;
  6859. private _autoRotationBehavior;
  6860. /**
  6861. * Gets the auto rotation behavior of the camera if it has been enabled.
  6862. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6863. */
  6864. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6865. /**
  6866. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  6867. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  6868. */
  6869. useAutoRotationBehavior: boolean;
  6870. /**
  6871. * Observable triggered when the mesh target has been changed on the camera.
  6872. */
  6873. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6874. /**
  6875. * Event raised when the camera is colliding with a mesh.
  6876. */
  6877. onCollide: (collidedMesh: AbstractMesh) => void;
  6878. /**
  6879. * Defines whether the camera should check collision with the objects oh the scene.
  6880. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  6881. */
  6882. checkCollisions: boolean;
  6883. /**
  6884. * Defines the collision radius of the camera.
  6885. * This simulates a sphere around the camera.
  6886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  6887. */
  6888. collisionRadius: Vector3;
  6889. protected _collider: Collider;
  6890. protected _previousPosition: Vector3;
  6891. protected _collisionVelocity: Vector3;
  6892. protected _newPosition: Vector3;
  6893. protected _previousAlpha: number;
  6894. protected _previousBeta: number;
  6895. protected _previousRadius: number;
  6896. protected _collisionTriggered: boolean;
  6897. protected _targetBoundingCenter: Nullable<Vector3>;
  6898. private _computationVector;
  6899. /**
  6900. * Instantiates a new ArcRotateCamera in a given scene
  6901. * @param name Defines the name of the camera
  6902. * @param alpha Defines the camera rotation along the logitudinal axis
  6903. * @param beta Defines the camera rotation along the latitudinal axis
  6904. * @param radius Defines the camera distance from its target
  6905. * @param target Defines the camera target
  6906. * @param scene Defines the scene the camera belongs to
  6907. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  6908. */
  6909. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6910. /** @hidden */
  6911. _initCache(): void;
  6912. /** @hidden */
  6913. _updateCache(ignoreParentClass?: boolean): void;
  6914. protected _getTargetPosition(): Vector3;
  6915. private _storedAlpha;
  6916. private _storedBeta;
  6917. private _storedRadius;
  6918. private _storedTarget;
  6919. /**
  6920. * Stores the current state of the camera (alpha, beta, radius and target)
  6921. * @returns the camera itself
  6922. */
  6923. storeState(): Camera;
  6924. /**
  6925. * @hidden
  6926. * Restored camera state. You must call storeState() first
  6927. */
  6928. _restoreStateValues(): boolean;
  6929. /** @hidden */
  6930. _isSynchronizedViewMatrix(): boolean;
  6931. /**
  6932. * Attached controls to the current camera.
  6933. * @param element Defines the element the controls should be listened from
  6934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6935. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  6936. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  6937. */
  6938. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6939. /**
  6940. * Detach the current controls from the camera.
  6941. * The camera will stop reacting to inputs.
  6942. * @param element Defines the element to stop listening the inputs from
  6943. */
  6944. detachControl(element: HTMLElement): void;
  6945. /** @hidden */
  6946. _checkInputs(): void;
  6947. protected _checkLimits(): void;
  6948. /**
  6949. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  6950. */
  6951. rebuildAnglesAndRadius(): void;
  6952. /**
  6953. * Use a position to define the current camera related information like aplha, beta and radius
  6954. * @param position Defines the position to set the camera at
  6955. */
  6956. setPosition(position: Vector3): void;
  6957. /**
  6958. * Defines the target the camera should look at.
  6959. * This will automatically adapt alpha beta and radius to fit within the new target.
  6960. * @param target Defines the new target as a Vector or a mesh
  6961. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  6962. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  6963. */
  6964. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6965. /** @hidden */
  6966. _getViewMatrix(): Matrix;
  6967. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6968. /**
  6969. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  6970. * @param meshes Defines the mesh to zoom on
  6971. * @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)
  6972. */
  6973. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6974. /**
  6975. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  6976. * The target will be changed but the radius
  6977. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  6978. * @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)
  6979. */
  6980. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6981. min: Vector3;
  6982. max: Vector3;
  6983. distance: number;
  6984. }, doNotUpdateMaxZ?: boolean): void;
  6985. /**
  6986. * @override
  6987. * Override Camera.createRigCamera
  6988. */
  6989. createRigCamera(name: string, cameraIndex: number): Camera;
  6990. /**
  6991. * @hidden
  6992. * @override
  6993. * Override Camera._updateRigCameras
  6994. */
  6995. _updateRigCameras(): void;
  6996. /**
  6997. * Destroy the camera and release the current resources hold by it.
  6998. */
  6999. dispose(): void;
  7000. /**
  7001. * Gets the current object class name.
  7002. * @return the class name
  7003. */
  7004. getClassName(): string;
  7005. }
  7006. }
  7007. declare module BABYLON {
  7008. /**
  7009. * Default Inputs manager for the ArcRotateCamera.
  7010. * It groups all the default supported inputs for ease of use.
  7011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7012. */
  7013. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7014. /**
  7015. * Instantiates a new ArcRotateCameraInputsManager.
  7016. * @param camera Defines the camera the inputs belong to
  7017. */
  7018. constructor(camera: ArcRotateCamera);
  7019. /**
  7020. * Add mouse wheel input support to the input manager.
  7021. * @returns the current input manager
  7022. */
  7023. addMouseWheel(): ArcRotateCameraInputsManager;
  7024. /**
  7025. * Add pointers input support to the input manager.
  7026. * @returns the current input manager
  7027. */
  7028. addPointers(): ArcRotateCameraInputsManager;
  7029. /**
  7030. * Add keyboard input support to the input manager.
  7031. * @returns the current input manager
  7032. */
  7033. addKeyboard(): ArcRotateCameraInputsManager;
  7034. /**
  7035. * Add orientation input support to the input manager.
  7036. * @returns the current input manager
  7037. */
  7038. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7039. }
  7040. }
  7041. declare module BABYLON {
  7042. /**
  7043. * This is the base class of all the camera used in the application.
  7044. * @see http://doc.babylonjs.com/features/cameras
  7045. */
  7046. class Camera extends Node {
  7047. /**
  7048. * This is the default projection mode used by the cameras.
  7049. * It helps recreating a feeling of perspective and better appreciate depth.
  7050. * This is the best way to simulate real life cameras.
  7051. */
  7052. static readonly PERSPECTIVE_CAMERA: number;
  7053. /**
  7054. * This helps creating camera with an orthographic mode.
  7055. * 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.
  7056. */
  7057. static readonly ORTHOGRAPHIC_CAMERA: number;
  7058. /**
  7059. * This is the default FOV mode for perspective cameras.
  7060. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7061. */
  7062. static readonly FOVMODE_VERTICAL_FIXED: number;
  7063. /**
  7064. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7065. */
  7066. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7067. /**
  7068. * This specifies ther is no need for a camera rig.
  7069. * Basically only one eye is rendered corresponding to the camera.
  7070. */
  7071. static readonly RIG_MODE_NONE: number;
  7072. /**
  7073. * Simulates a camera Rig with one blue eye and one red eye.
  7074. * This can be use with 3d blue and red glasses.
  7075. */
  7076. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7077. /**
  7078. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7079. */
  7080. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7081. /**
  7082. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7083. */
  7084. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7085. /**
  7086. * Defines that both eyes of the camera will be rendered over under each other.
  7087. */
  7088. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7089. /**
  7090. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7091. */
  7092. static readonly RIG_MODE_VR: number;
  7093. /**
  7094. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7095. */
  7096. static readonly RIG_MODE_WEBVR: number;
  7097. /**
  7098. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7099. */
  7100. static readonly RIG_MODE_CUSTOM: number;
  7101. /**
  7102. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7103. */
  7104. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7105. /**
  7106. * @hidden
  7107. * Might be removed once multiview will be a thing
  7108. */
  7109. static UseAlternateWebVRRendering: boolean;
  7110. /**
  7111. * Define the input manager associated with the camera.
  7112. */
  7113. inputs: CameraInputsManager<Camera>;
  7114. /**
  7115. * Define the current local position of the camera in the scene
  7116. */
  7117. position: Vector3;
  7118. /**
  7119. * The vector the camera should consider as up.
  7120. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7121. */
  7122. upVector: Vector3;
  7123. /**
  7124. * Define the current limit on the left side for an orthographic camera
  7125. * In scene unit
  7126. */
  7127. orthoLeft: Nullable<number>;
  7128. /**
  7129. * Define the current limit on the right side for an orthographic camera
  7130. * In scene unit
  7131. */
  7132. orthoRight: Nullable<number>;
  7133. /**
  7134. * Define the current limit on the bottom side for an orthographic camera
  7135. * In scene unit
  7136. */
  7137. orthoBottom: Nullable<number>;
  7138. /**
  7139. * Define the current limit on the top side for an orthographic camera
  7140. * In scene unit
  7141. */
  7142. orthoTop: Nullable<number>;
  7143. /**
  7144. * Field Of View is set in Radians. (default is 0.8)
  7145. */
  7146. fov: number;
  7147. /**
  7148. * Define the minimum distance the camera can see from.
  7149. * This is important to note that the depth buffer are not infinite and the closer it starts
  7150. * the more your scene might encounter depth fighting issue.
  7151. */
  7152. minZ: number;
  7153. /**
  7154. * Define the maximum distance the camera can see to.
  7155. * This is important to note that the depth buffer are not infinite and the further it end
  7156. * the more your scene might encounter depth fighting issue.
  7157. */
  7158. maxZ: number;
  7159. /**
  7160. * Define the default inertia of the camera.
  7161. * This helps giving a smooth feeling to the camera movement.
  7162. */
  7163. inertia: number;
  7164. /**
  7165. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7166. */
  7167. mode: number;
  7168. /**
  7169. * Define wether the camera is intermediate.
  7170. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  7171. */
  7172. isIntermediate: boolean;
  7173. /**
  7174. * Define the viewport of the camera.
  7175. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7176. */
  7177. viewport: Viewport;
  7178. /**
  7179. * Restricts the camera to viewing objects with the same layerMask.
  7180. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7181. */
  7182. layerMask: number;
  7183. /**
  7184. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7185. */
  7186. fovMode: number;
  7187. /**
  7188. * Rig mode of the camera.
  7189. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7190. * This is normally controlled byt the camera themselves as internal use.
  7191. */
  7192. cameraRigMode: number;
  7193. /**
  7194. * Defines the distance between both "eyes" in case of a RIG
  7195. */
  7196. interaxialDistance: number;
  7197. /**
  7198. * Defines if stereoscopic rendering is done side by side or over under.
  7199. */
  7200. isStereoscopicSideBySide: boolean;
  7201. /**
  7202. * Defines the list of custom render target the camera should render to.
  7203. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7204. * else in the scene.
  7205. */
  7206. customRenderTargets: RenderTargetTexture[];
  7207. /**
  7208. * When set, the camera will render to this render target instead of the default canvas
  7209. */
  7210. customDefaultRenderTarget: Nullable<RenderTargetTexture>;
  7211. /**
  7212. * Observable triggered when the camera view matrix has changed.
  7213. */
  7214. onViewMatrixChangedObservable: Observable<Camera>;
  7215. /**
  7216. * Observable triggered when the camera Projection matrix has changed.
  7217. */
  7218. onProjectionMatrixChangedObservable: Observable<Camera>;
  7219. /**
  7220. * Observable triggered when the inputs have been processed.
  7221. */
  7222. onAfterCheckInputsObservable: Observable<Camera>;
  7223. /**
  7224. * Observable triggered when reset has been called and applied to the camera.
  7225. */
  7226. onRestoreStateObservable: Observable<Camera>;
  7227. /** @hidden */
  7228. _cameraRigParams: any;
  7229. /** @hidden */
  7230. _rigCameras: Camera[];
  7231. /** @hidden */
  7232. _rigPostProcess: Nullable<PostProcess>;
  7233. protected _webvrViewMatrix: Matrix;
  7234. /** @hidden */
  7235. _skipRendering: boolean;
  7236. /** @hidden */
  7237. _alternateCamera: Camera;
  7238. /** @hidden */
  7239. _projectionMatrix: Matrix;
  7240. /** @hidden */
  7241. _postProcesses: Nullable<PostProcess>[];
  7242. /** @hidden */
  7243. _activeMeshes: SmartArray<AbstractMesh>;
  7244. protected _globalPosition: Vector3;
  7245. private _computedViewMatrix;
  7246. private _doNotComputeProjectionMatrix;
  7247. private _transformMatrix;
  7248. private _frustumPlanes;
  7249. private _refreshFrustumPlanes;
  7250. private _storedFov;
  7251. private _stateStored;
  7252. /**
  7253. * Instantiates a new camera object.
  7254. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7255. * @see http://doc.babylonjs.com/features/cameras
  7256. * @param name Defines the name of the camera in the scene
  7257. * @param position Defines the position of the camera
  7258. * @param scene Defines the scene the camera belongs too
  7259. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7260. */
  7261. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7262. /**
  7263. * Store current camera state (fov, position, etc..)
  7264. * @returns the camera
  7265. */
  7266. storeState(): Camera;
  7267. /**
  7268. * Restores the camera state values if it has been stored. You must call storeState() first
  7269. */
  7270. protected _restoreStateValues(): boolean;
  7271. /**
  7272. * Restored camera state. You must call storeState() first.
  7273. * @returns true if restored and false otherwise
  7274. */
  7275. restoreState(): boolean;
  7276. /**
  7277. * Gets the class name of the camera.
  7278. * @returns the class name
  7279. */
  7280. getClassName(): string;
  7281. /**
  7282. * Gets a string representation of the camera usefull for debug purpose.
  7283. * @param fullDetails Defines that a more verboe level of logging is required
  7284. * @returns the string representation
  7285. */
  7286. toString(fullDetails?: boolean): string;
  7287. /**
  7288. * Gets the current world space position of the camera.
  7289. */
  7290. readonly globalPosition: Vector3;
  7291. /**
  7292. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7293. * @returns the active meshe list
  7294. */
  7295. getActiveMeshes(): SmartArray<AbstractMesh>;
  7296. /**
  7297. * Check wether a mesh is part of the current active mesh list of the camera
  7298. * @param mesh Defines the mesh to check
  7299. * @returns true if active, false otherwise
  7300. */
  7301. isActiveMesh(mesh: Mesh): boolean;
  7302. /**
  7303. * Is this camera ready to be used/rendered
  7304. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7305. * @return true if the camera is ready
  7306. */
  7307. isReady(completeCheck?: boolean): boolean;
  7308. /** @hidden */
  7309. _initCache(): void;
  7310. /** @hidden */
  7311. _updateCache(ignoreParentClass?: boolean): void;
  7312. /** @hidden */
  7313. _isSynchronized(): boolean;
  7314. /** @hidden */
  7315. _isSynchronizedViewMatrix(): boolean;
  7316. /** @hidden */
  7317. _isSynchronizedProjectionMatrix(): boolean;
  7318. /**
  7319. * Attach the input controls to a specific dom element to get the input from.
  7320. * @param element Defines the element the controls should be listened from
  7321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7322. */
  7323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7324. /**
  7325. * Detach the current controls from the specified dom element.
  7326. * @param element Defines the element to stop listening the inputs from
  7327. */
  7328. detachControl(element: HTMLElement): void;
  7329. /**
  7330. * Update the camera state according to the different inputs gathered during the frame.
  7331. */
  7332. update(): void;
  7333. /** @hidden */
  7334. _checkInputs(): void;
  7335. /** @hidden */
  7336. readonly rigCameras: Camera[];
  7337. /**
  7338. * Gets the post process used by the rig cameras
  7339. */
  7340. readonly rigPostProcess: Nullable<PostProcess>;
  7341. /**
  7342. * Internal, gets the first post proces.
  7343. * @returns the first post process to be run on this camera.
  7344. */
  7345. _getFirstPostProcess(): Nullable<PostProcess>;
  7346. private _cascadePostProcessesToRigCams;
  7347. /**
  7348. * Attach a post process to the camera.
  7349. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7350. * @param postProcess The post process to attach to the camera
  7351. * @param insertAt The position of the post process in case several of them are in use in the scene
  7352. * @returns the position the post process has been inserted at
  7353. */
  7354. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7355. /**
  7356. * Detach a post process to the camera.
  7357. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7358. * @param postProcess The post process to detach from the camera
  7359. */
  7360. detachPostProcess(postProcess: PostProcess): void;
  7361. /**
  7362. * Gets the current world matrix of the camera
  7363. */
  7364. getWorldMatrix(): Matrix;
  7365. /** @hidden */
  7366. protected _getViewMatrix(): Matrix;
  7367. /**
  7368. * Gets the current view matrix of the camera.
  7369. * @param force forces the camera to recompute the matrix without looking at the cached state
  7370. * @returns the view matrix
  7371. */
  7372. getViewMatrix(force?: boolean): Matrix;
  7373. /**
  7374. * Freeze the projection matrix.
  7375. * It will prevent the cache check of the camera projection compute and can speed up perf
  7376. * if no parameter of the camera are meant to change
  7377. * @param projection Defines manually a projection if necessary
  7378. */
  7379. freezeProjectionMatrix(projection?: Matrix): void;
  7380. /**
  7381. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7382. */
  7383. unfreezeProjectionMatrix(): void;
  7384. /**
  7385. * Gets the current projection matrix of the camera.
  7386. * @param force forces the camera to recompute the matrix without looking at the cached state
  7387. * @returns the projection matrix
  7388. */
  7389. getProjectionMatrix(force?: boolean): Matrix;
  7390. /**
  7391. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7392. * @returns a Matrix
  7393. */
  7394. getTransformationMatrix(): Matrix;
  7395. private _updateFrustumPlanes;
  7396. /**
  7397. * Checks if a cullable object (mesh...) is in the camera frustum
  7398. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7399. * @param target The object to check
  7400. * @returns true if the object is in frustum otherwise false
  7401. */
  7402. isInFrustum(target: ICullable): boolean;
  7403. /**
  7404. * Checks if a cullable object (mesh...) is in the camera frustum
  7405. * Unlike isInFrustum this cheks the full bounding box
  7406. * @param target The object to check
  7407. * @returns true if the object is in frustum otherwise false
  7408. */
  7409. isCompletelyInFrustum(target: ICullable): boolean;
  7410. /**
  7411. * Gets a ray in the forward direction from the camera.
  7412. * @param length Defines the length of the ray to create
  7413. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7414. * @param origin Defines the start point of the ray which defaults to the camera position
  7415. * @returns the forward ray
  7416. */
  7417. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7418. /**
  7419. * Releases resources associated with this node.
  7420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7422. */
  7423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7424. /**
  7425. * Gets the left camera of a rig setup in case of Rigged Camera
  7426. */
  7427. readonly leftCamera: Nullable<FreeCamera>;
  7428. /**
  7429. * Gets the right camera of a rig setup in case of Rigged Camera
  7430. */
  7431. readonly rightCamera: Nullable<FreeCamera>;
  7432. /**
  7433. * Gets the left camera target of a rig setup in case of Rigged Camera
  7434. * @returns the target position
  7435. */
  7436. getLeftTarget(): Nullable<Vector3>;
  7437. /**
  7438. * Gets the right camera target of a rig setup in case of Rigged Camera
  7439. * @returns the target position
  7440. */
  7441. getRightTarget(): Nullable<Vector3>;
  7442. /**
  7443. * @hidden
  7444. */
  7445. setCameraRigMode(mode: number, rigParams: any): void;
  7446. private _getVRProjectionMatrix;
  7447. protected _updateCameraRotationMatrix(): void;
  7448. protected _updateWebVRCameraRotationMatrix(): void;
  7449. /**
  7450. * This function MUST be overwritten by the different WebVR cameras available.
  7451. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7452. */
  7453. protected _getWebVRProjectionMatrix(): Matrix;
  7454. /**
  7455. * This function MUST be overwritten by the different WebVR cameras available.
  7456. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7457. */
  7458. protected _getWebVRViewMatrix(): Matrix;
  7459. /** @hidden */
  7460. setCameraRigParameter(name: string, value: any): void;
  7461. /**
  7462. * needs to be overridden by children so sub has required properties to be copied
  7463. * @hidden
  7464. */
  7465. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7466. /**
  7467. * May need to be overridden by children
  7468. * @hidden
  7469. */
  7470. _updateRigCameras(): void;
  7471. /** @hidden */
  7472. _setupInputs(): void;
  7473. /**
  7474. * Serialiaze the camera setup to a json represention
  7475. * @returns the JSON representation
  7476. */
  7477. serialize(): any;
  7478. /**
  7479. * Clones the current camera.
  7480. * @param name The cloned camera name
  7481. * @returns the cloned camera
  7482. */
  7483. clone(name: string): Camera;
  7484. /**
  7485. * Gets the direction of the camera relative to a given local axis.
  7486. * @param localAxis Defines the reference axis to provide a relative direction.
  7487. * @return the direction
  7488. */
  7489. getDirection(localAxis: Vector3): Vector3;
  7490. /**
  7491. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7492. * @param localAxis Defines the reference axis to provide a relative direction.
  7493. * @param result Defines the vector to store the result in
  7494. */
  7495. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7496. /**
  7497. * Gets a camera constructor for a given camera type
  7498. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  7499. * @param name The name of the camera the result will be able to instantiate
  7500. * @param scene The scene the result will construct the camera in
  7501. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  7502. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  7503. * @returns a factory method to construc the camera
  7504. */
  7505. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  7506. /**
  7507. * Compute the world matrix of the camera.
  7508. * @returns the camera workd matrix
  7509. */
  7510. computeWorldMatrix(): Matrix;
  7511. /**
  7512. * Parse a JSON and creates the camera from the parsed information
  7513. * @param parsedCamera The JSON to parse
  7514. * @param scene The scene to instantiate the camera in
  7515. * @returns the newly constructed camera
  7516. */
  7517. static Parse(parsedCamera: any, scene: Scene): Camera;
  7518. }
  7519. }
  7520. declare module BABYLON {
  7521. /**
  7522. * @ignore
  7523. * This is a list of all the different input types that are available in the application.
  7524. * Fo instance: ArcRotateCameraGamepadInput...
  7525. */
  7526. var CameraInputTypes: {};
  7527. /**
  7528. * This is the contract to implement in order to create a new input class.
  7529. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7530. */
  7531. interface ICameraInput<TCamera extends Camera> {
  7532. /**
  7533. * Defines the camera the input is attached to.
  7534. */
  7535. camera: Nullable<TCamera>;
  7536. /**
  7537. * Gets the class name of the current intput.
  7538. * @returns the class name
  7539. */
  7540. getClassName(): string;
  7541. /**
  7542. * Get the friendly name associated with the input class.
  7543. * @returns the input friendly name
  7544. */
  7545. getSimpleName(): string;
  7546. /**
  7547. * Attach the input controls to a specific dom element to get the input from.
  7548. * @param element Defines the element the controls should be listened from
  7549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7550. */
  7551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7552. /**
  7553. * Detach the current controls from the specified dom element.
  7554. * @param element Defines the element to stop listening the inputs from
  7555. */
  7556. detachControl(element: Nullable<HTMLElement>): void;
  7557. /**
  7558. * Update the current camera state depending on the inputs that have been used this frame.
  7559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7560. */
  7561. checkInputs?: () => void;
  7562. }
  7563. /**
  7564. * Represents a map of input types to input instance or input index to input instance.
  7565. */
  7566. interface CameraInputsMap<TCamera extends Camera> {
  7567. /**
  7568. * Accessor to the input by input type.
  7569. */
  7570. [name: string]: ICameraInput<TCamera>;
  7571. /**
  7572. * Accessor to the input by input index.
  7573. */
  7574. [idx: number]: ICameraInput<TCamera>;
  7575. }
  7576. /**
  7577. * This represents the input manager used within a camera.
  7578. * It helps dealing with all the different kind of input attached to a camera.
  7579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7580. */
  7581. class CameraInputsManager<TCamera extends Camera> {
  7582. /**
  7583. * Defines the list of inputs attahed to the camera.
  7584. */
  7585. attached: CameraInputsMap<TCamera>;
  7586. /**
  7587. * Defines the dom element the camera is collecting inputs from.
  7588. * This is null if the controls have not been attached.
  7589. */
  7590. attachedElement: Nullable<HTMLElement>;
  7591. /**
  7592. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7593. */
  7594. noPreventDefault: boolean;
  7595. /**
  7596. * Defined the camera the input manager belongs to.
  7597. */
  7598. camera: TCamera;
  7599. /**
  7600. * Update the current camera state depending on the inputs that have been used this frame.
  7601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7602. */
  7603. checkInputs: () => void;
  7604. /**
  7605. * Instantiate a new Camera Input Manager.
  7606. * @param camera Defines the camera the input manager blongs to
  7607. */
  7608. constructor(camera: TCamera);
  7609. /**
  7610. * Add an input method to a camera
  7611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7612. * @param input camera input method
  7613. */
  7614. add(input: ICameraInput<TCamera>): void;
  7615. /**
  7616. * Remove a specific input method from a camera
  7617. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7618. * @param inputToRemove camera input method
  7619. */
  7620. remove(inputToRemove: ICameraInput<TCamera>): void;
  7621. /**
  7622. * Remove a specific input type from a camera
  7623. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7624. * @param inputType the type of the input to remove
  7625. */
  7626. removeByType(inputType: string): void;
  7627. private _addCheckInputs;
  7628. /**
  7629. * Attach the input controls to the currently attached dom element to listen the events from.
  7630. * @param input Defines the input to attach
  7631. */
  7632. attachInput(input: ICameraInput<TCamera>): void;
  7633. /**
  7634. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7635. * @param element Defines the dom element to collect the events from
  7636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7637. */
  7638. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7639. /**
  7640. * Detach the current manager inputs controls from a specific dom element.
  7641. * @param element Defines the dom element to collect the events from
  7642. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7643. */
  7644. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7645. /**
  7646. * Rebuild the dynamic inputCheck function from the current list of
  7647. * defined inputs in the manager.
  7648. */
  7649. rebuildInputCheck(): void;
  7650. /**
  7651. * Remove all attached input methods from a camera
  7652. */
  7653. clear(): void;
  7654. /**
  7655. * Serialize the current input manager attached to a camera.
  7656. * This ensures than once parsed,
  7657. * the input associated to the camera will be identical to the current ones
  7658. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7659. */
  7660. serialize(serializedCamera: any): void;
  7661. /**
  7662. * Parses an input manager serialized JSON to restore the previous list of inputs
  7663. * and states associated to a camera.
  7664. * @param parsedCamera Defines the JSON to parse
  7665. */
  7666. parse(parsedCamera: any): void;
  7667. }
  7668. }
  7669. declare module BABYLON {
  7670. /**
  7671. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  7672. * being tilted forward or back and left or right.
  7673. */
  7674. class DeviceOrientationCamera extends FreeCamera {
  7675. private _initialQuaternion;
  7676. private _quaternionCache;
  7677. /**
  7678. * Creates a new device orientation camera
  7679. * @param name The name of the camera
  7680. * @param position The start position camera
  7681. * @param scene The scene the camera belongs to
  7682. */
  7683. constructor(name: string, position: Vector3, scene: Scene);
  7684. /**
  7685. * Gets the current instance class name ("DeviceOrientationCamera").
  7686. * This helps avoiding instanceof at run time.
  7687. * @returns the class name
  7688. */
  7689. getClassName(): string;
  7690. /**
  7691. * @hidden
  7692. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  7693. */
  7694. _checkInputs(): void;
  7695. /**
  7696. * Reset the camera to its default orientation on the specified axis only.
  7697. * @param axis The axis to reset
  7698. */
  7699. resetToCurrentRotation(axis?: Axis): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7705. * such as in a 3D Space Shooter or a Flight Simulator.
  7706. */
  7707. class FlyCamera extends TargetCamera {
  7708. /**
  7709. * Define the collision ellipsoid of the camera.
  7710. * This is helpful for simulating a camera body, like a player's body.
  7711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7712. */
  7713. ellipsoid: Vector3;
  7714. /**
  7715. * Define an offset for the position of the ellipsoid around the camera.
  7716. * This can be helpful if the camera is attached away from the player's body center,
  7717. * such as at its head.
  7718. */
  7719. ellipsoidOffset: Vector3;
  7720. /**
  7721. * Enable or disable collisions of the camera with the rest of the scene objects.
  7722. */
  7723. checkCollisions: boolean;
  7724. /**
  7725. * Enable or disable gravity on the camera.
  7726. */
  7727. applyGravity: boolean;
  7728. /**
  7729. * Define the current direction the camera is moving to.
  7730. */
  7731. cameraDirection: Vector3;
  7732. /**
  7733. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  7734. * This overrides and empties cameraRotation.
  7735. */
  7736. rotationQuaternion: BABYLON.Quaternion;
  7737. /**
  7738. * Track Roll to maintain the wanted Rolling when looking around.
  7739. */
  7740. _trackRoll: number;
  7741. /**
  7742. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  7743. */
  7744. rollCorrect: number;
  7745. /**
  7746. * Mimic a banked turn, Rolling the camera when Yawing.
  7747. * It's recommended to use rollCorrect = 10 for faster banking correction.
  7748. */
  7749. bankedTurn: boolean;
  7750. /**
  7751. * Limit in radians for how much Roll banking will add. (Default: 90°)
  7752. */
  7753. bankedTurnLimit: number;
  7754. /**
  7755. * Value of 0 disables the banked Roll.
  7756. * Value of 1 is equal to the Yaw angle in radians.
  7757. */
  7758. bankedTurnMultiplier: number;
  7759. /**
  7760. * The inputs manager loads all the input sources, such as keyboard and mouse.
  7761. */
  7762. inputs: FlyCameraInputsManager;
  7763. /**
  7764. * Gets the input sensibility for mouse input.
  7765. * Higher values reduce sensitivity.
  7766. */
  7767. /**
  7768. * Sets the input sensibility for a mouse input.
  7769. * Higher values reduce sensitivity.
  7770. */
  7771. angularSensibility: number;
  7772. /**
  7773. * Get the keys for camera movement forward.
  7774. */
  7775. /**
  7776. * Set the keys for camera movement forward.
  7777. */
  7778. keysForward: number[];
  7779. /**
  7780. * Get the keys for camera movement backward.
  7781. */
  7782. keysBackward: number[];
  7783. /**
  7784. * Get the keys for camera movement up.
  7785. */
  7786. /**
  7787. * Set the keys for camera movement up.
  7788. */
  7789. keysUp: number[];
  7790. /**
  7791. * Get the keys for camera movement down.
  7792. */
  7793. /**
  7794. * Set the keys for camera movement down.
  7795. */
  7796. keysDown: number[];
  7797. /**
  7798. * Get the keys for camera movement left.
  7799. */
  7800. /**
  7801. * Set the keys for camera movement left.
  7802. */
  7803. keysLeft: number[];
  7804. /**
  7805. * Set the keys for camera movement right.
  7806. */
  7807. /**
  7808. * Set the keys for camera movement right.
  7809. */
  7810. keysRight: number[];
  7811. /**
  7812. * Event raised when the camera collides with a mesh in the scene.
  7813. */
  7814. onCollide: (collidedMesh: AbstractMesh) => void;
  7815. private _collider;
  7816. private _needMoveForGravity;
  7817. private _oldPosition;
  7818. private _diffPosition;
  7819. private _newPosition;
  7820. /** @hidden */
  7821. _localDirection: Vector3;
  7822. /** @hidden */
  7823. _transformedDirection: Vector3;
  7824. /**
  7825. * Instantiates a FlyCamera.
  7826. * This is a flying camera, designed for 3D movement and rotation in all directions,
  7827. * such as in a 3D Space Shooter or a Flight Simulator.
  7828. * @param name Define the name of the camera in the scene.
  7829. * @param position Define the starting position of the camera in the scene.
  7830. * @param scene Define the scene the camera belongs to.
  7831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  7832. */
  7833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7834. /**
  7835. * Attach a control to the HTML DOM element.
  7836. * @param element Defines the element that listens to the input events.
  7837. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  7838. */
  7839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7840. /**
  7841. * Detach a control from the HTML DOM element.
  7842. * The camera will stop reacting to that input.
  7843. * @param element Defines the element that listens to the input events.
  7844. */
  7845. detachControl(element: HTMLElement): void;
  7846. private _collisionMask;
  7847. /**
  7848. * Get the mask that the camera ignores in collision events.
  7849. */
  7850. /**
  7851. * Set the mask that the camera ignores in collision events.
  7852. */
  7853. collisionMask: number;
  7854. /** @hidden */
  7855. _collideWithWorld(displacement: Vector3): void;
  7856. /** @hidden */
  7857. private _onCollisionPositionChange;
  7858. /** @hidden */
  7859. _checkInputs(): void;
  7860. /** @hidden */
  7861. _decideIfNeedsToMove(): boolean;
  7862. /** @hidden */
  7863. _updatePosition(): void;
  7864. /**
  7865. * Restore the Roll to its target value at the rate specified.
  7866. * @param rate - Higher means slower restoring.
  7867. * @hidden
  7868. */
  7869. restoreRoll(rate: number): void;
  7870. /**
  7871. * Destroy the camera and release the current resources held by it.
  7872. */
  7873. dispose(): void;
  7874. /**
  7875. * Get the current object class name.
  7876. * @returns the class name.
  7877. */
  7878. getClassName(): string;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Default Inputs manager for the FlyCamera.
  7884. * It groups all the default supported inputs for ease of use.
  7885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7886. */
  7887. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  7888. /**
  7889. * Instantiates a new FlyCameraInputsManager.
  7890. * @param camera Defines the camera the inputs belong to.
  7891. */
  7892. constructor(camera: FlyCamera);
  7893. /**
  7894. * Add keyboard input support to the input manager.
  7895. * @returns the new FlyCameraKeyboardMoveInput().
  7896. */
  7897. addKeyboard(): FlyCameraInputsManager;
  7898. /**
  7899. * Add mouse input support to the input manager.
  7900. * @param touchEnabled Enable touch screen support.
  7901. * @returns the new FlyCameraMouseInput().
  7902. */
  7903. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  7904. }
  7905. }
  7906. declare module BABYLON {
  7907. /**
  7908. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  7909. * an arc rotate version arcFollowCamera are available.
  7910. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7911. */
  7912. class FollowCamera extends TargetCamera {
  7913. /**
  7914. * Distance the follow camera should follow an object at
  7915. */
  7916. radius: number;
  7917. /**
  7918. * Define a rotation offset between the camera and the object it follows
  7919. */
  7920. rotationOffset: number;
  7921. /**
  7922. * Define a height offset between the camera and the object it follows.
  7923. * It can help following an object from the top (like a car chaing a plane)
  7924. */
  7925. heightOffset: number;
  7926. /**
  7927. * Define how fast the camera can accelerate to follow it s target.
  7928. */
  7929. cameraAcceleration: number;
  7930. /**
  7931. * Define the speed limit of the camera following an object.
  7932. */
  7933. maxCameraSpeed: number;
  7934. /**
  7935. * Define the target of the camera.
  7936. */
  7937. lockedTarget: Nullable<AbstractMesh>;
  7938. /**
  7939. * Instantiates the follow camera.
  7940. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7941. * @param name Define the name of the camera in the scene
  7942. * @param position Define the position of the camera
  7943. * @param scene Define the scene the camera belong to
  7944. * @param lockedTarget Define the target of the camera
  7945. */
  7946. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  7947. private _follow;
  7948. /** @hidden */
  7949. _checkInputs(): void;
  7950. /**
  7951. * Gets the camera class name.
  7952. * @returns the class name
  7953. */
  7954. getClassName(): string;
  7955. }
  7956. /**
  7957. * Arc Rotate version of the follow camera.
  7958. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  7959. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7960. */
  7961. class ArcFollowCamera extends TargetCamera {
  7962. /** The longitudinal angle of the camera */
  7963. alpha: number;
  7964. /** The latitudinal angle of the camera */
  7965. beta: number;
  7966. /** The radius of the camera from its target */
  7967. radius: number;
  7968. /** Define the camera target (the messh it should follow) */
  7969. target: Nullable<AbstractMesh>;
  7970. private _cartesianCoordinates;
  7971. /**
  7972. * Instantiates a new ArcFollowCamera
  7973. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  7974. * @param name Define the name of the camera
  7975. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  7976. * @param beta Define the rotation angle of the camera around the elevation axis
  7977. * @param radius Define the radius of the camera from its target point
  7978. * @param target Define the target of the camera
  7979. * @param scene Define the scene the camera belongs to
  7980. */
  7981. constructor(name: string,
  7982. /** The longitudinal angle of the camera */
  7983. alpha: number,
  7984. /** The latitudinal angle of the camera */
  7985. beta: number,
  7986. /** The radius of the camera from its target */
  7987. radius: number,
  7988. /** Define the camera target (the messh it should follow) */
  7989. target: Nullable<AbstractMesh>, scene: Scene);
  7990. private _follow;
  7991. /** @hidden */
  7992. _checkInputs(): void;
  7993. /**
  7994. * Returns the class name of the object.
  7995. * It is mostly used internally for serialization purposes.
  7996. */
  7997. getClassName(): string;
  7998. }
  7999. }
  8000. declare module BABYLON {
  8001. /**
  8002. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8003. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8004. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8005. */
  8006. class FreeCamera extends TargetCamera {
  8007. /**
  8008. * Define the collision ellipsoid of the camera.
  8009. * This is helpful to simulate a camera body like the player body around the camera
  8010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8011. */
  8012. ellipsoid: Vector3;
  8013. /**
  8014. * Define an offset for the position of the ellipsoid around the camera.
  8015. * This can be helpful to determine the center of the body near the gravity center of the body
  8016. * instead of its head.
  8017. */
  8018. ellipsoidOffset: Vector3;
  8019. /**
  8020. * Enable or disable collisions of the camera with the rest of the scene objects.
  8021. */
  8022. checkCollisions: boolean;
  8023. /**
  8024. * Enable or disable gravity on the camera.
  8025. */
  8026. applyGravity: boolean;
  8027. /**
  8028. * Define the input manager associated to the camera.
  8029. */
  8030. inputs: FreeCameraInputsManager;
  8031. /**
  8032. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8033. * Higher values reduce sensitivity.
  8034. */
  8035. /**
  8036. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8037. * Higher values reduce sensitivity.
  8038. */
  8039. angularSensibility: number;
  8040. /**
  8041. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8042. */
  8043. keysUp: number[];
  8044. /**
  8045. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8046. */
  8047. keysDown: number[];
  8048. /**
  8049. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8050. */
  8051. keysLeft: number[];
  8052. /**
  8053. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8054. */
  8055. keysRight: number[];
  8056. /**
  8057. * Event raised when the camera collide with a mesh in the scene.
  8058. */
  8059. onCollide: (collidedMesh: AbstractMesh) => void;
  8060. private _collider;
  8061. private _needMoveForGravity;
  8062. private _oldPosition;
  8063. private _diffPosition;
  8064. private _newPosition;
  8065. /** @hidden */
  8066. _localDirection: Vector3;
  8067. /** @hidden */
  8068. _transformedDirection: Vector3;
  8069. /**
  8070. * Instantiates a Free Camera.
  8071. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8072. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8073. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8074. * @param name Define the name of the camera in the scene
  8075. * @param position Define the start position of the camera in the scene
  8076. * @param scene Define the scene the camera belongs to
  8077. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8078. */
  8079. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8080. /**
  8081. * Attached controls to the current camera.
  8082. * @param element Defines the element the controls should be listened from
  8083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8084. */
  8085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8086. /**
  8087. * Detach the current controls from the camera.
  8088. * The camera will stop reacting to inputs.
  8089. * @param element Defines the element to stop listening the inputs from
  8090. */
  8091. detachControl(element: HTMLElement): void;
  8092. private _collisionMask;
  8093. /**
  8094. * Define a collision mask to limit the list of object the camera can collide with
  8095. */
  8096. collisionMask: number;
  8097. /** @hidden */
  8098. _collideWithWorld(displacement: Vector3): void;
  8099. private _onCollisionPositionChange;
  8100. /** @hidden */
  8101. _checkInputs(): void;
  8102. /** @hidden */
  8103. _decideIfNeedsToMove(): boolean;
  8104. /** @hidden */
  8105. _updatePosition(): void;
  8106. /**
  8107. * Destroy the camera and release the current resources hold by it.
  8108. */
  8109. dispose(): void;
  8110. /**
  8111. * Gets the current object class name.
  8112. * @return the class name
  8113. */
  8114. getClassName(): string;
  8115. }
  8116. }
  8117. declare module BABYLON {
  8118. /**
  8119. * Default Inputs manager for the FreeCamera.
  8120. * It groups all the default supported inputs for ease of use.
  8121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8122. */
  8123. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8124. /**
  8125. * Instantiates a new FreeCameraInputsManager.
  8126. * @param camera Defines the camera the inputs belong to
  8127. */
  8128. constructor(camera: FreeCamera);
  8129. /**
  8130. * Add keyboard input support to the input manager.
  8131. * @returns the current input manager
  8132. */
  8133. addKeyboard(): FreeCameraInputsManager;
  8134. /**
  8135. * Add mouse input support to the input manager.
  8136. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8137. * @returns the current input manager
  8138. */
  8139. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8140. /**
  8141. * Add orientation input support to the input manager.
  8142. * @returns the current input manager
  8143. */
  8144. addDeviceOrientation(): FreeCameraInputsManager;
  8145. /**
  8146. * Add touch input support to the input manager.
  8147. * @returns the current input manager
  8148. */
  8149. addTouch(): FreeCameraInputsManager;
  8150. /**
  8151. * Add virtual joystick input support to the input manager.
  8152. * @returns the current input manager
  8153. */
  8154. addVirtualJoystick(): FreeCameraInputsManager;
  8155. }
  8156. }
  8157. declare module BABYLON {
  8158. /**
  8159. * This represents a FPS type of camera. This is only here for back compat purpose.
  8160. * Please use the UniversalCamera instead as both are identical.
  8161. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8162. */
  8163. class GamepadCamera extends UniversalCamera {
  8164. /**
  8165. * Instantiates a new Gamepad Camera
  8166. * This represents a FPS type of camera. This is only here for back compat purpose.
  8167. * Please use the UniversalCamera instead as both are identical.
  8168. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8169. * @param name Define the name of the camera in the scene
  8170. * @param position Define the start position of the camera in the scene
  8171. * @param scene Define the scene the camera belongs to
  8172. */
  8173. constructor(name: string, position: Vector3, scene: Scene);
  8174. /**
  8175. * Gets the current object class name.
  8176. * @return the class name
  8177. */
  8178. getClassName(): string;
  8179. }
  8180. }
  8181. declare module BABYLON {
  8182. /**
  8183. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8184. * This is the base of the follow, arc rotate cameras and Free camera
  8185. * @see http://doc.babylonjs.com/features/cameras
  8186. */
  8187. class TargetCamera extends Camera {
  8188. /**
  8189. * Define the current direction the camera is moving to
  8190. */
  8191. cameraDirection: Vector3;
  8192. /**
  8193. * Define the current rotation the camera is rotating to
  8194. */
  8195. cameraRotation: Vector2;
  8196. /**
  8197. * Define the current rotation of the camera
  8198. */
  8199. rotation: Vector3;
  8200. /**
  8201. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8202. */
  8203. rotationQuaternion: Quaternion;
  8204. /**
  8205. * Define the current speed of the camera
  8206. */
  8207. speed: number;
  8208. /**
  8209. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8210. * around all axis.
  8211. */
  8212. noRotationConstraint: boolean;
  8213. /**
  8214. * Define the current target of the camera as an object or a position.
  8215. */
  8216. lockedTarget: any;
  8217. /** @hidden */
  8218. _currentTarget: Vector3;
  8219. /** @hidden */
  8220. _viewMatrix: Matrix;
  8221. /** @hidden */
  8222. _camMatrix: Matrix;
  8223. /** @hidden */
  8224. _cameraTransformMatrix: Matrix;
  8225. /** @hidden */
  8226. _cameraRotationMatrix: Matrix;
  8227. private _rigCamTransformMatrix;
  8228. /** @hidden */
  8229. _referencePoint: Vector3;
  8230. /** @hidden */
  8231. _transformedReferencePoint: Vector3;
  8232. protected _globalCurrentTarget: Vector3;
  8233. protected _globalCurrentUpVector: Vector3;
  8234. /** @hidden */
  8235. _reset: () => void;
  8236. private _defaultUp;
  8237. /**
  8238. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8239. * This is the base of the follow, arc rotate cameras and Free camera
  8240. * @see http://doc.babylonjs.com/features/cameras
  8241. * @param name Defines the name of the camera in the scene
  8242. * @param position Defines the start position of the camera in the scene
  8243. * @param scene Defines the scene the camera belongs to
  8244. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8245. */
  8246. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8247. /**
  8248. * Gets the position in front of the camera at a given distance.
  8249. * @param distance The distance from the camera we want the position to be
  8250. * @returns the position
  8251. */
  8252. getFrontPosition(distance: number): Vector3;
  8253. /** @hidden */
  8254. _getLockedTargetPosition(): Nullable<Vector3>;
  8255. private _storedPosition;
  8256. private _storedRotation;
  8257. private _storedRotationQuaternion;
  8258. /**
  8259. * Store current camera state of the camera (fov, position, rotation, etc..)
  8260. * @returns the camera
  8261. */
  8262. storeState(): Camera;
  8263. /**
  8264. * Restored camera state. You must call storeState() first
  8265. * @returns whether it was successful or not
  8266. * @hidden
  8267. */
  8268. _restoreStateValues(): boolean;
  8269. /** @hidden */
  8270. _initCache(): void;
  8271. /** @hidden */
  8272. _updateCache(ignoreParentClass?: boolean): void;
  8273. /** @hidden */
  8274. _isSynchronizedViewMatrix(): boolean;
  8275. /** @hidden */
  8276. _computeLocalCameraSpeed(): number;
  8277. /** @hidden */
  8278. setTarget(target: Vector3): void;
  8279. /**
  8280. * Return the current target position of the camera. This value is expressed in local space.
  8281. * @returns the target position
  8282. */
  8283. getTarget(): Vector3;
  8284. /** @hidden */
  8285. _decideIfNeedsToMove(): boolean;
  8286. /** @hidden */
  8287. _updatePosition(): void;
  8288. /** @hidden */
  8289. _checkInputs(): void;
  8290. protected _updateCameraRotationMatrix(): void;
  8291. /**
  8292. * 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)
  8293. * @returns the current camera
  8294. */
  8295. private _rotateUpVectorWithCameraRotationMatrix;
  8296. private _cachedRotationZ;
  8297. private _cachedQuaternionRotationZ;
  8298. /** @hidden */
  8299. _getViewMatrix(): Matrix;
  8300. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8301. /**
  8302. * @hidden
  8303. */
  8304. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8305. /**
  8306. * @hidden
  8307. */
  8308. _updateRigCameras(): void;
  8309. private _getRigCamPosition;
  8310. /**
  8311. * Gets the current object class name.
  8312. * @return the class name
  8313. */
  8314. getClassName(): string;
  8315. }
  8316. }
  8317. declare module BABYLON {
  8318. /**
  8319. * This represents a FPS type of camera controlled by touch.
  8320. * This is like a universal camera minus the Gamepad controls.
  8321. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8322. */
  8323. class TouchCamera extends FreeCamera {
  8324. /**
  8325. * Defines the touch sensibility for rotation.
  8326. * The higher the faster.
  8327. */
  8328. touchAngularSensibility: number;
  8329. /**
  8330. * Defines the touch sensibility for move.
  8331. * The higher the faster.
  8332. */
  8333. touchMoveSensibility: number;
  8334. /**
  8335. * Instantiates a new touch camera.
  8336. * This represents a FPS type of camera controlled by touch.
  8337. * This is like a universal camera minus the Gamepad controls.
  8338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8339. * @param name Define the name of the camera in the scene
  8340. * @param position Define the start position of the camera in the scene
  8341. * @param scene Define the scene the camera belongs to
  8342. */
  8343. constructor(name: string, position: Vector3, scene: Scene);
  8344. /**
  8345. * Gets the current object class name.
  8346. * @return the class name
  8347. */
  8348. getClassName(): string;
  8349. /** @hidden */
  8350. _setupInputs(): void;
  8351. }
  8352. }
  8353. declare module BABYLON {
  8354. /**
  8355. * 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,
  8356. * which still works and will still be found in many Playgrounds.
  8357. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8358. */
  8359. class UniversalCamera extends TouchCamera {
  8360. /**
  8361. * Defines the gamepad rotation sensiblity.
  8362. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8363. */
  8364. gamepadAngularSensibility: number;
  8365. /**
  8366. * Defines the gamepad move sensiblity.
  8367. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8368. */
  8369. gamepadMoveSensibility: number;
  8370. /**
  8371. * 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,
  8372. * which still works and will still be found in many Playgrounds.
  8373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8374. * @param name Define the name of the camera in the scene
  8375. * @param position Define the start position of the camera in the scene
  8376. * @param scene Define the scene the camera belongs to
  8377. */
  8378. constructor(name: string, position: Vector3, scene: Scene);
  8379. /**
  8380. * Gets the current object class name.
  8381. * @return the class name
  8382. */
  8383. getClassName(): string;
  8384. }
  8385. }
  8386. declare module BABYLON {
  8387. /**
  8388. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8389. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8390. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8391. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8392. */
  8393. class VirtualJoysticksCamera extends FreeCamera {
  8394. /**
  8395. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  8396. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8397. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8398. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8399. * @param name Define the name of the camera in the scene
  8400. * @param position Define the start position of the camera in the scene
  8401. * @param scene Define the scene the camera belongs to
  8402. */
  8403. constructor(name: string, position: Vector3, scene: Scene);
  8404. /**
  8405. * Gets the current object class name.
  8406. * @return the class name
  8407. */
  8408. getClassName(): string;
  8409. }
  8410. }
  8411. interface VRDisplay extends EventTarget {
  8412. /**
  8413. * Dictionary of capabilities describing the VRDisplay.
  8414. */
  8415. readonly capabilities: VRDisplayCapabilities;
  8416. /**
  8417. * z-depth defining the far plane of the eye view frustum
  8418. * enables mapping of values in the render target depth
  8419. * attachment to scene coordinates. Initially set to 10000.0.
  8420. */
  8421. depthFar: number;
  8422. /**
  8423. * z-depth defining the near plane of the eye view frustum
  8424. * enables mapping of values in the render target depth
  8425. * attachment to scene coordinates. Initially set to 0.01.
  8426. */
  8427. depthNear: number;
  8428. /**
  8429. * An identifier for this distinct VRDisplay. Used as an
  8430. * association point in the Gamepad API.
  8431. */
  8432. readonly displayId: number;
  8433. /**
  8434. * A display name, a user-readable name identifying it.
  8435. */
  8436. readonly displayName: string;
  8437. readonly isConnected: boolean;
  8438. readonly isPresenting: boolean;
  8439. /**
  8440. * If this VRDisplay supports room-scale experiences, the optional
  8441. * stage attribute contains details on the room-scale parameters.
  8442. */
  8443. readonly stageParameters: VRStageParameters | null;
  8444. /**
  8445. * Passing the value returned by `requestAnimationFrame` to
  8446. * `cancelAnimationFrame` will unregister the callback.
  8447. * @param handle Define the hanle of the request to cancel
  8448. */
  8449. cancelAnimationFrame(handle: number): void;
  8450. /**
  8451. * Stops presenting to the VRDisplay.
  8452. * @returns a promise to know when it stopped
  8453. */
  8454. exitPresent(): Promise<void>;
  8455. /**
  8456. * Return the current VREyeParameters for the given eye.
  8457. * @param whichEye Define the eye we want the parameter for
  8458. * @returns the eye parameters
  8459. */
  8460. getEyeParameters(whichEye: string): VREyeParameters;
  8461. /**
  8462. * Populates the passed VRFrameData with the information required to render
  8463. * the current frame.
  8464. * @param frameData Define the data structure to populate
  8465. * @returns true if ok otherwise false
  8466. */
  8467. getFrameData(frameData: VRFrameData): boolean;
  8468. /**
  8469. * Get the layers currently being presented.
  8470. * @returns the list of VR layers
  8471. */
  8472. getLayers(): VRLayer[];
  8473. /**
  8474. * Return a VRPose containing the future predicted pose of the VRDisplay
  8475. * when the current frame will be presented. The value returned will not
  8476. * change until JavaScript has returned control to the browser.
  8477. *
  8478. * The VRPose will contain the position, orientation, velocity,
  8479. * and acceleration of each of these properties.
  8480. * @returns the pose object
  8481. */
  8482. getPose(): VRPose;
  8483. /**
  8484. * Return the current instantaneous pose of the VRDisplay, with no
  8485. * prediction applied.
  8486. * @returns the current instantaneous pose
  8487. */
  8488. getImmediatePose(): VRPose;
  8489. /**
  8490. * The callback passed to `requestAnimationFrame` will be called
  8491. * any time a new frame should be rendered. When the VRDisplay is
  8492. * presenting the callback will be called at the native refresh
  8493. * rate of the HMD. When not presenting this function acts
  8494. * identically to how window.requestAnimationFrame acts. Content should
  8495. * make no assumptions of frame rate or vsync behavior as the HMD runs
  8496. * asynchronously from other displays and at differing refresh rates.
  8497. * @param callback Define the eaction to run next frame
  8498. * @returns the request handle it
  8499. */
  8500. requestAnimationFrame(callback: FrameRequestCallback): number;
  8501. /**
  8502. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  8503. * Repeat calls while already presenting will update the VRLayers being displayed.
  8504. * @param layers Define the list of layer to present
  8505. * @returns a promise to know when the request has been fulfilled
  8506. */
  8507. requestPresent(layers: VRLayer[]): Promise<void>;
  8508. /**
  8509. * Reset the pose for this display, treating its current position and
  8510. * orientation as the "origin/zero" values. VRPose.position,
  8511. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  8512. * updated when calling resetPose(). This should be called in only
  8513. * sitting-space experiences.
  8514. */
  8515. resetPose(): void;
  8516. /**
  8517. * The VRLayer provided to the VRDisplay will be captured and presented
  8518. * in the HMD. Calling this function has the same effect on the source
  8519. * canvas as any other operation that uses its source image, and canvases
  8520. * created without preserveDrawingBuffer set to true will be cleared.
  8521. * @param pose Define the pose to submit
  8522. */
  8523. submitFrame(pose?: VRPose): void;
  8524. }
  8525. declare var VRDisplay: {
  8526. prototype: VRDisplay;
  8527. new (): VRDisplay;
  8528. };
  8529. interface VRLayer {
  8530. leftBounds?: number[] | Float32Array | null;
  8531. rightBounds?: number[] | Float32Array | null;
  8532. source?: HTMLCanvasElement | null;
  8533. }
  8534. interface VRDisplayCapabilities {
  8535. readonly canPresent: boolean;
  8536. readonly hasExternalDisplay: boolean;
  8537. readonly hasOrientation: boolean;
  8538. readonly hasPosition: boolean;
  8539. readonly maxLayers: number;
  8540. }
  8541. interface VREyeParameters {
  8542. /** @deprecated */
  8543. readonly fieldOfView: VRFieldOfView;
  8544. readonly offset: Float32Array;
  8545. readonly renderHeight: number;
  8546. readonly renderWidth: number;
  8547. }
  8548. interface VRFieldOfView {
  8549. readonly downDegrees: number;
  8550. readonly leftDegrees: number;
  8551. readonly rightDegrees: number;
  8552. readonly upDegrees: number;
  8553. }
  8554. interface VRFrameData {
  8555. readonly leftProjectionMatrix: Float32Array;
  8556. readonly leftViewMatrix: Float32Array;
  8557. readonly pose: VRPose;
  8558. readonly rightProjectionMatrix: Float32Array;
  8559. readonly rightViewMatrix: Float32Array;
  8560. readonly timestamp: number;
  8561. }
  8562. interface VRPose {
  8563. readonly angularAcceleration: Float32Array | null;
  8564. readonly angularVelocity: Float32Array | null;
  8565. readonly linearAcceleration: Float32Array | null;
  8566. readonly linearVelocity: Float32Array | null;
  8567. readonly orientation: Float32Array | null;
  8568. readonly position: Float32Array | null;
  8569. readonly timestamp: number;
  8570. }
  8571. interface VRStageParameters {
  8572. sittingToStandingTransform?: Float32Array;
  8573. sizeX?: number;
  8574. sizeY?: number;
  8575. }
  8576. interface Navigator {
  8577. getVRDisplays(): Promise<VRDisplay[]>;
  8578. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  8579. }
  8580. interface Window {
  8581. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  8582. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  8583. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  8584. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8585. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  8586. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  8587. }
  8588. interface Gamepad {
  8589. readonly displayId: number;
  8590. }
  8591. declare module BABYLON {
  8592. /**
  8593. * Class used to store bounding box information
  8594. */
  8595. class BoundingBox implements ICullable {
  8596. /**
  8597. * Gets the 8 vectors representing the bounding box in local space
  8598. */
  8599. vectors: Vector3[];
  8600. /**
  8601. * Gets the center of the bounding box in local space
  8602. */
  8603. center: Vector3;
  8604. /**
  8605. * Gets the center of the bounding box in world space
  8606. */
  8607. centerWorld: Vector3;
  8608. /**
  8609. * Gets the extend size in local space
  8610. */
  8611. extendSize: Vector3;
  8612. /**
  8613. * Gets the extend size in world space
  8614. */
  8615. extendSizeWorld: Vector3;
  8616. /**
  8617. * Gets the OBB (object bounding box) directions
  8618. */
  8619. directions: Vector3[];
  8620. /**
  8621. * Gets the 8 vectors representing the bounding box in world space
  8622. */
  8623. vectorsWorld: Vector3[];
  8624. /**
  8625. * Gets the minimum vector in world space
  8626. */
  8627. minimumWorld: Vector3;
  8628. /**
  8629. * Gets the maximum vector in world space
  8630. */
  8631. maximumWorld: Vector3;
  8632. /**
  8633. * Gets the minimum vector in local space
  8634. */
  8635. minimum: Vector3;
  8636. /**
  8637. * Gets the maximum vector in local space
  8638. */
  8639. maximum: Vector3;
  8640. private _worldMatrix;
  8641. private static TmpVector3;
  8642. /**
  8643. * @hidden
  8644. */
  8645. _tag: number;
  8646. /**
  8647. * Creates a new bounding box
  8648. * @param min defines the minimum vector (in local space)
  8649. * @param max defines the maximum vector (in local space)
  8650. * @param worldMatrix defines the new world matrix
  8651. */
  8652. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  8653. /**
  8654. * Recreates the entire bounding box from scratch
  8655. * @param min defines the new minimum vector (in local space)
  8656. * @param max defines the new maximum vector (in local space)
  8657. * @param worldMatrix defines the new world matrix
  8658. */
  8659. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8660. /**
  8661. * Scale the current bounding box by applying a scale factor
  8662. * @param factor defines the scale factor to apply
  8663. * @returns the current bounding box
  8664. */
  8665. scale(factor: number): BoundingBox;
  8666. /**
  8667. * Gets the world matrix of the bounding box
  8668. * @returns a matrix
  8669. */
  8670. getWorldMatrix(): Matrix;
  8671. /**
  8672. * Sets the world matrix stored in the bounding box
  8673. * @param matrix defines the matrix to store
  8674. * @returns current bounding box
  8675. */
  8676. setWorldMatrix(matrix: Matrix): BoundingBox;
  8677. /** @hidden */
  8678. _update(world: Matrix): void;
  8679. /**
  8680. * Tests if the bounding box is intersecting the frustum planes
  8681. * @param frustumPlanes defines the frustum planes to test
  8682. * @returns true if there is an intersection
  8683. */
  8684. isInFrustum(frustumPlanes: Plane[]): boolean;
  8685. /**
  8686. * Tests if the bounding box is entirely inside the frustum planes
  8687. * @param frustumPlanes defines the frustum planes to test
  8688. * @returns true if there is an inclusion
  8689. */
  8690. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8691. /**
  8692. * Tests if a point is inside the bounding box
  8693. * @param point defines the point to test
  8694. * @returns true if the point is inside the bounding box
  8695. */
  8696. intersectsPoint(point: Vector3): boolean;
  8697. /**
  8698. * Tests if the bounding box intersects with a bounding sphere
  8699. * @param sphere defines the sphere to test
  8700. * @returns true if there is an intersection
  8701. */
  8702. intersectsSphere(sphere: BoundingSphere): boolean;
  8703. /**
  8704. * Tests if the bounding box intersects with a box defined by a min and max vectors
  8705. * @param min defines the min vector to use
  8706. * @param max defines the max vector to use
  8707. * @returns true if there is an intersection
  8708. */
  8709. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  8710. /**
  8711. * Tests if two bounding boxes are intersections
  8712. * @param box0 defines the first box to test
  8713. * @param box1 defines the second box to test
  8714. * @returns true if there is an intersection
  8715. */
  8716. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  8717. /**
  8718. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  8719. * @param minPoint defines the minimum vector of the bounding box
  8720. * @param maxPoint defines the maximum vector of the bounding box
  8721. * @param sphereCenter defines the sphere center
  8722. * @param sphereRadius defines the sphere radius
  8723. * @returns true if there is an intersection
  8724. */
  8725. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  8726. /**
  8727. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  8728. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8729. * @param frustumPlanes defines the frustum planes to test
  8730. * @return true if there is an inclusion
  8731. */
  8732. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8733. /**
  8734. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  8735. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  8736. * @param frustumPlanes defines the frustum planes to test
  8737. * @return true if there is an intersection
  8738. */
  8739. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  8740. }
  8741. }
  8742. declare module BABYLON {
  8743. /**
  8744. * Interface for cullable objects
  8745. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  8746. */
  8747. interface ICullable {
  8748. /**
  8749. * Checks if the object or part of the object is in the frustum
  8750. * @param frustumPlanes Camera near/planes
  8751. * @returns true if the object is in frustum otherwise false
  8752. */
  8753. isInFrustum(frustumPlanes: Plane[]): boolean;
  8754. /**
  8755. * Checks if a cullable object (mesh...) is in the camera frustum
  8756. * Unlike isInFrustum this cheks the full bounding box
  8757. * @param frustumPlanes Camera near/planes
  8758. * @returns true if the object is in frustum otherwise false
  8759. */
  8760. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8761. }
  8762. /**
  8763. * Info for a bounding data of a mesh
  8764. */
  8765. class BoundingInfo implements ICullable {
  8766. /**
  8767. * Bounding box for the mesh
  8768. */
  8769. boundingBox: BoundingBox;
  8770. /**
  8771. * Bounding sphere for the mesh
  8772. */
  8773. boundingSphere: BoundingSphere;
  8774. private _isLocked;
  8775. /**
  8776. * Constructs bounding info
  8777. * @param minimum min vector of the bounding box/sphere
  8778. * @param maximum max vector of the bounding box/sphere
  8779. * @param worldMatrix defines the new world matrix
  8780. */
  8781. constructor(minimum: Vector3, maximum: Vector3, worldMatrix?: Matrix);
  8782. /**
  8783. * Recreates the entire bounding info from scratch
  8784. * @param min defines the new minimum vector (in local space)
  8785. * @param max defines the new maximum vector (in local space)
  8786. * @param worldMatrix defines the new world matrix
  8787. */
  8788. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8789. /**
  8790. * min vector of the bounding box/sphere
  8791. */
  8792. readonly minimum: Vector3;
  8793. /**
  8794. * max vector of the bounding box/sphere
  8795. */
  8796. readonly maximum: Vector3;
  8797. /**
  8798. * If the info is locked and won't be updated to avoid perf overhead
  8799. */
  8800. isLocked: boolean;
  8801. /**
  8802. * Updates the boudning sphere and box
  8803. * @param world world matrix to be used to update
  8804. */
  8805. update(world: Matrix): void;
  8806. /**
  8807. * Recreate the bounding info to be centered around a specific point given a specific extend.
  8808. * @param center New center of the bounding info
  8809. * @param extend New extend of the bounding info
  8810. * @returns the current bounding info
  8811. */
  8812. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  8813. /**
  8814. * Scale the current bounding info by applying a scale factor
  8815. * @param factor defines the scale factor to apply
  8816. * @returns the current bounding info
  8817. */
  8818. scale(factor: number): BoundingInfo;
  8819. /**
  8820. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  8821. * @param frustumPlanes defines the frustum to test
  8822. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  8823. * @returns true if the bounding info is in the frustum planes
  8824. */
  8825. isInFrustum(frustumPlanes: Plane[], strategy?: number): boolean;
  8826. /**
  8827. * Gets the world distance between the min and max points of the bounding box
  8828. */
  8829. readonly diagonalLength: number;
  8830. /**
  8831. * Checks if a cullable object (mesh...) is in the camera frustum
  8832. * Unlike isInFrustum this cheks the full bounding box
  8833. * @param frustumPlanes Camera near/planes
  8834. * @returns true if the object is in frustum otherwise false
  8835. */
  8836. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  8837. /** @hidden */
  8838. _checkCollision(collider: Collider): boolean;
  8839. /**
  8840. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  8841. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8842. * @param point the point to check intersection with
  8843. * @returns if the point intersects
  8844. */
  8845. intersectsPoint(point: Vector3): boolean;
  8846. /**
  8847. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  8848. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  8849. * @param boundingInfo the bounding info to check intersection with
  8850. * @param precise if the intersection should be done using OBB
  8851. * @returns if the bounding info intersects
  8852. */
  8853. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Class used to store bounding sphere information
  8859. */
  8860. class BoundingSphere {
  8861. /**
  8862. * Gets the center of the bounding sphere in local space
  8863. */
  8864. center: Vector3;
  8865. /**
  8866. * Radius of the bounding sphere in local space
  8867. */
  8868. radius: number;
  8869. /**
  8870. * Gets the center of the bounding sphere in world space
  8871. */
  8872. centerWorld: Vector3;
  8873. /**
  8874. * Radius of the bounding sphere in world space
  8875. */
  8876. radiusWorld: number;
  8877. /**
  8878. * Gets the minimum vector in local space
  8879. */
  8880. minimum: Vector3;
  8881. /**
  8882. * Gets the maximum vector in local space
  8883. */
  8884. maximum: Vector3;
  8885. private static TmpVector3;
  8886. /**
  8887. * Creates a new bounding sphere
  8888. * @param min defines the minimum vector (in local space)
  8889. * @param max defines the maximum vector (in local space)
  8890. * @param worldMatrix defines the new world matrix
  8891. */
  8892. constructor(min: Vector3, max: Vector3, worldMatrix?: Matrix);
  8893. /**
  8894. * Recreates the entire bounding sphere from scratch
  8895. * @param min defines the new minimum vector (in local space)
  8896. * @param max defines the new maximum vector (in local space)
  8897. * @param worldMatrix defines the new world matrix
  8898. */
  8899. reConstruct(min: Vector3, max: Vector3, worldMatrix?: Matrix): void;
  8900. /**
  8901. * Scale the current bounding sphere by applying a scale factor
  8902. * @param factor defines the scale factor to apply
  8903. * @returns the current bounding box
  8904. */
  8905. scale(factor: number): BoundingSphere;
  8906. /** @hidden */
  8907. _update(world: Matrix): void;
  8908. /**
  8909. * Tests if the bounding sphere is intersecting the frustum planes
  8910. * @param frustumPlanes defines the frustum planes to test
  8911. * @returns true if there is an intersection
  8912. */
  8913. isInFrustum(frustumPlanes: Plane[]): boolean;
  8914. /**
  8915. * Tests if a point is inside the bounding sphere
  8916. * @param point defines the point to test
  8917. * @returns true if the point is inside the bounding sphere
  8918. */
  8919. intersectsPoint(point: Vector3): boolean;
  8920. /**
  8921. * Checks if two sphere intersct
  8922. * @param sphere0 sphere 0
  8923. * @param sphere1 sphere 1
  8924. * @returns true if the speres intersect
  8925. */
  8926. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  8927. }
  8928. }
  8929. declare module BABYLON {
  8930. /**
  8931. * Class representing a ray with position and direction
  8932. */
  8933. class Ray {
  8934. /** origin point */
  8935. origin: Vector3;
  8936. /** direction */
  8937. direction: Vector3;
  8938. /** length of the ray */
  8939. length: number;
  8940. private _edge1;
  8941. private _edge2;
  8942. private _pvec;
  8943. private _tvec;
  8944. private _qvec;
  8945. private _tmpRay;
  8946. /**
  8947. * Creates a new ray
  8948. * @param origin origin point
  8949. * @param direction direction
  8950. * @param length length of the ray
  8951. */
  8952. constructor(
  8953. /** origin point */
  8954. origin: Vector3,
  8955. /** direction */
  8956. direction: Vector3,
  8957. /** length of the ray */
  8958. length?: number);
  8959. /**
  8960. * Checks if the ray intersects a box
  8961. * @param minimum bound of the box
  8962. * @param maximum bound of the box
  8963. * @returns if the box was hit
  8964. */
  8965. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  8966. /**
  8967. * Checks if the ray intersects a box
  8968. * @param box the bounding box to check
  8969. * @returns if the box was hit
  8970. */
  8971. intersectsBox(box: BoundingBox): boolean;
  8972. /**
  8973. * If the ray hits a sphere
  8974. * @param sphere the bounding sphere to check
  8975. * @returns true if it hits the sphere
  8976. */
  8977. intersectsSphere(sphere: BoundingSphere): boolean;
  8978. /**
  8979. * If the ray hits a triange
  8980. * @param vertex0 triangle vertex
  8981. * @param vertex1 triangle vertex
  8982. * @param vertex2 triangle vertex
  8983. * @returns intersection information if hit
  8984. */
  8985. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  8986. /**
  8987. * Checks if ray intersects a plane
  8988. * @param plane the plane to check
  8989. * @returns the distance away it was hit
  8990. */
  8991. intersectsPlane(plane: Plane): Nullable<number>;
  8992. /**
  8993. * Checks if ray intersects a mesh
  8994. * @param mesh the mesh to check
  8995. * @param fastCheck if only the bounding box should checked
  8996. * @returns picking info of the intersecton
  8997. */
  8998. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  8999. /**
  9000. * Checks if ray intersects a mesh
  9001. * @param meshes the meshes to check
  9002. * @param fastCheck if only the bounding box should checked
  9003. * @param results array to store result in
  9004. * @returns Array of picking infos
  9005. */
  9006. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9007. private _comparePickingInfo;
  9008. private static smallnum;
  9009. private static rayl;
  9010. /**
  9011. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9012. * @param sega the first point of the segment to test the intersection against
  9013. * @param segb the second point of the segment to test the intersection against
  9014. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9015. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9016. */
  9017. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  9018. /**
  9019. * Update the ray from viewport position
  9020. * @param x position
  9021. * @param y y position
  9022. * @param viewportWidth viewport width
  9023. * @param viewportHeight viewport height
  9024. * @param world world matrix
  9025. * @param view view matrix
  9026. * @param projection projection matrix
  9027. * @returns this ray updated
  9028. */
  9029. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9030. /**
  9031. * Creates a ray with origin and direction of 0,0,0
  9032. * @returns the new ray
  9033. */
  9034. static Zero(): Ray;
  9035. /**
  9036. * Creates a new ray from screen space and viewport
  9037. * @param x position
  9038. * @param y y position
  9039. * @param viewportWidth viewport width
  9040. * @param viewportHeight viewport height
  9041. * @param world world matrix
  9042. * @param view view matrix
  9043. * @param projection projection matrix
  9044. * @returns new ray
  9045. */
  9046. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  9047. /**
  9048. * 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
  9049. * transformed to the given world matrix.
  9050. * @param origin The origin point
  9051. * @param end The end point
  9052. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9053. * @returns the new ray
  9054. */
  9055. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  9056. /**
  9057. * Transforms a ray by a matrix
  9058. * @param ray ray to transform
  9059. * @param matrix matrix to apply
  9060. * @returns the resulting new ray
  9061. */
  9062. static Transform(ray: Ray, matrix: Matrix): Ray;
  9063. /**
  9064. * Transforms a ray by a matrix
  9065. * @param ray ray to transform
  9066. * @param matrix matrix to apply
  9067. * @param result ray to store result in
  9068. */
  9069. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  9070. }
  9071. }
  9072. /**
  9073. * Module Debug contains the (visual) components to debug a scene correctly
  9074. */
  9075. declare module BABYLON.Debug {
  9076. /**
  9077. * The Axes viewer will show 3 axes in a specific point in space
  9078. */
  9079. class AxesViewer {
  9080. private _xline;
  9081. private _yline;
  9082. private _zline;
  9083. private _xmesh;
  9084. private _ymesh;
  9085. private _zmesh;
  9086. /**
  9087. * Gets the hosting scene
  9088. */
  9089. scene: Nullable<Scene>;
  9090. /**
  9091. * Gets or sets a number used to scale line length
  9092. */
  9093. scaleLines: number;
  9094. /**
  9095. * Creates a new AxesViewer
  9096. * @param scene defines the hosting scene
  9097. * @param scaleLines defines a number used to scale line length (1 by default)
  9098. */
  9099. constructor(scene: Scene, scaleLines?: number);
  9100. /**
  9101. * Force the viewer to update
  9102. * @param position defines the position of the viewer
  9103. * @param xaxis defines the x axis of the viewer
  9104. * @param yaxis defines the y axis of the viewer
  9105. * @param zaxis defines the z axis of the viewer
  9106. */
  9107. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9108. /** Releases resources */
  9109. dispose(): void;
  9110. }
  9111. }
  9112. declare module BABYLON.Debug {
  9113. /**
  9114. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9115. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9116. */
  9117. class BoneAxesViewer extends AxesViewer {
  9118. /**
  9119. * Gets or sets the target mesh where to display the axes viewer
  9120. */
  9121. mesh: Nullable<Mesh>;
  9122. /**
  9123. * Gets or sets the target bone where to display the axes viewer
  9124. */
  9125. bone: Nullable<Bone>;
  9126. /** Gets current position */
  9127. pos: Vector3;
  9128. /** Gets direction of X axis */
  9129. xaxis: Vector3;
  9130. /** Gets direction of Y axis */
  9131. yaxis: Vector3;
  9132. /** Gets direction of Z axis */
  9133. zaxis: Vector3;
  9134. /**
  9135. * Creates a new BoneAxesViewer
  9136. * @param scene defines the hosting scene
  9137. * @param bone defines the target bone
  9138. * @param mesh defines the target mesh
  9139. * @param scaleLines defines a scaling factor for line length (1 by default)
  9140. */
  9141. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9142. /**
  9143. * Force the viewer to update
  9144. */
  9145. update(): void;
  9146. /** Releases resources */
  9147. dispose(): void;
  9148. }
  9149. }
  9150. declare module BABYLON {
  9151. interface Scene {
  9152. /**
  9153. * @hidden
  9154. * Backing field
  9155. */
  9156. _debugLayer: DebugLayer;
  9157. /**
  9158. * Gets the debug layer (aka Inspector) associated with the scene
  9159. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9160. */
  9161. debugLayer: DebugLayer;
  9162. }
  9163. /**
  9164. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9165. * what is happening in your scene
  9166. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9167. */
  9168. class DebugLayer {
  9169. /**
  9170. * Define the url to get the inspector script from.
  9171. * By default it uses the babylonjs CDN.
  9172. * @ignoreNaming
  9173. */
  9174. static InspectorURL: string;
  9175. private _scene;
  9176. private _inspector;
  9177. private BJSINSPECTOR;
  9178. /**
  9179. * Observable triggered when a property is changed through the inspector.
  9180. */
  9181. onPropertyChangedObservable: Observable<{
  9182. object: any;
  9183. property: string;
  9184. value: any;
  9185. initialValue: any;
  9186. }>;
  9187. /**
  9188. * Instantiates a new debug layer.
  9189. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9190. * what is happening in your scene
  9191. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9192. * @param scene Defines the scene to inspect
  9193. */
  9194. constructor(scene: Scene);
  9195. /** Creates the inspector window. */
  9196. private _createInspector;
  9197. /**
  9198. * Get if the inspector is visible or not.
  9199. * @returns true if visible otherwise, false
  9200. */
  9201. isVisible(): boolean;
  9202. /**
  9203. * Hide the inspector and close its window.
  9204. */
  9205. hide(): void;
  9206. /**
  9207. *
  9208. * Launch the debugLayer.
  9209. *
  9210. * initialTab:
  9211. * | Value | Tab Name |
  9212. * | --- | --- |
  9213. * | 0 | Scene |
  9214. * | 1 | Console |
  9215. * | 2 | Stats |
  9216. * | 3 | Textures |
  9217. * | 4 | Mesh |
  9218. * | 5 | Light |
  9219. * | 6 | Material |
  9220. * | 7 | GLTF |
  9221. * | 8 | GUI |
  9222. * | 9 | Physics |
  9223. * | 10 | Camera |
  9224. * | 11 | Audio |
  9225. *
  9226. * @param config Define the configuration of the inspector
  9227. */
  9228. show(config?: {
  9229. popup?: boolean;
  9230. initialTab?: number | string;
  9231. parentElement?: HTMLElement;
  9232. newColors?: {
  9233. backgroundColor?: string;
  9234. backgroundColorLighter?: string;
  9235. backgroundColorLighter2?: string;
  9236. backgroundColorLighter3?: string;
  9237. color?: string;
  9238. colorTop?: string;
  9239. colorBot?: string;
  9240. };
  9241. }): void;
  9242. /**
  9243. * Gets the active tab
  9244. * @return the index of the active tab or -1 if the inspector is hidden
  9245. */
  9246. getActiveTab(): number;
  9247. }
  9248. }
  9249. declare module BABYLON.Debug {
  9250. /**
  9251. * Used to show the physics impostor around the specific mesh
  9252. */
  9253. class PhysicsViewer {
  9254. /** @hidden */
  9255. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9256. /** @hidden */
  9257. protected _meshes: Array<Nullable<AbstractMesh>>;
  9258. /** @hidden */
  9259. protected _scene: Nullable<Scene>;
  9260. /** @hidden */
  9261. protected _numMeshes: number;
  9262. /** @hidden */
  9263. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9264. private _renderFunction;
  9265. private _debugBoxMesh;
  9266. private _debugSphereMesh;
  9267. private _debugMaterial;
  9268. /**
  9269. * Creates a new PhysicsViewer
  9270. * @param scene defines the hosting scene
  9271. */
  9272. constructor(scene: Scene);
  9273. /** @hidden */
  9274. protected _updateDebugMeshes(): void;
  9275. /**
  9276. * Renders a specified physic impostor
  9277. * @param impostor defines the impostor to render
  9278. */
  9279. showImpostor(impostor: PhysicsImpostor): void;
  9280. /**
  9281. * Hides a specified physic impostor
  9282. * @param impostor defines the impostor to hide
  9283. */
  9284. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9285. private _getDebugMaterial;
  9286. private _getDebugBoxMesh;
  9287. private _getDebugSphereMesh;
  9288. private _getDebugMesh;
  9289. /** Releases all resources */
  9290. dispose(): void;
  9291. }
  9292. }
  9293. declare module BABYLON {
  9294. /**
  9295. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9296. * in order to better appreciate the issue one might have.
  9297. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9298. */
  9299. class RayHelper {
  9300. /**
  9301. * Defines the ray we are currently tryin to visualize.
  9302. */
  9303. ray: Nullable<Ray>;
  9304. private _renderPoints;
  9305. private _renderLine;
  9306. private _renderFunction;
  9307. private _scene;
  9308. private _updateToMeshFunction;
  9309. private _attachedToMesh;
  9310. private _meshSpaceDirection;
  9311. private _meshSpaceOrigin;
  9312. /**
  9313. * Helper function to create a colored helper in a scene in one line.
  9314. * @param ray Defines the ray we are currently tryin to visualize
  9315. * @param scene Defines the scene the ray is used in
  9316. * @param color Defines the color we want to see the ray in
  9317. * @returns The newly created ray helper.
  9318. */
  9319. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9320. /**
  9321. * Instantiate a new ray helper.
  9322. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9323. * in order to better appreciate the issue one might have.
  9324. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9325. * @param ray Defines the ray we are currently tryin to visualize
  9326. */
  9327. constructor(ray: Ray);
  9328. /**
  9329. * Shows the ray we are willing to debug.
  9330. * @param scene Defines the scene the ray needs to be rendered in
  9331. * @param color Defines the color the ray needs to be rendered in
  9332. */
  9333. show(scene: Scene, color?: Color3): void;
  9334. /**
  9335. * Hides the ray we are debugging.
  9336. */
  9337. hide(): void;
  9338. private _render;
  9339. /**
  9340. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9341. * @param mesh Defines the mesh we want the helper attached to
  9342. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9343. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9344. * @param length Defines the length of the ray
  9345. */
  9346. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9347. /**
  9348. * Detach the ray helper from the mesh it has previously been attached to.
  9349. */
  9350. detachFromMesh(): void;
  9351. private _updateToMesh;
  9352. /**
  9353. * Dispose the helper and release its associated resources.
  9354. */
  9355. dispose(): void;
  9356. }
  9357. }
  9358. declare module BABYLON.Debug {
  9359. /**
  9360. * Class used to render a debug view of a given skeleton
  9361. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9362. */
  9363. class SkeletonViewer {
  9364. /** defines the skeleton to render */
  9365. skeleton: Skeleton;
  9366. /** defines the mesh attached to the skeleton */
  9367. mesh: AbstractMesh;
  9368. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9369. autoUpdateBonesMatrices: boolean;
  9370. /** defines the rendering group id to use with the viewer */
  9371. renderingGroupId: number;
  9372. /** Gets or sets the color used to render the skeleton */
  9373. color: Color3;
  9374. private _scene;
  9375. private _debugLines;
  9376. private _debugMesh;
  9377. private _isEnabled;
  9378. private _renderFunction;
  9379. /**
  9380. * Creates a new SkeletonViewer
  9381. * @param skeleton defines the skeleton to render
  9382. * @param mesh defines the mesh attached to the skeleton
  9383. * @param scene defines the hosting scene
  9384. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9385. * @param renderingGroupId defines the rendering group id to use with the viewer
  9386. */
  9387. constructor(
  9388. /** defines the skeleton to render */
  9389. skeleton: Skeleton,
  9390. /** defines the mesh attached to the skeleton */
  9391. mesh: AbstractMesh, scene: Scene,
  9392. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9393. autoUpdateBonesMatrices?: boolean,
  9394. /** defines the rendering group id to use with the viewer */
  9395. renderingGroupId?: number);
  9396. /** Gets or sets a boolean indicating if the viewer is enabled */
  9397. isEnabled: boolean;
  9398. private _getBonePosition;
  9399. private _getLinesForBonesWithLength;
  9400. private _getLinesForBonesNoLength;
  9401. /** Update the viewer to sync with current skeleton state */
  9402. update(): void;
  9403. /** Release associated resources */
  9404. dispose(): void;
  9405. }
  9406. }
  9407. declare module BABYLON {
  9408. /** @hidden */
  9409. class Collider {
  9410. /** Define if a collision was found */
  9411. collisionFound: boolean;
  9412. /**
  9413. * Define last intersection point in local space
  9414. */
  9415. intersectionPoint: Vector3;
  9416. /**
  9417. * Define last collided mesh
  9418. */
  9419. collidedMesh: Nullable<AbstractMesh>;
  9420. private _collisionPoint;
  9421. private _planeIntersectionPoint;
  9422. private _tempVector;
  9423. private _tempVector2;
  9424. private _tempVector3;
  9425. private _tempVector4;
  9426. private _edge;
  9427. private _baseToVertex;
  9428. private _destinationPoint;
  9429. private _slidePlaneNormal;
  9430. private _displacementVector;
  9431. /** @hidden */
  9432. _radius: Vector3;
  9433. /** @hidden */
  9434. _retry: number;
  9435. private _velocity;
  9436. private _basePoint;
  9437. private _epsilon;
  9438. /** @hidden */
  9439. _velocityWorldLength: number;
  9440. /** @hidden */
  9441. _basePointWorld: Vector3;
  9442. private _velocityWorld;
  9443. private _normalizedVelocity;
  9444. /** @hidden */
  9445. _initialVelocity: Vector3;
  9446. /** @hidden */
  9447. _initialPosition: Vector3;
  9448. private _nearestDistance;
  9449. private _collisionMask;
  9450. collisionMask: number;
  9451. /**
  9452. * Gets the plane normal used to compute the sliding response (in local space)
  9453. */
  9454. readonly slidePlaneNormal: Vector3;
  9455. /** @hidden */
  9456. _initialize(source: Vector3, dir: Vector3, e: number): void;
  9457. /** @hidden */
  9458. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  9459. /** @hidden */
  9460. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  9461. /** @hidden */
  9462. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  9463. /** @hidden */
  9464. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  9465. /** @hidden */
  9466. _getResponse(pos: Vector3, vel: Vector3): void;
  9467. }
  9468. }
  9469. declare module BABYLON {
  9470. /** @hidden */
  9471. var CollisionWorker: string;
  9472. /** @hidden */
  9473. interface ICollisionCoordinator {
  9474. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9475. init(scene: Scene): void;
  9476. destroy(): void;
  9477. onMeshAdded(mesh: AbstractMesh): void;
  9478. onMeshUpdated(mesh: AbstractMesh): void;
  9479. onMeshRemoved(mesh: AbstractMesh): void;
  9480. onGeometryAdded(geometry: Geometry): void;
  9481. onGeometryUpdated(geometry: Geometry): void;
  9482. onGeometryDeleted(geometry: Geometry): void;
  9483. }
  9484. /** @hidden */
  9485. interface SerializedMesh {
  9486. id: string;
  9487. name: string;
  9488. uniqueId: number;
  9489. geometryId: Nullable<string>;
  9490. sphereCenter: Array<number>;
  9491. sphereRadius: number;
  9492. boxMinimum: Array<number>;
  9493. boxMaximum: Array<number>;
  9494. worldMatrixFromCache: any;
  9495. subMeshes: Array<SerializedSubMesh>;
  9496. checkCollisions: boolean;
  9497. }
  9498. /** @hidden */
  9499. interface SerializedSubMesh {
  9500. position: number;
  9501. verticesStart: number;
  9502. verticesCount: number;
  9503. indexStart: number;
  9504. indexCount: number;
  9505. hasMaterial: boolean;
  9506. sphereCenter: Array<number>;
  9507. sphereRadius: number;
  9508. boxMinimum: Array<number>;
  9509. boxMaximum: Array<number>;
  9510. }
  9511. /**
  9512. * Interface describing the value associated with a geometry.
  9513. * @hidden
  9514. */
  9515. interface SerializedGeometry {
  9516. /**
  9517. * Defines the unique ID of the geometry
  9518. */
  9519. id: string;
  9520. /**
  9521. * Defines the array containing the positions
  9522. */
  9523. positions: Float32Array;
  9524. /**
  9525. * Defines the array containing the indices
  9526. */
  9527. indices: Uint32Array;
  9528. /**
  9529. * Defines the array containing the normals
  9530. */
  9531. normals: Float32Array;
  9532. }
  9533. /** @hidden */
  9534. interface BabylonMessage {
  9535. taskType: WorkerTaskType;
  9536. payload: InitPayload | CollidePayload | UpdatePayload;
  9537. }
  9538. /** @hidden */
  9539. interface SerializedColliderToWorker {
  9540. position: Array<number>;
  9541. velocity: Array<number>;
  9542. radius: Array<number>;
  9543. }
  9544. /** Defines supported task for worker process */
  9545. enum WorkerTaskType {
  9546. /** Initialization */
  9547. INIT = 0,
  9548. /** Update of geometry */
  9549. UPDATE = 1,
  9550. /** Evaluate collision */
  9551. COLLIDE = 2
  9552. }
  9553. /** @hidden */
  9554. interface WorkerReply {
  9555. error: WorkerReplyType;
  9556. taskType: WorkerTaskType;
  9557. payload?: any;
  9558. }
  9559. /** @hidden */
  9560. interface CollisionReplyPayload {
  9561. newPosition: Array<number>;
  9562. collisionId: number;
  9563. collidedMeshUniqueId: number;
  9564. }
  9565. /** @hidden */
  9566. interface InitPayload {
  9567. }
  9568. /** @hidden */
  9569. interface CollidePayload {
  9570. collisionId: number;
  9571. collider: SerializedColliderToWorker;
  9572. maximumRetry: number;
  9573. excludedMeshUniqueId: Nullable<number>;
  9574. }
  9575. /** @hidden */
  9576. interface UpdatePayload {
  9577. updatedMeshes: {
  9578. [n: number]: SerializedMesh;
  9579. };
  9580. updatedGeometries: {
  9581. [s: string]: SerializedGeometry;
  9582. };
  9583. removedMeshes: Array<number>;
  9584. removedGeometries: Array<string>;
  9585. }
  9586. /** Defines kind of replies returned by worker */
  9587. enum WorkerReplyType {
  9588. /** Success */
  9589. SUCCESS = 0,
  9590. /** Unkown error */
  9591. UNKNOWN_ERROR = 1
  9592. }
  9593. /** @hidden */
  9594. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  9595. private _scene;
  9596. private _scaledPosition;
  9597. private _scaledVelocity;
  9598. private _collisionsCallbackArray;
  9599. private _init;
  9600. private _runningUpdated;
  9601. private _worker;
  9602. private _addUpdateMeshesList;
  9603. private _addUpdateGeometriesList;
  9604. private _toRemoveMeshesArray;
  9605. private _toRemoveGeometryArray;
  9606. constructor();
  9607. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  9608. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  9609. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9610. init(scene: Scene): void;
  9611. destroy(): void;
  9612. onMeshAdded(mesh: AbstractMesh): void;
  9613. onMeshUpdated: (transformNode: TransformNode) => void;
  9614. onMeshRemoved(mesh: AbstractMesh): void;
  9615. onGeometryAdded(geometry: Geometry): void;
  9616. onGeometryUpdated: (geometry: Geometry) => void;
  9617. onGeometryDeleted(geometry: Geometry): void;
  9618. private _afterRender;
  9619. private _onMessageFromWorker;
  9620. }
  9621. /** @hidden */
  9622. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  9623. private _scene;
  9624. private _scaledPosition;
  9625. private _scaledVelocity;
  9626. private _finalPosition;
  9627. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  9628. init(scene: Scene): void;
  9629. destroy(): void;
  9630. onMeshAdded(mesh: AbstractMesh): void;
  9631. onMeshUpdated(mesh: AbstractMesh): void;
  9632. onMeshRemoved(mesh: AbstractMesh): void;
  9633. onGeometryAdded(geometry: Geometry): void;
  9634. onGeometryUpdated(geometry: Geometry): void;
  9635. onGeometryDeleted(geometry: Geometry): void;
  9636. private _collideWithWorld;
  9637. }
  9638. }
  9639. declare function importScripts(...urls: string[]): void;
  9640. declare const safePostMessage: any;
  9641. declare module BABYLON {
  9642. /** @hidden */
  9643. var WorkerIncluded: boolean;
  9644. /** @hidden */
  9645. class CollisionCache {
  9646. private _meshes;
  9647. private _geometries;
  9648. getMeshes(): {
  9649. [n: number]: SerializedMesh;
  9650. };
  9651. getGeometries(): {
  9652. [s: number]: SerializedGeometry;
  9653. };
  9654. getMesh(id: any): SerializedMesh;
  9655. addMesh(mesh: SerializedMesh): void;
  9656. removeMesh(uniqueId: number): void;
  9657. getGeometry(id: string): SerializedGeometry;
  9658. addGeometry(geometry: SerializedGeometry): void;
  9659. removeGeometry(id: string): void;
  9660. }
  9661. /** @hidden */
  9662. class CollideWorker {
  9663. collider: Collider;
  9664. private _collisionCache;
  9665. private finalPosition;
  9666. private collisionsScalingMatrix;
  9667. private collisionTranformationMatrix;
  9668. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  9669. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  9670. private checkCollision;
  9671. private processCollisionsForSubMeshes;
  9672. private collideForSubMesh;
  9673. private checkSubmeshCollision;
  9674. }
  9675. /** @hidden */
  9676. interface ICollisionDetector {
  9677. onInit(payload: InitPayload): void;
  9678. onUpdate(payload: UpdatePayload): void;
  9679. onCollision(payload: CollidePayload): void;
  9680. }
  9681. /** @hidden */
  9682. class CollisionDetectorTransferable implements ICollisionDetector {
  9683. private _collisionCache;
  9684. onInit(payload: InitPayload): void;
  9685. onUpdate(payload: UpdatePayload): void;
  9686. onCollision(payload: CollidePayload): void;
  9687. }
  9688. }
  9689. declare module BABYLON {
  9690. /**
  9691. * @hidden
  9692. */
  9693. class IntersectionInfo {
  9694. bu: Nullable<number>;
  9695. bv: Nullable<number>;
  9696. distance: number;
  9697. faceId: number;
  9698. subMeshId: number;
  9699. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  9700. }
  9701. /**
  9702. * Information about the result of picking within a scene
  9703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  9704. */
  9705. class PickingInfo {
  9706. /**
  9707. * If the pick collided with an object
  9708. */
  9709. hit: boolean;
  9710. /**
  9711. * Distance away where the pick collided
  9712. */
  9713. distance: number;
  9714. /**
  9715. * The location of pick collision
  9716. */
  9717. pickedPoint: Nullable<Vector3>;
  9718. /**
  9719. * The mesh corresponding the the pick collision
  9720. */
  9721. pickedMesh: Nullable<AbstractMesh>;
  9722. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  9723. bu: number;
  9724. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  9725. bv: number;
  9726. /** The id of the face on the mesh that was picked */
  9727. faceId: number;
  9728. /** Id of the the submesh that was picked */
  9729. subMeshId: number;
  9730. /** If a sprite was picked, this will be the sprite the pick collided with */
  9731. pickedSprite: Nullable<Sprite>;
  9732. /**
  9733. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  9734. */
  9735. originMesh: Nullable<AbstractMesh>;
  9736. /**
  9737. * The ray that was used to perform the picking.
  9738. */
  9739. ray: Nullable<Ray>;
  9740. /**
  9741. * Gets the normal correspodning to the face the pick collided with
  9742. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  9743. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  9744. * @returns The normal correspodning to the face the pick collided with
  9745. */
  9746. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  9747. /**
  9748. * Gets the texture coordinates of where the pick occured
  9749. * @returns the vector containing the coordnates of the texture
  9750. */
  9751. getTextureCoordinates(): Nullable<Vector2>;
  9752. }
  9753. }
  9754. declare module BABYLON {
  9755. /**
  9756. * Interface for attribute information associated with buffer instanciation
  9757. */
  9758. class InstancingAttributeInfo {
  9759. /**
  9760. * Index/offset of the attribute in the vertex shader
  9761. */
  9762. index: number;
  9763. /**
  9764. * size of the attribute, 1, 2, 3 or 4
  9765. */
  9766. attributeSize: number;
  9767. /**
  9768. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9769. * default is FLOAT
  9770. */
  9771. attribyteType: number;
  9772. /**
  9773. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9774. */
  9775. normalized: boolean;
  9776. /**
  9777. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9778. */
  9779. offset: number;
  9780. /**
  9781. * Name of the GLSL attribute, for debugging purpose only
  9782. */
  9783. attributeName: string;
  9784. }
  9785. /**
  9786. * Define options used to create a render target texture
  9787. */
  9788. class RenderTargetCreationOptions {
  9789. /**
  9790. * Specifies is mipmaps must be generated
  9791. */
  9792. generateMipMaps?: boolean;
  9793. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9794. generateDepthBuffer?: boolean;
  9795. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9796. generateStencilBuffer?: boolean;
  9797. /** Defines texture type (int by default) */
  9798. type?: number;
  9799. /** Defines sampling mode (trilinear by default) */
  9800. samplingMode?: number;
  9801. /** Defines format (RGBA by default) */
  9802. format?: number;
  9803. }
  9804. /**
  9805. * Define options used to create a depth texture
  9806. */
  9807. class DepthTextureCreationOptions {
  9808. /** Specifies whether or not a stencil should be allocated in the texture */
  9809. generateStencil?: boolean;
  9810. /** Specifies whether or not bilinear filtering is enable on the texture */
  9811. bilinearFiltering?: boolean;
  9812. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9813. comparisonFunction?: number;
  9814. /** Specifies if the created texture is a cube texture */
  9815. isCube?: boolean;
  9816. }
  9817. /**
  9818. * Class used to describe the capabilities of the engine relatively to the current browser
  9819. */
  9820. class EngineCapabilities {
  9821. /** Maximum textures units per fragment shader */
  9822. maxTexturesImageUnits: number;
  9823. /** Maximum texture units per vertex shader */
  9824. maxVertexTextureImageUnits: number;
  9825. /** Maximum textures units in the entire pipeline */
  9826. maxCombinedTexturesImageUnits: number;
  9827. /** Maximum texture size */
  9828. maxTextureSize: number;
  9829. /** Maximum cube texture size */
  9830. maxCubemapTextureSize: number;
  9831. /** Maximum render texture size */
  9832. maxRenderTextureSize: number;
  9833. /** Maximum number of vertex attributes */
  9834. maxVertexAttribs: number;
  9835. /** Maximum number of varyings */
  9836. maxVaryingVectors: number;
  9837. /** Maximum number of uniforms per vertex shader */
  9838. maxVertexUniformVectors: number;
  9839. /** Maximum number of uniforms per fragment shader */
  9840. maxFragmentUniformVectors: number;
  9841. /** Defines if standard derivates (dx/dy) are supported */
  9842. standardDerivatives: boolean;
  9843. /** Defines if s3tc texture compression is supported */
  9844. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9845. /** Defines if pvrtc texture compression is supported */
  9846. pvrtc: any;
  9847. /** Defines if etc1 texture compression is supported */
  9848. etc1: any;
  9849. /** Defines if etc2 texture compression is supported */
  9850. etc2: any;
  9851. /** Defines if astc texture compression is supported */
  9852. astc: any;
  9853. /** Defines if float textures are supported */
  9854. textureFloat: boolean;
  9855. /** Defines if vertex array objects are supported */
  9856. vertexArrayObject: boolean;
  9857. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9858. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9859. /** Gets the maximum level of anisotropy supported */
  9860. maxAnisotropy: number;
  9861. /** Defines if instancing is supported */
  9862. instancedArrays: boolean;
  9863. /** Defines if 32 bits indices are supported */
  9864. uintIndices: boolean;
  9865. /** Defines if high precision shaders are supported */
  9866. highPrecisionShaderSupported: boolean;
  9867. /** Defines if depth reading in the fragment shader is supported */
  9868. fragmentDepthSupported: boolean;
  9869. /** Defines if float texture linear filtering is supported*/
  9870. textureFloatLinearFiltering: boolean;
  9871. /** Defines if rendering to float textures is supported */
  9872. textureFloatRender: boolean;
  9873. /** Defines if half float textures are supported*/
  9874. textureHalfFloat: boolean;
  9875. /** Defines if half float texture linear filtering is supported*/
  9876. textureHalfFloatLinearFiltering: boolean;
  9877. /** Defines if rendering to half float textures is supported */
  9878. textureHalfFloatRender: boolean;
  9879. /** Defines if textureLOD shader command is supported */
  9880. textureLOD: boolean;
  9881. /** Defines if draw buffers extension is supported */
  9882. drawBuffersExtension: boolean;
  9883. /** Defines if depth textures are supported */
  9884. depthTextureExtension: boolean;
  9885. /** Defines if float color buffer are supported */
  9886. colorBufferFloat: boolean;
  9887. /** Gets disjoint timer query extension (null if not supported) */
  9888. timerQuery: EXT_disjoint_timer_query;
  9889. /** Defines if timestamp can be used with timer query */
  9890. canUseTimestampForTimerQuery: boolean;
  9891. /** Function used to let the system compiles shaders in background */
  9892. parallelShaderCompile: {
  9893. MAX_SHADER_COMPILER_THREADS_KHR: number;
  9894. maxShaderCompilerThreadsKHR: (thread: number) => void;
  9895. COMPLETION_STATUS_KHR: number;
  9896. };
  9897. }
  9898. /** Interface defining initialization parameters for Engine class */
  9899. interface EngineOptions extends WebGLContextAttributes {
  9900. /**
  9901. * Defines if the engine should no exceed a specified device ratio
  9902. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  9903. */
  9904. limitDeviceRatio?: number;
  9905. /**
  9906. * Defines if webvr should be enabled automatically
  9907. * @see http://doc.babylonjs.com/how_to/webvr_camera
  9908. */
  9909. autoEnableWebVR?: boolean;
  9910. /**
  9911. * Defines if webgl2 should be turned off even if supported
  9912. * @see http://doc.babylonjs.com/features/webgl2
  9913. */
  9914. disableWebGL2Support?: boolean;
  9915. /**
  9916. * Defines if webaudio should be initialized as well
  9917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  9918. */
  9919. audioEngine?: boolean;
  9920. /**
  9921. * Defines if animations should run using a deterministic lock step
  9922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  9923. */
  9924. deterministicLockstep?: boolean;
  9925. /** Defines the maximum steps to use with deterministic lock step mode */
  9926. lockstepMaxSteps?: number;
  9927. /**
  9928. * Defines that engine should ignore context lost events
  9929. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  9930. */
  9931. doNotHandleContextLost?: boolean;
  9932. }
  9933. /**
  9934. * Defines the interface used by display changed events
  9935. */
  9936. interface IDisplayChangedEventArgs {
  9937. /** Gets the vrDisplay object (if any) */
  9938. vrDisplay: Nullable<any>;
  9939. /** Gets a boolean indicating if webVR is supported */
  9940. vrSupported: boolean;
  9941. }
  9942. /**
  9943. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  9944. */
  9945. class Engine {
  9946. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  9947. static ExceptionList: ({
  9948. key: string;
  9949. capture: string;
  9950. captureConstraint: number;
  9951. targets: string[];
  9952. } | {
  9953. key: string;
  9954. capture: null;
  9955. captureConstraint: null;
  9956. targets: string[];
  9957. })[];
  9958. /** Gets the list of created engines */
  9959. static Instances: Engine[];
  9960. /**
  9961. * Gets the latest created engine
  9962. */
  9963. static readonly LastCreatedEngine: Nullable<Engine>;
  9964. /**
  9965. * Gets the latest created scene
  9966. */
  9967. static readonly LastCreatedScene: Nullable<Scene>;
  9968. /**
  9969. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  9970. * @param flag defines which part of the materials must be marked as dirty
  9971. * @param predicate defines a predicate used to filter which materials should be affected
  9972. */
  9973. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  9974. /**
  9975. * Hidden
  9976. */
  9977. static _TextureLoaders: IInternalTextureLoader[];
  9978. /** Defines that alpha blending is disabled */
  9979. static readonly ALPHA_DISABLE: number;
  9980. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  9981. static readonly ALPHA_ADD: number;
  9982. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  9983. static readonly ALPHA_COMBINE: number;
  9984. /** Defines that alpha blending to DEST - SRC * DEST */
  9985. static readonly ALPHA_SUBTRACT: number;
  9986. /** Defines that alpha blending to SRC * DEST */
  9987. static readonly ALPHA_MULTIPLY: number;
  9988. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  9989. static readonly ALPHA_MAXIMIZED: number;
  9990. /** Defines that alpha blending to SRC + DEST */
  9991. static readonly ALPHA_ONEONE: number;
  9992. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  9993. static readonly ALPHA_PREMULTIPLIED: number;
  9994. /**
  9995. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  9996. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  9997. */
  9998. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  9999. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10000. static readonly ALPHA_INTERPOLATE: number;
  10001. /**
  10002. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10003. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10004. */
  10005. static readonly ALPHA_SCREENMODE: number;
  10006. /** Defines that the ressource is not delayed*/
  10007. static readonly DELAYLOADSTATE_NONE: number;
  10008. /** Defines that the ressource was successfully delay loaded */
  10009. static readonly DELAYLOADSTATE_LOADED: number;
  10010. /** Defines that the ressource is currently delay loading */
  10011. static readonly DELAYLOADSTATE_LOADING: number;
  10012. /** Defines that the ressource is delayed and has not started loading */
  10013. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10014. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10015. static readonly NEVER: number;
  10016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  10017. static readonly ALWAYS: number;
  10018. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10019. static readonly LESS: number;
  10020. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10021. static readonly EQUAL: number;
  10022. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  10023. static readonly LEQUAL: number;
  10024. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10025. static readonly GREATER: number;
  10026. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  10027. static readonly GEQUAL: number;
  10028. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  10029. static readonly NOTEQUAL: number;
  10030. /** Passed to stencilOperation to specify that stencil value must be kept */
  10031. static readonly KEEP: number;
  10032. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10033. static readonly REPLACE: number;
  10034. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10035. static readonly INCR: number;
  10036. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10037. static readonly DECR: number;
  10038. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10039. static readonly INVERT: number;
  10040. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10041. static readonly INCR_WRAP: number;
  10042. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10043. static readonly DECR_WRAP: number;
  10044. /** Texture is not repeating outside of 0..1 UVs */
  10045. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10046. /** Texture is repeating outside of 0..1 UVs */
  10047. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10048. /** Texture is repeating and mirrored */
  10049. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10050. /** ALPHA */
  10051. static readonly TEXTUREFORMAT_ALPHA: number;
  10052. /** LUMINANCE */
  10053. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10054. /** LUMINANCE_ALPHA */
  10055. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10056. /** RGB */
  10057. static readonly TEXTUREFORMAT_RGB: number;
  10058. /** RGBA */
  10059. static readonly TEXTUREFORMAT_RGBA: number;
  10060. /** RED */
  10061. static readonly TEXTUREFORMAT_RED: number;
  10062. /** RED (2nd reference) */
  10063. static readonly TEXTUREFORMAT_R: number;
  10064. /** RG */
  10065. static readonly TEXTUREFORMAT_RG: number;
  10066. /** RED_INTEGER */
  10067. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10068. /** RED_INTEGER (2nd reference) */
  10069. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10070. /** RG_INTEGER */
  10071. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10072. /** RGB_INTEGER */
  10073. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10074. /** RGBA_INTEGER */
  10075. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10076. /** UNSIGNED_BYTE */
  10077. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10078. /** UNSIGNED_BYTE (2nd reference) */
  10079. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10080. /** FLOAT */
  10081. static readonly TEXTURETYPE_FLOAT: number;
  10082. /** HALF_FLOAT */
  10083. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10084. /** BYTE */
  10085. static readonly TEXTURETYPE_BYTE: number;
  10086. /** SHORT */
  10087. static readonly TEXTURETYPE_SHORT: number;
  10088. /** UNSIGNED_SHORT */
  10089. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10090. /** INT */
  10091. static readonly TEXTURETYPE_INT: number;
  10092. /** UNSIGNED_INT */
  10093. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10094. /** UNSIGNED_SHORT_4_4_4_4 */
  10095. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10096. /** UNSIGNED_SHORT_5_5_5_1 */
  10097. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10098. /** UNSIGNED_SHORT_5_6_5 */
  10099. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10100. /** UNSIGNED_INT_2_10_10_10_REV */
  10101. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10102. /** UNSIGNED_INT_24_8 */
  10103. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10104. /** UNSIGNED_INT_10F_11F_11F_REV */
  10105. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10106. /** UNSIGNED_INT_5_9_9_9_REV */
  10107. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10108. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10109. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10110. /** nearest is mag = nearest and min = nearest and mip = linear */
  10111. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10112. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10113. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10114. /** Trilinear is mag = linear and min = linear and mip = linear */
  10115. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10116. /** nearest is mag = nearest and min = nearest and mip = linear */
  10117. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10119. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10120. /** Trilinear is mag = linear and min = linear and mip = linear */
  10121. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10122. /** mag = nearest and min = nearest and mip = nearest */
  10123. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10124. /** mag = nearest and min = linear and mip = nearest */
  10125. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10126. /** mag = nearest and min = linear and mip = linear */
  10127. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10128. /** mag = nearest and min = linear and mip = none */
  10129. static readonly TEXTURE_NEAREST_LINEAR: number;
  10130. /** mag = nearest and min = nearest and mip = none */
  10131. static readonly TEXTURE_NEAREST_NEAREST: number;
  10132. /** mag = linear and min = nearest and mip = nearest */
  10133. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10134. /** mag = linear and min = nearest and mip = linear */
  10135. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10136. /** mag = linear and min = linear and mip = none */
  10137. static readonly TEXTURE_LINEAR_LINEAR: number;
  10138. /** mag = linear and min = nearest and mip = none */
  10139. static readonly TEXTURE_LINEAR_NEAREST: number;
  10140. /** Explicit coordinates mode */
  10141. static readonly TEXTURE_EXPLICIT_MODE: number;
  10142. /** Spherical coordinates mode */
  10143. static readonly TEXTURE_SPHERICAL_MODE: number;
  10144. /** Planar coordinates mode */
  10145. static readonly TEXTURE_PLANAR_MODE: number;
  10146. /** Cubic coordinates mode */
  10147. static readonly TEXTURE_CUBIC_MODE: number;
  10148. /** Projection coordinates mode */
  10149. static readonly TEXTURE_PROJECTION_MODE: number;
  10150. /** Skybox coordinates mode */
  10151. static readonly TEXTURE_SKYBOX_MODE: number;
  10152. /** Inverse Cubic coordinates mode */
  10153. static readonly TEXTURE_INVCUBIC_MODE: number;
  10154. /** Equirectangular coordinates mode */
  10155. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10156. /** Equirectangular Fixed coordinates mode */
  10157. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10158. /** Equirectangular Fixed Mirrored coordinates mode */
  10159. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10160. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10161. static readonly SCALEMODE_FLOOR: number;
  10162. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10163. static readonly SCALEMODE_NEAREST: number;
  10164. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10165. static readonly SCALEMODE_CEILING: number;
  10166. /**
  10167. * Returns the current version of the framework
  10168. */
  10169. static readonly Version: string;
  10170. /**
  10171. * Returns a string describing the current engine
  10172. */
  10173. readonly description: string;
  10174. /**
  10175. * Gets or sets the epsilon value used by collision engine
  10176. */
  10177. static CollisionsEpsilon: number;
  10178. /**
  10179. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10180. */
  10181. static CodeRepository: string;
  10182. /**
  10183. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10184. */
  10185. static ShadersRepository: string;
  10186. /**
  10187. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10188. */
  10189. forcePOTTextures: boolean;
  10190. /**
  10191. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10192. */
  10193. isFullscreen: boolean;
  10194. /**
  10195. * Gets a boolean indicating if the pointer is currently locked
  10196. */
  10197. isPointerLock: boolean;
  10198. /**
  10199. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10200. */
  10201. cullBackFaces: boolean;
  10202. /**
  10203. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10204. */
  10205. renderEvenInBackground: boolean;
  10206. /**
  10207. * Gets or sets a boolean indicating that cache can be kept between frames
  10208. */
  10209. preventCacheWipeBetweenFrames: boolean;
  10210. /**
  10211. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10212. **/
  10213. enableOfflineSupport: boolean;
  10214. /**
  10215. * 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)
  10216. **/
  10217. disableManifestCheck: boolean;
  10218. /**
  10219. * Gets the list of created scenes
  10220. */
  10221. scenes: Scene[];
  10222. /**
  10223. * Gets the list of created postprocesses
  10224. */
  10225. postProcesses: PostProcess[];
  10226. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10227. validateShaderPrograms: boolean;
  10228. /**
  10229. * Observable event triggered each time the rendering canvas is resized
  10230. */
  10231. onResizeObservable: Observable<Engine>;
  10232. /**
  10233. * Observable event triggered each time the canvas loses focus
  10234. */
  10235. onCanvasBlurObservable: Observable<Engine>;
  10236. /**
  10237. * Observable event triggered each time the canvas gains focus
  10238. */
  10239. onCanvasFocusObservable: Observable<Engine>;
  10240. /**
  10241. * Observable event triggered each time the canvas receives pointerout event
  10242. */
  10243. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10244. /**
  10245. * Observable event triggered before each texture is initialized
  10246. */
  10247. onBeforeTextureInitObservable: Observable<Texture>;
  10248. private _vrDisplay;
  10249. private _vrSupported;
  10250. private _oldSize;
  10251. private _oldHardwareScaleFactor;
  10252. private _vrExclusivePointerMode;
  10253. private _webVRInitPromise;
  10254. /**
  10255. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10256. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10257. */
  10258. readonly isInVRExclusivePointerMode: boolean;
  10259. /**
  10260. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10261. */
  10262. disableUniformBuffers: boolean;
  10263. /** @hidden */
  10264. _uniformBuffers: UniformBuffer[];
  10265. /**
  10266. * Gets a boolean indicating that the engine supports uniform buffers
  10267. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10268. */
  10269. readonly supportsUniformBuffers: boolean;
  10270. /**
  10271. * Observable raised when the engine begins a new frame
  10272. */
  10273. onBeginFrameObservable: Observable<Engine>;
  10274. /**
  10275. * If set, will be used to request the next animation frame for the render loop
  10276. */
  10277. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10278. /**
  10279. * Observable raised when the engine ends the current frame
  10280. */
  10281. onEndFrameObservable: Observable<Engine>;
  10282. /**
  10283. * Observable raised when the engine is about to compile a shader
  10284. */
  10285. onBeforeShaderCompilationObservable: Observable<Engine>;
  10286. /**
  10287. * Observable raised when the engine has jsut compiled a shader
  10288. */
  10289. onAfterShaderCompilationObservable: Observable<Engine>;
  10290. /** @hidden */
  10291. _gl: WebGLRenderingContext;
  10292. private _renderingCanvas;
  10293. private _windowIsBackground;
  10294. private _webGLVersion;
  10295. /**
  10296. * Gets a boolean indicating that only power of 2 textures are supported
  10297. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10298. */
  10299. readonly needPOTTextures: boolean;
  10300. /** @hidden */
  10301. _badOS: boolean;
  10302. /** @hidden */
  10303. _badDesktopOS: boolean;
  10304. /**
  10305. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10306. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10307. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10308. */
  10309. disableTextureBindingOptimization: boolean;
  10310. /**
  10311. * Gets the audio engine
  10312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10313. * @ignorenaming
  10314. */
  10315. static audioEngine: IAudioEngine;
  10316. /**
  10317. * Default AudioEngine factory responsible of creating the Audio Engine.
  10318. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10319. */
  10320. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10321. /**
  10322. * Default offline support factory responsible of creating a tool used to store data locally.
  10323. * By default, this will create a Database object if the workload has been embedded.
  10324. */
  10325. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10326. private _onFocus;
  10327. private _onBlur;
  10328. private _onCanvasPointerOut;
  10329. private _onCanvasBlur;
  10330. private _onCanvasFocus;
  10331. private _onFullscreenChange;
  10332. private _onPointerLockChange;
  10333. private _onVRDisplayPointerRestricted;
  10334. private _onVRDisplayPointerUnrestricted;
  10335. private _onVrDisplayConnect;
  10336. private _onVrDisplayDisconnect;
  10337. private _onVrDisplayPresentChange;
  10338. /**
  10339. * Observable signaled when VR display mode changes
  10340. */
  10341. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10342. /**
  10343. * Observable signaled when VR request present is complete
  10344. */
  10345. onVRRequestPresentComplete: Observable<boolean>;
  10346. /**
  10347. * Observable signaled when VR request present starts
  10348. */
  10349. onVRRequestPresentStart: Observable<Engine>;
  10350. private _hardwareScalingLevel;
  10351. /** @hidden */
  10352. protected _caps: EngineCapabilities;
  10353. private _pointerLockRequested;
  10354. private _isStencilEnable;
  10355. private _colorWrite;
  10356. private _loadingScreen;
  10357. /** @hidden */
  10358. _drawCalls: PerfCounter;
  10359. /** @hidden */
  10360. _textureCollisions: PerfCounter;
  10361. private _glVersion;
  10362. private _glRenderer;
  10363. private _glVendor;
  10364. private _videoTextureSupported;
  10365. private _renderingQueueLaunched;
  10366. private _activeRenderLoops;
  10367. private _deterministicLockstep;
  10368. private _lockstepMaxSteps;
  10369. /**
  10370. * Observable signaled when a context lost event is raised
  10371. */
  10372. onContextLostObservable: Observable<Engine>;
  10373. /**
  10374. * Observable signaled when a context restored event is raised
  10375. */
  10376. onContextRestoredObservable: Observable<Engine>;
  10377. private _onContextLost;
  10378. private _onContextRestored;
  10379. private _contextWasLost;
  10380. private _doNotHandleContextLost;
  10381. /**
  10382. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10383. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10384. */
  10385. doNotHandleContextLost: boolean;
  10386. private _performanceMonitor;
  10387. private _fps;
  10388. private _deltaTime;
  10389. /**
  10390. * Turn this value on if you want to pause FPS computation when in background
  10391. */
  10392. disablePerformanceMonitorInBackground: boolean;
  10393. /**
  10394. * Gets the performance monitor attached to this engine
  10395. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10396. */
  10397. readonly performanceMonitor: PerformanceMonitor;
  10398. /** @hidden */
  10399. protected _depthCullingState: _DepthCullingState;
  10400. /** @hidden */
  10401. protected _stencilState: _StencilState;
  10402. /** @hidden */
  10403. protected _alphaState: _AlphaState;
  10404. /** @hidden */
  10405. protected _alphaMode: number;
  10406. protected _internalTexturesCache: InternalTexture[];
  10407. /** @hidden */
  10408. protected _activeChannel: number;
  10409. private _currentTextureChannel;
  10410. /** @hidden */
  10411. protected _boundTexturesCache: {
  10412. [key: string]: Nullable<InternalTexture>;
  10413. };
  10414. /** @hidden */
  10415. protected _currentEffect: Nullable<Effect>;
  10416. /** @hidden */
  10417. protected _currentProgram: Nullable<WebGLProgram>;
  10418. private _compiledEffects;
  10419. private _vertexAttribArraysEnabled;
  10420. /** @hidden */
  10421. protected _cachedViewport: Nullable<Viewport>;
  10422. private _cachedVertexArrayObject;
  10423. /** @hidden */
  10424. protected _cachedVertexBuffers: any;
  10425. /** @hidden */
  10426. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10427. /** @hidden */
  10428. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10429. /** @hidden */
  10430. protected _currentRenderTarget: Nullable<InternalTexture>;
  10431. private _uintIndicesCurrentlySet;
  10432. private _currentBoundBuffer;
  10433. /** @hidden */
  10434. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10435. private _currentBufferPointers;
  10436. private _currentInstanceLocations;
  10437. private _currentInstanceBuffers;
  10438. private _textureUnits;
  10439. private _firstBoundInternalTextureTracker;
  10440. private _lastBoundInternalTextureTracker;
  10441. private _workingCanvas;
  10442. private _workingContext;
  10443. private _rescalePostProcess;
  10444. private _dummyFramebuffer;
  10445. private _externalData;
  10446. private _bindedRenderFunction;
  10447. private _vaoRecordInProgress;
  10448. private _mustWipeVertexAttributes;
  10449. private _emptyTexture;
  10450. private _emptyCubeTexture;
  10451. private _emptyTexture3D;
  10452. private _frameHandler;
  10453. private _nextFreeTextureSlots;
  10454. private _maxSimultaneousTextures;
  10455. private _activeRequests;
  10456. private _texturesSupported;
  10457. private _textureFormatInUse;
  10458. /**
  10459. * Gets the list of texture formats supported
  10460. */
  10461. readonly texturesSupported: Array<string>;
  10462. /**
  10463. * Gets the list of texture formats in use
  10464. */
  10465. readonly textureFormatInUse: Nullable<string>;
  10466. /**
  10467. * Gets the current viewport
  10468. */
  10469. readonly currentViewport: Nullable<Viewport>;
  10470. /**
  10471. * Gets the default empty texture
  10472. */
  10473. readonly emptyTexture: InternalTexture;
  10474. /**
  10475. * Gets the default empty 3D texture
  10476. */
  10477. readonly emptyTexture3D: InternalTexture;
  10478. /**
  10479. * Gets the default empty cube texture
  10480. */
  10481. readonly emptyCubeTexture: InternalTexture;
  10482. /**
  10483. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10484. */
  10485. readonly premultipliedAlpha: boolean;
  10486. /**
  10487. * Creates a new engine
  10488. * @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
  10489. * @param antialias defines enable antialiasing (default: false)
  10490. * @param options defines further options to be sent to the getContext() function
  10491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10492. */
  10493. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10494. private _rebuildInternalTextures;
  10495. private _rebuildEffects;
  10496. /**
  10497. * Gets a boolean indicating if all created effects are ready
  10498. * @returns true if all effects are ready
  10499. */
  10500. areAllEffectsReady(): boolean;
  10501. private _rebuildBuffers;
  10502. private _initGLContext;
  10503. /**
  10504. * Gets version of the current webGL context
  10505. */
  10506. readonly webGLVersion: number;
  10507. /**
  10508. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10509. */
  10510. readonly isStencilEnable: boolean;
  10511. private _prepareWorkingCanvas;
  10512. /**
  10513. * Reset the texture cache to empty state
  10514. */
  10515. resetTextureCache(): void;
  10516. /**
  10517. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10518. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10519. * @returns true if engine is in deterministic lock step mode
  10520. */
  10521. isDeterministicLockStep(): boolean;
  10522. /**
  10523. * Gets the max steps when engine is running in deterministic lock step
  10524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10525. * @returns the max steps
  10526. */
  10527. getLockstepMaxSteps(): number;
  10528. /**
  10529. * Gets an object containing information about the current webGL context
  10530. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10531. */
  10532. getGlInfo(): {
  10533. vendor: string;
  10534. renderer: string;
  10535. version: string;
  10536. };
  10537. /**
  10538. * Gets current aspect ratio
  10539. * @param camera defines the camera to use to get the aspect ratio
  10540. * @param useScreen defines if screen size must be used (or the current render target if any)
  10541. * @returns a number defining the aspect ratio
  10542. */
  10543. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10544. /**
  10545. * Gets current screen aspect ratio
  10546. * @returns a number defining the aspect ratio
  10547. */
  10548. getScreenAspectRatio(): number;
  10549. /**
  10550. * Gets the current render width
  10551. * @param useScreen defines if screen size must be used (or the current render target if any)
  10552. * @returns a number defining the current render width
  10553. */
  10554. getRenderWidth(useScreen?: boolean): number;
  10555. /**
  10556. * Gets the current render height
  10557. * @param useScreen defines if screen size must be used (or the current render target if any)
  10558. * @returns a number defining the current render height
  10559. */
  10560. getRenderHeight(useScreen?: boolean): number;
  10561. /**
  10562. * Gets the HTML canvas attached with the current webGL context
  10563. * @returns a HTML canvas
  10564. */
  10565. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10566. /**
  10567. * Gets the client rect of the HTML canvas attached with the current webGL context
  10568. * @returns a client rectanglee
  10569. */
  10570. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10571. /**
  10572. * Defines the hardware scaling level.
  10573. * By default the hardware scaling level is computed from the window device ratio.
  10574. * 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.
  10575. * @param level defines the level to use
  10576. */
  10577. setHardwareScalingLevel(level: number): void;
  10578. /**
  10579. * Gets the current hardware scaling level.
  10580. * By default the hardware scaling level is computed from the window device ratio.
  10581. * 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.
  10582. * @returns a number indicating the current hardware scaling level
  10583. */
  10584. getHardwareScalingLevel(): number;
  10585. /**
  10586. * Gets the list of loaded textures
  10587. * @returns an array containing all loaded textures
  10588. */
  10589. getLoadedTexturesCache(): InternalTexture[];
  10590. /**
  10591. * Gets the object containing all engine capabilities
  10592. * @returns the EngineCapabilities object
  10593. */
  10594. getCaps(): EngineCapabilities;
  10595. /** @hidden */
  10596. readonly drawCalls: number;
  10597. /** @hidden */
  10598. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  10599. /**
  10600. * Gets the current depth function
  10601. * @returns a number defining the depth function
  10602. */
  10603. getDepthFunction(): Nullable<number>;
  10604. /**
  10605. * Sets the current depth function
  10606. * @param depthFunc defines the function to use
  10607. */
  10608. setDepthFunction(depthFunc: number): void;
  10609. /**
  10610. * Sets the current depth function to GREATER
  10611. */
  10612. setDepthFunctionToGreater(): void;
  10613. /**
  10614. * Sets the current depth function to GEQUAL
  10615. */
  10616. setDepthFunctionToGreaterOrEqual(): void;
  10617. /**
  10618. * Sets the current depth function to LESS
  10619. */
  10620. setDepthFunctionToLess(): void;
  10621. /**
  10622. * Sets the current depth function to LEQUAL
  10623. */
  10624. setDepthFunctionToLessOrEqual(): void;
  10625. /**
  10626. * Gets a boolean indicating if stencil buffer is enabled
  10627. * @returns the current stencil buffer state
  10628. */
  10629. getStencilBuffer(): boolean;
  10630. /**
  10631. * Enable or disable the stencil buffer
  10632. * @param enable defines if the stencil buffer must be enabled or disabled
  10633. */
  10634. setStencilBuffer(enable: boolean): void;
  10635. /**
  10636. * Gets the current stencil mask
  10637. * @returns a number defining the new stencil mask to use
  10638. */
  10639. getStencilMask(): number;
  10640. /**
  10641. * Sets the current stencil mask
  10642. * @param mask defines the new stencil mask to use
  10643. */
  10644. setStencilMask(mask: number): void;
  10645. /**
  10646. * Gets the current stencil function
  10647. * @returns a number defining the stencil function to use
  10648. */
  10649. getStencilFunction(): number;
  10650. /**
  10651. * Gets the current stencil reference value
  10652. * @returns a number defining the stencil reference value to use
  10653. */
  10654. getStencilFunctionReference(): number;
  10655. /**
  10656. * Gets the current stencil mask
  10657. * @returns a number defining the stencil mask to use
  10658. */
  10659. getStencilFunctionMask(): number;
  10660. /**
  10661. * Sets the current stencil function
  10662. * @param stencilFunc defines the new stencil function to use
  10663. */
  10664. setStencilFunction(stencilFunc: number): void;
  10665. /**
  10666. * Sets the current stencil reference
  10667. * @param reference defines the new stencil reference to use
  10668. */
  10669. setStencilFunctionReference(reference: number): void;
  10670. /**
  10671. * Sets the current stencil mask
  10672. * @param mask defines the new stencil mask to use
  10673. */
  10674. setStencilFunctionMask(mask: number): void;
  10675. /**
  10676. * Gets the current stencil operation when stencil fails
  10677. * @returns a number defining stencil operation to use when stencil fails
  10678. */
  10679. getStencilOperationFail(): number;
  10680. /**
  10681. * Gets the current stencil operation when depth fails
  10682. * @returns a number defining stencil operation to use when depth fails
  10683. */
  10684. getStencilOperationDepthFail(): number;
  10685. /**
  10686. * Gets the current stencil operation when stencil passes
  10687. * @returns a number defining stencil operation to use when stencil passes
  10688. */
  10689. getStencilOperationPass(): number;
  10690. /**
  10691. * Sets the stencil operation to use when stencil fails
  10692. * @param operation defines the stencil operation to use when stencil fails
  10693. */
  10694. setStencilOperationFail(operation: number): void;
  10695. /**
  10696. * Sets the stencil operation to use when depth fails
  10697. * @param operation defines the stencil operation to use when depth fails
  10698. */
  10699. setStencilOperationDepthFail(operation: number): void;
  10700. /**
  10701. * Sets the stencil operation to use when stencil passes
  10702. * @param operation defines the stencil operation to use when stencil passes
  10703. */
  10704. setStencilOperationPass(operation: number): void;
  10705. /**
  10706. * Sets a boolean indicating if the dithering state is enabled or disabled
  10707. * @param value defines the dithering state
  10708. */
  10709. setDitheringState(value: boolean): void;
  10710. /**
  10711. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10712. * @param value defines the rasterizer state
  10713. */
  10714. setRasterizerState(value: boolean): void;
  10715. /**
  10716. * stop executing a render loop function and remove it from the execution array
  10717. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10718. */
  10719. stopRenderLoop(renderFunction?: () => void): void;
  10720. /** @hidden */
  10721. _renderLoop(): void;
  10722. /**
  10723. * Register and execute a render loop. The engine can have more than one render function
  10724. * @param renderFunction defines the function to continuously execute
  10725. */
  10726. runRenderLoop(renderFunction: () => void): void;
  10727. /**
  10728. * Toggle full screen mode
  10729. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10730. */
  10731. switchFullscreen(requestPointerLock: boolean): void;
  10732. /**
  10733. * Clear the current render buffer or the current render target (if any is set up)
  10734. * @param color defines the color to use
  10735. * @param backBuffer defines if the back buffer must be cleared
  10736. * @param depth defines if the depth buffer must be cleared
  10737. * @param stencil defines if the stencil buffer must be cleared
  10738. */
  10739. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10740. /**
  10741. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10742. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10743. * @param y defines the y-coordinate of the corner of the clear rectangle
  10744. * @param width defines the width of the clear rectangle
  10745. * @param height defines the height of the clear rectangle
  10746. * @param clearColor defines the clear color
  10747. */
  10748. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10749. private _viewportCached;
  10750. /** @hidden */
  10751. _viewport(x: number, y: number, width: number, height: number): void;
  10752. /**
  10753. * Set the WebGL's viewport
  10754. * @param viewport defines the viewport element to be used
  10755. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10756. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10757. */
  10758. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10759. /**
  10760. * Directly set the WebGL Viewport
  10761. * @param x defines the x coordinate of the viewport (in screen space)
  10762. * @param y defines the y coordinate of the viewport (in screen space)
  10763. * @param width defines the width of the viewport (in screen space)
  10764. * @param height defines the height of the viewport (in screen space)
  10765. * @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
  10766. */
  10767. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10768. /**
  10769. * Begin a new frame
  10770. */
  10771. beginFrame(): void;
  10772. /**
  10773. * Enf the current frame
  10774. */
  10775. endFrame(): void;
  10776. /**
  10777. * Resize the view according to the canvas' size
  10778. */
  10779. resize(): void;
  10780. /**
  10781. * Force a specific size of the canvas
  10782. * @param width defines the new canvas' width
  10783. * @param height defines the new canvas' height
  10784. */
  10785. setSize(width: number, height: number): void;
  10786. /**
  10787. * Gets a boolean indicating if a webVR device was detected
  10788. * @returns true if a webVR device was detected
  10789. */
  10790. isVRDevicePresent(): boolean;
  10791. /**
  10792. * Gets the current webVR device
  10793. * @returns the current webVR device (or null)
  10794. */
  10795. getVRDevice(): any;
  10796. /**
  10797. * Initializes a webVR display and starts listening to display change events
  10798. * The onVRDisplayChangedObservable will be notified upon these changes
  10799. * @returns The onVRDisplayChangedObservable
  10800. */
  10801. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10802. /**
  10803. * Initializes a webVR display and starts listening to display change events
  10804. * The onVRDisplayChangedObservable will be notified upon these changes
  10805. * @returns A promise containing a VRDisplay and if vr is supported
  10806. */
  10807. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10808. /**
  10809. * Call this function to switch to webVR mode
  10810. * Will do nothing if webVR is not supported or if there is no webVR device
  10811. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10812. */
  10813. enableVR(): void;
  10814. /**
  10815. * Call this function to leave webVR mode
  10816. * Will do nothing if webVR is not supported or if there is no webVR device
  10817. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10818. */
  10819. disableVR(): void;
  10820. private _onVRFullScreenTriggered;
  10821. private _getVRDisplaysAsync;
  10822. /**
  10823. * Binds the frame buffer to the specified texture.
  10824. * @param texture The texture to render to or null for the default canvas
  10825. * @param faceIndex The face of the texture to render to in case of cube texture
  10826. * @param requiredWidth The width of the target to render to
  10827. * @param requiredHeight The height of the target to render to
  10828. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10829. * @param depthStencilTexture The depth stencil texture to use to render
  10830. * @param lodLevel defines le lod level to bind to the frame buffer
  10831. */
  10832. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10833. private bindUnboundFramebuffer;
  10834. /**
  10835. * Unbind the current render target texture from the webGL context
  10836. * @param texture defines the render target texture to unbind
  10837. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10838. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10839. */
  10840. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10841. /**
  10842. * Unbind a list of render target textures from the webGL context
  10843. * This is used only when drawBuffer extension or webGL2 are active
  10844. * @param textures defines the render target textures to unbind
  10845. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10846. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10847. */
  10848. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10849. /**
  10850. * Force the mipmap generation for the given render target texture
  10851. * @param texture defines the render target texture to use
  10852. */
  10853. generateMipMapsForCubemap(texture: InternalTexture): void;
  10854. /**
  10855. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10856. */
  10857. flushFramebuffer(): void;
  10858. /**
  10859. * Unbind the current render target and bind the default framebuffer
  10860. */
  10861. restoreDefaultFramebuffer(): void;
  10862. /**
  10863. * Create an uniform buffer
  10864. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10865. * @param elements defines the content of the uniform buffer
  10866. * @returns the webGL uniform buffer
  10867. */
  10868. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10869. /**
  10870. * Create a dynamic uniform buffer
  10871. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10872. * @param elements defines the content of the uniform buffer
  10873. * @returns the webGL uniform buffer
  10874. */
  10875. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10876. /**
  10877. * Update an existing uniform buffer
  10878. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10879. * @param uniformBuffer defines the target uniform buffer
  10880. * @param elements defines the content to update
  10881. * @param offset defines the offset in the uniform buffer where update should start
  10882. * @param count defines the size of the data to update
  10883. */
  10884. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10885. private _resetVertexBufferBinding;
  10886. /**
  10887. * Creates a vertex buffer
  10888. * @param data the data for the vertex buffer
  10889. * @returns the new WebGL static buffer
  10890. */
  10891. createVertexBuffer(data: DataArray): WebGLBuffer;
  10892. /**
  10893. * Creates a dynamic vertex buffer
  10894. * @param data the data for the dynamic vertex buffer
  10895. * @returns the new WebGL dynamic buffer
  10896. */
  10897. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  10898. /**
  10899. * Update a dynamic index buffer
  10900. * @param indexBuffer defines the target index buffer
  10901. * @param indices defines the data to update
  10902. * @param offset defines the offset in the target index buffer where update should start
  10903. */
  10904. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  10905. /**
  10906. * Updates a dynamic vertex buffer.
  10907. * @param vertexBuffer the vertex buffer to update
  10908. * @param data the data used to update the vertex buffer
  10909. * @param byteOffset the byte offset of the data
  10910. * @param byteLength the byte length of the data
  10911. */
  10912. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  10913. private _resetIndexBufferBinding;
  10914. /**
  10915. * Creates a new index buffer
  10916. * @param indices defines the content of the index buffer
  10917. * @param updatable defines if the index buffer must be updatable
  10918. * @returns a new webGL buffer
  10919. */
  10920. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  10921. /**
  10922. * Bind a webGL buffer to the webGL context
  10923. * @param buffer defines the buffer to bind
  10924. */
  10925. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  10926. /**
  10927. * Bind an uniform buffer to the current webGL context
  10928. * @param buffer defines the buffer to bind
  10929. */
  10930. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  10931. /**
  10932. * Bind a buffer to the current webGL context at a given location
  10933. * @param buffer defines the buffer to bind
  10934. * @param location defines the index where to bind the buffer
  10935. */
  10936. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  10937. /**
  10938. * Bind a specific block at a given index in a specific shader program
  10939. * @param shaderProgram defines the shader program
  10940. * @param blockName defines the block name
  10941. * @param index defines the index where to bind the block
  10942. */
  10943. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  10944. private bindIndexBuffer;
  10945. private bindBuffer;
  10946. /**
  10947. * update the bound buffer with the given data
  10948. * @param data defines the data to update
  10949. */
  10950. updateArrayBuffer(data: Float32Array): void;
  10951. private _vertexAttribPointer;
  10952. private _bindIndexBufferWithCache;
  10953. private _bindVertexBuffersAttributes;
  10954. /**
  10955. * Records a vertex array object
  10956. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10957. * @param vertexBuffers defines the list of vertex buffers to store
  10958. * @param indexBuffer defines the index buffer to store
  10959. * @param effect defines the effect to store
  10960. * @returns the new vertex array object
  10961. */
  10962. recordVertexArrayObject(vertexBuffers: {
  10963. [key: string]: VertexBuffer;
  10964. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  10965. /**
  10966. * Bind a specific vertex array object
  10967. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  10968. * @param vertexArrayObject defines the vertex array object to bind
  10969. * @param indexBuffer defines the index buffer to bind
  10970. */
  10971. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  10972. /**
  10973. * Bind webGl buffers directly to the webGL context
  10974. * @param vertexBuffer defines the vertex buffer to bind
  10975. * @param indexBuffer defines the index buffer to bind
  10976. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  10977. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  10978. * @param effect defines the effect associated with the vertex buffer
  10979. */
  10980. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  10981. private _unbindVertexArrayObject;
  10982. /**
  10983. * Bind a list of vertex buffers to the webGL context
  10984. * @param vertexBuffers defines the list of vertex buffers to bind
  10985. * @param indexBuffer defines the index buffer to bind
  10986. * @param effect defines the effect associated with the vertex buffers
  10987. */
  10988. bindBuffers(vertexBuffers: {
  10989. [key: string]: Nullable<VertexBuffer>;
  10990. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  10991. /**
  10992. * Unbind all instance attributes
  10993. */
  10994. unbindInstanceAttributes(): void;
  10995. /**
  10996. * Release and free the memory of a vertex array object
  10997. * @param vao defines the vertex array object to delete
  10998. */
  10999. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11000. /** @hidden */
  11001. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11002. /**
  11003. * Creates a webGL buffer to use with instanciation
  11004. * @param capacity defines the size of the buffer
  11005. * @returns the webGL buffer
  11006. */
  11007. createInstancesBuffer(capacity: number): WebGLBuffer;
  11008. /**
  11009. * Delete a webGL buffer used with instanciation
  11010. * @param buffer defines the webGL buffer to delete
  11011. */
  11012. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11013. /**
  11014. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11015. * @param instancesBuffer defines the webGL buffer to update and bind
  11016. * @param data defines the data to store in the buffer
  11017. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11018. */
  11019. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11020. /**
  11021. * Apply all cached states (depth, culling, stencil and alpha)
  11022. */
  11023. applyStates(): void;
  11024. /**
  11025. * Send a draw order
  11026. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11027. * @param indexStart defines the starting index
  11028. * @param indexCount defines the number of index to draw
  11029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11030. */
  11031. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11032. /**
  11033. * Draw a list of points
  11034. * @param verticesStart defines the index of first vertex to draw
  11035. * @param verticesCount defines the count of vertices to draw
  11036. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11037. */
  11038. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11039. /**
  11040. * Draw a list of unindexed primitives
  11041. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11042. * @param verticesStart defines the index of first vertex to draw
  11043. * @param verticesCount defines the count of vertices to draw
  11044. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11045. */
  11046. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11047. /**
  11048. * Draw a list of indexed primitives
  11049. * @param fillMode defines the primitive to use
  11050. * @param indexStart defines the starting index
  11051. * @param indexCount defines the number of index to draw
  11052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11053. */
  11054. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11055. /**
  11056. * Draw a list of unindexed primitives
  11057. * @param fillMode defines the primitive to use
  11058. * @param verticesStart defines the index of first vertex to draw
  11059. * @param verticesCount defines the count of vertices to draw
  11060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11061. */
  11062. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11063. private _drawMode;
  11064. /** @hidden */
  11065. _releaseEffect(effect: Effect): void;
  11066. /** @hidden */
  11067. _deleteProgram(program: WebGLProgram): void;
  11068. /**
  11069. * Create a new effect (used to store vertex/fragment shaders)
  11070. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11071. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11072. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11073. * @param samplers defines an array of string used to represent textures
  11074. * @param defines defines the string containing the defines to use to compile the shaders
  11075. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11076. * @param onCompiled defines a function to call when the effect creation is successful
  11077. * @param onError defines a function to call when the effect creation has failed
  11078. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11079. * @returns the new Effect
  11080. */
  11081. 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;
  11082. private _compileShader;
  11083. private _compileRawShader;
  11084. /**
  11085. * Directly creates a webGL program
  11086. * @param vertexCode defines the vertex shader code to use
  11087. * @param fragmentCode defines the fragment shader code to use
  11088. * @param context defines the webGL context to use (if not set, the current one will be used)
  11089. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11090. * @returns the new webGL program
  11091. */
  11092. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11093. /**
  11094. * Creates a webGL program
  11095. * @param vertexCode defines the vertex shader code to use
  11096. * @param fragmentCode defines the fragment shader code to use
  11097. * @param defines defines the string containing the defines to use to compile the shaders
  11098. * @param context defines the webGL context to use (if not set, the current one will be used)
  11099. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11100. * @returns the new webGL program
  11101. */
  11102. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11103. private _createShaderProgram;
  11104. private _finalizeProgram;
  11105. /** @hidden */
  11106. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11107. /** @hidden */
  11108. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11109. /**
  11110. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11111. * @param shaderProgram defines the webGL program to use
  11112. * @param uniformsNames defines the list of uniform names
  11113. * @returns an array of webGL uniform locations
  11114. */
  11115. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11116. /**
  11117. * Gets the lsit of active attributes for a given webGL program
  11118. * @param shaderProgram defines the webGL program to use
  11119. * @param attributesNames defines the list of attribute names to get
  11120. * @returns an array of indices indicating the offset of each attribute
  11121. */
  11122. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11123. /**
  11124. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11125. * @param effect defines the effect to activate
  11126. */
  11127. enableEffect(effect: Nullable<Effect>): void;
  11128. /**
  11129. * Set the value of an uniform to an array of int32
  11130. * @param uniform defines the webGL uniform location where to store the value
  11131. * @param array defines the array of int32 to store
  11132. */
  11133. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11134. /**
  11135. * Set the value of an uniform to an array of int32 (stored as vec2)
  11136. * @param uniform defines the webGL uniform location where to store the value
  11137. * @param array defines the array of int32 to store
  11138. */
  11139. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11140. /**
  11141. * Set the value of an uniform to an array of int32 (stored as vec3)
  11142. * @param uniform defines the webGL uniform location where to store the value
  11143. * @param array defines the array of int32 to store
  11144. */
  11145. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11146. /**
  11147. * Set the value of an uniform to an array of int32 (stored as vec4)
  11148. * @param uniform defines the webGL uniform location where to store the value
  11149. * @param array defines the array of int32 to store
  11150. */
  11151. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11152. /**
  11153. * Set the value of an uniform to an array of float32
  11154. * @param uniform defines the webGL uniform location where to store the value
  11155. * @param array defines the array of float32 to store
  11156. */
  11157. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11158. /**
  11159. * Set the value of an uniform to an array of float32 (stored as vec2)
  11160. * @param uniform defines the webGL uniform location where to store the value
  11161. * @param array defines the array of float32 to store
  11162. */
  11163. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11164. /**
  11165. * Set the value of an uniform to an array of float32 (stored as vec3)
  11166. * @param uniform defines the webGL uniform location where to store the value
  11167. * @param array defines the array of float32 to store
  11168. */
  11169. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11170. /**
  11171. * Set the value of an uniform to an array of float32 (stored as vec4)
  11172. * @param uniform defines the webGL uniform location where to store the value
  11173. * @param array defines the array of float32 to store
  11174. */
  11175. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11176. /**
  11177. * Set the value of an uniform to an array of number
  11178. * @param uniform defines the webGL uniform location where to store the value
  11179. * @param array defines the array of number to store
  11180. */
  11181. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11182. /**
  11183. * Set the value of an uniform to an array of number (stored as vec2)
  11184. * @param uniform defines the webGL uniform location where to store the value
  11185. * @param array defines the array of number to store
  11186. */
  11187. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11188. /**
  11189. * Set the value of an uniform to an array of number (stored as vec3)
  11190. * @param uniform defines the webGL uniform location where to store the value
  11191. * @param array defines the array of number to store
  11192. */
  11193. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11194. /**
  11195. * Set the value of an uniform to an array of number (stored as vec4)
  11196. * @param uniform defines the webGL uniform location where to store the value
  11197. * @param array defines the array of number to store
  11198. */
  11199. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11200. /**
  11201. * Set the value of an uniform to an array of float32 (stored as matrices)
  11202. * @param uniform defines the webGL uniform location where to store the value
  11203. * @param matrices defines the array of float32 to store
  11204. */
  11205. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11206. /**
  11207. * Set the value of an uniform to a matrix
  11208. * @param uniform defines the webGL uniform location where to store the value
  11209. * @param matrix defines the matrix to store
  11210. */
  11211. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11212. /**
  11213. * Set the value of an uniform to a matrix (3x3)
  11214. * @param uniform defines the webGL uniform location where to store the value
  11215. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11216. */
  11217. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11218. /**
  11219. * Set the value of an uniform to a matrix (2x2)
  11220. * @param uniform defines the webGL uniform location where to store the value
  11221. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11222. */
  11223. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11224. /**
  11225. * Set the value of an uniform to a number (int)
  11226. * @param uniform defines the webGL uniform location where to store the value
  11227. * @param value defines the int number to store
  11228. */
  11229. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11230. /**
  11231. * Set the value of an uniform to a number (float)
  11232. * @param uniform defines the webGL uniform location where to store the value
  11233. * @param value defines the float number to store
  11234. */
  11235. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11236. /**
  11237. * Set the value of an uniform to a vec2
  11238. * @param uniform defines the webGL uniform location where to store the value
  11239. * @param x defines the 1st component of the value
  11240. * @param y defines the 2nd component of the value
  11241. */
  11242. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11243. /**
  11244. * Set the value of an uniform to a vec3
  11245. * @param uniform defines the webGL uniform location where to store the value
  11246. * @param x defines the 1st component of the value
  11247. * @param y defines the 2nd component of the value
  11248. * @param z defines the 3rd component of the value
  11249. */
  11250. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11251. /**
  11252. * Set the value of an uniform to a boolean
  11253. * @param uniform defines the webGL uniform location where to store the value
  11254. * @param bool defines the boolean to store
  11255. */
  11256. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11257. /**
  11258. * Set the value of an uniform to a vec4
  11259. * @param uniform defines the webGL uniform location where to store the value
  11260. * @param x defines the 1st component of the value
  11261. * @param y defines the 2nd component of the value
  11262. * @param z defines the 3rd component of the value
  11263. * @param w defines the 4th component of the value
  11264. */
  11265. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11266. /**
  11267. * Set the value of an uniform to a Color3
  11268. * @param uniform defines the webGL uniform location where to store the value
  11269. * @param color3 defines the color to store
  11270. */
  11271. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11272. /**
  11273. * Set the value of an uniform to a Color3 and an alpha value
  11274. * @param uniform defines the webGL uniform location where to store the value
  11275. * @param color3 defines the color to store
  11276. * @param alpha defines the alpha component to store
  11277. */
  11278. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11279. /**
  11280. * Sets a Color4 on a uniform variable
  11281. * @param uniform defines the uniform location
  11282. * @param color4 defines the value to be set
  11283. */
  11284. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11285. /**
  11286. * Set various states to the webGL context
  11287. * @param culling defines backface culling state
  11288. * @param zOffset defines the value to apply to zOffset (0 by default)
  11289. * @param force defines if states must be applied even if cache is up to date
  11290. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11291. */
  11292. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11293. /**
  11294. * Set the z offset to apply to current rendering
  11295. * @param value defines the offset to apply
  11296. */
  11297. setZOffset(value: number): void;
  11298. /**
  11299. * Gets the current value of the zOffset
  11300. * @returns the current zOffset state
  11301. */
  11302. getZOffset(): number;
  11303. /**
  11304. * Enable or disable depth buffering
  11305. * @param enable defines the state to set
  11306. */
  11307. setDepthBuffer(enable: boolean): void;
  11308. /**
  11309. * Gets a boolean indicating if depth writing is enabled
  11310. * @returns the current depth writing state
  11311. */
  11312. getDepthWrite(): boolean;
  11313. /**
  11314. * Enable or disable depth writing
  11315. * @param enable defines the state to set
  11316. */
  11317. setDepthWrite(enable: boolean): void;
  11318. /**
  11319. * Enable or disable color writing
  11320. * @param enable defines the state to set
  11321. */
  11322. setColorWrite(enable: boolean): void;
  11323. /**
  11324. * Gets a boolean indicating if color writing is enabled
  11325. * @returns the current color writing state
  11326. */
  11327. getColorWrite(): boolean;
  11328. /**
  11329. * Sets alpha constants used by some alpha blending modes
  11330. * @param r defines the red component
  11331. * @param g defines the green component
  11332. * @param b defines the blue component
  11333. * @param a defines the alpha component
  11334. */
  11335. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11336. /**
  11337. * Sets the current alpha mode
  11338. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11339. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11340. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11341. */
  11342. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11343. /**
  11344. * Gets the current alpha mode
  11345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11346. * @returns the current alpha mode
  11347. */
  11348. getAlphaMode(): number;
  11349. /**
  11350. * Clears the list of texture accessible through engine.
  11351. * This can help preventing texture load conflict due to name collision.
  11352. */
  11353. clearInternalTexturesCache(): void;
  11354. /**
  11355. * Force the entire cache to be cleared
  11356. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11357. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11358. */
  11359. wipeCaches(bruteForce?: boolean): void;
  11360. /**
  11361. * Set the compressed texture format to use, based on the formats you have, and the formats
  11362. * supported by the hardware / browser.
  11363. *
  11364. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11365. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11366. * to API arguments needed to compressed textures. This puts the burden on the container
  11367. * generator to house the arcane code for determining these for current & future formats.
  11368. *
  11369. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11370. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11371. *
  11372. * Note: The result of this call is not taken into account when a texture is base64.
  11373. *
  11374. * @param formatsAvailable defines the list of those format families you have created
  11375. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11376. *
  11377. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11378. * @returns The extension selected.
  11379. */
  11380. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11381. private _getSamplingParameters;
  11382. private _partialLoadImg;
  11383. private _cascadeLoadImgs;
  11384. /** @hidden */
  11385. _createTexture(): WebGLTexture;
  11386. /**
  11387. * Usually called from BABYLON.Texture.ts.
  11388. * Passed information to create a WebGLTexture
  11389. * @param urlArg defines a value which contains one of the following:
  11390. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11391. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11392. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11393. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11394. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11395. * @param scene needed for loading to the correct scene
  11396. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11397. * @param onLoad optional callback to be called upon successful completion
  11398. * @param onError optional callback to be called upon failure
  11399. * @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
  11400. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11401. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11402. * @param forcedExtension defines the extension to use to pick the right loader
  11403. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11404. */
  11405. 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;
  11406. private _rescaleTexture;
  11407. /**
  11408. * Update a raw texture
  11409. * @param texture defines the texture to update
  11410. * @param data defines the data to store in the texture
  11411. * @param format defines the format of the data
  11412. * @param invertY defines if data must be stored with Y axis inverted
  11413. * @param compression defines the compression used (null by default)
  11414. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11415. */
  11416. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11417. /**
  11418. * Creates a raw texture
  11419. * @param data defines the data to store in the texture
  11420. * @param width defines the width of the texture
  11421. * @param height defines the height of the texture
  11422. * @param format defines the format of the data
  11423. * @param generateMipMaps defines if the engine should generate the mip levels
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11426. * @param compression defines the compression used (null by default)
  11427. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11428. * @returns the raw texture inside an InternalTexture
  11429. */
  11430. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11431. private _unpackFlipYCached;
  11432. /**
  11433. * In case you are sharing the context with other applications, it might
  11434. * be interested to not cache the unpack flip y state to ensure a consistent
  11435. * value would be set.
  11436. */
  11437. enableUnpackFlipYCached: boolean;
  11438. /** @hidden */
  11439. _unpackFlipY(value: boolean): void;
  11440. /** @hidden */
  11441. _getUnpackAlignement(): number;
  11442. /**
  11443. * Creates a dynamic texture
  11444. * @param width defines the width of the texture
  11445. * @param height defines the height of the texture
  11446. * @param generateMipMaps defines if the engine should generate the mip levels
  11447. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11448. * @returns the dynamic texture inside an InternalTexture
  11449. */
  11450. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11451. /**
  11452. * Update the sampling mode of a given texture
  11453. * @param samplingMode defines the required sampling mode
  11454. * @param texture defines the texture to update
  11455. */
  11456. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11457. /**
  11458. * Update the content of a dynamic texture
  11459. * @param texture defines the texture to update
  11460. * @param canvas defines the canvas containing the source
  11461. * @param invertY defines if data must be stored with Y axis inverted
  11462. * @param premulAlpha defines if alpha is stored as premultiplied
  11463. * @param format defines the format of the data
  11464. */
  11465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11466. /**
  11467. * Update a video texture
  11468. * @param texture defines the texture to update
  11469. * @param video defines the video element to use
  11470. * @param invertY defines if data must be stored with Y axis inverted
  11471. */
  11472. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11473. /**
  11474. * Updates a depth texture Comparison Mode and Function.
  11475. * If the comparison Function is equal to 0, the mode will be set to none.
  11476. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11477. * @param texture The texture to set the comparison function for
  11478. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11479. */
  11480. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11481. private _setupDepthStencilTexture;
  11482. /**
  11483. * Creates a depth stencil texture.
  11484. * This is only available in WebGL 2 or with the depth texture extension available.
  11485. * @param size The size of face edge in the texture.
  11486. * @param options The options defining the texture.
  11487. * @returns The texture
  11488. */
  11489. createDepthStencilTexture(size: number | {
  11490. width: number;
  11491. height: number;
  11492. }, options: DepthTextureCreationOptions): InternalTexture;
  11493. /**
  11494. * Creates a depth stencil texture.
  11495. * This is only available in WebGL 2 or with the depth texture extension available.
  11496. * @param size The size of face edge in the texture.
  11497. * @param options The options defining the texture.
  11498. * @returns The texture
  11499. */
  11500. private _createDepthStencilTexture;
  11501. /**
  11502. * Creates a depth stencil cube texture.
  11503. * This is only available in WebGL 2.
  11504. * @param size The size of face edge in the cube texture.
  11505. * @param options The options defining the cube texture.
  11506. * @returns The cube texture
  11507. */
  11508. private _createDepthStencilCubeTexture;
  11509. /**
  11510. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11511. * @param renderTarget The render target to set the frame buffer for
  11512. */
  11513. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11514. /**
  11515. * Creates a new render target texture
  11516. * @param size defines the size of the texture
  11517. * @param options defines the options used to create the texture
  11518. * @returns a new render target texture stored in an InternalTexture
  11519. */
  11520. createRenderTargetTexture(size: number | {
  11521. width: number;
  11522. height: number;
  11523. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11524. /**
  11525. * Create a multi render target texture
  11526. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11527. * @param size defines the size of the texture
  11528. * @param options defines the creation options
  11529. * @returns the cube texture as an InternalTexture
  11530. */
  11531. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11532. private _setupFramebufferDepthAttachments;
  11533. /**
  11534. * Updates the sample count of a render target texture
  11535. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11536. * @param texture defines the texture to update
  11537. * @param samples defines the sample count to set
  11538. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11539. */
  11540. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11541. /**
  11542. * Update the sample count for a given multiple render target texture
  11543. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11544. * @param textures defines the textures to update
  11545. * @param samples defines the sample count to set
  11546. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11547. */
  11548. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11549. /** @hidden */
  11550. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11551. /** @hidden */
  11552. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11553. /** @hidden */
  11554. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11555. /** @hidden */
  11556. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11557. /**
  11558. * Creates a new render target cube texture
  11559. * @param size defines the size of the texture
  11560. * @param options defines the options used to create the texture
  11561. * @returns a new render target cube texture stored in an InternalTexture
  11562. */
  11563. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11564. /**
  11565. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11566. * @param rootUrl defines the url where the file to load is located
  11567. * @param scene defines the current scene
  11568. * @param lodScale defines scale to apply to the mip map selection
  11569. * @param lodOffset defines offset to apply to the mip map selection
  11570. * @param onLoad defines an optional callback raised when the texture is loaded
  11571. * @param onError defines an optional callback raised if there is an issue to load the texture
  11572. * @param format defines the format of the data
  11573. * @param forcedExtension defines the extension to use to pick the right loader
  11574. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11575. * @returns the cube texture as an InternalTexture
  11576. */
  11577. 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;
  11578. /**
  11579. * Creates a cube texture
  11580. * @param rootUrl defines the url where the files to load is located
  11581. * @param scene defines the current scene
  11582. * @param files defines the list of files to load (1 per face)
  11583. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11584. * @param onLoad defines an optional callback raised when the texture is loaded
  11585. * @param onError defines an optional callback raised if there is an issue to load the texture
  11586. * @param format defines the format of the data
  11587. * @param forcedExtension defines the extension to use to pick the right loader
  11588. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11589. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11590. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11591. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11592. * @returns the cube texture as an InternalTexture
  11593. */
  11594. 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;
  11595. /**
  11596. * @hidden
  11597. */
  11598. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11599. /**
  11600. * Update a raw cube texture
  11601. * @param texture defines the texture to udpdate
  11602. * @param data defines the data to store
  11603. * @param format defines the data format
  11604. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11605. * @param invertY defines if data must be stored with Y axis inverted
  11606. * @param compression defines the compression used (null by default)
  11607. * @param level defines which level of the texture to update
  11608. */
  11609. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11610. /**
  11611. * Creates a new raw cube texture
  11612. * @param data defines the array of data to use to create each face
  11613. * @param size defines the size of the textures
  11614. * @param format defines the format of the data
  11615. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11616. * @param generateMipMaps defines if the engine should generate the mip levels
  11617. * @param invertY defines if data must be stored with Y axis inverted
  11618. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11619. * @param compression defines the compression used (null by default)
  11620. * @returns the cube texture as an InternalTexture
  11621. */
  11622. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11623. /**
  11624. * Creates a new raw cube texture from a specified url
  11625. * @param url defines the url where the data is located
  11626. * @param scene defines the current scene
  11627. * @param size defines the size of the textures
  11628. * @param format defines the format of the data
  11629. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11630. * @param noMipmap defines if the engine should avoid generating the mip levels
  11631. * @param callback defines a callback used to extract texture data from loaded data
  11632. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11633. * @param onLoad defines a callback called when texture is loaded
  11634. * @param onError defines a callback called if there is an error
  11635. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @returns the cube texture as an InternalTexture
  11638. */
  11639. 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;
  11640. /**
  11641. * Update a raw 3D texture
  11642. * @param texture defines the texture to update
  11643. * @param data defines the data to store
  11644. * @param format defines the data format
  11645. * @param invertY defines if data must be stored with Y axis inverted
  11646. * @param compression defines the used compression (can be null)
  11647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11648. */
  11649. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11650. /**
  11651. * Creates a new raw 3D texture
  11652. * @param data defines the data used to create the texture
  11653. * @param width defines the width of the texture
  11654. * @param height defines the height of the texture
  11655. * @param depth defines the depth of the texture
  11656. * @param format defines the format of the texture
  11657. * @param generateMipMaps defines if the engine must generate mip levels
  11658. * @param invertY defines if data must be stored with Y axis inverted
  11659. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11660. * @param compression defines the compressed used (can be null)
  11661. * @param textureType defines the compressed used (can be null)
  11662. * @returns a new raw 3D texture (stored in an InternalTexture)
  11663. */
  11664. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11665. private _prepareWebGLTextureContinuation;
  11666. private _prepareWebGLTexture;
  11667. private _convertRGBtoRGBATextureData;
  11668. /** @hidden */
  11669. _releaseFramebufferObjects(texture: InternalTexture): void;
  11670. /** @hidden */
  11671. _releaseTexture(texture: InternalTexture): void;
  11672. private setProgram;
  11673. private _boundUniforms;
  11674. /**
  11675. * Binds an effect to the webGL context
  11676. * @param effect defines the effect to bind
  11677. */
  11678. bindSamplers(effect: Effect): void;
  11679. private _moveBoundTextureOnTop;
  11680. private _getCorrectTextureChannel;
  11681. private _linkTrackers;
  11682. private _removeDesignatedSlot;
  11683. private _activateCurrentTexture;
  11684. /** @hidden */
  11685. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11686. /** @hidden */
  11687. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11688. /**
  11689. * Sets a texture to the webGL context from a postprocess
  11690. * @param channel defines the channel to use
  11691. * @param postProcess defines the source postprocess
  11692. */
  11693. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11694. /**
  11695. * Binds the output of the passed in post process to the texture channel specified
  11696. * @param channel The channel the texture should be bound to
  11697. * @param postProcess The post process which's output should be bound
  11698. */
  11699. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11700. /**
  11701. * Unbind all textures from the webGL context
  11702. */
  11703. unbindAllTextures(): void;
  11704. /**
  11705. * Sets a texture to the according uniform.
  11706. * @param channel The texture channel
  11707. * @param uniform The uniform to set
  11708. * @param texture The texture to apply
  11709. */
  11710. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11711. /**
  11712. * Sets a depth stencil texture from a render target to the according uniform.
  11713. * @param channel The texture channel
  11714. * @param uniform The uniform to set
  11715. * @param texture The render target texture containing the depth stencil texture to apply
  11716. */
  11717. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11718. private _bindSamplerUniformToChannel;
  11719. private _getTextureWrapMode;
  11720. private _setTexture;
  11721. /**
  11722. * Sets an array of texture to the webGL context
  11723. * @param channel defines the channel where the texture array must be set
  11724. * @param uniform defines the associated uniform location
  11725. * @param textures defines the array of textures to bind
  11726. */
  11727. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11728. /** @hidden */
  11729. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11730. private _setTextureParameterFloat;
  11731. private _setTextureParameterInteger;
  11732. /**
  11733. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11734. * @param x defines the x coordinate of the rectangle where pixels must be read
  11735. * @param y defines the y coordinate of the rectangle where pixels must be read
  11736. * @param width defines the width of the rectangle where pixels must be read
  11737. * @param height defines the height of the rectangle where pixels must be read
  11738. * @returns a Uint8Array containing RGBA colors
  11739. */
  11740. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11741. /**
  11742. * Add an externaly attached data from its key.
  11743. * This method call will fail and return false, if such key already exists.
  11744. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11745. * @param key the unique key that identifies the data
  11746. * @param data the data object to associate to the key for this Engine instance
  11747. * @return true if no such key were already present and the data was added successfully, false otherwise
  11748. */
  11749. addExternalData<T>(key: string, data: T): boolean;
  11750. /**
  11751. * Get an externaly attached data from its key
  11752. * @param key the unique key that identifies the data
  11753. * @return the associated data, if present (can be null), or undefined if not present
  11754. */
  11755. getExternalData<T>(key: string): T;
  11756. /**
  11757. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11758. * @param key the unique key that identifies the data
  11759. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11760. * @return the associated data, can be null if the factory returned null.
  11761. */
  11762. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11763. /**
  11764. * Remove an externaly attached data from the Engine instance
  11765. * @param key the unique key that identifies the data
  11766. * @return true if the data was successfully removed, false if it doesn't exist
  11767. */
  11768. removeExternalData(key: string): boolean;
  11769. /**
  11770. * Unbind all vertex attributes from the webGL context
  11771. */
  11772. unbindAllAttributes(): void;
  11773. /**
  11774. * 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
  11775. */
  11776. releaseEffects(): void;
  11777. /**
  11778. * Dispose and release all associated resources
  11779. */
  11780. dispose(): void;
  11781. /**
  11782. * Display the loading screen
  11783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11784. */
  11785. displayLoadingUI(): void;
  11786. /**
  11787. * Hide the loading screen
  11788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11789. */
  11790. hideLoadingUI(): void;
  11791. /**
  11792. * Gets the current loading screen object
  11793. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11794. */
  11795. /**
  11796. * Sets the current loading screen object
  11797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11798. */
  11799. loadingScreen: ILoadingScreen;
  11800. /**
  11801. * Sets the current loading screen text
  11802. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11803. */
  11804. loadingUIText: string;
  11805. /**
  11806. * Sets the current loading screen background color
  11807. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11808. */
  11809. loadingUIBackgroundColor: string;
  11810. /**
  11811. * Attach a new callback raised when context lost event is fired
  11812. * @param callback defines the callback to call
  11813. */
  11814. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11815. /**
  11816. * Attach a new callback raised when context restored event is fired
  11817. * @param callback defines the callback to call
  11818. */
  11819. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11820. /**
  11821. * Gets the source code of the vertex shader associated with a specific webGL program
  11822. * @param program defines the program to use
  11823. * @returns a string containing the source code of the vertex shader associated with the program
  11824. */
  11825. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11826. /**
  11827. * Gets the source code of the fragment shader associated with a specific webGL program
  11828. * @param program defines the program to use
  11829. * @returns a string containing the source code of the fragment shader associated with the program
  11830. */
  11831. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11832. /**
  11833. * Get the current error code of the webGL context
  11834. * @returns the error code
  11835. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11836. */
  11837. getError(): number;
  11838. /**
  11839. * Gets the current framerate
  11840. * @returns a number representing the framerate
  11841. */
  11842. getFps(): number;
  11843. /**
  11844. * Gets the time spent between current and previous frame
  11845. * @returns a number representing the delta time in ms
  11846. */
  11847. getDeltaTime(): number;
  11848. private _measureFps;
  11849. /** @hidden */
  11850. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11851. private _canRenderToFloatFramebuffer;
  11852. private _canRenderToHalfFloatFramebuffer;
  11853. private _canRenderToFramebuffer;
  11854. /** @hidden */
  11855. _getWebGLTextureType(type: number): number;
  11856. private _getInternalFormat;
  11857. /** @hidden */
  11858. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11859. /** @hidden */
  11860. _getRGBAMultiSampleBufferFormat(type: number): number;
  11861. /** @hidden */
  11862. _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;
  11863. /** @hidden */
  11864. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11865. private _partialLoadFile;
  11866. private _cascadeLoadFiles;
  11867. /**
  11868. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11869. * @returns true if the engine can be created
  11870. * @ignorenaming
  11871. */
  11872. static isSupported(): boolean;
  11873. }
  11874. }
  11875. declare module BABYLON {
  11876. /**
  11877. * Options to create the null engine
  11878. */
  11879. class NullEngineOptions {
  11880. /**
  11881. * Render width (Default: 512)
  11882. */
  11883. renderWidth: number;
  11884. /**
  11885. * Render height (Default: 256)
  11886. */
  11887. renderHeight: number;
  11888. /**
  11889. * Texture size (Default: 512)
  11890. */
  11891. textureSize: number;
  11892. /**
  11893. * If delta time between frames should be constant
  11894. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11895. */
  11896. deterministicLockstep: boolean;
  11897. /**
  11898. * Maximum about of steps between frames (Default: 4)
  11899. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11900. */
  11901. lockstepMaxSteps: number;
  11902. }
  11903. /**
  11904. * The null engine class provides support for headless version of babylon.js.
  11905. * This can be used in server side scenario or for testing purposes
  11906. */
  11907. class NullEngine extends Engine {
  11908. private _options;
  11909. /**
  11910. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  11911. */
  11912. isDeterministicLockStep(): boolean;
  11913. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  11914. getLockstepMaxSteps(): number;
  11915. /**
  11916. * Sets hardware scaling, used to save performance if needed
  11917. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  11918. */
  11919. getHardwareScalingLevel(): number;
  11920. constructor(options?: NullEngineOptions);
  11921. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11922. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  11923. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  11924. getRenderWidth(useScreen?: boolean): number;
  11925. getRenderHeight(useScreen?: boolean): number;
  11926. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  11927. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  11928. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  11929. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11930. bindSamplers(effect: Effect): void;
  11931. enableEffect(effect: Effect): void;
  11932. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11933. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  11934. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  11935. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  11936. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  11937. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  11938. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  11939. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  11940. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  11941. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  11942. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  11943. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  11944. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  11945. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  11946. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  11947. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11948. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  11949. setFloat(uniform: WebGLUniformLocation, value: number): void;
  11950. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  11951. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  11952. setBool(uniform: WebGLUniformLocation, bool: number): void;
  11953. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  11954. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  11955. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  11956. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11957. bindBuffers(vertexBuffers: {
  11958. [key: string]: VertexBuffer;
  11959. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  11960. wipeCaches(bruteForce?: boolean): void;
  11961. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11962. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11963. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11964. /** @hidden */
  11965. _createTexture(): WebGLTexture;
  11966. /** @hidden */
  11967. _releaseTexture(texture: InternalTexture): void;
  11968. 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;
  11969. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11970. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11971. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  11972. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11973. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  11974. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  11975. areAllEffectsReady(): boolean;
  11976. /**
  11977. * @hidden
  11978. * Get the current error code of the webGL context
  11979. * @returns the error code
  11980. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11981. */
  11982. getError(): number;
  11983. /** @hidden */
  11984. _getUnpackAlignement(): number;
  11985. /** @hidden */
  11986. _unpackFlipY(value: boolean): void;
  11987. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11988. /**
  11989. * Updates a dynamic vertex buffer.
  11990. * @param vertexBuffer the vertex buffer to update
  11991. * @param data the data used to update the vertex buffer
  11992. * @param byteOffset the byte offset of the data (optional)
  11993. * @param byteLength the byte length of the data (optional)
  11994. */
  11995. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  11996. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  11997. /** @hidden */
  11998. _bindTexture(channel: number, texture: InternalTexture): void;
  11999. /** @hidden */
  12000. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12001. releaseEffects(): void;
  12002. displayLoadingUI(): void;
  12003. hideLoadingUI(): void;
  12004. /** @hidden */
  12005. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12006. /** @hidden */
  12007. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12008. /** @hidden */
  12009. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12010. /** @hidden */
  12011. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12012. }
  12013. }
  12014. interface WebGLRenderingContext {
  12015. readonly RASTERIZER_DISCARD: number;
  12016. readonly DEPTH_COMPONENT24: number;
  12017. readonly TEXTURE_3D: number;
  12018. readonly TEXTURE_2D_ARRAY: number;
  12019. readonly TEXTURE_COMPARE_FUNC: number;
  12020. readonly TEXTURE_COMPARE_MODE: number;
  12021. readonly COMPARE_REF_TO_TEXTURE: number;
  12022. readonly TEXTURE_WRAP_R: number;
  12023. readonly HALF_FLOAT: number;
  12024. readonly RGB8: number;
  12025. readonly RED_INTEGER: number;
  12026. readonly RG_INTEGER: number;
  12027. readonly RGB_INTEGER: number;
  12028. readonly RGBA_INTEGER: number;
  12029. readonly R8_SNORM: number;
  12030. readonly RG8_SNORM: number;
  12031. readonly RGB8_SNORM: number;
  12032. readonly RGBA8_SNORM: number;
  12033. readonly R8I: number;
  12034. readonly RG8I: number;
  12035. readonly RGB8I: number;
  12036. readonly RGBA8I: number;
  12037. readonly R8UI: number;
  12038. readonly RG8UI: number;
  12039. readonly RGB8UI: number;
  12040. readonly RGBA8UI: number;
  12041. readonly R16I: number;
  12042. readonly RG16I: number;
  12043. readonly RGB16I: number;
  12044. readonly RGBA16I: number;
  12045. readonly R16UI: number;
  12046. readonly RG16UI: number;
  12047. readonly RGB16UI: number;
  12048. readonly RGBA16UI: number;
  12049. readonly R32I: number;
  12050. readonly RG32I: number;
  12051. readonly RGB32I: number;
  12052. readonly RGBA32I: number;
  12053. readonly R32UI: number;
  12054. readonly RG32UI: number;
  12055. readonly RGB32UI: number;
  12056. readonly RGBA32UI: number;
  12057. readonly RGB10_A2UI: number;
  12058. readonly R11F_G11F_B10F: number;
  12059. readonly RGB9_E5: number;
  12060. readonly RGB10_A2: number;
  12061. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12062. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12063. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12064. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12065. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12066. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12067. 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;
  12068. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12069. readonly TRANSFORM_FEEDBACK: number;
  12070. readonly INTERLEAVED_ATTRIBS: number;
  12071. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12072. createTransformFeedback(): WebGLTransformFeedback;
  12073. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12074. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12075. beginTransformFeedback(primitiveMode: number): void;
  12076. endTransformFeedback(): void;
  12077. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12078. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12079. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12080. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12081. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12082. }
  12083. interface ImageBitmap {
  12084. readonly width: number;
  12085. readonly height: number;
  12086. close(): void;
  12087. }
  12088. interface WebGLQuery extends WebGLObject {
  12089. }
  12090. declare var WebGLQuery: {
  12091. prototype: WebGLQuery;
  12092. new (): WebGLQuery;
  12093. };
  12094. interface WebGLSampler extends WebGLObject {
  12095. }
  12096. declare var WebGLSampler: {
  12097. prototype: WebGLSampler;
  12098. new (): WebGLSampler;
  12099. };
  12100. interface WebGLSync extends WebGLObject {
  12101. }
  12102. declare var WebGLSync: {
  12103. prototype: WebGLSync;
  12104. new (): WebGLSync;
  12105. };
  12106. interface WebGLTransformFeedback extends WebGLObject {
  12107. }
  12108. declare var WebGLTransformFeedback: {
  12109. prototype: WebGLTransformFeedback;
  12110. new (): WebGLTransformFeedback;
  12111. };
  12112. interface WebGLVertexArrayObject extends WebGLObject {
  12113. }
  12114. declare var WebGLVertexArrayObject: {
  12115. prototype: WebGLVertexArrayObject;
  12116. new (): WebGLVertexArrayObject;
  12117. };
  12118. declare module BABYLON {
  12119. /**
  12120. * Gather the list of keyboard event types as constants.
  12121. */
  12122. class KeyboardEventTypes {
  12123. /**
  12124. * The keydown event is fired when a key becomes active (pressed).
  12125. */
  12126. static readonly KEYDOWN: number;
  12127. /**
  12128. * The keyup event is fired when a key has been released.
  12129. */
  12130. static readonly KEYUP: number;
  12131. }
  12132. /**
  12133. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12134. */
  12135. class KeyboardInfo {
  12136. /**
  12137. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12138. */
  12139. type: number;
  12140. /**
  12141. * Defines the related dom event
  12142. */
  12143. event: KeyboardEvent;
  12144. /**
  12145. * Instantiates a new keyboard info.
  12146. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12147. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12148. * @param event Defines the related dom event
  12149. */
  12150. constructor(
  12151. /**
  12152. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12153. */
  12154. type: number,
  12155. /**
  12156. * Defines the related dom event
  12157. */
  12158. event: KeyboardEvent);
  12159. }
  12160. /**
  12161. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12162. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12163. */
  12164. class KeyboardInfoPre extends KeyboardInfo {
  12165. /**
  12166. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12167. */
  12168. type: number;
  12169. /**
  12170. * Defines the related dom event
  12171. */
  12172. event: KeyboardEvent;
  12173. /**
  12174. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12175. */
  12176. skipOnPointerObservable: boolean;
  12177. /**
  12178. * Instantiates a new keyboard pre info.
  12179. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12180. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12181. * @param event Defines the related dom event
  12182. */
  12183. constructor(
  12184. /**
  12185. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12186. */
  12187. type: number,
  12188. /**
  12189. * Defines the related dom event
  12190. */
  12191. event: KeyboardEvent);
  12192. }
  12193. }
  12194. declare module BABYLON {
  12195. /**
  12196. * Gather the list of pointer event types as constants.
  12197. */
  12198. class PointerEventTypes {
  12199. /**
  12200. * 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.
  12201. */
  12202. static readonly POINTERDOWN: number;
  12203. /**
  12204. * The pointerup event is fired when a pointer is no longer active.
  12205. */
  12206. static readonly POINTERUP: number;
  12207. /**
  12208. * The pointermove event is fired when a pointer changes coordinates.
  12209. */
  12210. static readonly POINTERMOVE: number;
  12211. /**
  12212. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12213. */
  12214. static readonly POINTERWHEEL: number;
  12215. /**
  12216. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12217. */
  12218. static readonly POINTERPICK: number;
  12219. /**
  12220. * The pointertap event is fired when a the object has been touched and released without drag.
  12221. */
  12222. static readonly POINTERTAP: number;
  12223. /**
  12224. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12225. */
  12226. static readonly POINTERDOUBLETAP: number;
  12227. }
  12228. /**
  12229. * Base class of pointer info types.
  12230. */
  12231. class PointerInfoBase {
  12232. /**
  12233. * Defines the type of event (BABYLON.PointerEventTypes)
  12234. */
  12235. type: number;
  12236. /**
  12237. * Defines the related dom event
  12238. */
  12239. event: PointerEvent | MouseWheelEvent;
  12240. /**
  12241. * Instantiates the base class of pointers info.
  12242. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12243. * @param event Defines the related dom event
  12244. */
  12245. constructor(
  12246. /**
  12247. * Defines the type of event (BABYLON.PointerEventTypes)
  12248. */
  12249. type: number,
  12250. /**
  12251. * Defines the related dom event
  12252. */
  12253. event: PointerEvent | MouseWheelEvent);
  12254. }
  12255. /**
  12256. * This class is used to store pointer related info for the onPrePointerObservable event.
  12257. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12258. */
  12259. class PointerInfoPre extends PointerInfoBase {
  12260. /**
  12261. * Ray from a pointer if availible (eg. 6dof controller)
  12262. */
  12263. ray: Nullable<Ray>;
  12264. /**
  12265. * Defines the local position of the pointer on the canvas.
  12266. */
  12267. localPosition: Vector2;
  12268. /**
  12269. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12270. */
  12271. skipOnPointerObservable: boolean;
  12272. /**
  12273. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12274. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12275. * @param event Defines the related dom event
  12276. * @param localX Defines the local x coordinates of the pointer when the event occured
  12277. * @param localY Defines the local y coordinates of the pointer when the event occured
  12278. */
  12279. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12280. }
  12281. /**
  12282. * This type contains all the data related to a pointer event in Babylon.js.
  12283. * 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.
  12284. */
  12285. class PointerInfo extends PointerInfoBase {
  12286. /**
  12287. * Defines the picking info associated to the info (if any)\
  12288. */
  12289. pickInfo: Nullable<PickingInfo>;
  12290. /**
  12291. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12292. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12293. * @param event Defines the related dom event
  12294. * @param pickInfo Defines the picking info associated to the info (if any)\
  12295. */
  12296. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12297. /**
  12298. * Defines the picking info associated to the info (if any)\
  12299. */
  12300. pickInfo: Nullable<PickingInfo>);
  12301. }
  12302. }
  12303. declare module BABYLON {
  12304. /**
  12305. * Represents a gamepad control stick position
  12306. */
  12307. class StickValues {
  12308. /**
  12309. * The x component of the control stick
  12310. */
  12311. x: number;
  12312. /**
  12313. * The y component of the control stick
  12314. */
  12315. y: number;
  12316. /**
  12317. * Initializes the gamepad x and y control stick values
  12318. * @param x The x component of the gamepad control stick value
  12319. * @param y The y component of the gamepad control stick value
  12320. */
  12321. constructor(
  12322. /**
  12323. * The x component of the control stick
  12324. */
  12325. x: number,
  12326. /**
  12327. * The y component of the control stick
  12328. */
  12329. y: number);
  12330. }
  12331. /**
  12332. * An interface which manages callbacks for gamepad button changes
  12333. */
  12334. interface GamepadButtonChanges {
  12335. /**
  12336. * Called when a gamepad has been changed
  12337. */
  12338. changed: boolean;
  12339. /**
  12340. * Called when a gamepad press event has been triggered
  12341. */
  12342. pressChanged: boolean;
  12343. /**
  12344. * Called when a touch event has been triggered
  12345. */
  12346. touchChanged: boolean;
  12347. /**
  12348. * Called when a value has changed
  12349. */
  12350. valueChanged: boolean;
  12351. }
  12352. /**
  12353. * Represents a gamepad
  12354. */
  12355. class Gamepad {
  12356. /**
  12357. * The id of the gamepad
  12358. */
  12359. id: string;
  12360. /**
  12361. * The index of the gamepad
  12362. */
  12363. index: number;
  12364. /**
  12365. * The browser gamepad
  12366. */
  12367. browserGamepad: any;
  12368. /**
  12369. * Specifies what type of gamepad this represents
  12370. */
  12371. type: number;
  12372. private _leftStick;
  12373. private _rightStick;
  12374. /** @hidden */
  12375. _isConnected: boolean;
  12376. private _leftStickAxisX;
  12377. private _leftStickAxisY;
  12378. private _rightStickAxisX;
  12379. private _rightStickAxisY;
  12380. /**
  12381. * Triggered when the left control stick has been changed
  12382. */
  12383. private _onleftstickchanged;
  12384. /**
  12385. * Triggered when the right control stick has been changed
  12386. */
  12387. private _onrightstickchanged;
  12388. /**
  12389. * Represents a gamepad controller
  12390. */
  12391. static GAMEPAD: number;
  12392. /**
  12393. * Represents a generic controller
  12394. */
  12395. static GENERIC: number;
  12396. /**
  12397. * Represents an XBox controller
  12398. */
  12399. static XBOX: number;
  12400. /**
  12401. * Represents a pose-enabled controller
  12402. */
  12403. static POSE_ENABLED: number;
  12404. /**
  12405. * Specifies whether the left control stick should be Y-inverted
  12406. */
  12407. protected _invertLeftStickY: boolean;
  12408. /**
  12409. * Specifies if the gamepad has been connected
  12410. */
  12411. readonly isConnected: boolean;
  12412. /**
  12413. * Initializes the gamepad
  12414. * @param id The id of the gamepad
  12415. * @param index The index of the gamepad
  12416. * @param browserGamepad The browser gamepad
  12417. * @param leftStickX The x component of the left joystick
  12418. * @param leftStickY The y component of the left joystick
  12419. * @param rightStickX The x component of the right joystick
  12420. * @param rightStickY The y component of the right joystick
  12421. */
  12422. constructor(
  12423. /**
  12424. * The id of the gamepad
  12425. */
  12426. id: string,
  12427. /**
  12428. * The index of the gamepad
  12429. */
  12430. index: number,
  12431. /**
  12432. * The browser gamepad
  12433. */
  12434. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12435. /**
  12436. * Callback triggered when the left joystick has changed
  12437. * @param callback
  12438. */
  12439. onleftstickchanged(callback: (values: StickValues) => void): void;
  12440. /**
  12441. * Callback triggered when the right joystick has changed
  12442. * @param callback
  12443. */
  12444. onrightstickchanged(callback: (values: StickValues) => void): void;
  12445. /**
  12446. * Gets the left joystick
  12447. */
  12448. /**
  12449. * Sets the left joystick values
  12450. */
  12451. leftStick: StickValues;
  12452. /**
  12453. * Gets the right joystick
  12454. */
  12455. /**
  12456. * Sets the right joystick value
  12457. */
  12458. rightStick: StickValues;
  12459. /**
  12460. * Updates the gamepad joystick positions
  12461. */
  12462. update(): void;
  12463. /**
  12464. * Disposes the gamepad
  12465. */
  12466. dispose(): void;
  12467. }
  12468. /**
  12469. * Represents a generic gamepad
  12470. */
  12471. class GenericPad extends Gamepad {
  12472. private _buttons;
  12473. private _onbuttondown;
  12474. private _onbuttonup;
  12475. /**
  12476. * Observable triggered when a button has been pressed
  12477. */
  12478. onButtonDownObservable: Observable<number>;
  12479. /**
  12480. * Observable triggered when a button has been released
  12481. */
  12482. onButtonUpObservable: Observable<number>;
  12483. /**
  12484. * Callback triggered when a button has been pressed
  12485. * @param callback Called when a button has been pressed
  12486. */
  12487. onbuttondown(callback: (buttonPressed: number) => void): void;
  12488. /**
  12489. * Callback triggered when a button has been released
  12490. * @param callback Called when a button has been released
  12491. */
  12492. onbuttonup(callback: (buttonReleased: number) => void): void;
  12493. /**
  12494. * Initializes the generic gamepad
  12495. * @param id The id of the generic gamepad
  12496. * @param index The index of the generic gamepad
  12497. * @param browserGamepad The browser gamepad
  12498. */
  12499. constructor(id: string, index: number, browserGamepad: any);
  12500. private _setButtonValue;
  12501. /**
  12502. * Updates the generic gamepad
  12503. */
  12504. update(): void;
  12505. /**
  12506. * Disposes the generic gamepad
  12507. */
  12508. dispose(): void;
  12509. }
  12510. }
  12511. declare module BABYLON {
  12512. /**
  12513. * Manager for handling gamepads
  12514. */
  12515. class GamepadManager {
  12516. private _scene?;
  12517. private _babylonGamepads;
  12518. private _oneGamepadConnected;
  12519. /** @hidden */
  12520. _isMonitoring: boolean;
  12521. private _gamepadEventSupported;
  12522. private _gamepadSupport;
  12523. /**
  12524. * observable to be triggered when the gamepad controller has been connected
  12525. */
  12526. onGamepadConnectedObservable: Observable<Gamepad>;
  12527. /**
  12528. * observable to be triggered when the gamepad controller has been disconnected
  12529. */
  12530. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12531. private _onGamepadConnectedEvent;
  12532. private _onGamepadDisconnectedEvent;
  12533. /**
  12534. * Initializes the gamepad manager
  12535. * @param _scene BabylonJS scene
  12536. */
  12537. constructor(_scene?: Scene | undefined);
  12538. /**
  12539. * The gamepads in the game pad manager
  12540. */
  12541. readonly gamepads: Gamepad[];
  12542. /**
  12543. * Get the gamepad controllers based on type
  12544. * @param type The type of gamepad controller
  12545. * @returns Nullable gamepad
  12546. */
  12547. getGamepadByType(type?: number): Nullable<Gamepad>;
  12548. /**
  12549. * Disposes the gamepad manager
  12550. */
  12551. dispose(): void;
  12552. private _addNewGamepad;
  12553. private _startMonitoringGamepads;
  12554. private _stopMonitoringGamepads;
  12555. /** @hidden */
  12556. _checkGamepadsStatus(): void;
  12557. private _updateGamepadObjects;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. interface Scene {
  12562. /** @hidden */
  12563. _gamepadManager: Nullable<GamepadManager>;
  12564. /**
  12565. * Gets the gamepad manager associated with the scene
  12566. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12567. */
  12568. gamepadManager: GamepadManager;
  12569. }
  12570. /**
  12571. * Interface representing a free camera inputs manager
  12572. */
  12573. interface FreeCameraInputsManager {
  12574. /**
  12575. * Adds gamepad input support to the FreeCameraInputsManager.
  12576. * @returns the FreeCameraInputsManager
  12577. */
  12578. addGamepad(): FreeCameraInputsManager;
  12579. }
  12580. /**
  12581. * Interface representing an arc rotate camera inputs manager
  12582. */
  12583. interface ArcRotateCameraInputsManager {
  12584. /**
  12585. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12586. * @returns the camera inputs manager
  12587. */
  12588. addGamepad(): ArcRotateCameraInputsManager;
  12589. }
  12590. /**
  12591. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12592. */
  12593. class GamepadSystemSceneComponent implements ISceneComponent {
  12594. /**
  12595. * The component name helpfull to identify the component in the list of scene components.
  12596. */
  12597. readonly name: string;
  12598. /**
  12599. * The scene the component belongs to.
  12600. */
  12601. scene: Scene;
  12602. /**
  12603. * Creates a new instance of the component for the given scene
  12604. * @param scene Defines the scene to register the component in
  12605. */
  12606. constructor(scene: Scene);
  12607. /**
  12608. * Registers the component in a given scene
  12609. */
  12610. register(): void;
  12611. /**
  12612. * Rebuilds the elements related to this component in case of
  12613. * context lost for instance.
  12614. */
  12615. rebuild(): void;
  12616. /**
  12617. * Disposes the component and the associated ressources
  12618. */
  12619. dispose(): void;
  12620. private _beforeCameraUpdate;
  12621. }
  12622. }
  12623. declare module BABYLON {
  12624. /**
  12625. * Defines supported buttons for XBox360 compatible gamepads
  12626. */
  12627. enum Xbox360Button {
  12628. /** A */
  12629. A = 0,
  12630. /** B */
  12631. B = 1,
  12632. /** X */
  12633. X = 2,
  12634. /** Y */
  12635. Y = 3,
  12636. /** Start */
  12637. Start = 4,
  12638. /** Back */
  12639. Back = 5,
  12640. /** Left button */
  12641. LB = 6,
  12642. /** Right button */
  12643. RB = 7,
  12644. /** Left stick */
  12645. LeftStick = 8,
  12646. /** Right stick */
  12647. RightStick = 9
  12648. }
  12649. /** Defines values for XBox360 DPad */
  12650. enum Xbox360Dpad {
  12651. /** Up */
  12652. Up = 0,
  12653. /** Down */
  12654. Down = 1,
  12655. /** Left */
  12656. Left = 2,
  12657. /** Right */
  12658. Right = 3
  12659. }
  12660. /**
  12661. * Defines a XBox360 gamepad
  12662. */
  12663. class Xbox360Pad extends Gamepad {
  12664. private _leftTrigger;
  12665. private _rightTrigger;
  12666. private _onlefttriggerchanged;
  12667. private _onrighttriggerchanged;
  12668. private _onbuttondown;
  12669. private _onbuttonup;
  12670. private _ondpaddown;
  12671. private _ondpadup;
  12672. /** Observable raised when a button is pressed */
  12673. onButtonDownObservable: Observable<Xbox360Button>;
  12674. /** Observable raised when a button is released */
  12675. onButtonUpObservable: Observable<Xbox360Button>;
  12676. /** Observable raised when a pad is pressed */
  12677. onPadDownObservable: Observable<Xbox360Dpad>;
  12678. /** Observable raised when a pad is released */
  12679. onPadUpObservable: Observable<Xbox360Dpad>;
  12680. private _buttonA;
  12681. private _buttonB;
  12682. private _buttonX;
  12683. private _buttonY;
  12684. private _buttonBack;
  12685. private _buttonStart;
  12686. private _buttonLB;
  12687. private _buttonRB;
  12688. private _buttonLeftStick;
  12689. private _buttonRightStick;
  12690. private _dPadUp;
  12691. private _dPadDown;
  12692. private _dPadLeft;
  12693. private _dPadRight;
  12694. private _isXboxOnePad;
  12695. /**
  12696. * Creates a new XBox360 gamepad object
  12697. * @param id defines the id of this gamepad
  12698. * @param index defines its index
  12699. * @param gamepad defines the internal HTML gamepad object
  12700. * @param xboxOne defines if it is a XBox One gamepad
  12701. */
  12702. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12703. /**
  12704. * Defines the callback to call when left trigger is pressed
  12705. * @param callback defines the callback to use
  12706. */
  12707. onlefttriggerchanged(callback: (value: number) => void): void;
  12708. /**
  12709. * Defines the callback to call when right trigger is pressed
  12710. * @param callback defines the callback to use
  12711. */
  12712. onrighttriggerchanged(callback: (value: number) => void): void;
  12713. /**
  12714. * Gets the left trigger value
  12715. */
  12716. /**
  12717. * Sets the left trigger value
  12718. */
  12719. leftTrigger: number;
  12720. /**
  12721. * Gets the right trigger value
  12722. */
  12723. /**
  12724. * Sets the right trigger value
  12725. */
  12726. rightTrigger: number;
  12727. /**
  12728. * Defines the callback to call when a button is pressed
  12729. * @param callback defines the callback to use
  12730. */
  12731. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12732. /**
  12733. * Defines the callback to call when a button is released
  12734. * @param callback defines the callback to use
  12735. */
  12736. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12737. /**
  12738. * Defines the callback to call when a pad is pressed
  12739. * @param callback defines the callback to use
  12740. */
  12741. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12742. /**
  12743. * Defines the callback to call when a pad is released
  12744. * @param callback defines the callback to use
  12745. */
  12746. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12747. private _setButtonValue;
  12748. private _setDPadValue;
  12749. /**
  12750. * Gets the value of the `A` button
  12751. */
  12752. /**
  12753. * Sets the value of the `A` button
  12754. */
  12755. buttonA: number;
  12756. /**
  12757. * Gets the value of the `B` button
  12758. */
  12759. /**
  12760. * Sets the value of the `B` button
  12761. */
  12762. buttonB: number;
  12763. /**
  12764. * Gets the value of the `X` button
  12765. */
  12766. /**
  12767. * Sets the value of the `X` button
  12768. */
  12769. buttonX: number;
  12770. /**
  12771. * Gets the value of the `Y` button
  12772. */
  12773. /**
  12774. * Sets the value of the `Y` button
  12775. */
  12776. buttonY: number;
  12777. /**
  12778. * Gets the value of the `Start` button
  12779. */
  12780. /**
  12781. * Sets the value of the `Start` button
  12782. */
  12783. buttonStart: number;
  12784. /**
  12785. * Gets the value of the `Back` button
  12786. */
  12787. /**
  12788. * Sets the value of the `Back` button
  12789. */
  12790. buttonBack: number;
  12791. /**
  12792. * Gets the value of the `Left` button
  12793. */
  12794. /**
  12795. * Sets the value of the `Left` button
  12796. */
  12797. buttonLB: number;
  12798. /**
  12799. * Gets the value of the `Right` button
  12800. */
  12801. /**
  12802. * Sets the value of the `Right` button
  12803. */
  12804. buttonRB: number;
  12805. /**
  12806. * Gets the value of the Left joystick
  12807. */
  12808. /**
  12809. * Sets the value of the Left joystick
  12810. */
  12811. buttonLeftStick: number;
  12812. /**
  12813. * Gets the value of the Right joystick
  12814. */
  12815. /**
  12816. * Sets the value of the Right joystick
  12817. */
  12818. buttonRightStick: number;
  12819. /**
  12820. * Gets the value of D-pad up
  12821. */
  12822. /**
  12823. * Sets the value of D-pad up
  12824. */
  12825. dPadUp: number;
  12826. /**
  12827. * Gets the value of D-pad down
  12828. */
  12829. /**
  12830. * Sets the value of D-pad down
  12831. */
  12832. dPadDown: number;
  12833. /**
  12834. * Gets the value of D-pad left
  12835. */
  12836. /**
  12837. * Sets the value of D-pad left
  12838. */
  12839. dPadLeft: number;
  12840. /**
  12841. * Gets the value of D-pad right
  12842. */
  12843. /**
  12844. * Sets the value of D-pad right
  12845. */
  12846. dPadRight: number;
  12847. /**
  12848. * Force the gamepad to synchronize with device values
  12849. */
  12850. update(): void;
  12851. /**
  12852. * Disposes the gamepad
  12853. */
  12854. dispose(): void;
  12855. }
  12856. }
  12857. declare module BABYLON {
  12858. /**
  12859. * Represents the different options available during the creation of
  12860. * a Environment helper.
  12861. *
  12862. * This can control the default ground, skybox and image processing setup of your scene.
  12863. */
  12864. interface IEnvironmentHelperOptions {
  12865. /**
  12866. * Specifies wether or not to create a ground.
  12867. * True by default.
  12868. */
  12869. createGround: boolean;
  12870. /**
  12871. * Specifies the ground size.
  12872. * 15 by default.
  12873. */
  12874. groundSize: number;
  12875. /**
  12876. * The texture used on the ground for the main color.
  12877. * Comes from the BabylonJS CDN by default.
  12878. *
  12879. * Remarks: Can be either a texture or a url.
  12880. */
  12881. groundTexture: string | BaseTexture;
  12882. /**
  12883. * The color mixed in the ground texture by default.
  12884. * BabylonJS clearColor by default.
  12885. */
  12886. groundColor: Color3;
  12887. /**
  12888. * Specifies the ground opacity.
  12889. * 1 by default.
  12890. */
  12891. groundOpacity: number;
  12892. /**
  12893. * Enables the ground to receive shadows.
  12894. * True by default.
  12895. */
  12896. enableGroundShadow: boolean;
  12897. /**
  12898. * Helps preventing the shadow to be fully black on the ground.
  12899. * 0.5 by default.
  12900. */
  12901. groundShadowLevel: number;
  12902. /**
  12903. * Creates a mirror texture attach to the ground.
  12904. * false by default.
  12905. */
  12906. enableGroundMirror: boolean;
  12907. /**
  12908. * Specifies the ground mirror size ratio.
  12909. * 0.3 by default as the default kernel is 64.
  12910. */
  12911. groundMirrorSizeRatio: number;
  12912. /**
  12913. * Specifies the ground mirror blur kernel size.
  12914. * 64 by default.
  12915. */
  12916. groundMirrorBlurKernel: number;
  12917. /**
  12918. * Specifies the ground mirror visibility amount.
  12919. * 1 by default
  12920. */
  12921. groundMirrorAmount: number;
  12922. /**
  12923. * Specifies the ground mirror reflectance weight.
  12924. * This uses the standard weight of the background material to setup the fresnel effect
  12925. * of the mirror.
  12926. * 1 by default.
  12927. */
  12928. groundMirrorFresnelWeight: number;
  12929. /**
  12930. * Specifies the ground mirror Falloff distance.
  12931. * This can helps reducing the size of the reflection.
  12932. * 0 by Default.
  12933. */
  12934. groundMirrorFallOffDistance: number;
  12935. /**
  12936. * Specifies the ground mirror texture type.
  12937. * Unsigned Int by Default.
  12938. */
  12939. groundMirrorTextureType: number;
  12940. /**
  12941. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  12942. * the shown objects.
  12943. */
  12944. groundYBias: number;
  12945. /**
  12946. * Specifies wether or not to create a skybox.
  12947. * True by default.
  12948. */
  12949. createSkybox: boolean;
  12950. /**
  12951. * Specifies the skybox size.
  12952. * 20 by default.
  12953. */
  12954. skyboxSize: number;
  12955. /**
  12956. * The texture used on the skybox for the main color.
  12957. * Comes from the BabylonJS CDN by default.
  12958. *
  12959. * Remarks: Can be either a texture or a url.
  12960. */
  12961. skyboxTexture: string | BaseTexture;
  12962. /**
  12963. * The color mixed in the skybox texture by default.
  12964. * BabylonJS clearColor by default.
  12965. */
  12966. skyboxColor: Color3;
  12967. /**
  12968. * The background rotation around the Y axis of the scene.
  12969. * This helps aligning the key lights of your scene with the background.
  12970. * 0 by default.
  12971. */
  12972. backgroundYRotation: number;
  12973. /**
  12974. * Compute automatically the size of the elements to best fit with the scene.
  12975. */
  12976. sizeAuto: boolean;
  12977. /**
  12978. * Default position of the rootMesh if autoSize is not true.
  12979. */
  12980. rootPosition: Vector3;
  12981. /**
  12982. * Sets up the image processing in the scene.
  12983. * true by default.
  12984. */
  12985. setupImageProcessing: boolean;
  12986. /**
  12987. * The texture used as your environment texture in the scene.
  12988. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  12989. *
  12990. * Remarks: Can be either a texture or a url.
  12991. */
  12992. environmentTexture: string | BaseTexture;
  12993. /**
  12994. * The value of the exposure to apply to the scene.
  12995. * 0.6 by default if setupImageProcessing is true.
  12996. */
  12997. cameraExposure: number;
  12998. /**
  12999. * The value of the contrast to apply to the scene.
  13000. * 1.6 by default if setupImageProcessing is true.
  13001. */
  13002. cameraContrast: number;
  13003. /**
  13004. * Specifies wether or not tonemapping should be enabled in the scene.
  13005. * true by default if setupImageProcessing is true.
  13006. */
  13007. toneMappingEnabled: boolean;
  13008. }
  13009. /**
  13010. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13011. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13012. * It also helps with the default setup of your imageProcessing configuration.
  13013. */
  13014. class EnvironmentHelper {
  13015. /**
  13016. * Default ground texture URL.
  13017. */
  13018. private static _groundTextureCDNUrl;
  13019. /**
  13020. * Default skybox texture URL.
  13021. */
  13022. private static _skyboxTextureCDNUrl;
  13023. /**
  13024. * Default environment texture URL.
  13025. */
  13026. private static _environmentTextureCDNUrl;
  13027. /**
  13028. * Creates the default options for the helper.
  13029. */
  13030. private static _getDefaultOptions;
  13031. private _rootMesh;
  13032. /**
  13033. * Gets the root mesh created by the helper.
  13034. */
  13035. readonly rootMesh: Mesh;
  13036. private _skybox;
  13037. /**
  13038. * Gets the skybox created by the helper.
  13039. */
  13040. readonly skybox: Nullable<Mesh>;
  13041. private _skyboxTexture;
  13042. /**
  13043. * Gets the skybox texture created by the helper.
  13044. */
  13045. readonly skyboxTexture: Nullable<BaseTexture>;
  13046. private _skyboxMaterial;
  13047. /**
  13048. * Gets the skybox material created by the helper.
  13049. */
  13050. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13051. private _ground;
  13052. /**
  13053. * Gets the ground mesh created by the helper.
  13054. */
  13055. readonly ground: Nullable<Mesh>;
  13056. private _groundTexture;
  13057. /**
  13058. * Gets the ground texture created by the helper.
  13059. */
  13060. readonly groundTexture: Nullable<BaseTexture>;
  13061. private _groundMirror;
  13062. /**
  13063. * Gets the ground mirror created by the helper.
  13064. */
  13065. readonly groundMirror: Nullable<MirrorTexture>;
  13066. /**
  13067. * Gets the ground mirror render list to helps pushing the meshes
  13068. * you wish in the ground reflection.
  13069. */
  13070. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13071. private _groundMaterial;
  13072. /**
  13073. * Gets the ground material created by the helper.
  13074. */
  13075. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13076. /**
  13077. * Stores the creation options.
  13078. */
  13079. private readonly _scene;
  13080. private _options;
  13081. /**
  13082. * This observable will be notified with any error during the creation of the environment,
  13083. * mainly texture creation errors.
  13084. */
  13085. onErrorObservable: Observable<{
  13086. message?: string;
  13087. exception?: any;
  13088. }>;
  13089. /**
  13090. * constructor
  13091. * @param options
  13092. * @param scene The scene to add the material to
  13093. */
  13094. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13095. /**
  13096. * Updates the background according to the new options
  13097. * @param options
  13098. */
  13099. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13100. /**
  13101. * Sets the primary color of all the available elements.
  13102. * @param color the main color to affect to the ground and the background
  13103. */
  13104. setMainColor(color: Color3): void;
  13105. /**
  13106. * Setup the image processing according to the specified options.
  13107. */
  13108. private _setupImageProcessing;
  13109. /**
  13110. * Setup the environment texture according to the specified options.
  13111. */
  13112. private _setupEnvironmentTexture;
  13113. /**
  13114. * Setup the background according to the specified options.
  13115. */
  13116. private _setupBackground;
  13117. /**
  13118. * Get the scene sizes according to the setup.
  13119. */
  13120. private _getSceneSize;
  13121. /**
  13122. * Setup the ground according to the specified options.
  13123. */
  13124. private _setupGround;
  13125. /**
  13126. * Setup the ground material according to the specified options.
  13127. */
  13128. private _setupGroundMaterial;
  13129. /**
  13130. * Setup the ground diffuse texture according to the specified options.
  13131. */
  13132. private _setupGroundDiffuseTexture;
  13133. /**
  13134. * Setup the ground mirror texture according to the specified options.
  13135. */
  13136. private _setupGroundMirrorTexture;
  13137. /**
  13138. * Setup the ground to receive the mirror texture.
  13139. */
  13140. private _setupMirrorInGroundMaterial;
  13141. /**
  13142. * Setup the skybox according to the specified options.
  13143. */
  13144. private _setupSkybox;
  13145. /**
  13146. * Setup the skybox material according to the specified options.
  13147. */
  13148. private _setupSkyboxMaterial;
  13149. /**
  13150. * Setup the skybox reflection texture according to the specified options.
  13151. */
  13152. private _setupSkyboxReflectionTexture;
  13153. private _errorHandler;
  13154. /**
  13155. * Dispose all the elements created by the Helper.
  13156. */
  13157. dispose(): void;
  13158. }
  13159. }
  13160. declare module BABYLON {
  13161. /**
  13162. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13163. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13164. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13165. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13166. */
  13167. class PhotoDome extends TransformNode {
  13168. private _useDirectMapping;
  13169. /**
  13170. * The texture being displayed on the sphere
  13171. */
  13172. protected _photoTexture: Texture;
  13173. /**
  13174. * Gets or sets the texture being displayed on the sphere
  13175. */
  13176. photoTexture: Texture;
  13177. /**
  13178. * Observable raised when an error occured while loading the 360 image
  13179. */
  13180. onLoadErrorObservable: Observable<string>;
  13181. /**
  13182. * The skybox material
  13183. */
  13184. protected _material: BackgroundMaterial;
  13185. /**
  13186. * The surface used for the skybox
  13187. */
  13188. protected _mesh: Mesh;
  13189. /**
  13190. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13191. * Also see the options.resolution property.
  13192. */
  13193. fovMultiplier: number;
  13194. /**
  13195. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13196. * @param name Element's name, child elements will append suffixes for their own names.
  13197. * @param urlsOfPhoto defines the url of the photo to display
  13198. * @param options defines an object containing optional or exposed sub element properties
  13199. * @param onError defines a callback called when an error occured while loading the texture
  13200. */
  13201. constructor(name: string, urlOfPhoto: string, options: {
  13202. resolution?: number;
  13203. size?: number;
  13204. useDirectMapping?: boolean;
  13205. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13206. /**
  13207. * Releases resources associated with this node.
  13208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13210. */
  13211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13212. }
  13213. }
  13214. declare module BABYLON {
  13215. interface Scene {
  13216. /**
  13217. * Creates a default light for the scene.
  13218. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13219. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13220. */
  13221. createDefaultLight(replace?: boolean): void;
  13222. /**
  13223. * Creates a default camera for the scene.
  13224. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13225. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13226. * @param replace has default false, when true replaces the active camera in the scene
  13227. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13228. */
  13229. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13230. /**
  13231. * Creates a default camera and a default light.
  13232. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13233. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13234. * @param replace has the default false, when true replaces the active camera/light in the scene
  13235. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13236. */
  13237. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13238. /**
  13239. * Creates a new sky box
  13240. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13241. * @param environmentTexture defines the texture to use as environment texture
  13242. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13243. * @param scale defines the overall scale of the skybox
  13244. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13245. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13246. * @returns a new mesh holding the sky box
  13247. */
  13248. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13249. /**
  13250. * Creates a new environment
  13251. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13252. * @param options defines the options you can use to configure the environment
  13253. * @returns the new EnvironmentHelper
  13254. */
  13255. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13256. /**
  13257. * Creates a new VREXperienceHelper
  13258. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13259. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13260. * @returns a new VREXperienceHelper
  13261. */
  13262. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13263. }
  13264. }
  13265. declare module BABYLON {
  13266. /**
  13267. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13268. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13269. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13270. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13271. */
  13272. class VideoDome extends TransformNode {
  13273. private _useDirectMapping;
  13274. /**
  13275. * The video texture being displayed on the sphere
  13276. */
  13277. protected _videoTexture: VideoTexture;
  13278. /**
  13279. * Gets the video texture being displayed on the sphere
  13280. */
  13281. readonly videoTexture: VideoTexture;
  13282. /**
  13283. * The skybox material
  13284. */
  13285. protected _material: BackgroundMaterial;
  13286. /**
  13287. * The surface used for the skybox
  13288. */
  13289. protected _mesh: Mesh;
  13290. /**
  13291. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13292. * Also see the options.resolution property.
  13293. */
  13294. fovMultiplier: number;
  13295. /**
  13296. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13297. * @param name Element's name, child elements will append suffixes for their own names.
  13298. * @param urlsOrVideo defines the url(s) or the video element to use
  13299. * @param options An object containing optional or exposed sub element properties
  13300. */
  13301. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13302. resolution?: number;
  13303. clickToPlay?: boolean;
  13304. autoPlay?: boolean;
  13305. loop?: boolean;
  13306. size?: number;
  13307. poster?: string;
  13308. useDirectMapping?: boolean;
  13309. }, scene: Scene);
  13310. /**
  13311. * Releases resources associated with this node.
  13312. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13313. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13314. */
  13315. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13316. }
  13317. }
  13318. declare module BABYLON {
  13319. /**
  13320. * Single axis drag gizmo
  13321. */
  13322. class AxisDragGizmo extends Gizmo {
  13323. /**
  13324. * Drag behavior responsible for the gizmos dragging interactions
  13325. */
  13326. dragBehavior: PointerDragBehavior;
  13327. private _pointerObserver;
  13328. /**
  13329. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13330. */
  13331. snapDistance: number;
  13332. /**
  13333. * Event that fires each time the gizmo snaps to a new location.
  13334. * * snapDistance is the the change in distance
  13335. */
  13336. onSnapObservable: Observable<{
  13337. snapDistance: number;
  13338. }>;
  13339. /**
  13340. * Creates an AxisDragGizmo
  13341. * @param gizmoLayer The utility layer the gizmo will be added to
  13342. * @param dragAxis The axis which the gizmo will be able to drag on
  13343. * @param color The color of the gizmo
  13344. */
  13345. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13346. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13347. /**
  13348. * Disposes of the gizmo
  13349. */
  13350. dispose(): void;
  13351. }
  13352. }
  13353. declare module BABYLON {
  13354. /**
  13355. * Single axis scale gizmo
  13356. */
  13357. class AxisScaleGizmo extends Gizmo {
  13358. private _coloredMaterial;
  13359. /**
  13360. * Drag behavior responsible for the gizmos dragging interactions
  13361. */
  13362. dragBehavior: PointerDragBehavior;
  13363. private _pointerObserver;
  13364. /**
  13365. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13366. */
  13367. snapDistance: number;
  13368. /**
  13369. * Event that fires each time the gizmo snaps to a new location.
  13370. * * snapDistance is the the change in distance
  13371. */
  13372. onSnapObservable: Observable<{
  13373. snapDistance: number;
  13374. }>;
  13375. /**
  13376. * If the scaling operation should be done on all axis (default: false)
  13377. */
  13378. uniformScaling: boolean;
  13379. /**
  13380. * Creates an AxisScaleGizmo
  13381. * @param gizmoLayer The utility layer the gizmo will be added to
  13382. * @param dragAxis The axis which the gizmo will be able to scale on
  13383. * @param color The color of the gizmo
  13384. */
  13385. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13386. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13387. /**
  13388. * Disposes of the gizmo
  13389. */
  13390. dispose(): void;
  13391. /**
  13392. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13393. * @param mesh The mesh to replace the default mesh of the gizmo
  13394. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13395. */
  13396. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13397. }
  13398. }
  13399. declare module BABYLON {
  13400. /**
  13401. * Bounding box gizmo
  13402. */
  13403. class BoundingBoxGizmo extends Gizmo {
  13404. private _lineBoundingBox;
  13405. private _rotateSpheresParent;
  13406. private _scaleBoxesParent;
  13407. private _boundingDimensions;
  13408. private _renderObserver;
  13409. private _pointerObserver;
  13410. private _scaleDragSpeed;
  13411. private _tmpQuaternion;
  13412. private _tmpVector;
  13413. private _tmpRotationMatrix;
  13414. /**
  13415. * 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)
  13416. */
  13417. ignoreChildren: boolean;
  13418. /**
  13419. * 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)
  13420. */
  13421. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13422. /**
  13423. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13424. */
  13425. rotationSphereSize: number;
  13426. /**
  13427. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13428. */
  13429. scaleBoxSize: number;
  13430. /**
  13431. * 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)
  13432. */
  13433. fixedDragMeshScreenSize: boolean;
  13434. /**
  13435. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13436. */
  13437. fixedDragMeshScreenSizeDistanceFactor: number;
  13438. /**
  13439. * Fired when a rotation sphere or scale box is dragged
  13440. */
  13441. onDragStartObservable: Observable<{}>;
  13442. /**
  13443. * Fired when a scale box is dragged
  13444. */
  13445. onScaleBoxDragObservable: Observable<{}>;
  13446. /**
  13447. * Fired when a scale box drag is ended
  13448. */
  13449. onScaleBoxDragEndObservable: Observable<{}>;
  13450. /**
  13451. * Fired when a rotation sphere is dragged
  13452. */
  13453. onRotationSphereDragObservable: Observable<{}>;
  13454. /**
  13455. * Fired when a rotation sphere drag is ended
  13456. */
  13457. onRotationSphereDragEndObservable: Observable<{}>;
  13458. /**
  13459. * 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)
  13460. */
  13461. scalePivot: Nullable<Vector3>;
  13462. private _anchorMesh;
  13463. private _existingMeshScale;
  13464. private static _PivotCached;
  13465. private static _OldPivotPoint;
  13466. private static _PivotTranslation;
  13467. private static _PivotTmpVector;
  13468. /** @hidden */
  13469. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13470. /** @hidden */
  13471. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13472. /**
  13473. * Creates an BoundingBoxGizmo
  13474. * @param gizmoLayer The utility layer the gizmo will be added to
  13475. * @param color The color of the gizmo
  13476. */
  13477. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13479. private _selectNode;
  13480. /**
  13481. * Updates the bounding box information for the Gizmo
  13482. */
  13483. updateBoundingBox(): void;
  13484. /**
  13485. * Enables rotation on the specified axis and disables rotation on the others
  13486. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13487. */
  13488. setEnabledRotationAxis(axis: string): void;
  13489. /**
  13490. * Disposes of the gizmo
  13491. */
  13492. dispose(): void;
  13493. /**
  13494. * 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)
  13495. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13496. * @returns the bounding box mesh with the passed in mesh as a child
  13497. */
  13498. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13499. /**
  13500. * CustomMeshes are not supported by this gizmo
  13501. * @param mesh The mesh to replace the default mesh of the gizmo
  13502. */
  13503. setCustomMesh(mesh: Mesh): void;
  13504. }
  13505. }
  13506. declare module BABYLON {
  13507. /**
  13508. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13509. */
  13510. class Gizmo implements IDisposable {
  13511. /** The utility layer the gizmo will be added to */
  13512. gizmoLayer: UtilityLayerRenderer;
  13513. /**
  13514. * The root mesh of the gizmo
  13515. */
  13516. protected _rootMesh: Mesh;
  13517. private _attachedMesh;
  13518. /**
  13519. * Ratio for the scale of the gizmo (Default: 1)
  13520. */
  13521. scaleRatio: number;
  13522. private _tmpMatrix;
  13523. /**
  13524. * If a custom mesh has been set (Default: false)
  13525. */
  13526. protected _customMeshSet: boolean;
  13527. /**
  13528. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13529. * * When set, interactions will be enabled
  13530. */
  13531. attachedMesh: Nullable<AbstractMesh>;
  13532. /**
  13533. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13534. * @param mesh The mesh to replace the default mesh of the gizmo
  13535. */
  13536. setCustomMesh(mesh: Mesh): void;
  13537. /**
  13538. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13539. */
  13540. updateGizmoRotationToMatchAttachedMesh: boolean;
  13541. /**
  13542. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13543. */
  13544. updateGizmoPositionToMatchAttachedMesh: boolean;
  13545. /**
  13546. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13547. */
  13548. protected _updateScale: boolean;
  13549. protected _interactionsEnabled: boolean;
  13550. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13551. private _beforeRenderObserver;
  13552. /**
  13553. * Creates a gizmo
  13554. * @param gizmoLayer The utility layer the gizmo will be added to
  13555. */
  13556. constructor(
  13557. /** The utility layer the gizmo will be added to */
  13558. gizmoLayer?: UtilityLayerRenderer);
  13559. private _tempVector;
  13560. /**
  13561. * @hidden
  13562. * Updates the gizmo to match the attached mesh's position/rotation
  13563. */
  13564. protected _update(): void;
  13565. /**
  13566. * Disposes of the gizmo
  13567. */
  13568. dispose(): void;
  13569. }
  13570. }
  13571. declare module BABYLON {
  13572. /**
  13573. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13574. */
  13575. class GizmoManager implements IDisposable {
  13576. private scene;
  13577. /**
  13578. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13579. */
  13580. gizmos: {
  13581. positionGizmo: Nullable<PositionGizmo>;
  13582. rotationGizmo: Nullable<RotationGizmo>;
  13583. scaleGizmo: Nullable<ScaleGizmo>;
  13584. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13585. };
  13586. private _gizmosEnabled;
  13587. private _pointerObserver;
  13588. private _attachedMesh;
  13589. private _boundingBoxColor;
  13590. private _defaultUtilityLayer;
  13591. private _defaultKeepDepthUtilityLayer;
  13592. /**
  13593. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13594. */
  13595. boundingBoxDragBehavior: SixDofDragBehavior;
  13596. /**
  13597. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13598. */
  13599. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13600. /**
  13601. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13602. */
  13603. usePointerToAttachGizmos: boolean;
  13604. /**
  13605. * Instatiates a gizmo manager
  13606. * @param scene the scene to overlay the gizmos on top of
  13607. */
  13608. constructor(scene: Scene);
  13609. /**
  13610. * Attaches a set of gizmos to the specified mesh
  13611. * @param mesh The mesh the gizmo's should be attached to
  13612. */
  13613. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13614. /**
  13615. * If the position gizmo is enabled
  13616. */
  13617. positionGizmoEnabled: boolean;
  13618. /**
  13619. * If the rotation gizmo is enabled
  13620. */
  13621. rotationGizmoEnabled: boolean;
  13622. /**
  13623. * If the scale gizmo is enabled
  13624. */
  13625. scaleGizmoEnabled: boolean;
  13626. /**
  13627. * If the boundingBox gizmo is enabled
  13628. */
  13629. boundingBoxGizmoEnabled: boolean;
  13630. /**
  13631. * Disposes of the gizmo manager
  13632. */
  13633. dispose(): void;
  13634. }
  13635. }
  13636. declare module BABYLON {
  13637. /**
  13638. * Single plane rotation gizmo
  13639. */
  13640. class PlaneRotationGizmo extends Gizmo {
  13641. /**
  13642. * Drag behavior responsible for the gizmos dragging interactions
  13643. */
  13644. dragBehavior: PointerDragBehavior;
  13645. private _pointerObserver;
  13646. /**
  13647. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13648. */
  13649. snapDistance: number;
  13650. /**
  13651. * Event that fires each time the gizmo snaps to a new location.
  13652. * * snapDistance is the the change in distance
  13653. */
  13654. onSnapObservable: Observable<{
  13655. snapDistance: number;
  13656. }>;
  13657. /**
  13658. * Creates a PlaneRotationGizmo
  13659. * @param gizmoLayer The utility layer the gizmo will be added to
  13660. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13661. * @param color The color of the gizmo
  13662. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13663. */
  13664. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13666. /**
  13667. * Disposes of the gizmo
  13668. */
  13669. dispose(): void;
  13670. }
  13671. }
  13672. declare module BABYLON {
  13673. /**
  13674. * Gizmo that enables dragging a mesh along 3 axis
  13675. */
  13676. class PositionGizmo extends Gizmo {
  13677. /**
  13678. * Internal gizmo used for interactions on the x axis
  13679. */
  13680. xGizmo: AxisDragGizmo;
  13681. /**
  13682. * Internal gizmo used for interactions on the y axis
  13683. */
  13684. yGizmo: AxisDragGizmo;
  13685. /**
  13686. * Internal gizmo used for interactions on the z axis
  13687. */
  13688. zGizmo: AxisDragGizmo;
  13689. /** Fires an event when any of it's sub gizmos are dragged */
  13690. onDragStartObservable: Observable<{}>;
  13691. /** Fires an event when any of it's sub gizmos are released from dragging */
  13692. onDragEndObservable: Observable<{}>;
  13693. attachedMesh: Nullable<AbstractMesh>;
  13694. /**
  13695. * Creates a PositionGizmo
  13696. * @param gizmoLayer The utility layer the gizmo will be added to
  13697. */
  13698. constructor(gizmoLayer?: UtilityLayerRenderer);
  13699. updateGizmoRotationToMatchAttachedMesh: boolean;
  13700. /**
  13701. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13702. */
  13703. snapDistance: number;
  13704. /**
  13705. * Ratio for the scale of the gizmo (Default: 1)
  13706. */
  13707. scaleRatio: number;
  13708. /**
  13709. * Disposes of the gizmo
  13710. */
  13711. dispose(): void;
  13712. /**
  13713. * CustomMeshes are not supported by this gizmo
  13714. * @param mesh The mesh to replace the default mesh of the gizmo
  13715. */
  13716. setCustomMesh(mesh: Mesh): void;
  13717. }
  13718. }
  13719. declare module BABYLON {
  13720. /**
  13721. * Gizmo that enables rotating a mesh along 3 axis
  13722. */
  13723. class RotationGizmo extends Gizmo {
  13724. /**
  13725. * Internal gizmo used for interactions on the x axis
  13726. */
  13727. xGizmo: PlaneRotationGizmo;
  13728. /**
  13729. * Internal gizmo used for interactions on the y axis
  13730. */
  13731. yGizmo: PlaneRotationGizmo;
  13732. /**
  13733. * Internal gizmo used for interactions on the z axis
  13734. */
  13735. zGizmo: PlaneRotationGizmo;
  13736. /** Fires an event when any of it's sub gizmos are dragged */
  13737. onDragStartObservable: Observable<{}>;
  13738. /** Fires an event when any of it's sub gizmos are released from dragging */
  13739. onDragEndObservable: Observable<{}>;
  13740. attachedMesh: Nullable<AbstractMesh>;
  13741. /**
  13742. * Creates a RotationGizmo
  13743. * @param gizmoLayer The utility layer the gizmo will be added to
  13744. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13745. */
  13746. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13747. updateGizmoRotationToMatchAttachedMesh: boolean;
  13748. /**
  13749. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13750. */
  13751. snapDistance: number;
  13752. /**
  13753. * Ratio for the scale of the gizmo (Default: 1)
  13754. */
  13755. scaleRatio: number;
  13756. /**
  13757. * Disposes of the gizmo
  13758. */
  13759. dispose(): void;
  13760. /**
  13761. * CustomMeshes are not supported by this gizmo
  13762. * @param mesh The mesh to replace the default mesh of the gizmo
  13763. */
  13764. setCustomMesh(mesh: Mesh): void;
  13765. }
  13766. }
  13767. declare module BABYLON {
  13768. /**
  13769. * Gizmo that enables scaling a mesh along 3 axis
  13770. */
  13771. class ScaleGizmo extends Gizmo {
  13772. /**
  13773. * Internal gizmo used for interactions on the x axis
  13774. */
  13775. xGizmo: AxisScaleGizmo;
  13776. /**
  13777. * Internal gizmo used for interactions on the y axis
  13778. */
  13779. yGizmo: AxisScaleGizmo;
  13780. /**
  13781. * Internal gizmo used for interactions on the z axis
  13782. */
  13783. zGizmo: AxisScaleGizmo;
  13784. /**
  13785. * Internal gizmo used to scale all axis equally
  13786. */
  13787. uniformScaleGizmo: AxisScaleGizmo;
  13788. /** Fires an event when any of it's sub gizmos are dragged */
  13789. onDragStartObservable: Observable<{}>;
  13790. /** Fires an event when any of it's sub gizmos are released from dragging */
  13791. onDragEndObservable: Observable<{}>;
  13792. attachedMesh: Nullable<AbstractMesh>;
  13793. /**
  13794. * Creates a ScaleGizmo
  13795. * @param gizmoLayer The utility layer the gizmo will be added to
  13796. */
  13797. constructor(gizmoLayer?: UtilityLayerRenderer);
  13798. updateGizmoRotationToMatchAttachedMesh: boolean;
  13799. /**
  13800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13801. */
  13802. snapDistance: number;
  13803. /**
  13804. * Ratio for the scale of the gizmo (Default: 1)
  13805. */
  13806. scaleRatio: number;
  13807. /**
  13808. * Disposes of the gizmo
  13809. */
  13810. dispose(): void;
  13811. }
  13812. }
  13813. declare module BABYLON {
  13814. /**
  13815. * This class can be used to get instrumentation data from a Babylon engine
  13816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13817. */
  13818. class EngineInstrumentation implements IDisposable {
  13819. /**
  13820. * Define the instrumented engine.
  13821. */
  13822. engine: Engine;
  13823. private _captureGPUFrameTime;
  13824. private _gpuFrameTimeToken;
  13825. private _gpuFrameTime;
  13826. private _captureShaderCompilationTime;
  13827. private _shaderCompilationTime;
  13828. private _onBeginFrameObserver;
  13829. private _onEndFrameObserver;
  13830. private _onBeforeShaderCompilationObserver;
  13831. private _onAfterShaderCompilationObserver;
  13832. /**
  13833. * Gets the perf counter used for GPU frame time
  13834. */
  13835. readonly gpuFrameTimeCounter: PerfCounter;
  13836. /**
  13837. * Gets the GPU frame time capture status
  13838. */
  13839. /**
  13840. * Enable or disable the GPU frame time capture
  13841. */
  13842. captureGPUFrameTime: boolean;
  13843. /**
  13844. * Gets the perf counter used for shader compilation time
  13845. */
  13846. readonly shaderCompilationTimeCounter: PerfCounter;
  13847. /**
  13848. * Gets the shader compilation time capture status
  13849. */
  13850. /**
  13851. * Enable or disable the shader compilation time capture
  13852. */
  13853. captureShaderCompilationTime: boolean;
  13854. /**
  13855. * Instantiates a new engine instrumentation.
  13856. * This class can be used to get instrumentation data from a Babylon engine
  13857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13858. * @param engine Defines the engine to instrument
  13859. */
  13860. constructor(
  13861. /**
  13862. * Define the instrumented engine.
  13863. */
  13864. engine: Engine);
  13865. /**
  13866. * Dispose and release associated resources.
  13867. */
  13868. dispose(): void;
  13869. }
  13870. }
  13871. declare module BABYLON {
  13872. /**
  13873. * This class can be used to get instrumentation data from a Babylon engine
  13874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  13875. */
  13876. class SceneInstrumentation implements IDisposable {
  13877. /**
  13878. * Defines the scene to instrument
  13879. */
  13880. scene: Scene;
  13881. private _captureActiveMeshesEvaluationTime;
  13882. private _activeMeshesEvaluationTime;
  13883. private _captureRenderTargetsRenderTime;
  13884. private _renderTargetsRenderTime;
  13885. private _captureFrameTime;
  13886. private _frameTime;
  13887. private _captureRenderTime;
  13888. private _renderTime;
  13889. private _captureInterFrameTime;
  13890. private _interFrameTime;
  13891. private _captureParticlesRenderTime;
  13892. private _particlesRenderTime;
  13893. private _captureSpritesRenderTime;
  13894. private _spritesRenderTime;
  13895. private _capturePhysicsTime;
  13896. private _physicsTime;
  13897. private _captureAnimationsTime;
  13898. private _animationsTime;
  13899. private _captureCameraRenderTime;
  13900. private _cameraRenderTime;
  13901. private _onBeforeActiveMeshesEvaluationObserver;
  13902. private _onAfterActiveMeshesEvaluationObserver;
  13903. private _onBeforeRenderTargetsRenderObserver;
  13904. private _onAfterRenderTargetsRenderObserver;
  13905. private _onAfterRenderObserver;
  13906. private _onBeforeDrawPhaseObserver;
  13907. private _onAfterDrawPhaseObserver;
  13908. private _onBeforeAnimationsObserver;
  13909. private _onBeforeParticlesRenderingObserver;
  13910. private _onAfterParticlesRenderingObserver;
  13911. private _onBeforeSpritesRenderingObserver;
  13912. private _onAfterSpritesRenderingObserver;
  13913. private _onBeforePhysicsObserver;
  13914. private _onAfterPhysicsObserver;
  13915. private _onAfterAnimationsObserver;
  13916. private _onBeforeCameraRenderObserver;
  13917. private _onAfterCameraRenderObserver;
  13918. /**
  13919. * Gets the perf counter used for active meshes evaluation time
  13920. */
  13921. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  13922. /**
  13923. * Gets the active meshes evaluation time capture status
  13924. */
  13925. /**
  13926. * Enable or disable the active meshes evaluation time capture
  13927. */
  13928. captureActiveMeshesEvaluationTime: boolean;
  13929. /**
  13930. * Gets the perf counter used for render targets render time
  13931. */
  13932. readonly renderTargetsRenderTimeCounter: PerfCounter;
  13933. /**
  13934. * Gets the render targets render time capture status
  13935. */
  13936. /**
  13937. * Enable or disable the render targets render time capture
  13938. */
  13939. captureRenderTargetsRenderTime: boolean;
  13940. /**
  13941. * Gets the perf counter used for particles render time
  13942. */
  13943. readonly particlesRenderTimeCounter: PerfCounter;
  13944. /**
  13945. * Gets the particles render time capture status
  13946. */
  13947. /**
  13948. * Enable or disable the particles render time capture
  13949. */
  13950. captureParticlesRenderTime: boolean;
  13951. /**
  13952. * Gets the perf counter used for sprites render time
  13953. */
  13954. readonly spritesRenderTimeCounter: PerfCounter;
  13955. /**
  13956. * Gets the sprites render time capture status
  13957. */
  13958. /**
  13959. * Enable or disable the sprites render time capture
  13960. */
  13961. captureSpritesRenderTime: boolean;
  13962. /**
  13963. * Gets the perf counter used for physics time
  13964. */
  13965. readonly physicsTimeCounter: PerfCounter;
  13966. /**
  13967. * Gets the physics time capture status
  13968. */
  13969. /**
  13970. * Enable or disable the physics time capture
  13971. */
  13972. capturePhysicsTime: boolean;
  13973. /**
  13974. * Gets the perf counter used for animations time
  13975. */
  13976. readonly animationsTimeCounter: PerfCounter;
  13977. /**
  13978. * Gets the animations time capture status
  13979. */
  13980. /**
  13981. * Enable or disable the animations time capture
  13982. */
  13983. captureAnimationsTime: boolean;
  13984. /**
  13985. * Gets the perf counter used for frame time capture
  13986. */
  13987. readonly frameTimeCounter: PerfCounter;
  13988. /**
  13989. * Gets the frame time capture status
  13990. */
  13991. /**
  13992. * Enable or disable the frame time capture
  13993. */
  13994. captureFrameTime: boolean;
  13995. /**
  13996. * Gets the perf counter used for inter-frames time capture
  13997. */
  13998. readonly interFrameTimeCounter: PerfCounter;
  13999. /**
  14000. * Gets the inter-frames time capture status
  14001. */
  14002. /**
  14003. * Enable or disable the inter-frames time capture
  14004. */
  14005. captureInterFrameTime: boolean;
  14006. /**
  14007. * Gets the perf counter used for render time capture
  14008. */
  14009. readonly renderTimeCounter: PerfCounter;
  14010. /**
  14011. * Gets the render time capture status
  14012. */
  14013. /**
  14014. * Enable or disable the render time capture
  14015. */
  14016. captureRenderTime: boolean;
  14017. /**
  14018. * Gets the perf counter used for camera render time capture
  14019. */
  14020. readonly cameraRenderTimeCounter: PerfCounter;
  14021. /**
  14022. * Gets the camera render time capture status
  14023. */
  14024. /**
  14025. * Enable or disable the camera render time capture
  14026. */
  14027. captureCameraRenderTime: boolean;
  14028. /**
  14029. * Gets the perf counter used for draw calls
  14030. */
  14031. readonly drawCallsCounter: PerfCounter;
  14032. /**
  14033. * Gets the perf counter used for texture collisions
  14034. */
  14035. readonly textureCollisionsCounter: PerfCounter;
  14036. /**
  14037. * Instantiates a new scene instrumentation.
  14038. * This class can be used to get instrumentation data from a Babylon engine
  14039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14040. * @param scene Defines the scene to instrument
  14041. */
  14042. constructor(
  14043. /**
  14044. * Defines the scene to instrument
  14045. */
  14046. scene: Scene);
  14047. /**
  14048. * Dispose and release associated resources.
  14049. */
  14050. dispose(): void;
  14051. }
  14052. }
  14053. declare module BABYLON {
  14054. /**
  14055. * @hidden
  14056. **/
  14057. class _TimeToken {
  14058. _startTimeQuery: Nullable<WebGLQuery>;
  14059. _endTimeQuery: Nullable<WebGLQuery>;
  14060. _timeElapsedQuery: Nullable<WebGLQuery>;
  14061. _timeElapsedQueryEnded: boolean;
  14062. }
  14063. }
  14064. declare module BABYLON {
  14065. /**
  14066. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14067. * It controls one of the indiviual texture used in the effect.
  14068. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14069. */
  14070. class LensFlare {
  14071. /**
  14072. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14073. */
  14074. size: number;
  14075. /**
  14076. * 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.
  14077. */
  14078. position: number;
  14079. /**
  14080. * Define the lens color.
  14081. */
  14082. color: Color3;
  14083. /**
  14084. * Define the lens texture.
  14085. */
  14086. texture: Nullable<Texture>;
  14087. /**
  14088. * Define the alpha mode to render this particular lens.
  14089. */
  14090. alphaMode: number;
  14091. private _system;
  14092. /**
  14093. * Creates a new Lens Flare.
  14094. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14095. * It controls one of the indiviual texture used in the effect.
  14096. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14097. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  14098. * @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.
  14099. * @param color Define the lens color
  14100. * @param imgUrl Define the lens texture url
  14101. * @param system Define the `lensFlareSystem` this flare is part of
  14102. * @returns The newly created Lens Flare
  14103. */
  14104. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  14105. /**
  14106. * Instantiates a new Lens Flare.
  14107. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  14108. * It controls one of the indiviual texture used in the effect.
  14109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14110. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  14111. * @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.
  14112. * @param color Define the lens color
  14113. * @param imgUrl Define the lens texture url
  14114. * @param system Define the `lensFlareSystem` this flare is part of
  14115. */
  14116. constructor(
  14117. /**
  14118. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  14119. */
  14120. size: number,
  14121. /**
  14122. * 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.
  14123. */
  14124. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  14125. /**
  14126. * Dispose and release the lens flare with its associated resources.
  14127. */
  14128. dispose(): void;
  14129. }
  14130. }
  14131. declare module BABYLON {
  14132. /**
  14133. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14134. * It is usually composed of several `BABYLON.lensFlare`.
  14135. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14136. */
  14137. class LensFlareSystem {
  14138. /**
  14139. * Define the name of the lens flare system
  14140. */
  14141. name: string;
  14142. /**
  14143. * List of lens flares used in this system.
  14144. */
  14145. lensFlares: LensFlare[];
  14146. /**
  14147. * Define a limit from the border the lens flare can be visible.
  14148. */
  14149. borderLimit: number;
  14150. /**
  14151. * Define a viewport border we do not want to see the lens flare in.
  14152. */
  14153. viewportBorder: number;
  14154. /**
  14155. * Define a predicate which could limit the list of meshes able to occlude the effect.
  14156. */
  14157. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  14158. /**
  14159. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  14160. */
  14161. layerMask: number;
  14162. /**
  14163. * Define the id of the lens flare system in the scene.
  14164. * (equal to name by default)
  14165. */
  14166. id: string;
  14167. private _scene;
  14168. private _emitter;
  14169. private _vertexBuffers;
  14170. private _indexBuffer;
  14171. private _effect;
  14172. private _positionX;
  14173. private _positionY;
  14174. private _isEnabled;
  14175. /**
  14176. * Instantiates a lens flare system.
  14177. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  14178. * It is usually composed of several `BABYLON.lensFlare`.
  14179. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14180. * @param name Define the name of the lens flare system in the scene
  14181. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  14182. * @param scene Define the scene the lens flare system belongs to
  14183. */
  14184. constructor(
  14185. /**
  14186. * Define the name of the lens flare system
  14187. */
  14188. name: string, emitter: any, scene: Scene);
  14189. /**
  14190. * Define if the lens flare system is enabled.
  14191. */
  14192. isEnabled: boolean;
  14193. /**
  14194. * Get the scene the effects belongs to.
  14195. * @returns the scene holding the lens flare system
  14196. */
  14197. getScene(): Scene;
  14198. /**
  14199. * Get the emitter of the lens flare system.
  14200. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14201. * @returns the emitter of the lens flare system
  14202. */
  14203. getEmitter(): any;
  14204. /**
  14205. * Set the emitter of the lens flare system.
  14206. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  14207. * @param newEmitter Define the new emitter of the system
  14208. */
  14209. setEmitter(newEmitter: any): void;
  14210. /**
  14211. * Get the lens flare system emitter position.
  14212. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  14213. * @returns the position
  14214. */
  14215. getEmitterPosition(): Vector3;
  14216. /**
  14217. * @hidden
  14218. */
  14219. computeEffectivePosition(globalViewport: Viewport): boolean;
  14220. /** @hidden */
  14221. _isVisible(): boolean;
  14222. /**
  14223. * @hidden
  14224. */
  14225. render(): boolean;
  14226. /**
  14227. * Dispose and release the lens flare with its associated resources.
  14228. */
  14229. dispose(): void;
  14230. /**
  14231. * Parse a lens flare system from a JSON repressentation
  14232. * @param parsedLensFlareSystem Define the JSON to parse
  14233. * @param scene Define the scene the parsed system should be instantiated in
  14234. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  14235. * @returns the parsed system
  14236. */
  14237. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  14238. /**
  14239. * Serialize the current Lens Flare System into a JSON representation.
  14240. * @returns the serialized JSON
  14241. */
  14242. serialize(): any;
  14243. }
  14244. }
  14245. declare module BABYLON {
  14246. interface AbstractScene {
  14247. /**
  14248. * The list of lens flare system added to the scene
  14249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  14250. */
  14251. lensFlareSystems: Array<LensFlareSystem>;
  14252. /**
  14253. * Removes the given lens flare system from this scene.
  14254. * @param toRemove The lens flare system to remove
  14255. * @returns The index of the removed lens flare system
  14256. */
  14257. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  14258. /**
  14259. * Adds the given lens flare system to this scene
  14260. * @param newLensFlareSystem The lens flare system to add
  14261. */
  14262. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  14263. /**
  14264. * Gets a lens flare system using its name
  14265. * @param name defines the name to look for
  14266. * @returns the lens flare system or null if not found
  14267. */
  14268. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  14269. /**
  14270. * Gets a lens flare system using its id
  14271. * @param id defines the id to look for
  14272. * @returns the lens flare system or null if not found
  14273. */
  14274. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  14275. }
  14276. /**
  14277. * Defines the lens flare scene component responsible to manage any lens flares
  14278. * in a given scene.
  14279. */
  14280. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  14281. /**
  14282. * The component name helpfull to identify the component in the list of scene components.
  14283. */
  14284. readonly name: string;
  14285. /**
  14286. * The scene the component belongs to.
  14287. */
  14288. scene: Scene;
  14289. /**
  14290. * Creates a new instance of the component for the given scene
  14291. * @param scene Defines the scene to register the component in
  14292. */
  14293. constructor(scene: Scene);
  14294. /**
  14295. * Registers the component in a given scene
  14296. */
  14297. register(): void;
  14298. /**
  14299. * Rebuilds the elements related to this component in case of
  14300. * context lost for instance.
  14301. */
  14302. rebuild(): void;
  14303. /**
  14304. * Adds all the element from the container to the scene
  14305. * @param container the container holding the elements
  14306. */
  14307. addFromContainer(container: AbstractScene): void;
  14308. /**
  14309. * Removes all the elements in the container from the scene
  14310. * @param container contains the elements to remove
  14311. */
  14312. removeFromContainer(container: AbstractScene): void;
  14313. /**
  14314. * Serializes the component data to the specified json object
  14315. * @param serializationObject The object to serialize to
  14316. */
  14317. serialize(serializationObject: any): void;
  14318. /**
  14319. * Disposes the component and the associated ressources.
  14320. */
  14321. dispose(): void;
  14322. private _draw;
  14323. }
  14324. }
  14325. declare module BABYLON {
  14326. /**
  14327. * Effect layer options. This helps customizing the behaviour
  14328. * of the effect layer.
  14329. */
  14330. interface IEffectLayerOptions {
  14331. /**
  14332. * Multiplication factor apply to the canvas size to compute the render target size
  14333. * used to generated the objects (the smaller the faster).
  14334. */
  14335. mainTextureRatio: number;
  14336. /**
  14337. * Enforces a fixed size texture to ensure effect stability across devices.
  14338. */
  14339. mainTextureFixedSize?: number;
  14340. /**
  14341. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14342. */
  14343. alphaBlendingMode: number;
  14344. /**
  14345. * The camera attached to the layer.
  14346. */
  14347. camera: Nullable<Camera>;
  14348. /**
  14349. * The rendering group to draw the layer in.
  14350. */
  14351. renderingGroupId: number;
  14352. }
  14353. /**
  14354. * The effect layer Helps adding post process effect blended with the main pass.
  14355. *
  14356. * This can be for instance use to generate glow or higlight effects on the scene.
  14357. *
  14358. * The effect layer class can not be used directly and is intented to inherited from to be
  14359. * customized per effects.
  14360. */
  14361. abstract class EffectLayer {
  14362. private _vertexBuffers;
  14363. private _indexBuffer;
  14364. private _cachedDefines;
  14365. private _effectLayerMapGenerationEffect;
  14366. private _effectLayerOptions;
  14367. private _mergeEffect;
  14368. protected _scene: Scene;
  14369. protected _engine: Engine;
  14370. protected _maxSize: number;
  14371. protected _mainTextureDesiredSize: ISize;
  14372. protected _mainTexture: RenderTargetTexture;
  14373. protected _shouldRender: boolean;
  14374. protected _postProcesses: PostProcess[];
  14375. protected _textures: BaseTexture[];
  14376. protected _emissiveTextureAndColor: {
  14377. texture: Nullable<BaseTexture>;
  14378. color: Color4;
  14379. };
  14380. /**
  14381. * The name of the layer
  14382. */
  14383. name: string;
  14384. /**
  14385. * The clear color of the texture used to generate the glow map.
  14386. */
  14387. neutralColor: Color4;
  14388. /**
  14389. * Specifies wether the highlight layer is enabled or not.
  14390. */
  14391. isEnabled: boolean;
  14392. /**
  14393. * Gets the camera attached to the layer.
  14394. */
  14395. readonly camera: Nullable<Camera>;
  14396. /**
  14397. * Gets the rendering group id the layer should render in.
  14398. */
  14399. readonly renderingGroupId: number;
  14400. /**
  14401. * An event triggered when the effect layer has been disposed.
  14402. */
  14403. onDisposeObservable: Observable<EffectLayer>;
  14404. /**
  14405. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14406. */
  14407. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14408. /**
  14409. * An event triggered when the generated texture is being merged in the scene.
  14410. */
  14411. onBeforeComposeObservable: Observable<EffectLayer>;
  14412. /**
  14413. * An event triggered when the generated texture has been merged in the scene.
  14414. */
  14415. onAfterComposeObservable: Observable<EffectLayer>;
  14416. /**
  14417. * An event triggered when the efffect layer changes its size.
  14418. */
  14419. onSizeChangedObservable: Observable<EffectLayer>;
  14420. /**
  14421. * Instantiates a new effect Layer and references it in the scene.
  14422. * @param name The name of the layer
  14423. * @param scene The scene to use the layer in
  14424. */
  14425. constructor(
  14426. /** The Friendly of the effect in the scene */
  14427. name: string, scene: Scene);
  14428. /**
  14429. * Get the effect name of the layer.
  14430. * @return The effect name
  14431. */
  14432. abstract getEffectName(): string;
  14433. /**
  14434. * Checks for the readiness of the element composing the layer.
  14435. * @param subMesh the mesh to check for
  14436. * @param useInstances specify wether or not to use instances to render the mesh
  14437. * @return true if ready otherwise, false
  14438. */
  14439. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14440. /**
  14441. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14442. * @returns true if the effect requires stencil during the main canvas render pass.
  14443. */
  14444. abstract needStencil(): boolean;
  14445. /**
  14446. * Create the merge effect. This is the shader use to blit the information back
  14447. * to the main canvas at the end of the scene rendering.
  14448. * @returns The effect containing the shader used to merge the effect on the main canvas
  14449. */
  14450. protected abstract _createMergeEffect(): Effect;
  14451. /**
  14452. * Creates the render target textures and post processes used in the effect layer.
  14453. */
  14454. protected abstract _createTextureAndPostProcesses(): void;
  14455. /**
  14456. * Implementation specific of rendering the generating effect on the main canvas.
  14457. * @param effect The effect used to render through
  14458. */
  14459. protected abstract _internalRender(effect: Effect): void;
  14460. /**
  14461. * Sets the required values for both the emissive texture and and the main color.
  14462. */
  14463. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14464. /**
  14465. * Free any resources and references associated to a mesh.
  14466. * Internal use
  14467. * @param mesh The mesh to free.
  14468. */
  14469. abstract _disposeMesh(mesh: Mesh): void;
  14470. /**
  14471. * Serializes this layer (Glow or Highlight for example)
  14472. * @returns a serialized layer object
  14473. */
  14474. abstract serialize?(): any;
  14475. /**
  14476. * Initializes the effect layer with the required options.
  14477. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14478. */
  14479. protected _init(options: Partial<IEffectLayerOptions>): void;
  14480. /**
  14481. * Generates the index buffer of the full screen quad blending to the main canvas.
  14482. */
  14483. private _generateIndexBuffer;
  14484. /**
  14485. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14486. */
  14487. private _genrateVertexBuffer;
  14488. /**
  14489. * Sets the main texture desired size which is the closest power of two
  14490. * of the engine canvas size.
  14491. */
  14492. private _setMainTextureSize;
  14493. /**
  14494. * Creates the main texture for the effect layer.
  14495. */
  14496. protected _createMainTexture(): void;
  14497. /**
  14498. * Checks for the readiness of the element composing the layer.
  14499. * @param subMesh the mesh to check for
  14500. * @param useInstances specify wether or not to use instances to render the mesh
  14501. * @param emissiveTexture the associated emissive texture used to generate the glow
  14502. * @return true if ready otherwise, false
  14503. */
  14504. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14505. /**
  14506. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14507. */
  14508. render(): void;
  14509. /**
  14510. * Determine if a given mesh will be used in the current effect.
  14511. * @param mesh mesh to test
  14512. * @returns true if the mesh will be used
  14513. */
  14514. hasMesh(mesh: AbstractMesh): boolean;
  14515. /**
  14516. * Returns true if the layer contains information to display, otherwise false.
  14517. * @returns true if the glow layer should be rendered
  14518. */
  14519. shouldRender(): boolean;
  14520. /**
  14521. * Returns true if the mesh should render, otherwise false.
  14522. * @param mesh The mesh to render
  14523. * @returns true if it should render otherwise false
  14524. */
  14525. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14526. /**
  14527. * Returns true if the mesh should render, otherwise false.
  14528. * @param mesh The mesh to render
  14529. * @returns true if it should render otherwise false
  14530. */
  14531. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14532. /**
  14533. * Renders the submesh passed in parameter to the generation map.
  14534. */
  14535. protected _renderSubMesh(subMesh: SubMesh): void;
  14536. /**
  14537. * Rebuild the required buffers.
  14538. * @hidden Internal use only.
  14539. */
  14540. _rebuild(): void;
  14541. /**
  14542. * Dispose only the render target textures and post process.
  14543. */
  14544. private _disposeTextureAndPostProcesses;
  14545. /**
  14546. * Dispose the highlight layer and free resources.
  14547. */
  14548. dispose(): void;
  14549. /**
  14550. * Gets the class name of the effect layer
  14551. * @returns the string with the class name of the effect layer
  14552. */
  14553. getClassName(): string;
  14554. /**
  14555. * Creates an effect layer from parsed effect layer data
  14556. * @param parsedEffectLayer defines effect layer data
  14557. * @param scene defines the current scene
  14558. * @param rootUrl defines the root URL containing the effect layer information
  14559. * @returns a parsed effect Layer
  14560. */
  14561. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14562. }
  14563. }
  14564. declare module BABYLON {
  14565. interface AbstractScene {
  14566. /**
  14567. * The list of effect layers (highlights/glow) added to the scene
  14568. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14569. * @see http://doc.babylonjs.com/how_to/glow_layer
  14570. */
  14571. effectLayers: Array<EffectLayer>;
  14572. /**
  14573. * Removes the given effect layer from this scene.
  14574. * @param toRemove defines the effect layer to remove
  14575. * @returns the index of the removed effect layer
  14576. */
  14577. removeEffectLayer(toRemove: EffectLayer): number;
  14578. /**
  14579. * Adds the given effect layer to this scene
  14580. * @param newEffectLayer defines the effect layer to add
  14581. */
  14582. addEffectLayer(newEffectLayer: EffectLayer): void;
  14583. }
  14584. /**
  14585. * Defines the layer scene component responsible to manage any effect layers
  14586. * in a given scene.
  14587. */
  14588. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14589. /**
  14590. * The component name helpfull to identify the component in the list of scene components.
  14591. */
  14592. readonly name: string;
  14593. /**
  14594. * The scene the component belongs to.
  14595. */
  14596. scene: Scene;
  14597. private _engine;
  14598. private _renderEffects;
  14599. private _needStencil;
  14600. private _previousStencilState;
  14601. /**
  14602. * Creates a new instance of the component for the given scene
  14603. * @param scene Defines the scene to register the component in
  14604. */
  14605. constructor(scene: Scene);
  14606. /**
  14607. * Registers the component in a given scene
  14608. */
  14609. register(): void;
  14610. /**
  14611. * Rebuilds the elements related to this component in case of
  14612. * context lost for instance.
  14613. */
  14614. rebuild(): void;
  14615. /**
  14616. * Serializes the component data to the specified json object
  14617. * @param serializationObject The object to serialize to
  14618. */
  14619. serialize(serializationObject: any): void;
  14620. /**
  14621. * Adds all the element from the container to the scene
  14622. * @param container the container holding the elements
  14623. */
  14624. addFromContainer(container: AbstractScene): void;
  14625. /**
  14626. * Removes all the elements in the container from the scene
  14627. * @param container contains the elements to remove
  14628. */
  14629. removeFromContainer(container: AbstractScene): void;
  14630. /**
  14631. * Disposes the component and the associated ressources.
  14632. */
  14633. dispose(): void;
  14634. private _isReadyForMesh;
  14635. private _renderMainTexture;
  14636. private _setStencil;
  14637. private _setStencilBack;
  14638. private _draw;
  14639. private _drawCamera;
  14640. private _drawRenderingGroup;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. interface AbstractScene {
  14645. /**
  14646. * Return a the first highlight layer of the scene with a given name.
  14647. * @param name The name of the highlight layer to look for.
  14648. * @return The highlight layer if found otherwise null.
  14649. */
  14650. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14651. }
  14652. /**
  14653. * Glow layer options. This helps customizing the behaviour
  14654. * of the glow layer.
  14655. */
  14656. interface IGlowLayerOptions {
  14657. /**
  14658. * Multiplication factor apply to the canvas size to compute the render target size
  14659. * used to generated the glowing objects (the smaller the faster).
  14660. */
  14661. mainTextureRatio: number;
  14662. /**
  14663. * Enforces a fixed size texture to ensure resize independant blur.
  14664. */
  14665. mainTextureFixedSize?: number;
  14666. /**
  14667. * How big is the kernel of the blur texture.
  14668. */
  14669. blurKernelSize: number;
  14670. /**
  14671. * The camera attached to the layer.
  14672. */
  14673. camera: Nullable<Camera>;
  14674. /**
  14675. * Enable MSAA by chosing the number of samples.
  14676. */
  14677. mainTextureSamples?: number;
  14678. /**
  14679. * The rendering group to draw the layer in.
  14680. */
  14681. renderingGroupId: number;
  14682. }
  14683. /**
  14684. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14685. *
  14686. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14687. * glowy meshes to your scene.
  14688. *
  14689. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14690. */
  14691. class GlowLayer extends EffectLayer {
  14692. /**
  14693. * Effect Name of the layer.
  14694. */
  14695. static readonly EffectName: string;
  14696. /**
  14697. * The default blur kernel size used for the glow.
  14698. */
  14699. static DefaultBlurKernelSize: number;
  14700. /**
  14701. * The default texture size ratio used for the glow.
  14702. */
  14703. static DefaultTextureRatio: number;
  14704. /**
  14705. * Sets the kernel size of the blur.
  14706. */
  14707. /**
  14708. * Gets the kernel size of the blur.
  14709. */
  14710. blurKernelSize: number;
  14711. /**
  14712. * Sets the glow intensity.
  14713. */
  14714. /**
  14715. * Gets the glow intensity.
  14716. */
  14717. intensity: number;
  14718. private _options;
  14719. private _intensity;
  14720. private _horizontalBlurPostprocess1;
  14721. private _verticalBlurPostprocess1;
  14722. private _horizontalBlurPostprocess2;
  14723. private _verticalBlurPostprocess2;
  14724. private _blurTexture1;
  14725. private _blurTexture2;
  14726. private _postProcesses1;
  14727. private _postProcesses2;
  14728. private _includedOnlyMeshes;
  14729. private _excludedMeshes;
  14730. /**
  14731. * Callback used to let the user override the color selection on a per mesh basis
  14732. */
  14733. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14734. /**
  14735. * Callback used to let the user override the texture selection on a per mesh basis
  14736. */
  14737. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14738. /**
  14739. * Instantiates a new glow Layer and references it to the scene.
  14740. * @param name The name of the layer
  14741. * @param scene The scene to use the layer in
  14742. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14743. */
  14744. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14745. /**
  14746. * Get the effect name of the layer.
  14747. * @return The effect name
  14748. */
  14749. getEffectName(): string;
  14750. /**
  14751. * Create the merge effect. This is the shader use to blit the information back
  14752. * to the main canvas at the end of the scene rendering.
  14753. */
  14754. protected _createMergeEffect(): Effect;
  14755. /**
  14756. * Creates the render target textures and post processes used in the glow layer.
  14757. */
  14758. protected _createTextureAndPostProcesses(): void;
  14759. /**
  14760. * Checks for the readiness of the element composing the layer.
  14761. * @param subMesh the mesh to check for
  14762. * @param useInstances specify wether or not to use instances to render the mesh
  14763. * @param emissiveTexture the associated emissive texture used to generate the glow
  14764. * @return true if ready otherwise, false
  14765. */
  14766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14767. /**
  14768. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14769. */
  14770. needStencil(): boolean;
  14771. /**
  14772. * Implementation specific of rendering the generating effect on the main canvas.
  14773. * @param effect The effect used to render through
  14774. */
  14775. protected _internalRender(effect: Effect): void;
  14776. /**
  14777. * Sets the required values for both the emissive texture and and the main color.
  14778. */
  14779. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14780. /**
  14781. * Returns true if the mesh should render, otherwise false.
  14782. * @param mesh The mesh to render
  14783. * @returns true if it should render otherwise false
  14784. */
  14785. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14786. /**
  14787. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14788. * @param mesh The mesh to exclude from the glow layer
  14789. */
  14790. addExcludedMesh(mesh: Mesh): void;
  14791. /**
  14792. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14793. * @param mesh The mesh to remove
  14794. */
  14795. removeExcludedMesh(mesh: Mesh): void;
  14796. /**
  14797. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14798. * @param mesh The mesh to include in the glow layer
  14799. */
  14800. addIncludedOnlyMesh(mesh: Mesh): void;
  14801. /**
  14802. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14803. * @param mesh The mesh to remove
  14804. */
  14805. removeIncludedOnlyMesh(mesh: Mesh): void;
  14806. /**
  14807. * Determine if a given mesh will be used in the glow layer
  14808. * @param mesh The mesh to test
  14809. * @returns true if the mesh will be highlighted by the current glow layer
  14810. */
  14811. hasMesh(mesh: AbstractMesh): boolean;
  14812. /**
  14813. * Free any resources and references associated to a mesh.
  14814. * Internal use
  14815. * @param mesh The mesh to free.
  14816. * @hidden
  14817. */
  14818. _disposeMesh(mesh: Mesh): void;
  14819. /**
  14820. * Gets the class name of the effect layer
  14821. * @returns the string with the class name of the effect layer
  14822. */
  14823. getClassName(): string;
  14824. /**
  14825. * Serializes this glow layer
  14826. * @returns a serialized glow layer object
  14827. */
  14828. serialize(): any;
  14829. /**
  14830. * Creates a Glow Layer from parsed glow layer data
  14831. * @param parsedGlowLayer defines glow layer data
  14832. * @param scene defines the current scene
  14833. * @param rootUrl defines the root URL containing the glow layer information
  14834. * @returns a parsed Glow Layer
  14835. */
  14836. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14837. }
  14838. }
  14839. declare module BABYLON {
  14840. interface AbstractScene {
  14841. /**
  14842. * Return a the first highlight layer of the scene with a given name.
  14843. * @param name The name of the highlight layer to look for.
  14844. * @return The highlight layer if found otherwise null.
  14845. */
  14846. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14847. }
  14848. /**
  14849. * Highlight layer options. This helps customizing the behaviour
  14850. * of the highlight layer.
  14851. */
  14852. interface IHighlightLayerOptions {
  14853. /**
  14854. * Multiplication factor apply to the canvas size to compute the render target size
  14855. * used to generated the glowing objects (the smaller the faster).
  14856. */
  14857. mainTextureRatio: number;
  14858. /**
  14859. * Enforces a fixed size texture to ensure resize independant blur.
  14860. */
  14861. mainTextureFixedSize?: number;
  14862. /**
  14863. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14864. * of the picture to blur (the smaller the faster).
  14865. */
  14866. blurTextureSizeRatio: number;
  14867. /**
  14868. * How big in texel of the blur texture is the vertical blur.
  14869. */
  14870. blurVerticalSize: number;
  14871. /**
  14872. * How big in texel of the blur texture is the horizontal blur.
  14873. */
  14874. blurHorizontalSize: number;
  14875. /**
  14876. * Alpha blending mode used to apply the blur. Default is combine.
  14877. */
  14878. alphaBlendingMode: number;
  14879. /**
  14880. * The camera attached to the layer.
  14881. */
  14882. camera: Nullable<Camera>;
  14883. /**
  14884. * Should we display highlight as a solid stroke?
  14885. */
  14886. isStroke?: boolean;
  14887. /**
  14888. * The rendering group to draw the layer in.
  14889. */
  14890. renderingGroupId: number;
  14891. }
  14892. /**
  14893. * The highlight layer Helps adding a glow effect around a mesh.
  14894. *
  14895. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14896. * glowy meshes to your scene.
  14897. *
  14898. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14899. */
  14900. class HighlightLayer extends EffectLayer {
  14901. name: string;
  14902. /**
  14903. * Effect Name of the highlight layer.
  14904. */
  14905. static readonly EffectName: string;
  14906. /**
  14907. * The neutral color used during the preparation of the glow effect.
  14908. * This is black by default as the blend operation is a blend operation.
  14909. */
  14910. static NeutralColor: Color4;
  14911. /**
  14912. * Stencil value used for glowing meshes.
  14913. */
  14914. static GlowingMeshStencilReference: number;
  14915. /**
  14916. * Stencil value used for the other meshes in the scene.
  14917. */
  14918. static NormalMeshStencilReference: number;
  14919. /**
  14920. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14921. */
  14922. innerGlow: boolean;
  14923. /**
  14924. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14925. */
  14926. outerGlow: boolean;
  14927. /**
  14928. * Specifies the horizontal size of the blur.
  14929. */
  14930. /**
  14931. * Gets the horizontal size of the blur.
  14932. */
  14933. blurHorizontalSize: number;
  14934. /**
  14935. * Specifies the vertical size of the blur.
  14936. */
  14937. /**
  14938. * Gets the vertical size of the blur.
  14939. */
  14940. blurVerticalSize: number;
  14941. /**
  14942. * An event triggered when the highlight layer is being blurred.
  14943. */
  14944. onBeforeBlurObservable: Observable<HighlightLayer>;
  14945. /**
  14946. * An event triggered when the highlight layer has been blurred.
  14947. */
  14948. onAfterBlurObservable: Observable<HighlightLayer>;
  14949. private _instanceGlowingMeshStencilReference;
  14950. private _options;
  14951. private _downSamplePostprocess;
  14952. private _horizontalBlurPostprocess;
  14953. private _verticalBlurPostprocess;
  14954. private _blurTexture;
  14955. private _meshes;
  14956. private _excludedMeshes;
  14957. /**
  14958. * Instantiates a new highlight Layer and references it to the scene..
  14959. * @param name The name of the layer
  14960. * @param scene The scene to use the layer in
  14961. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14962. */
  14963. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14964. /**
  14965. * Get the effect name of the layer.
  14966. * @return The effect name
  14967. */
  14968. getEffectName(): string;
  14969. /**
  14970. * Create the merge effect. This is the shader use to blit the information back
  14971. * to the main canvas at the end of the scene rendering.
  14972. */
  14973. protected _createMergeEffect(): Effect;
  14974. /**
  14975. * Creates the render target textures and post processes used in the highlight layer.
  14976. */
  14977. protected _createTextureAndPostProcesses(): void;
  14978. /**
  14979. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14980. */
  14981. needStencil(): boolean;
  14982. /**
  14983. * Checks for the readiness of the element composing the layer.
  14984. * @param subMesh the mesh to check for
  14985. * @param useInstances specify wether or not to use instances to render the mesh
  14986. * @param emissiveTexture the associated emissive texture used to generate the glow
  14987. * @return true if ready otherwise, false
  14988. */
  14989. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14990. /**
  14991. * Implementation specific of rendering the generating effect on the main canvas.
  14992. * @param effect The effect used to render through
  14993. */
  14994. protected _internalRender(effect: Effect): void;
  14995. /**
  14996. * Returns true if the layer contains information to display, otherwise false.
  14997. */
  14998. shouldRender(): boolean;
  14999. /**
  15000. * Returns true if the mesh should render, otherwise false.
  15001. * @param mesh The mesh to render
  15002. * @returns true if it should render otherwise false
  15003. */
  15004. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15005. /**
  15006. * Sets the required values for both the emissive texture and and the main color.
  15007. */
  15008. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15009. /**
  15010. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15011. * @param mesh The mesh to exclude from the highlight layer
  15012. */
  15013. addExcludedMesh(mesh: Mesh): void;
  15014. /**
  15015. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15016. * @param mesh The mesh to highlight
  15017. */
  15018. removeExcludedMesh(mesh: Mesh): void;
  15019. /**
  15020. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15021. * @param mesh mesh to test
  15022. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15023. */
  15024. hasMesh(mesh: AbstractMesh): boolean;
  15025. /**
  15026. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15027. * @param mesh The mesh to highlight
  15028. * @param color The color of the highlight
  15029. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15030. */
  15031. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15032. /**
  15033. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15034. * @param mesh The mesh to highlight
  15035. */
  15036. removeMesh(mesh: Mesh): void;
  15037. /**
  15038. * Force the stencil to the normal expected value for none glowing parts
  15039. */
  15040. private _defaultStencilReference;
  15041. /**
  15042. * Free any resources and references associated to a mesh.
  15043. * Internal use
  15044. * @param mesh The mesh to free.
  15045. * @hidden
  15046. */
  15047. _disposeMesh(mesh: Mesh): void;
  15048. /**
  15049. * Dispose the highlight layer and free resources.
  15050. */
  15051. dispose(): void;
  15052. /**
  15053. * Gets the class name of the effect layer
  15054. * @returns the string with the class name of the effect layer
  15055. */
  15056. getClassName(): string;
  15057. /**
  15058. * Serializes this Highlight layer
  15059. * @returns a serialized Highlight layer object
  15060. */
  15061. serialize(): any;
  15062. /**
  15063. * Creates a Highlight layer from parsed Highlight layer data
  15064. * @param parsedHightlightLayer defines the Highlight layer data
  15065. * @param scene defines the current scene
  15066. * @param rootUrl defines the root URL containing the Highlight layer information
  15067. * @returns a parsed Highlight layer
  15068. */
  15069. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15070. }
  15071. }
  15072. declare module BABYLON {
  15073. /**
  15074. * This represents a full screen 2d layer.
  15075. * This can be usefull to display a picture in the background of your scene for instance.
  15076. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15077. */
  15078. class Layer {
  15079. /**
  15080. * Define the name of the layer.
  15081. */
  15082. name: string;
  15083. /**
  15084. * Define the texture the layer should display.
  15085. */
  15086. texture: Nullable<Texture>;
  15087. /**
  15088. * Is the layer in background or foreground.
  15089. */
  15090. isBackground: boolean;
  15091. /**
  15092. * Define the color of the layer (instead of texture).
  15093. */
  15094. color: Color4;
  15095. /**
  15096. * Define the scale of the layer in order to zoom in out of the texture.
  15097. */
  15098. scale: Vector2;
  15099. /**
  15100. * Define an offset for the layer in order to shift the texture.
  15101. */
  15102. offset: Vector2;
  15103. /**
  15104. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15105. */
  15106. alphaBlendingMode: number;
  15107. /**
  15108. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15109. * Alpha test will not mix with the background color in case of transparency.
  15110. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15111. */
  15112. alphaTest: boolean;
  15113. /**
  15114. * Define a mask to restrict the layer to only some of the scene cameras.
  15115. */
  15116. layerMask: number;
  15117. private _scene;
  15118. private _vertexBuffers;
  15119. private _indexBuffer;
  15120. private _effect;
  15121. private _alphaTestEffect;
  15122. /**
  15123. * An event triggered when the layer is disposed.
  15124. */
  15125. onDisposeObservable: Observable<Layer>;
  15126. private _onDisposeObserver;
  15127. /**
  15128. * Back compatibility with callback before the onDisposeObservable existed.
  15129. * The set callback will be triggered when the layer has been disposed.
  15130. */
  15131. onDispose: () => void;
  15132. /**
  15133. * An event triggered before rendering the scene
  15134. */
  15135. onBeforeRenderObservable: Observable<Layer>;
  15136. private _onBeforeRenderObserver;
  15137. /**
  15138. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15139. * The set callback will be triggered just before rendering the layer.
  15140. */
  15141. onBeforeRender: () => void;
  15142. /**
  15143. * An event triggered after rendering the scene
  15144. */
  15145. onAfterRenderObservable: Observable<Layer>;
  15146. private _onAfterRenderObserver;
  15147. /**
  15148. * Back compatibility with callback before the onAfterRenderObservable existed.
  15149. * The set callback will be triggered just after rendering the layer.
  15150. */
  15151. onAfterRender: () => void;
  15152. /**
  15153. * Instantiates a new layer.
  15154. * This represents a full screen 2d layer.
  15155. * This can be usefull to display a picture in the background of your scene for instance.
  15156. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15157. * @param name Define the name of the layer in the scene
  15158. * @param imgUrl Define the url of the texture to display in the layer
  15159. * @param scene Define the scene the layer belongs to
  15160. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15161. * @param color Defines a color for the layer
  15162. */
  15163. constructor(
  15164. /**
  15165. * Define the name of the layer.
  15166. */
  15167. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15168. private _createIndexBuffer;
  15169. /** @hidden */
  15170. _rebuild(): void;
  15171. /**
  15172. * Renders the layer in the scene.
  15173. */
  15174. render(): void;
  15175. /**
  15176. * Disposes and releases the associated ressources.
  15177. */
  15178. dispose(): void;
  15179. }
  15180. }
  15181. declare module BABYLON {
  15182. interface AbstractScene {
  15183. /**
  15184. * The list of layers (background and foreground) of the scene
  15185. */
  15186. layers: Array<Layer>;
  15187. }
  15188. /**
  15189. * Defines the layer scene component responsible to manage any layers
  15190. * in a given scene.
  15191. */
  15192. class LayerSceneComponent implements ISceneComponent {
  15193. /**
  15194. * The component name helpfull to identify the component in the list of scene components.
  15195. */
  15196. readonly name: string;
  15197. /**
  15198. * The scene the component belongs to.
  15199. */
  15200. scene: Scene;
  15201. private _engine;
  15202. /**
  15203. * Creates a new instance of the component for the given scene
  15204. * @param scene Defines the scene to register the component in
  15205. */
  15206. constructor(scene: Scene);
  15207. /**
  15208. * Registers the component in a given scene
  15209. */
  15210. register(): void;
  15211. /**
  15212. * Rebuilds the elements related to this component in case of
  15213. * context lost for instance.
  15214. */
  15215. rebuild(): void;
  15216. /**
  15217. * Disposes the component and the associated ressources.
  15218. */
  15219. dispose(): void;
  15220. private _draw;
  15221. private _drawBackground;
  15222. private _drawForeground;
  15223. }
  15224. }
  15225. declare module BABYLON {
  15226. /**
  15227. * A directional light is defined by a direction (what a surprise!).
  15228. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15229. * 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.
  15230. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15231. */
  15232. class DirectionalLight extends ShadowLight {
  15233. private _shadowFrustumSize;
  15234. /**
  15235. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15236. */
  15237. /**
  15238. * Specifies a fix frustum size for the shadow generation.
  15239. */
  15240. shadowFrustumSize: number;
  15241. private _shadowOrthoScale;
  15242. /**
  15243. * Gets the shadow projection scale against the optimal computed one.
  15244. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15245. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15246. */
  15247. /**
  15248. * Sets the shadow projection scale against the optimal computed one.
  15249. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15250. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15251. */
  15252. shadowOrthoScale: number;
  15253. /**
  15254. * Automatically compute the projection matrix to best fit (including all the casters)
  15255. * on each frame.
  15256. */
  15257. autoUpdateExtends: boolean;
  15258. private _orthoLeft;
  15259. private _orthoRight;
  15260. private _orthoTop;
  15261. private _orthoBottom;
  15262. /**
  15263. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15264. * The directional light is emitted from everywhere in the given direction.
  15265. * It can cast shadows.
  15266. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15267. * @param name The friendly name of the light
  15268. * @param direction The direction of the light
  15269. * @param scene The scene the light belongs to
  15270. */
  15271. constructor(name: string, direction: Vector3, scene: Scene);
  15272. /**
  15273. * Returns the string "DirectionalLight".
  15274. * @return The class name
  15275. */
  15276. getClassName(): string;
  15277. /**
  15278. * Returns the integer 1.
  15279. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15280. */
  15281. getTypeID(): number;
  15282. /**
  15283. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15284. * Returns the DirectionalLight Shadow projection matrix.
  15285. */
  15286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15287. /**
  15288. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15289. * Returns the DirectionalLight Shadow projection matrix.
  15290. */
  15291. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15292. /**
  15293. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15294. * Returns the DirectionalLight Shadow projection matrix.
  15295. */
  15296. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15297. protected _buildUniformLayout(): void;
  15298. /**
  15299. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15300. * @param effect The effect to update
  15301. * @param lightIndex The index of the light in the effect to update
  15302. * @returns The directional light
  15303. */
  15304. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15305. /**
  15306. * Gets the minZ used for shadow according to both the scene and the light.
  15307. *
  15308. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15309. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15310. * @param activeCamera The camera we are returning the min for
  15311. * @returns the depth min z
  15312. */
  15313. getDepthMinZ(activeCamera: Camera): number;
  15314. /**
  15315. * Gets the maxZ used for shadow according to both the scene and the light.
  15316. *
  15317. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15318. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15319. * @param activeCamera The camera we are returning the max for
  15320. * @returns the depth max z
  15321. */
  15322. getDepthMaxZ(activeCamera: Camera): number;
  15323. /**
  15324. * Prepares the list of defines specific to the light type.
  15325. * @param defines the list of defines
  15326. * @param lightIndex defines the index of the light for the effect
  15327. */
  15328. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15329. }
  15330. }
  15331. declare module BABYLON {
  15332. /**
  15333. * The HemisphericLight simulates the ambient environment light,
  15334. * so the passed direction is the light reflection direction, not the incoming direction.
  15335. */
  15336. class HemisphericLight extends Light {
  15337. /**
  15338. * The groundColor is the light in the opposite direction to the one specified during creation.
  15339. * 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.
  15340. */
  15341. groundColor: Color3;
  15342. /**
  15343. * The light reflection direction, not the incoming direction.
  15344. */
  15345. direction: Vector3;
  15346. /**
  15347. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15348. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15349. * The HemisphericLight can't cast shadows.
  15350. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15351. * @param name The friendly name of the light
  15352. * @param direction The direction of the light reflection
  15353. * @param scene The scene the light belongs to
  15354. */
  15355. constructor(name: string, direction: Vector3, scene: Scene);
  15356. protected _buildUniformLayout(): void;
  15357. /**
  15358. * Returns the string "HemisphericLight".
  15359. * @return The class name
  15360. */
  15361. getClassName(): string;
  15362. /**
  15363. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15364. * Returns the updated direction.
  15365. * @param target The target the direction should point to
  15366. * @return The computed direction
  15367. */
  15368. setDirectionToTarget(target: Vector3): Vector3;
  15369. /**
  15370. * Returns the shadow generator associated to the light.
  15371. * @returns Always null for hemispheric lights because it does not support shadows.
  15372. */
  15373. getShadowGenerator(): Nullable<IShadowGenerator>;
  15374. /**
  15375. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15376. * @param effect The effect to update
  15377. * @param lightIndex The index of the light in the effect to update
  15378. * @returns The hemispheric light
  15379. */
  15380. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15381. /**
  15382. * Computes the world matrix of the node
  15383. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15384. * @param useWasUpdatedFlag defines a reserved property
  15385. * @returns the world matrix
  15386. */
  15387. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15388. /**
  15389. * Returns the integer 3.
  15390. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15391. */
  15392. getTypeID(): number;
  15393. /**
  15394. * Prepares the list of defines specific to the light type.
  15395. * @param defines the list of defines
  15396. * @param lightIndex defines the index of the light for the effect
  15397. */
  15398. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15399. }
  15400. }
  15401. declare module BABYLON {
  15402. /**
  15403. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15404. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15405. * 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.
  15406. */
  15407. abstract class Light extends Node {
  15408. /**
  15409. * Falloff Default: light is falling off following the material specification:
  15410. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15411. */
  15412. static readonly FALLOFF_DEFAULT: number;
  15413. /**
  15414. * Falloff Physical: light is falling off following the inverse squared distance law.
  15415. */
  15416. static readonly FALLOFF_PHYSICAL: number;
  15417. /**
  15418. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15419. * to enhance interoperability with other engines.
  15420. */
  15421. static readonly FALLOFF_GLTF: number;
  15422. /**
  15423. * Falloff Standard: light is falling off like in the standard material
  15424. * to enhance interoperability with other materials.
  15425. */
  15426. static readonly FALLOFF_STANDARD: number;
  15427. /**
  15428. * If every light affecting the material is in this lightmapMode,
  15429. * material.lightmapTexture adds or multiplies
  15430. * (depends on material.useLightmapAsShadowmap)
  15431. * after every other light calculations.
  15432. */
  15433. static readonly LIGHTMAP_DEFAULT: number;
  15434. /**
  15435. * material.lightmapTexture as only diffuse lighting from this light
  15436. * adds only specular lighting from this light
  15437. * adds dynamic shadows
  15438. */
  15439. static readonly LIGHTMAP_SPECULAR: number;
  15440. /**
  15441. * material.lightmapTexture as only lighting
  15442. * no light calculation from this light
  15443. * only adds dynamic shadows from this light
  15444. */
  15445. static readonly LIGHTMAP_SHADOWSONLY: number;
  15446. /**
  15447. * Each light type uses the default quantity according to its type:
  15448. * point/spot lights use luminous intensity
  15449. * directional lights use illuminance
  15450. */
  15451. static readonly INTENSITYMODE_AUTOMATIC: number;
  15452. /**
  15453. * lumen (lm)
  15454. */
  15455. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15456. /**
  15457. * candela (lm/sr)
  15458. */
  15459. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15460. /**
  15461. * lux (lm/m^2)
  15462. */
  15463. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15464. /**
  15465. * nit (cd/m^2)
  15466. */
  15467. static readonly INTENSITYMODE_LUMINANCE: number;
  15468. /**
  15469. * Light type const id of the point light.
  15470. */
  15471. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15472. /**
  15473. * Light type const id of the directional light.
  15474. */
  15475. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15476. /**
  15477. * Light type const id of the spot light.
  15478. */
  15479. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15480. /**
  15481. * Light type const id of the hemispheric light.
  15482. */
  15483. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15484. /**
  15485. * Diffuse gives the basic color to an object.
  15486. */
  15487. diffuse: Color3;
  15488. /**
  15489. * Specular produces a highlight color on an object.
  15490. * Note: This is note affecting PBR materials.
  15491. */
  15492. specular: Color3;
  15493. /**
  15494. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15495. * falling off base on range or angle.
  15496. * This can be set to any values in Light.FALLOFF_x.
  15497. *
  15498. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15499. * other types of materials.
  15500. */
  15501. falloffType: number;
  15502. /**
  15503. * Strength of the light.
  15504. * Note: By default it is define in the framework own unit.
  15505. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15506. */
  15507. intensity: number;
  15508. private _range;
  15509. protected _inverseSquaredRange: number;
  15510. /**
  15511. * Defines how far from the source the light is impacting in scene units.
  15512. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15513. */
  15514. /**
  15515. * Defines how far from the source the light is impacting in scene units.
  15516. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15517. */
  15518. range: number;
  15519. /**
  15520. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15521. * of light.
  15522. */
  15523. private _photometricScale;
  15524. private _intensityMode;
  15525. /**
  15526. * Gets the photometric scale used to interpret the intensity.
  15527. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15528. */
  15529. /**
  15530. * Sets the photometric scale used to interpret the intensity.
  15531. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15532. */
  15533. intensityMode: number;
  15534. private _radius;
  15535. /**
  15536. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15537. */
  15538. /**
  15539. * sets the light radius used by PBR Materials to simulate soft area lights.
  15540. */
  15541. radius: number;
  15542. private _renderPriority;
  15543. /**
  15544. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15545. * exceeding the number allowed of the materials.
  15546. */
  15547. renderPriority: number;
  15548. private _shadowEnabled;
  15549. /**
  15550. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15551. * the current shadow generator.
  15552. */
  15553. /**
  15554. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15555. * the current shadow generator.
  15556. */
  15557. shadowEnabled: boolean;
  15558. private _includedOnlyMeshes;
  15559. /**
  15560. * Gets the only meshes impacted by this light.
  15561. */
  15562. /**
  15563. * Sets the only meshes impacted by this light.
  15564. */
  15565. includedOnlyMeshes: AbstractMesh[];
  15566. private _excludedMeshes;
  15567. /**
  15568. * Gets the meshes not impacted by this light.
  15569. */
  15570. /**
  15571. * Sets the meshes not impacted by this light.
  15572. */
  15573. excludedMeshes: AbstractMesh[];
  15574. private _excludeWithLayerMask;
  15575. /**
  15576. * Gets the layer id use to find what meshes are not impacted by the light.
  15577. * Inactive if 0
  15578. */
  15579. /**
  15580. * Sets the layer id use to find what meshes are not impacted by the light.
  15581. * Inactive if 0
  15582. */
  15583. excludeWithLayerMask: number;
  15584. private _includeOnlyWithLayerMask;
  15585. /**
  15586. * Gets the layer id use to find what meshes are impacted by the light.
  15587. * Inactive if 0
  15588. */
  15589. /**
  15590. * Sets the layer id use to find what meshes are impacted by the light.
  15591. * Inactive if 0
  15592. */
  15593. includeOnlyWithLayerMask: number;
  15594. private _lightmapMode;
  15595. /**
  15596. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15597. */
  15598. /**
  15599. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15600. */
  15601. lightmapMode: number;
  15602. /**
  15603. * Shadow generator associted to the light.
  15604. * @hidden Internal use only.
  15605. */
  15606. _shadowGenerator: Nullable<IShadowGenerator>;
  15607. /**
  15608. * @hidden Internal use only.
  15609. */
  15610. _excludedMeshesIds: string[];
  15611. /**
  15612. * @hidden Internal use only.
  15613. */
  15614. _includedOnlyMeshesIds: string[];
  15615. /**
  15616. * The current light unifom buffer.
  15617. * @hidden Internal use only.
  15618. */
  15619. _uniformBuffer: UniformBuffer;
  15620. /**
  15621. * Creates a Light object in the scene.
  15622. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15623. * @param name The firendly name of the light
  15624. * @param scene The scene the light belongs too
  15625. */
  15626. constructor(name: string, scene: Scene);
  15627. protected abstract _buildUniformLayout(): void;
  15628. /**
  15629. * Sets the passed Effect "effect" with the Light information.
  15630. * @param effect The effect to update
  15631. * @param lightIndex The index of the light in the effect to update
  15632. * @returns The light
  15633. */
  15634. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15635. /**
  15636. * Returns the string "Light".
  15637. * @returns the class name
  15638. */
  15639. getClassName(): string;
  15640. /**
  15641. * Converts the light information to a readable string for debug purpose.
  15642. * @param fullDetails Supports for multiple levels of logging within scene loading
  15643. * @returns the human readable light info
  15644. */
  15645. toString(fullDetails?: boolean): string;
  15646. /** @hidden */
  15647. protected _syncParentEnabledState(): void;
  15648. /**
  15649. * Set the enabled state of this node.
  15650. * @param value - the new enabled state
  15651. */
  15652. setEnabled(value: boolean): void;
  15653. /**
  15654. * Returns the Light associated shadow generator if any.
  15655. * @return the associated shadow generator.
  15656. */
  15657. getShadowGenerator(): Nullable<IShadowGenerator>;
  15658. /**
  15659. * Returns a Vector3, the absolute light position in the World.
  15660. * @returns the world space position of the light
  15661. */
  15662. getAbsolutePosition(): Vector3;
  15663. /**
  15664. * Specifies if the light will affect the passed mesh.
  15665. * @param mesh The mesh to test against the light
  15666. * @return true the mesh is affected otherwise, false.
  15667. */
  15668. canAffectMesh(mesh: AbstractMesh): boolean;
  15669. /**
  15670. * Sort function to order lights for rendering.
  15671. * @param a First Light object to compare to second.
  15672. * @param b Second Light object to compare first.
  15673. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15674. */
  15675. static CompareLightsPriority(a: Light, b: Light): number;
  15676. /**
  15677. * Releases resources associated with this node.
  15678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15680. */
  15681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15682. /**
  15683. * Returns the light type ID (integer).
  15684. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15685. */
  15686. getTypeID(): number;
  15687. /**
  15688. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15689. * @returns the scaled intensity in intensity mode unit
  15690. */
  15691. getScaledIntensity(): number;
  15692. /**
  15693. * Returns a new Light object, named "name", from the current one.
  15694. * @param name The name of the cloned light
  15695. * @returns the new created light
  15696. */
  15697. clone(name: string): Nullable<Light>;
  15698. /**
  15699. * Serializes the current light into a Serialization object.
  15700. * @returns the serialized object.
  15701. */
  15702. serialize(): any;
  15703. /**
  15704. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15705. * This new light is named "name" and added to the passed scene.
  15706. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15707. * @param name The friendly name of the light
  15708. * @param scene The scene the new light will belong to
  15709. * @returns the constructor function
  15710. */
  15711. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15712. /**
  15713. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15714. * @param parsedLight The JSON representation of the light
  15715. * @param scene The scene to create the parsed light in
  15716. * @returns the created light after parsing
  15717. */
  15718. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15719. private _hookArrayForExcluded;
  15720. private _hookArrayForIncludedOnly;
  15721. private _resyncMeshes;
  15722. /**
  15723. * Forces the meshes to update their light related information in their rendering used effects
  15724. * @hidden Internal Use Only
  15725. */
  15726. _markMeshesAsLightDirty(): void;
  15727. /**
  15728. * Recomputes the cached photometric scale if needed.
  15729. */
  15730. private _computePhotometricScale;
  15731. /**
  15732. * Returns the Photometric Scale according to the light type and intensity mode.
  15733. */
  15734. private _getPhotometricScale;
  15735. /**
  15736. * Reorder the light in the scene according to their defined priority.
  15737. * @hidden Internal Use Only
  15738. */
  15739. _reorderLightsInScene(): void;
  15740. /**
  15741. * Prepares the list of defines specific to the light type.
  15742. * @param defines the list of defines
  15743. * @param lightIndex defines the index of the light for the effect
  15744. */
  15745. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15746. }
  15747. }
  15748. declare module BABYLON {
  15749. /**
  15750. * A point light is a light defined by an unique point in world space.
  15751. * The light is emitted in every direction from this point.
  15752. * A good example of a point light is a standard light bulb.
  15753. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15754. */
  15755. class PointLight extends ShadowLight {
  15756. private _shadowAngle;
  15757. /**
  15758. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15759. * This specifies what angle the shadow will use to be created.
  15760. *
  15761. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15762. */
  15763. /**
  15764. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15765. * This specifies what angle the shadow will use to be created.
  15766. *
  15767. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15768. */
  15769. shadowAngle: number;
  15770. /**
  15771. * Gets the direction if it has been set.
  15772. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15773. */
  15774. /**
  15775. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15776. */
  15777. direction: Vector3;
  15778. /**
  15779. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15780. * A PointLight emits the light in every direction.
  15781. * It can cast shadows.
  15782. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15783. * ```javascript
  15784. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15785. * ```
  15786. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15787. * @param name The light friendly name
  15788. * @param position The position of the point light in the scene
  15789. * @param scene The scene the lights belongs to
  15790. */
  15791. constructor(name: string, position: Vector3, scene: Scene);
  15792. /**
  15793. * Returns the string "PointLight"
  15794. * @returns the class name
  15795. */
  15796. getClassName(): string;
  15797. /**
  15798. * Returns the integer 0.
  15799. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15800. */
  15801. getTypeID(): number;
  15802. /**
  15803. * Specifies wether or not the shadowmap should be a cube texture.
  15804. * @returns true if the shadowmap needs to be a cube texture.
  15805. */
  15806. needCube(): boolean;
  15807. /**
  15808. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15809. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15810. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15811. */
  15812. getShadowDirection(faceIndex?: number): Vector3;
  15813. /**
  15814. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  15815. * - fov = PI / 2
  15816. * - aspect ratio : 1.0
  15817. * - z-near and far equal to the active camera minZ and maxZ.
  15818. * Returns the PointLight.
  15819. */
  15820. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15821. protected _buildUniformLayout(): void;
  15822. /**
  15823. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  15824. * @param effect The effect to update
  15825. * @param lightIndex The index of the light in the effect to update
  15826. * @returns The point light
  15827. */
  15828. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  15829. /**
  15830. * Prepares the list of defines specific to the light type.
  15831. * @param defines the list of defines
  15832. * @param lightIndex defines the index of the light for the effect
  15833. */
  15834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15835. }
  15836. }
  15837. declare module BABYLON {
  15838. /**
  15839. * Interface describing all the common properties and methods a shadow light needs to implement.
  15840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  15841. * as well as binding the different shadow properties to the effects.
  15842. */
  15843. interface IShadowLight extends Light {
  15844. /**
  15845. * The light id in the scene (used in scene.findLighById for instance)
  15846. */
  15847. id: string;
  15848. /**
  15849. * The position the shdow will be casted from.
  15850. */
  15851. position: Vector3;
  15852. /**
  15853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  15854. */
  15855. direction: Vector3;
  15856. /**
  15857. * The transformed position. Position of the light in world space taking parenting in account.
  15858. */
  15859. transformedPosition: Vector3;
  15860. /**
  15861. * The transformed direction. Direction of the light in world space taking parenting in account.
  15862. */
  15863. transformedDirection: Vector3;
  15864. /**
  15865. * The friendly name of the light in the scene.
  15866. */
  15867. name: string;
  15868. /**
  15869. * Defines the shadow projection clipping minimum z value.
  15870. */
  15871. shadowMinZ: number;
  15872. /**
  15873. * Defines the shadow projection clipping maximum z value.
  15874. */
  15875. shadowMaxZ: number;
  15876. /**
  15877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15879. */
  15880. computeTransformedInformation(): boolean;
  15881. /**
  15882. * Gets the scene the light belongs to.
  15883. * @returns The scene
  15884. */
  15885. getScene(): Scene;
  15886. /**
  15887. * Callback defining a custom Projection Matrix Builder.
  15888. * This can be used to override the default projection matrix computation.
  15889. */
  15890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15891. /**
  15892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  15893. * @param matrix The materix to updated with the projection information
  15894. * @param viewMatrix The transform matrix of the light
  15895. * @param renderList The list of mesh to render in the map
  15896. * @returns The current light
  15897. */
  15898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  15899. /**
  15900. * Gets the current depth scale used in ESM.
  15901. * @returns The scale
  15902. */
  15903. getDepthScale(): number;
  15904. /**
  15905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  15906. * @returns true if a cube texture needs to be use
  15907. */
  15908. needCube(): boolean;
  15909. /**
  15910. * Detects if the projection matrix requires to be recomputed this frame.
  15911. * @returns true if it requires to be recomputed otherwise, false.
  15912. */
  15913. needProjectionMatrixCompute(): boolean;
  15914. /**
  15915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  15916. */
  15917. forceProjectionMatrixCompute(): void;
  15918. /**
  15919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  15920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15922. */
  15923. getShadowDirection(faceIndex?: number): Vector3;
  15924. /**
  15925. * Gets the minZ used for shadow according to both the scene and the light.
  15926. * @param activeCamera The camera we are returning the min for
  15927. * @returns the depth min z
  15928. */
  15929. getDepthMinZ(activeCamera: Camera): number;
  15930. /**
  15931. * Gets the maxZ used for shadow according to both the scene and the light.
  15932. * @param activeCamera The camera we are returning the max for
  15933. * @returns the depth max z
  15934. */
  15935. getDepthMaxZ(activeCamera: Camera): number;
  15936. }
  15937. /**
  15938. * Base implementation IShadowLight
  15939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  15940. */
  15941. abstract class ShadowLight extends Light implements IShadowLight {
  15942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15943. protected _position: Vector3;
  15944. protected _setPosition(value: Vector3): void;
  15945. /**
  15946. * Sets the position the shadow will be casted from. Also use as the light position for both
  15947. * point and spot lights.
  15948. */
  15949. /**
  15950. * Sets the position the shadow will be casted from. Also use as the light position for both
  15951. * point and spot lights.
  15952. */
  15953. position: Vector3;
  15954. protected _direction: Vector3;
  15955. protected _setDirection(value: Vector3): void;
  15956. /**
  15957. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  15958. * Also use as the light direction on spot and directional lights.
  15959. */
  15960. /**
  15961. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  15962. * Also use as the light direction on spot and directional lights.
  15963. */
  15964. direction: Vector3;
  15965. private _shadowMinZ;
  15966. /**
  15967. * Gets the shadow projection clipping minimum z value.
  15968. */
  15969. /**
  15970. * Sets the shadow projection clipping minimum z value.
  15971. */
  15972. shadowMinZ: number;
  15973. private _shadowMaxZ;
  15974. /**
  15975. * Sets the shadow projection clipping maximum z value.
  15976. */
  15977. /**
  15978. * Gets the shadow projection clipping maximum z value.
  15979. */
  15980. shadowMaxZ: number;
  15981. /**
  15982. * Callback defining a custom Projection Matrix Builder.
  15983. * This can be used to override the default projection matrix computation.
  15984. */
  15985. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  15986. /**
  15987. * The transformed position. Position of the light in world space taking parenting in account.
  15988. */
  15989. transformedPosition: Vector3;
  15990. /**
  15991. * The transformed direction. Direction of the light in world space taking parenting in account.
  15992. */
  15993. transformedDirection: Vector3;
  15994. private _needProjectionMatrixCompute;
  15995. /**
  15996. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  15997. * @returns true if the information has been computed, false if it does not need to (no parenting)
  15998. */
  15999. computeTransformedInformation(): boolean;
  16000. /**
  16001. * Return the depth scale used for the shadow map.
  16002. * @returns the depth scale.
  16003. */
  16004. getDepthScale(): number;
  16005. /**
  16006. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16007. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16008. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16009. */
  16010. getShadowDirection(faceIndex?: number): Vector3;
  16011. /**
  16012. * Returns the ShadowLight absolute position in the World.
  16013. * @returns the position vector in world space
  16014. */
  16015. getAbsolutePosition(): Vector3;
  16016. /**
  16017. * Sets the ShadowLight direction toward the passed target.
  16018. * @param target The point tot target in local space
  16019. * @returns the updated ShadowLight direction
  16020. */
  16021. setDirectionToTarget(target: Vector3): Vector3;
  16022. /**
  16023. * Returns the light rotation in euler definition.
  16024. * @returns the x y z rotation in local space.
  16025. */
  16026. getRotation(): Vector3;
  16027. /**
  16028. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16029. * @returns true if a cube texture needs to be use
  16030. */
  16031. needCube(): boolean;
  16032. /**
  16033. * Detects if the projection matrix requires to be recomputed this frame.
  16034. * @returns true if it requires to be recomputed otherwise, false.
  16035. */
  16036. needProjectionMatrixCompute(): boolean;
  16037. /**
  16038. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16039. */
  16040. forceProjectionMatrixCompute(): void;
  16041. /** @hidden */
  16042. _initCache(): void;
  16043. /** @hidden */
  16044. _isSynchronized(): boolean;
  16045. /**
  16046. * Computes the world matrix of the node
  16047. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16048. * @returns the world matrix
  16049. */
  16050. computeWorldMatrix(force?: boolean): Matrix;
  16051. /**
  16052. * Gets the minZ used for shadow according to both the scene and the light.
  16053. * @param activeCamera The camera we are returning the min for
  16054. * @returns the depth min z
  16055. */
  16056. getDepthMinZ(activeCamera: Camera): number;
  16057. /**
  16058. * Gets the maxZ used for shadow according to both the scene and the light.
  16059. * @param activeCamera The camera we are returning the max for
  16060. * @returns the depth max z
  16061. */
  16062. getDepthMaxZ(activeCamera: Camera): number;
  16063. /**
  16064. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16065. * @param matrix The materix to updated with the projection information
  16066. * @param viewMatrix The transform matrix of the light
  16067. * @param renderList The list of mesh to render in the map
  16068. * @returns The current light
  16069. */
  16070. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16071. }
  16072. }
  16073. declare module BABYLON {
  16074. /**
  16075. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16076. * These values define a cone of light starting from the position, emitting toward the direction.
  16077. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16078. * and the exponent defines the speed of the decay of the light with distance (reach).
  16079. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16080. */
  16081. class SpotLight extends ShadowLight {
  16082. private _angle;
  16083. private _innerAngle;
  16084. private _cosHalfAngle;
  16085. private _lightAngleScale;
  16086. private _lightAngleOffset;
  16087. /**
  16088. * Gets the cone angle of the spot light in Radians.
  16089. */
  16090. /**
  16091. * Sets the cone angle of the spot light in Radians.
  16092. */
  16093. angle: number;
  16094. /**
  16095. * Only used in gltf falloff mode, this defines the angle where
  16096. * the directional falloff will start before cutting at angle which could be seen
  16097. * as outer angle.
  16098. */
  16099. /**
  16100. * Only used in gltf falloff mode, this defines the angle where
  16101. * the directional falloff will start before cutting at angle which could be seen
  16102. * as outer angle.
  16103. */
  16104. innerAngle: number;
  16105. private _shadowAngleScale;
  16106. /**
  16107. * Allows scaling the angle of the light for shadow generation only.
  16108. */
  16109. /**
  16110. * Allows scaling the angle of the light for shadow generation only.
  16111. */
  16112. shadowAngleScale: number;
  16113. /**
  16114. * The light decay speed with the distance from the emission spot.
  16115. */
  16116. exponent: number;
  16117. private _projectionTextureMatrix;
  16118. /**
  16119. * Allows reading the projecton texture
  16120. */
  16121. readonly projectionTextureMatrix: Matrix;
  16122. protected _projectionTextureLightNear: number;
  16123. /**
  16124. * Gets the near clip of the Spotlight for texture projection.
  16125. */
  16126. /**
  16127. * Sets the near clip of the Spotlight for texture projection.
  16128. */
  16129. projectionTextureLightNear: number;
  16130. protected _projectionTextureLightFar: number;
  16131. /**
  16132. * Gets the far clip of the Spotlight for texture projection.
  16133. */
  16134. /**
  16135. * Sets the far clip of the Spotlight for texture projection.
  16136. */
  16137. projectionTextureLightFar: number;
  16138. protected _projectionTextureUpDirection: Vector3;
  16139. /**
  16140. * Gets the Up vector of the Spotlight for texture projection.
  16141. */
  16142. /**
  16143. * Sets the Up vector of the Spotlight for texture projection.
  16144. */
  16145. projectionTextureUpDirection: Vector3;
  16146. private _projectionTexture;
  16147. /**
  16148. * Gets the projection texture of the light.
  16149. */
  16150. /**
  16151. * Sets the projection texture of the light.
  16152. */
  16153. projectionTexture: Nullable<BaseTexture>;
  16154. private _projectionTextureViewLightDirty;
  16155. private _projectionTextureProjectionLightDirty;
  16156. private _projectionTextureDirty;
  16157. private _projectionTextureViewTargetVector;
  16158. private _projectionTextureViewLightMatrix;
  16159. private _projectionTextureProjectionLightMatrix;
  16160. private _projectionTextureScalingMatrix;
  16161. /**
  16162. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16163. * It can cast shadows.
  16164. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16165. * @param name The light friendly name
  16166. * @param position The position of the spot light in the scene
  16167. * @param direction The direction of the light in the scene
  16168. * @param angle The cone angle of the light in Radians
  16169. * @param exponent The light decay speed with the distance from the emission spot
  16170. * @param scene The scene the lights belongs to
  16171. */
  16172. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16173. /**
  16174. * Returns the string "SpotLight".
  16175. * @returns the class name
  16176. */
  16177. getClassName(): string;
  16178. /**
  16179. * Returns the integer 2.
  16180. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16181. */
  16182. getTypeID(): number;
  16183. /**
  16184. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16185. */
  16186. protected _setDirection(value: Vector3): void;
  16187. /**
  16188. * Overrides the position setter to recompute the projection texture view light Matrix.
  16189. */
  16190. protected _setPosition(value: Vector3): void;
  16191. /**
  16192. * 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.
  16193. * Returns the SpotLight.
  16194. */
  16195. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16196. protected _computeProjectionTextureViewLightMatrix(): void;
  16197. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16198. /**
  16199. * Main function for light texture projection matrix computing.
  16200. */
  16201. protected _computeProjectionTextureMatrix(): void;
  16202. protected _buildUniformLayout(): void;
  16203. private _computeAngleValues;
  16204. /**
  16205. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16206. * @param effect The effect to update
  16207. * @param lightIndex The index of the light in the effect to update
  16208. * @returns The spot light
  16209. */
  16210. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16211. /**
  16212. * Disposes the light and the associated resources.
  16213. */
  16214. dispose(): void;
  16215. /**
  16216. * Prepares the list of defines specific to the light type.
  16217. * @param defines the list of defines
  16218. * @param lightIndex defines the index of the light for the effect
  16219. */
  16220. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16221. }
  16222. }
  16223. declare module BABYLON {
  16224. /**
  16225. * Interface used to present a loading screen while loading a scene
  16226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16227. */
  16228. interface ILoadingScreen {
  16229. /**
  16230. * Function called to display the loading screen
  16231. */
  16232. displayLoadingUI: () => void;
  16233. /**
  16234. * Function called to hide the loading screen
  16235. */
  16236. hideLoadingUI: () => void;
  16237. /**
  16238. * Gets or sets the color to use for the background
  16239. */
  16240. loadingUIBackgroundColor: string;
  16241. /**
  16242. * Gets or sets the text to display while loading
  16243. */
  16244. loadingUIText: string;
  16245. }
  16246. /**
  16247. * Class used for the default loading screen
  16248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16249. */
  16250. class DefaultLoadingScreen implements ILoadingScreen {
  16251. private _renderingCanvas;
  16252. private _loadingText;
  16253. private _loadingDivBackgroundColor;
  16254. private _loadingDiv;
  16255. private _loadingTextDiv;
  16256. /**
  16257. * Creates a new default loading screen
  16258. * @param _renderingCanvas defines the canvas used to render the scene
  16259. * @param _loadingText defines the default text to display
  16260. * @param _loadingDivBackgroundColor defines the default background color
  16261. */
  16262. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16263. /**
  16264. * Function called to display the loading screen
  16265. */
  16266. displayLoadingUI(): void;
  16267. /**
  16268. * Function called to hide the loading screen
  16269. */
  16270. hideLoadingUI(): void;
  16271. /**
  16272. * Gets or sets the text to display while loading
  16273. */
  16274. loadingUIText: string;
  16275. /**
  16276. * Gets or sets the color to use for the background
  16277. */
  16278. loadingUIBackgroundColor: string;
  16279. private _resizeLoadingUI;
  16280. }
  16281. }
  16282. declare module BABYLON {
  16283. /**
  16284. * Class used to represent data loading progression
  16285. */
  16286. class SceneLoaderProgressEvent {
  16287. /** defines if data length to load can be evaluated */
  16288. readonly lengthComputable: boolean;
  16289. /** defines the loaded data length */
  16290. readonly loaded: number;
  16291. /** defines the data length to load */
  16292. readonly total: number;
  16293. /**
  16294. * Create a new progress event
  16295. * @param lengthComputable defines if data length to load can be evaluated
  16296. * @param loaded defines the loaded data length
  16297. * @param total defines the data length to load
  16298. */
  16299. constructor(
  16300. /** defines if data length to load can be evaluated */
  16301. lengthComputable: boolean,
  16302. /** defines the loaded data length */
  16303. loaded: number,
  16304. /** defines the data length to load */
  16305. total: number);
  16306. /**
  16307. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16308. * @param event defines the source event
  16309. * @returns a new SceneLoaderProgressEvent
  16310. */
  16311. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16312. }
  16313. /**
  16314. * Interface used by SceneLoader plugins to define supported file extensions
  16315. */
  16316. interface ISceneLoaderPluginExtensions {
  16317. /**
  16318. * Defines the list of supported extensions
  16319. */
  16320. [extension: string]: {
  16321. isBinary: boolean;
  16322. };
  16323. }
  16324. /**
  16325. * Interface used by SceneLoader plugin factory
  16326. */
  16327. interface ISceneLoaderPluginFactory {
  16328. /**
  16329. * Defines the name of the factory
  16330. */
  16331. name: string;
  16332. /**
  16333. * Function called to create a new plugin
  16334. * @return the new plugin
  16335. */
  16336. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16337. /**
  16338. * Boolean indicating if the plugin can direct load specific data
  16339. */
  16340. canDirectLoad?: (data: string) => boolean;
  16341. }
  16342. /**
  16343. * Interface used to define a SceneLoader plugin
  16344. */
  16345. interface ISceneLoaderPlugin {
  16346. /**
  16347. * The friendly name of this plugin.
  16348. */
  16349. name: string;
  16350. /**
  16351. * The file extensions supported by this plugin.
  16352. */
  16353. extensions: string | ISceneLoaderPluginExtensions;
  16354. /**
  16355. * Import meshes into a scene.
  16356. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16357. * @param scene The scene to import into
  16358. * @param data The data to import
  16359. * @param rootUrl The root url for scene and resources
  16360. * @param meshes The meshes array to import into
  16361. * @param particleSystems The particle systems array to import into
  16362. * @param skeletons The skeletons array to import into
  16363. * @param onError The callback when import fails
  16364. * @returns True if successful or false otherwise
  16365. */
  16366. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16367. /**
  16368. * Load into a scene.
  16369. * @param scene The scene to load into
  16370. * @param data The data to import
  16371. * @param rootUrl The root url for scene and resources
  16372. * @param onError The callback when import fails
  16373. * @returns true if successful or false otherwise
  16374. */
  16375. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16376. /**
  16377. * The callback that returns true if the data can be directly loaded.
  16378. */
  16379. canDirectLoad?: (data: string) => boolean;
  16380. /**
  16381. * The callback that allows custom handling of the root url based on the response url.
  16382. */
  16383. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16384. /**
  16385. * Load into an asset container.
  16386. * @param scene The scene to load into
  16387. * @param data The data to import
  16388. * @param rootUrl The root url for scene and resources
  16389. * @param onError The callback when import fails
  16390. * @returns The loaded asset container
  16391. */
  16392. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16393. }
  16394. /**
  16395. * Interface used to define an async SceneLoader plugin
  16396. */
  16397. interface ISceneLoaderPluginAsync {
  16398. /**
  16399. * The friendly name of this plugin.
  16400. */
  16401. name: string;
  16402. /**
  16403. * The file extensions supported by this plugin.
  16404. */
  16405. extensions: string | ISceneLoaderPluginExtensions;
  16406. /**
  16407. * Import meshes into a scene.
  16408. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16409. * @param scene The scene to import into
  16410. * @param data The data to import
  16411. * @param rootUrl The root url for scene and resources
  16412. * @param onProgress The callback when the load progresses
  16413. * @param fileName Defines the name of the file to load
  16414. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16415. */
  16416. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16417. meshes: AbstractMesh[];
  16418. particleSystems: IParticleSystem[];
  16419. skeletons: Skeleton[];
  16420. animationGroups: AnimationGroup[];
  16421. }>;
  16422. /**
  16423. * Load into a scene.
  16424. * @param scene The scene to load into
  16425. * @param data The data to import
  16426. * @param rootUrl The root url for scene and resources
  16427. * @param onProgress The callback when the load progresses
  16428. * @param fileName Defines the name of the file to load
  16429. * @returns Nothing
  16430. */
  16431. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16432. /**
  16433. * The callback that returns true if the data can be directly loaded.
  16434. */
  16435. canDirectLoad?: (data: string) => boolean;
  16436. /**
  16437. * The callback that allows custom handling of the root url based on the response url.
  16438. */
  16439. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16440. /**
  16441. * Load into an asset container.
  16442. * @param scene The scene to load into
  16443. * @param data The data to import
  16444. * @param rootUrl The root url for scene and resources
  16445. * @param onProgress The callback when the load progresses
  16446. * @param fileName Defines the name of the file to load
  16447. * @returns The loaded asset container
  16448. */
  16449. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16450. }
  16451. /**
  16452. * Class used to load scene from various file formats using registered plugins
  16453. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16454. */
  16455. class SceneLoader {
  16456. private static _ForceFullSceneLoadingForIncremental;
  16457. private static _ShowLoadingScreen;
  16458. private static _CleanBoneMatrixWeights;
  16459. /**
  16460. * No logging while loading
  16461. */
  16462. static readonly NO_LOGGING: number;
  16463. /**
  16464. * Minimal logging while loading
  16465. */
  16466. static readonly MINIMAL_LOGGING: number;
  16467. /**
  16468. * Summary logging while loading
  16469. */
  16470. static readonly SUMMARY_LOGGING: number;
  16471. /**
  16472. * Detailled logging while loading
  16473. */
  16474. static readonly DETAILED_LOGGING: number;
  16475. private static _loggingLevel;
  16476. /**
  16477. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16478. */
  16479. static ForceFullSceneLoadingForIncremental: boolean;
  16480. /**
  16481. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16482. */
  16483. static ShowLoadingScreen: boolean;
  16484. /**
  16485. * Defines the current logging level (while loading the scene)
  16486. * @ignorenaming
  16487. */
  16488. static loggingLevel: number;
  16489. /**
  16490. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16491. */
  16492. static CleanBoneMatrixWeights: boolean;
  16493. /**
  16494. * Event raised when a plugin is used to load a scene
  16495. */
  16496. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16497. private static _registeredPlugins;
  16498. private static _getDefaultPlugin;
  16499. private static _getPluginForExtension;
  16500. private static _getPluginForDirectLoad;
  16501. private static _getPluginForFilename;
  16502. private static _getDirectLoad;
  16503. private static _loadData;
  16504. private static _getFileInfo;
  16505. /**
  16506. * Gets a plugin that can load the given extension
  16507. * @param extension defines the extension to load
  16508. * @returns a plugin or null if none works
  16509. */
  16510. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16511. /**
  16512. * Gets a boolean indicating that the given extension can be loaded
  16513. * @param extension defines the extension to load
  16514. * @returns true if the extension is supported
  16515. */
  16516. static IsPluginForExtensionAvailable(extension: string): boolean;
  16517. /**
  16518. * Adds a new plugin to the list of registered plugins
  16519. * @param plugin defines the plugin to add
  16520. */
  16521. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16522. /**
  16523. * Import meshes into a scene
  16524. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  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 scene the instance of BABYLON.Scene to append to
  16528. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons 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 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>;
  16535. /**
  16536. * Import meshes into a scene
  16537. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16538. * @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)
  16539. * @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)
  16540. * @param scene the instance of BABYLON.Scene to append to
  16541. * @param onProgress a callback with a progress event for each file being loaded
  16542. * @param pluginExtension the extension used to determine the plugin
  16543. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16544. */
  16545. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16546. meshes: AbstractMesh[];
  16547. particleSystems: IParticleSystem[];
  16548. skeletons: Skeleton[];
  16549. animationGroups: AnimationGroup[];
  16550. }>;
  16551. /**
  16552. * Load a scene
  16553. * @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)
  16554. * @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)
  16555. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16556. * @param onSuccess a callback with the scene when import succeeds
  16557. * @param onProgress a callback with a progress event for each file being loaded
  16558. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16559. * @param pluginExtension the extension used to determine the plugin
  16560. * @returns The loaded plugin
  16561. */
  16562. 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>;
  16563. /**
  16564. * Load a scene
  16565. * @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)
  16566. * @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)
  16567. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16568. * @param onProgress a callback with a progress event for each file being loaded
  16569. * @param pluginExtension the extension used to determine the plugin
  16570. * @returns The loaded scene
  16571. */
  16572. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16573. /**
  16574. * Append a scene
  16575. * @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)
  16576. * @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)
  16577. * @param scene is the instance of BABYLON.Scene to append to
  16578. * @param onSuccess a callback with the scene when import succeeds
  16579. * @param onProgress a callback with a progress event for each file being loaded
  16580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16581. * @param pluginExtension the extension used to determine the plugin
  16582. * @returns The loaded plugin
  16583. */
  16584. 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>;
  16585. /**
  16586. * Append a scene
  16587. * @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)
  16588. * @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)
  16589. * @param scene is the instance of BABYLON.Scene to append to
  16590. * @param onProgress a callback with a progress event for each file being loaded
  16591. * @param pluginExtension the extension used to determine the plugin
  16592. * @returns The given scene
  16593. */
  16594. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16595. /**
  16596. * Load a scene into an asset container
  16597. * @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)
  16598. * @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)
  16599. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16600. * @param onSuccess a callback with the scene when import succeeds
  16601. * @param onProgress a callback with a progress event for each file being loaded
  16602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16603. * @param pluginExtension the extension used to determine the plugin
  16604. * @returns The loaded plugin
  16605. */
  16606. 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>;
  16607. /**
  16608. * Load a scene into an asset container
  16609. * @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)
  16610. * @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)
  16611. * @param scene is the instance of BABYLON.Scene to append to
  16612. * @param onProgress a callback with a progress event for each file being loaded
  16613. * @param pluginExtension the extension used to determine the plugin
  16614. * @returns The loaded asset container
  16615. */
  16616. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16617. }
  16618. }
  16619. declare module BABYLON {
  16620. /**
  16621. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16622. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16623. * 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;
  16624. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16625. */
  16626. class ColorCurves {
  16627. private _dirty;
  16628. private _tempColor;
  16629. private _globalCurve;
  16630. private _highlightsCurve;
  16631. private _midtonesCurve;
  16632. private _shadowsCurve;
  16633. private _positiveCurve;
  16634. private _negativeCurve;
  16635. private _globalHue;
  16636. private _globalDensity;
  16637. private _globalSaturation;
  16638. private _globalExposure;
  16639. /**
  16640. * Gets the global Hue value.
  16641. * 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).
  16642. */
  16643. /**
  16644. * Sets the global Hue value.
  16645. * 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).
  16646. */
  16647. globalHue: number;
  16648. /**
  16649. * Gets the global Density value.
  16650. * 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.
  16651. * Values less than zero provide a filter of opposite hue.
  16652. */
  16653. /**
  16654. * Sets the global Density value.
  16655. * 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.
  16656. * Values less than zero provide a filter of opposite hue.
  16657. */
  16658. globalDensity: number;
  16659. /**
  16660. * Gets the global Saturation value.
  16661. * 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.
  16662. */
  16663. /**
  16664. * Sets the global Saturation value.
  16665. * 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.
  16666. */
  16667. globalSaturation: number;
  16668. /**
  16669. * Gets the global Exposure value.
  16670. * 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.
  16671. */
  16672. /**
  16673. * Sets the global Exposure value.
  16674. * 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.
  16675. */
  16676. globalExposure: number;
  16677. private _highlightsHue;
  16678. private _highlightsDensity;
  16679. private _highlightsSaturation;
  16680. private _highlightsExposure;
  16681. /**
  16682. * Gets the highlights Hue value.
  16683. * 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).
  16684. */
  16685. /**
  16686. * Sets the highlights Hue value.
  16687. * 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).
  16688. */
  16689. highlightsHue: number;
  16690. /**
  16691. * Gets the highlights Density value.
  16692. * 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.
  16693. * Values less than zero provide a filter of opposite hue.
  16694. */
  16695. /**
  16696. * Sets the highlights Density value.
  16697. * 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.
  16698. * Values less than zero provide a filter of opposite hue.
  16699. */
  16700. highlightsDensity: number;
  16701. /**
  16702. * Gets the highlights Saturation value.
  16703. * 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.
  16704. */
  16705. /**
  16706. * Sets the highlights Saturation value.
  16707. * 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.
  16708. */
  16709. highlightsSaturation: number;
  16710. /**
  16711. * Gets the highlights Exposure value.
  16712. * 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.
  16713. */
  16714. /**
  16715. * Sets the highlights Exposure value.
  16716. * 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.
  16717. */
  16718. highlightsExposure: number;
  16719. private _midtonesHue;
  16720. private _midtonesDensity;
  16721. private _midtonesSaturation;
  16722. private _midtonesExposure;
  16723. /**
  16724. * Gets the midtones Hue value.
  16725. * 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).
  16726. */
  16727. /**
  16728. * Sets the midtones Hue value.
  16729. * 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).
  16730. */
  16731. midtonesHue: number;
  16732. /**
  16733. * Gets the midtones Density value.
  16734. * 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.
  16735. * Values less than zero provide a filter of opposite hue.
  16736. */
  16737. /**
  16738. * Sets the midtones Density value.
  16739. * 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.
  16740. * Values less than zero provide a filter of opposite hue.
  16741. */
  16742. midtonesDensity: number;
  16743. /**
  16744. * Gets the midtones Saturation value.
  16745. * 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.
  16746. */
  16747. /**
  16748. * Sets the midtones Saturation value.
  16749. * 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.
  16750. */
  16751. midtonesSaturation: number;
  16752. /**
  16753. * Gets the midtones Exposure value.
  16754. * 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.
  16755. */
  16756. /**
  16757. * Sets the midtones Exposure value.
  16758. * 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.
  16759. */
  16760. midtonesExposure: number;
  16761. private _shadowsHue;
  16762. private _shadowsDensity;
  16763. private _shadowsSaturation;
  16764. private _shadowsExposure;
  16765. /**
  16766. * Gets the shadows Hue value.
  16767. * 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).
  16768. */
  16769. /**
  16770. * Sets the shadows Hue value.
  16771. * 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).
  16772. */
  16773. shadowsHue: number;
  16774. /**
  16775. * Gets the shadows Density value.
  16776. * 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.
  16777. * Values less than zero provide a filter of opposite hue.
  16778. */
  16779. /**
  16780. * Sets the shadows Density value.
  16781. * 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.
  16782. * Values less than zero provide a filter of opposite hue.
  16783. */
  16784. shadowsDensity: number;
  16785. /**
  16786. * Gets the shadows Saturation value.
  16787. * 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.
  16788. */
  16789. /**
  16790. * Sets the shadows Saturation value.
  16791. * 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.
  16792. */
  16793. shadowsSaturation: number;
  16794. /**
  16795. * Gets the shadows Exposure value.
  16796. * 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.
  16797. */
  16798. /**
  16799. * Sets the shadows Exposure value.
  16800. * 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.
  16801. */
  16802. shadowsExposure: number;
  16803. /**
  16804. * Returns the class name
  16805. * @returns The class name
  16806. */
  16807. getClassName(): string;
  16808. /**
  16809. * Binds the color curves to the shader.
  16810. * @param colorCurves The color curve to bind
  16811. * @param effect The effect to bind to
  16812. * @param positiveUniform The positive uniform shader parameter
  16813. * @param neutralUniform The neutral uniform shader parameter
  16814. * @param negativeUniform The negative uniform shader parameter
  16815. */
  16816. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  16817. /**
  16818. * Prepare the list of uniforms associated with the ColorCurves effects.
  16819. * @param uniformsList The list of uniforms used in the effect
  16820. */
  16821. static PrepareUniforms(uniformsList: string[]): void;
  16822. /**
  16823. * Returns color grading data based on a hue, density, saturation and exposure value.
  16824. * @param filterHue The hue of the color filter.
  16825. * @param filterDensity The density of the color filter.
  16826. * @param saturation The saturation.
  16827. * @param exposure The exposure.
  16828. * @param result The result data container.
  16829. */
  16830. private getColorGradingDataToRef;
  16831. /**
  16832. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  16833. * @param value The input slider value in range [-100,100].
  16834. * @returns Adjusted value.
  16835. */
  16836. private static applyColorGradingSliderNonlinear;
  16837. /**
  16838. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  16839. * @param hue The hue (H) input.
  16840. * @param saturation The saturation (S) input.
  16841. * @param brightness The brightness (B) input.
  16842. * @result An RGBA color represented as Vector4.
  16843. */
  16844. private static fromHSBToRef;
  16845. /**
  16846. * Returns a value clamped between min and max
  16847. * @param value The value to clamp
  16848. * @param min The minimum of value
  16849. * @param max The maximum of value
  16850. * @returns The clamped value.
  16851. */
  16852. private static clamp;
  16853. /**
  16854. * Clones the current color curve instance.
  16855. * @return The cloned curves
  16856. */
  16857. clone(): ColorCurves;
  16858. /**
  16859. * Serializes the current color curve instance to a json representation.
  16860. * @return a JSON representation
  16861. */
  16862. serialize(): any;
  16863. /**
  16864. * Parses the color curve from a json representation.
  16865. * @param source the JSON source to parse
  16866. * @return The parsed curves
  16867. */
  16868. static Parse(source: any): ColorCurves;
  16869. }
  16870. }
  16871. declare module BABYLON {
  16872. /**
  16873. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  16874. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  16875. */
  16876. class EffectFallbacks {
  16877. private _defines;
  16878. private _currentRank;
  16879. private _maxRank;
  16880. private _mesh;
  16881. /**
  16882. * Removes the fallback from the bound mesh.
  16883. */
  16884. unBindMesh(): void;
  16885. /**
  16886. * Adds a fallback on the specified property.
  16887. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16888. * @param define The name of the define in the shader
  16889. */
  16890. addFallback(rank: number, define: string): void;
  16891. /**
  16892. * Sets the mesh to use CPU skinning when needing to fallback.
  16893. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  16894. * @param mesh The mesh to use the fallbacks.
  16895. */
  16896. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  16897. /**
  16898. * Checks to see if more fallbacks are still availible.
  16899. */
  16900. readonly isMoreFallbacks: boolean;
  16901. /**
  16902. * Removes the defines that shoould be removed when falling back.
  16903. * @param currentDefines defines the current define statements for the shader.
  16904. * @param effect defines the current effect we try to compile
  16905. * @returns The resulting defines with defines of the current rank removed.
  16906. */
  16907. reduce(currentDefines: string, effect: Effect): string;
  16908. }
  16909. /**
  16910. * Options to be used when creating an effect.
  16911. */
  16912. class EffectCreationOptions {
  16913. /**
  16914. * Atrributes that will be used in the shader.
  16915. */
  16916. attributes: string[];
  16917. /**
  16918. * Uniform varible names that will be set in the shader.
  16919. */
  16920. uniformsNames: string[];
  16921. /**
  16922. * Uniform buffer varible names that will be set in the shader.
  16923. */
  16924. uniformBuffersNames: string[];
  16925. /**
  16926. * Sampler texture variable names that will be set in the shader.
  16927. */
  16928. samplers: string[];
  16929. /**
  16930. * Define statements that will be set in the shader.
  16931. */
  16932. defines: any;
  16933. /**
  16934. * Possible fallbacks for this effect to improve performance when needed.
  16935. */
  16936. fallbacks: Nullable<EffectFallbacks>;
  16937. /**
  16938. * Callback that will be called when the shader is compiled.
  16939. */
  16940. onCompiled: Nullable<(effect: Effect) => void>;
  16941. /**
  16942. * Callback that will be called if an error occurs during shader compilation.
  16943. */
  16944. onError: Nullable<(effect: Effect, errors: string) => void>;
  16945. /**
  16946. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  16947. */
  16948. indexParameters: any;
  16949. /**
  16950. * Max number of lights that can be used in the shader.
  16951. */
  16952. maxSimultaneousLights: number;
  16953. /**
  16954. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  16955. */
  16956. transformFeedbackVaryings: Nullable<string[]>;
  16957. }
  16958. /**
  16959. * Effect containing vertex and fragment shader that can be executed on an object.
  16960. */
  16961. class Effect {
  16962. /**
  16963. * Name of the effect.
  16964. */
  16965. name: any;
  16966. /**
  16967. * String container all the define statements that should be set on the shader.
  16968. */
  16969. defines: string;
  16970. /**
  16971. * Callback that will be called when the shader is compiled.
  16972. */
  16973. onCompiled: Nullable<(effect: Effect) => void>;
  16974. /**
  16975. * Callback that will be called if an error occurs during shader compilation.
  16976. */
  16977. onError: Nullable<(effect: Effect, errors: string) => void>;
  16978. /**
  16979. * Callback that will be called when effect is bound.
  16980. */
  16981. onBind: Nullable<(effect: Effect) => void>;
  16982. /**
  16983. * Unique ID of the effect.
  16984. */
  16985. uniqueId: number;
  16986. /**
  16987. * Observable that will be called when the shader is compiled.
  16988. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  16989. */
  16990. onCompileObservable: Observable<Effect>;
  16991. /**
  16992. * Observable that will be called if an error occurs during shader compilation.
  16993. */
  16994. onErrorObservable: Observable<Effect>;
  16995. /** @hidden */
  16996. _onBindObservable: Nullable<Observable<Effect>>;
  16997. /**
  16998. * Observable that will be called when effect is bound.
  16999. */
  17000. readonly onBindObservable: Observable<Effect>;
  17001. /** @hidden */
  17002. _bonesComputationForcedToCPU: boolean;
  17003. private static _uniqueIdSeed;
  17004. private _engine;
  17005. private _uniformBuffersNames;
  17006. private _uniformsNames;
  17007. private _samplers;
  17008. private _isReady;
  17009. private _compilationError;
  17010. private _attributesNames;
  17011. private _attributes;
  17012. private _uniforms;
  17013. /**
  17014. * Key for the effect.
  17015. * @hidden
  17016. */
  17017. _key: string;
  17018. private _indexParameters;
  17019. private _fallbacks;
  17020. private _vertexSourceCode;
  17021. private _fragmentSourceCode;
  17022. private _vertexSourceCodeOverride;
  17023. private _fragmentSourceCodeOverride;
  17024. private _transformFeedbackVaryings;
  17025. /**
  17026. * Compiled shader to webGL program.
  17027. * @hidden
  17028. */
  17029. _program: WebGLProgram;
  17030. private _valueCache;
  17031. private static _baseCache;
  17032. /**
  17033. * Instantiates an effect.
  17034. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17035. * @param baseName Name of the effect.
  17036. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17037. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17038. * @param samplers List of sampler variables that will be passed to the shader.
  17039. * @param engine Engine to be used to render the effect
  17040. * @param defines Define statements to be added to the shader.
  17041. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17042. * @param onCompiled Callback that will be called when the shader is compiled.
  17043. * @param onError Callback that will be called if an error occurs during shader compilation.
  17044. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17045. */
  17046. 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);
  17047. /**
  17048. * Unique key for this effect
  17049. */
  17050. readonly key: string;
  17051. /**
  17052. * If the effect has been compiled and prepared.
  17053. * @returns if the effect is compiled and prepared.
  17054. */
  17055. isReady(): boolean;
  17056. /**
  17057. * The engine the effect was initialized with.
  17058. * @returns the engine.
  17059. */
  17060. getEngine(): Engine;
  17061. /**
  17062. * The compiled webGL program for the effect
  17063. * @returns the webGL program.
  17064. */
  17065. getProgram(): WebGLProgram;
  17066. /**
  17067. * The set of names of attribute variables for the shader.
  17068. * @returns An array of attribute names.
  17069. */
  17070. getAttributesNames(): string[];
  17071. /**
  17072. * Returns the attribute at the given index.
  17073. * @param index The index of the attribute.
  17074. * @returns The location of the attribute.
  17075. */
  17076. getAttributeLocation(index: number): number;
  17077. /**
  17078. * Returns the attribute based on the name of the variable.
  17079. * @param name of the attribute to look up.
  17080. * @returns the attribute location.
  17081. */
  17082. getAttributeLocationByName(name: string): number;
  17083. /**
  17084. * The number of attributes.
  17085. * @returns the numnber of attributes.
  17086. */
  17087. getAttributesCount(): number;
  17088. /**
  17089. * Gets the index of a uniform variable.
  17090. * @param uniformName of the uniform to look up.
  17091. * @returns the index.
  17092. */
  17093. getUniformIndex(uniformName: string): number;
  17094. /**
  17095. * Returns the attribute based on the name of the variable.
  17096. * @param uniformName of the uniform to look up.
  17097. * @returns the location of the uniform.
  17098. */
  17099. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17100. /**
  17101. * Returns an array of sampler variable names
  17102. * @returns The array of sampler variable neames.
  17103. */
  17104. getSamplers(): string[];
  17105. /**
  17106. * The error from the last compilation.
  17107. * @returns the error string.
  17108. */
  17109. getCompilationError(): string;
  17110. /**
  17111. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17112. * @param func The callback to be used.
  17113. */
  17114. executeWhenCompiled(func: (effect: Effect) => void): void;
  17115. private _checkIsReady;
  17116. /** @hidden */
  17117. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17118. /** @hidden */
  17119. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17120. /** @hidden */
  17121. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17122. private _processShaderConversion;
  17123. private _processIncludes;
  17124. private _processPrecision;
  17125. /**
  17126. * Recompiles the webGL program
  17127. * @param vertexSourceCode The source code for the vertex shader.
  17128. * @param fragmentSourceCode The source code for the fragment shader.
  17129. * @param onCompiled Callback called when completed.
  17130. * @param onError Callback called on error.
  17131. * @hidden
  17132. */
  17133. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17134. /**
  17135. * Gets the uniform locations of the the specified variable names
  17136. * @param names THe names of the variables to lookup.
  17137. * @returns Array of locations in the same order as variable names.
  17138. */
  17139. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17140. /**
  17141. * Prepares the effect
  17142. * @hidden
  17143. */
  17144. _prepareEffect(): void;
  17145. /**
  17146. * Checks if the effect is supported. (Must be called after compilation)
  17147. */
  17148. readonly isSupported: boolean;
  17149. /**
  17150. * Binds a texture to the engine to be used as output of the shader.
  17151. * @param channel Name of the output variable.
  17152. * @param texture Texture to bind.
  17153. * @hidden
  17154. */
  17155. _bindTexture(channel: string, texture: InternalTexture): void;
  17156. /**
  17157. * Sets a texture on the engine to be used in the shader.
  17158. * @param channel Name of the sampler variable.
  17159. * @param texture Texture to set.
  17160. */
  17161. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17162. /**
  17163. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17164. * @param channel Name of the sampler variable.
  17165. * @param texture Texture to set.
  17166. */
  17167. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17168. /**
  17169. * Sets an array of textures on the engine to be used in the shader.
  17170. * @param channel Name of the variable.
  17171. * @param textures Textures to set.
  17172. */
  17173. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17174. /**
  17175. * 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)
  17176. * @param channel Name of the sampler variable.
  17177. * @param postProcess Post process to get the input texture from.
  17178. */
  17179. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17180. /**
  17181. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17182. * 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)
  17183. * @param channel Name of the sampler variable.
  17184. * @param postProcess Post process to get the output texture from.
  17185. */
  17186. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17187. /** @hidden */
  17188. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17189. /** @hidden */
  17190. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17191. /** @hidden */
  17192. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17193. /** @hidden */
  17194. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17195. /**
  17196. * Binds a buffer to a uniform.
  17197. * @param buffer Buffer to bind.
  17198. * @param name Name of the uniform variable to bind to.
  17199. */
  17200. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17201. /**
  17202. * Binds block to a uniform.
  17203. * @param blockName Name of the block to bind.
  17204. * @param index Index to bind.
  17205. */
  17206. bindUniformBlock(blockName: string, index: number): void;
  17207. /**
  17208. * Sets an interger value on a uniform variable.
  17209. * @param uniformName Name of the variable.
  17210. * @param value Value to be set.
  17211. * @returns this effect.
  17212. */
  17213. setInt(uniformName: string, value: number): Effect;
  17214. /**
  17215. * Sets an int 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. setIntArray(uniformName: string, array: Int32Array): Effect;
  17221. /**
  17222. * 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)
  17223. * @param uniformName Name of the variable.
  17224. * @param array array to be set.
  17225. * @returns this effect.
  17226. */
  17227. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17228. /**
  17229. * 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)
  17230. * @param uniformName Name of the variable.
  17231. * @param array array to be set.
  17232. * @returns this effect.
  17233. */
  17234. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17235. /**
  17236. * 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)
  17237. * @param uniformName Name of the variable.
  17238. * @param array array to be set.
  17239. * @returns this effect.
  17240. */
  17241. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17242. /**
  17243. * Sets an float 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. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17249. /**
  17250. * 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)
  17251. * @param uniformName Name of the variable.
  17252. * @param array array to be set.
  17253. * @returns this effect.
  17254. */
  17255. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17256. /**
  17257. * 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)
  17258. * @param uniformName Name of the variable.
  17259. * @param array array to be set.
  17260. * @returns this effect.
  17261. */
  17262. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17263. /**
  17264. * 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)
  17265. * @param uniformName Name of the variable.
  17266. * @param array array to be set.
  17267. * @returns this effect.
  17268. */
  17269. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17270. /**
  17271. * Sets an array on a uniform variable.
  17272. * @param uniformName Name of the variable.
  17273. * @param array array to be set.
  17274. * @returns this effect.
  17275. */
  17276. setArray(uniformName: string, array: number[]): Effect;
  17277. /**
  17278. * 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)
  17279. * @param uniformName Name of the variable.
  17280. * @param array array to be set.
  17281. * @returns this effect.
  17282. */
  17283. setArray2(uniformName: string, array: number[]): Effect;
  17284. /**
  17285. * 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)
  17286. * @param uniformName Name of the variable.
  17287. * @param array array to be set.
  17288. * @returns this effect.
  17289. */
  17290. setArray3(uniformName: string, array: number[]): Effect;
  17291. /**
  17292. * 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)
  17293. * @param uniformName Name of the variable.
  17294. * @param array array to be set.
  17295. * @returns this effect.
  17296. */
  17297. setArray4(uniformName: string, array: number[]): Effect;
  17298. /**
  17299. * Sets matrices on a uniform variable.
  17300. * @param uniformName Name of the variable.
  17301. * @param matrices matrices to be set.
  17302. * @returns this effect.
  17303. */
  17304. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17305. /**
  17306. * Sets matrix on a uniform variable.
  17307. * @param uniformName Name of the variable.
  17308. * @param matrix matrix to be set.
  17309. * @returns this effect.
  17310. */
  17311. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17312. /**
  17313. * 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)
  17314. * @param uniformName Name of the variable.
  17315. * @param matrix matrix to be set.
  17316. * @returns this effect.
  17317. */
  17318. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17319. /**
  17320. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17321. * @param uniformName Name of the variable.
  17322. * @param matrix matrix to be set.
  17323. * @returns this effect.
  17324. */
  17325. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17326. /**
  17327. * Sets a float on a uniform variable.
  17328. * @param uniformName Name of the variable.
  17329. * @param value value to be set.
  17330. * @returns this effect.
  17331. */
  17332. setFloat(uniformName: string, value: number): Effect;
  17333. /**
  17334. * Sets a boolean on a uniform variable.
  17335. * @param uniformName Name of the variable.
  17336. * @param bool value to be set.
  17337. * @returns this effect.
  17338. */
  17339. setBool(uniformName: string, bool: boolean): Effect;
  17340. /**
  17341. * Sets a Vector2 on a uniform variable.
  17342. * @param uniformName Name of the variable.
  17343. * @param vector2 vector2 to be set.
  17344. * @returns this effect.
  17345. */
  17346. setVector2(uniformName: string, vector2: Vector2): Effect;
  17347. /**
  17348. * Sets a float2 on a uniform variable.
  17349. * @param uniformName Name of the variable.
  17350. * @param x First float in float2.
  17351. * @param y Second float in float2.
  17352. * @returns this effect.
  17353. */
  17354. setFloat2(uniformName: string, x: number, y: number): Effect;
  17355. /**
  17356. * Sets a Vector3 on a uniform variable.
  17357. * @param uniformName Name of the variable.
  17358. * @param vector3 Value to be set.
  17359. * @returns this effect.
  17360. */
  17361. setVector3(uniformName: string, vector3: Vector3): Effect;
  17362. /**
  17363. * Sets a float3 on a uniform variable.
  17364. * @param uniformName Name of the variable.
  17365. * @param x First float in float3.
  17366. * @param y Second float in float3.
  17367. * @param z Third float in float3.
  17368. * @returns this effect.
  17369. */
  17370. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17371. /**
  17372. * Sets a Vector4 on a uniform variable.
  17373. * @param uniformName Name of the variable.
  17374. * @param vector4 Value to be set.
  17375. * @returns this effect.
  17376. */
  17377. setVector4(uniformName: string, vector4: Vector4): Effect;
  17378. /**
  17379. * Sets a float4 on a uniform variable.
  17380. * @param uniformName Name of the variable.
  17381. * @param x First float in float4.
  17382. * @param y Second float in float4.
  17383. * @param z Third float in float4.
  17384. * @param w Fourth float in float4.
  17385. * @returns this effect.
  17386. */
  17387. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17388. /**
  17389. * Sets a Color3 on a uniform variable.
  17390. * @param uniformName Name of the variable.
  17391. * @param color3 Value to be set.
  17392. * @returns this effect.
  17393. */
  17394. setColor3(uniformName: string, color3: Color3): Effect;
  17395. /**
  17396. * Sets a Color4 on a uniform variable.
  17397. * @param uniformName Name of the variable.
  17398. * @param color3 Value to be set.
  17399. * @param alpha Alpha value to be set.
  17400. * @returns this effect.
  17401. */
  17402. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17403. /**
  17404. * Sets a Color4 on a uniform variable
  17405. * @param uniformName defines the name of the variable
  17406. * @param color4 defines the value to be set
  17407. * @returns this effect.
  17408. */
  17409. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17410. /**
  17411. * This function will add a new shader to the shader store
  17412. * @param name the name of the shader
  17413. * @param pixelShader optional pixel shader content
  17414. * @param vertexShader optional vertex shader content
  17415. */
  17416. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17417. /**
  17418. * Store of each shader (The can be looked up using effect.key)
  17419. */
  17420. static ShadersStore: {
  17421. [key: string]: string;
  17422. };
  17423. /**
  17424. * Store of each included file for a shader (The can be looked up using effect.key)
  17425. */
  17426. static IncludesShadersStore: {
  17427. [key: string]: string;
  17428. };
  17429. /**
  17430. * Resets the cache of effects.
  17431. */
  17432. static ResetCache(): void;
  17433. }
  17434. }
  17435. declare module BABYLON {
  17436. /**
  17437. * This represents all the required information to add a fresnel effect on a material:
  17438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17439. */
  17440. class FresnelParameters {
  17441. private _isEnabled;
  17442. /**
  17443. * Define if the fresnel effect is enable or not.
  17444. */
  17445. isEnabled: boolean;
  17446. /**
  17447. * Define the color used on edges (grazing angle)
  17448. */
  17449. leftColor: Color3;
  17450. /**
  17451. * Define the color used on center
  17452. */
  17453. rightColor: Color3;
  17454. /**
  17455. * Define bias applied to computed fresnel term
  17456. */
  17457. bias: number;
  17458. /**
  17459. * Defined the power exponent applied to fresnel term
  17460. */
  17461. power: number;
  17462. /**
  17463. * Clones the current fresnel and its valuues
  17464. * @returns a clone fresnel configuration
  17465. */
  17466. clone(): FresnelParameters;
  17467. /**
  17468. * Serializes the current fresnel parameters to a JSON representation.
  17469. * @return the JSON serialization
  17470. */
  17471. serialize(): any;
  17472. /**
  17473. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17474. * @param parsedFresnelParameters Define the JSON representation
  17475. * @returns the parsed parameters
  17476. */
  17477. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17478. }
  17479. }
  17480. declare module BABYLON {
  17481. /**
  17482. * Interface to follow in your material defines to integrate easily the
  17483. * Image proccessing functions.
  17484. * @hidden
  17485. */
  17486. interface IImageProcessingConfigurationDefines {
  17487. IMAGEPROCESSING: boolean;
  17488. VIGNETTE: boolean;
  17489. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17490. VIGNETTEBLENDMODEOPAQUE: boolean;
  17491. TONEMAPPING: boolean;
  17492. TONEMAPPING_ACES: boolean;
  17493. CONTRAST: boolean;
  17494. EXPOSURE: boolean;
  17495. COLORCURVES: boolean;
  17496. COLORGRADING: boolean;
  17497. COLORGRADING3D: boolean;
  17498. SAMPLER3DGREENDEPTH: boolean;
  17499. SAMPLER3DBGRMAP: boolean;
  17500. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17501. }
  17502. /**
  17503. * @hidden
  17504. */
  17505. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17506. IMAGEPROCESSING: boolean;
  17507. VIGNETTE: boolean;
  17508. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17509. VIGNETTEBLENDMODEOPAQUE: boolean;
  17510. TONEMAPPING: boolean;
  17511. TONEMAPPING_ACES: boolean;
  17512. CONTRAST: boolean;
  17513. COLORCURVES: boolean;
  17514. COLORGRADING: boolean;
  17515. COLORGRADING3D: boolean;
  17516. SAMPLER3DGREENDEPTH: boolean;
  17517. SAMPLER3DBGRMAP: boolean;
  17518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17519. EXPOSURE: boolean;
  17520. constructor();
  17521. }
  17522. /**
  17523. * This groups together the common properties used for image processing either in direct forward pass
  17524. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17525. * or not.
  17526. */
  17527. class ImageProcessingConfiguration {
  17528. /**
  17529. * Default tone mapping applied in BabylonJS.
  17530. */
  17531. static readonly TONEMAPPING_STANDARD: number;
  17532. /**
  17533. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17534. * to other engines rendering to increase portability.
  17535. */
  17536. static readonly TONEMAPPING_ACES: number;
  17537. /**
  17538. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17539. */
  17540. colorCurves: Nullable<ColorCurves>;
  17541. private _colorCurvesEnabled;
  17542. /**
  17543. * Gets wether the color curves effect is enabled.
  17544. */
  17545. /**
  17546. * Sets wether the color curves effect is enabled.
  17547. */
  17548. colorCurvesEnabled: boolean;
  17549. private _colorGradingTexture;
  17550. /**
  17551. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17552. */
  17553. /**
  17554. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17555. */
  17556. colorGradingTexture: Nullable<BaseTexture>;
  17557. private _colorGradingEnabled;
  17558. /**
  17559. * Gets wether the color grading effect is enabled.
  17560. */
  17561. /**
  17562. * Sets wether the color grading effect is enabled.
  17563. */
  17564. colorGradingEnabled: boolean;
  17565. private _colorGradingWithGreenDepth;
  17566. /**
  17567. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17568. */
  17569. /**
  17570. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17571. */
  17572. colorGradingWithGreenDepth: boolean;
  17573. private _colorGradingBGR;
  17574. /**
  17575. * Gets wether the color grading texture contains BGR values.
  17576. */
  17577. /**
  17578. * Sets wether the color grading texture contains BGR values.
  17579. */
  17580. colorGradingBGR: boolean;
  17581. /** @hidden */
  17582. _exposure: number;
  17583. /**
  17584. * Gets the Exposure used in the effect.
  17585. */
  17586. /**
  17587. * Sets the Exposure used in the effect.
  17588. */
  17589. exposure: number;
  17590. private _toneMappingEnabled;
  17591. /**
  17592. * Gets wether the tone mapping effect is enabled.
  17593. */
  17594. /**
  17595. * Sets wether the tone mapping effect is enabled.
  17596. */
  17597. toneMappingEnabled: boolean;
  17598. private _toneMappingType;
  17599. /**
  17600. * Gets the type of tone mapping effect.
  17601. */
  17602. /**
  17603. * Sets the type of tone mapping effect used in BabylonJS.
  17604. */
  17605. toneMappingType: number;
  17606. protected _contrast: number;
  17607. /**
  17608. * Gets the contrast used in the effect.
  17609. */
  17610. /**
  17611. * Sets the contrast used in the effect.
  17612. */
  17613. contrast: number;
  17614. /**
  17615. * Vignette stretch size.
  17616. */
  17617. vignetteStretch: number;
  17618. /**
  17619. * Vignette centre X Offset.
  17620. */
  17621. vignetteCentreX: number;
  17622. /**
  17623. * Vignette centre Y Offset.
  17624. */
  17625. vignetteCentreY: number;
  17626. /**
  17627. * Vignette weight or intensity of the vignette effect.
  17628. */
  17629. vignetteWeight: number;
  17630. /**
  17631. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17632. * if vignetteEnabled is set to true.
  17633. */
  17634. vignetteColor: Color4;
  17635. /**
  17636. * Camera field of view used by the Vignette effect.
  17637. */
  17638. vignetteCameraFov: number;
  17639. private _vignetteBlendMode;
  17640. /**
  17641. * Gets the vignette blend mode allowing different kind of effect.
  17642. */
  17643. /**
  17644. * Sets the vignette blend mode allowing different kind of effect.
  17645. */
  17646. vignetteBlendMode: number;
  17647. private _vignetteEnabled;
  17648. /**
  17649. * Gets wether the vignette effect is enabled.
  17650. */
  17651. /**
  17652. * Sets wether the vignette effect is enabled.
  17653. */
  17654. vignetteEnabled: boolean;
  17655. private _applyByPostProcess;
  17656. /**
  17657. * Gets wether the image processing is applied through a post process or not.
  17658. */
  17659. /**
  17660. * Sets wether the image processing is applied through a post process or not.
  17661. */
  17662. applyByPostProcess: boolean;
  17663. private _isEnabled;
  17664. /**
  17665. * Gets wether the image processing is enabled or not.
  17666. */
  17667. /**
  17668. * Sets wether the image processing is enabled or not.
  17669. */
  17670. isEnabled: boolean;
  17671. /**
  17672. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17673. */
  17674. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17675. /**
  17676. * Method called each time the image processing information changes requires to recompile the effect.
  17677. */
  17678. protected _updateParameters(): void;
  17679. /**
  17680. * Gets the current class name.
  17681. * @return "ImageProcessingConfiguration"
  17682. */
  17683. getClassName(): string;
  17684. /**
  17685. * Prepare the list of uniforms associated with the Image Processing effects.
  17686. * @param uniforms The list of uniforms used in the effect
  17687. * @param defines the list of defines currently in use
  17688. */
  17689. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17690. /**
  17691. * Prepare the list of samplers associated with the Image Processing effects.
  17692. * @param samplersList The list of uniforms used in the effect
  17693. * @param defines the list of defines currently in use
  17694. */
  17695. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17696. /**
  17697. * Prepare the list of defines associated to the shader.
  17698. * @param defines the list of defines to complete
  17699. * @param forPostProcess Define if we are currently in post process mode or not
  17700. */
  17701. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17702. /**
  17703. * Returns true if all the image processing information are ready.
  17704. * @returns True if ready, otherwise, false
  17705. */
  17706. isReady(): boolean;
  17707. /**
  17708. * Binds the image processing to the shader.
  17709. * @param effect The effect to bind to
  17710. * @param aspectRatio Define the current aspect ratio of the effect
  17711. */
  17712. bind(effect: Effect, aspectRatio?: number): void;
  17713. /**
  17714. * Clones the current image processing instance.
  17715. * @return The cloned image processing
  17716. */
  17717. clone(): ImageProcessingConfiguration;
  17718. /**
  17719. * Serializes the current image processing instance to a json representation.
  17720. * @return a JSON representation
  17721. */
  17722. serialize(): any;
  17723. /**
  17724. * Parses the image processing from a json representation.
  17725. * @param source the JSON source to parse
  17726. * @return The parsed image processing
  17727. */
  17728. static Parse(source: any): ImageProcessingConfiguration;
  17729. private static _VIGNETTEMODE_MULTIPLY;
  17730. private static _VIGNETTEMODE_OPAQUE;
  17731. /**
  17732. * Used to apply the vignette as a mix with the pixel color.
  17733. */
  17734. static readonly VIGNETTEMODE_MULTIPLY: number;
  17735. /**
  17736. * Used to apply the vignette as a replacement of the pixel color.
  17737. */
  17738. static readonly VIGNETTEMODE_OPAQUE: number;
  17739. }
  17740. }
  17741. declare module BABYLON {
  17742. /**
  17743. * Manages the defines for the Material
  17744. */
  17745. class MaterialDefines {
  17746. private _keys;
  17747. private _isDirty;
  17748. /** @hidden */
  17749. _renderId: number;
  17750. /** @hidden */
  17751. _areLightsDirty: boolean;
  17752. /** @hidden */
  17753. _areAttributesDirty: boolean;
  17754. /** @hidden */
  17755. _areTexturesDirty: boolean;
  17756. /** @hidden */
  17757. _areFresnelDirty: boolean;
  17758. /** @hidden */
  17759. _areMiscDirty: boolean;
  17760. /** @hidden */
  17761. _areImageProcessingDirty: boolean;
  17762. /** @hidden */
  17763. _normals: boolean;
  17764. /** @hidden */
  17765. _uvs: boolean;
  17766. /** @hidden */
  17767. _needNormals: boolean;
  17768. /** @hidden */
  17769. _needUVs: boolean;
  17770. /**
  17771. * Specifies if the material needs to be re-calculated
  17772. */
  17773. readonly isDirty: boolean;
  17774. /**
  17775. * Marks the material to indicate that it has been re-calculated
  17776. */
  17777. markAsProcessed(): void;
  17778. /**
  17779. * Marks the material to indicate that it needs to be re-calculated
  17780. */
  17781. markAsUnprocessed(): void;
  17782. /**
  17783. * Marks the material to indicate all of its defines need to be re-calculated
  17784. */
  17785. markAllAsDirty(): void;
  17786. /**
  17787. * Marks the material to indicate that image processing needs to be re-calculated
  17788. */
  17789. markAsImageProcessingDirty(): void;
  17790. /**
  17791. * Marks the material to indicate the lights need to be re-calculated
  17792. */
  17793. markAsLightDirty(): void;
  17794. /**
  17795. * Marks the attribute state as changed
  17796. */
  17797. markAsAttributesDirty(): void;
  17798. /**
  17799. * Marks the texture state as changed
  17800. */
  17801. markAsTexturesDirty(): void;
  17802. /**
  17803. * Marks the fresnel state as changed
  17804. */
  17805. markAsFresnelDirty(): void;
  17806. /**
  17807. * Marks the misc state as changed
  17808. */
  17809. markAsMiscDirty(): void;
  17810. /**
  17811. * Rebuilds the material defines
  17812. */
  17813. rebuild(): void;
  17814. /**
  17815. * Specifies if two material defines are equal
  17816. * @param other - A material define instance to compare to
  17817. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  17818. */
  17819. isEqual(other: MaterialDefines): boolean;
  17820. /**
  17821. * Clones this instance's defines to another instance
  17822. * @param other - material defines to clone values to
  17823. */
  17824. cloneTo(other: MaterialDefines): void;
  17825. /**
  17826. * Resets the material define values
  17827. */
  17828. reset(): void;
  17829. /**
  17830. * Converts the material define values to a string
  17831. * @returns - String of material define information
  17832. */
  17833. toString(): string;
  17834. }
  17835. /**
  17836. * Base class for the main features of a material in Babylon.js
  17837. */
  17838. class Material implements IAnimatable {
  17839. private static _TriangleFillMode;
  17840. private static _WireFrameFillMode;
  17841. private static _PointFillMode;
  17842. private static _PointListDrawMode;
  17843. private static _LineListDrawMode;
  17844. private static _LineLoopDrawMode;
  17845. private static _LineStripDrawMode;
  17846. private static _TriangleStripDrawMode;
  17847. private static _TriangleFanDrawMode;
  17848. /**
  17849. * Returns the triangle fill mode
  17850. */
  17851. static readonly TriangleFillMode: number;
  17852. /**
  17853. * Returns the wireframe mode
  17854. */
  17855. static readonly WireFrameFillMode: number;
  17856. /**
  17857. * Returns the point fill mode
  17858. */
  17859. static readonly PointFillMode: number;
  17860. /**
  17861. * Returns the point list draw mode
  17862. */
  17863. static readonly PointListDrawMode: number;
  17864. /**
  17865. * Returns the line list draw mode
  17866. */
  17867. static readonly LineListDrawMode: number;
  17868. /**
  17869. * Returns the line loop draw mode
  17870. */
  17871. static readonly LineLoopDrawMode: number;
  17872. /**
  17873. * Returns the line strip draw mode
  17874. */
  17875. static readonly LineStripDrawMode: number;
  17876. /**
  17877. * Returns the triangle strip draw mode
  17878. */
  17879. static readonly TriangleStripDrawMode: number;
  17880. /**
  17881. * Returns the triangle fan draw mode
  17882. */
  17883. static readonly TriangleFanDrawMode: number;
  17884. /**
  17885. * Stores the clock-wise side orientation
  17886. */
  17887. private static _ClockWiseSideOrientation;
  17888. /**
  17889. * Stores the counter clock-wise side orientation
  17890. */
  17891. private static _CounterClockWiseSideOrientation;
  17892. /**
  17893. * Returns the clock-wise side orientation
  17894. */
  17895. static readonly ClockWiseSideOrientation: number;
  17896. /**
  17897. * Returns the counter clock-wise side orientation
  17898. */
  17899. static readonly CounterClockWiseSideOrientation: number;
  17900. /**
  17901. * The dirty texture flag value
  17902. */
  17903. static readonly TextureDirtyFlag: number;
  17904. /**
  17905. * The dirty light flag value
  17906. */
  17907. static readonly LightDirtyFlag: number;
  17908. /**
  17909. * The dirty fresnel flag value
  17910. */
  17911. static readonly FresnelDirtyFlag: number;
  17912. /**
  17913. * The dirty attribute flag value
  17914. */
  17915. static readonly AttributesDirtyFlag: number;
  17916. /**
  17917. * The dirty misc flag value
  17918. */
  17919. static readonly MiscDirtyFlag: number;
  17920. /**
  17921. * The all dirty flag value
  17922. */
  17923. static readonly AllDirtyFlag: number;
  17924. /**
  17925. * The ID of the material
  17926. */
  17927. id: string;
  17928. /**
  17929. * Gets or sets the unique id of the material
  17930. */
  17931. uniqueId: number;
  17932. /**
  17933. * The name of the material
  17934. */
  17935. name: string;
  17936. /**
  17937. * Specifies if the ready state should be checked on each call
  17938. */
  17939. checkReadyOnEveryCall: boolean;
  17940. /**
  17941. * Specifies if the ready state should be checked once
  17942. */
  17943. checkReadyOnlyOnce: boolean;
  17944. /**
  17945. * The state of the material
  17946. */
  17947. state: string;
  17948. /**
  17949. * The alpha value of the material
  17950. */
  17951. protected _alpha: number;
  17952. /**
  17953. * Sets the alpha value of the material
  17954. */
  17955. /**
  17956. * Gets the alpha value of the material
  17957. */
  17958. alpha: number;
  17959. /**
  17960. * Specifies if back face culling is enabled
  17961. */
  17962. protected _backFaceCulling: boolean;
  17963. /**
  17964. * Sets the back-face culling state
  17965. */
  17966. /**
  17967. * Gets the back-face culling state
  17968. */
  17969. backFaceCulling: boolean;
  17970. /**
  17971. * Stores the value for side orientation
  17972. */
  17973. sideOrientation: number;
  17974. /**
  17975. * Callback triggered when the material is compiled
  17976. */
  17977. onCompiled: (effect: Effect) => void;
  17978. /**
  17979. * Callback triggered when an error occurs
  17980. */
  17981. onError: (effect: Effect, errors: string) => void;
  17982. /**
  17983. * Callback triggered to get the render target textures
  17984. */
  17985. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17986. /**
  17987. * Gets a boolean indicating that current material needs to register RTT
  17988. */
  17989. readonly hasRenderTargetTextures: boolean;
  17990. /**
  17991. * Specifies if the material should be serialized
  17992. */
  17993. doNotSerialize: boolean;
  17994. /**
  17995. * @hidden
  17996. */
  17997. _storeEffectOnSubMeshes: boolean;
  17998. /**
  17999. * Stores the animations for the material
  18000. */
  18001. animations: Array<Animation>;
  18002. /**
  18003. * An event triggered when the material is disposed
  18004. */
  18005. onDisposeObservable: Observable<Material>;
  18006. /**
  18007. * An observer which watches for dispose events
  18008. */
  18009. private _onDisposeObserver;
  18010. private _onUnBindObservable;
  18011. /**
  18012. * Called during a dispose event
  18013. */
  18014. onDispose: () => void;
  18015. private _onBindObservable;
  18016. /**
  18017. * An event triggered when the material is bound
  18018. */
  18019. readonly onBindObservable: Observable<AbstractMesh>;
  18020. /**
  18021. * An observer which watches for bind events
  18022. */
  18023. private _onBindObserver;
  18024. /**
  18025. * Called during a bind event
  18026. */
  18027. onBind: (Mesh: AbstractMesh) => void;
  18028. /**
  18029. * An event triggered when the material is unbound
  18030. */
  18031. readonly onUnBindObservable: Observable<Material>;
  18032. /**
  18033. * Stores the value of the alpha mode
  18034. */
  18035. private _alphaMode;
  18036. /**
  18037. * Sets the value of the alpha mode.
  18038. *
  18039. * | Value | Type | Description |
  18040. * | --- | --- | --- |
  18041. * | 0 | ALPHA_DISABLE | |
  18042. * | 1 | ALPHA_ADD | |
  18043. * | 2 | ALPHA_COMBINE | |
  18044. * | 3 | ALPHA_SUBTRACT | |
  18045. * | 4 | ALPHA_MULTIPLY | |
  18046. * | 5 | ALPHA_MAXIMIZED | |
  18047. * | 6 | ALPHA_ONEONE | |
  18048. * | 7 | ALPHA_PREMULTIPLIED | |
  18049. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18050. * | 9 | ALPHA_INTERPOLATE | |
  18051. * | 10 | ALPHA_SCREENMODE | |
  18052. *
  18053. */
  18054. /**
  18055. * Gets the value of the alpha mode
  18056. */
  18057. alphaMode: number;
  18058. /**
  18059. * Stores the state of the need depth pre-pass value
  18060. */
  18061. private _needDepthPrePass;
  18062. /**
  18063. * Sets the need depth pre-pass value
  18064. */
  18065. /**
  18066. * Gets the depth pre-pass value
  18067. */
  18068. needDepthPrePass: boolean;
  18069. /**
  18070. * Specifies if depth writing should be disabled
  18071. */
  18072. disableDepthWrite: boolean;
  18073. /**
  18074. * Specifies if depth writing should be forced
  18075. */
  18076. forceDepthWrite: boolean;
  18077. /**
  18078. * Specifies if there should be a separate pass for culling
  18079. */
  18080. separateCullingPass: boolean;
  18081. /**
  18082. * Stores the state specifing if fog should be enabled
  18083. */
  18084. private _fogEnabled;
  18085. /**
  18086. * Sets the state for enabling fog
  18087. */
  18088. /**
  18089. * Gets the value of the fog enabled state
  18090. */
  18091. fogEnabled: boolean;
  18092. /**
  18093. * Stores the size of points
  18094. */
  18095. pointSize: number;
  18096. /**
  18097. * Stores the z offset value
  18098. */
  18099. zOffset: number;
  18100. /**
  18101. * Gets a value specifying if wireframe mode is enabled
  18102. */
  18103. /**
  18104. * Sets the state of wireframe mode
  18105. */
  18106. wireframe: boolean;
  18107. /**
  18108. * Gets the value specifying if point clouds are enabled
  18109. */
  18110. /**
  18111. * Sets the state of point cloud mode
  18112. */
  18113. pointsCloud: boolean;
  18114. /**
  18115. * Gets the material fill mode
  18116. */
  18117. /**
  18118. * Sets the material fill mode
  18119. */
  18120. fillMode: number;
  18121. /**
  18122. * @hidden
  18123. * Stores the effects for the material
  18124. */
  18125. _effect: Nullable<Effect>;
  18126. /**
  18127. * @hidden
  18128. * Specifies if the material was previously ready
  18129. */
  18130. _wasPreviouslyReady: boolean;
  18131. /**
  18132. * Specifies if uniform buffers should be used
  18133. */
  18134. private _useUBO;
  18135. /**
  18136. * Stores a reference to the scene
  18137. */
  18138. private _scene;
  18139. /**
  18140. * Stores the fill mode state
  18141. */
  18142. private _fillMode;
  18143. /**
  18144. * Specifies if the depth write state should be cached
  18145. */
  18146. private _cachedDepthWriteState;
  18147. /**
  18148. * Stores the uniform buffer
  18149. */
  18150. protected _uniformBuffer: UniformBuffer;
  18151. /** @hidden */
  18152. _indexInSceneMaterialArray: number;
  18153. /** @hidden */
  18154. meshMap: Nullable<{
  18155. [id: string]: AbstractMesh | undefined;
  18156. }>;
  18157. /**
  18158. * Creates a material instance
  18159. * @param name defines the name of the material
  18160. * @param scene defines the scene to reference
  18161. * @param doNotAdd specifies if the material should be added to the scene
  18162. */
  18163. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18164. /**
  18165. * Returns a string representation of the current material
  18166. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18167. * @returns a string with material information
  18168. */
  18169. toString(fullDetails?: boolean): string;
  18170. /**
  18171. * Gets the class name of the material
  18172. * @returns a string with the class name of the material
  18173. */
  18174. getClassName(): string;
  18175. /**
  18176. * Specifies if updates for the material been locked
  18177. */
  18178. readonly isFrozen: boolean;
  18179. /**
  18180. * Locks updates for the material
  18181. */
  18182. freeze(): void;
  18183. /**
  18184. * Unlocks updates for the material
  18185. */
  18186. unfreeze(): void;
  18187. /**
  18188. * Specifies if the material is ready to be used
  18189. * @param mesh defines the mesh to check
  18190. * @param useInstances specifies if instances should be used
  18191. * @returns a boolean indicating if the material is ready to be used
  18192. */
  18193. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18194. /**
  18195. * Specifies that the submesh is ready to be used
  18196. * @param mesh defines the mesh to check
  18197. * @param subMesh defines which submesh to check
  18198. * @param useInstances specifies that instances should be used
  18199. * @returns a boolean indicating that the submesh is ready or not
  18200. */
  18201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18202. /**
  18203. * Returns the material effect
  18204. * @returns the effect associated with the material
  18205. */
  18206. getEffect(): Nullable<Effect>;
  18207. /**
  18208. * Returns the current scene
  18209. * @returns a Scene
  18210. */
  18211. getScene(): Scene;
  18212. /**
  18213. * Specifies if the material will require alpha blending
  18214. * @returns a boolean specifying if alpha blending is needed
  18215. */
  18216. needAlphaBlending(): boolean;
  18217. /**
  18218. * Specifies if the mesh will require alpha blending
  18219. * @param mesh defines the mesh to check
  18220. * @returns a boolean specifying if alpha blending is needed for the mesh
  18221. */
  18222. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18223. /**
  18224. * Specifies if this material should be rendered in alpha test mode
  18225. * @returns a boolean specifying if an alpha test is needed.
  18226. */
  18227. needAlphaTesting(): boolean;
  18228. /**
  18229. * Gets the texture used for the alpha test
  18230. * @returns the texture to use for alpha testing
  18231. */
  18232. getAlphaTestTexture(): Nullable<BaseTexture>;
  18233. /**
  18234. * Marks the material to indicate that it needs to be re-calculated
  18235. */
  18236. markDirty(): void;
  18237. /** @hidden */
  18238. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18239. /**
  18240. * Binds the material to the mesh
  18241. * @param world defines the world transformation matrix
  18242. * @param mesh defines the mesh to bind the material to
  18243. */
  18244. bind(world: Matrix, mesh?: Mesh): void;
  18245. /**
  18246. * Binds the submesh to the material
  18247. * @param world defines the world transformation matrix
  18248. * @param mesh defines the mesh containing the submesh
  18249. * @param subMesh defines the submesh to bind the material to
  18250. */
  18251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18252. /**
  18253. * Binds the world matrix to the material
  18254. * @param world defines the world transformation matrix
  18255. */
  18256. bindOnlyWorldMatrix(world: Matrix): void;
  18257. /**
  18258. * Binds the scene's uniform buffer to the effect.
  18259. * @param effect defines the effect to bind to the scene uniform buffer
  18260. * @param sceneUbo defines the uniform buffer storing scene data
  18261. */
  18262. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18263. /**
  18264. * Binds the view matrix to the effect
  18265. * @param effect defines the effect to bind the view matrix to
  18266. */
  18267. bindView(effect: Effect): void;
  18268. /**
  18269. * Binds the view projection matrix to the effect
  18270. * @param effect defines the effect to bind the view projection matrix to
  18271. */
  18272. bindViewProjection(effect: Effect): void;
  18273. /**
  18274. * Specifies if material alpha testing should be turned on for the mesh
  18275. * @param mesh defines the mesh to check
  18276. */
  18277. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18278. /**
  18279. * Processes to execute after binding the material to a mesh
  18280. * @param mesh defines the rendered mesh
  18281. */
  18282. protected _afterBind(mesh?: Mesh): void;
  18283. /**
  18284. * Unbinds the material from the mesh
  18285. */
  18286. unbind(): void;
  18287. /**
  18288. * Gets the active textures from the material
  18289. * @returns an array of textures
  18290. */
  18291. getActiveTextures(): BaseTexture[];
  18292. /**
  18293. * Specifies if the material uses a texture
  18294. * @param texture defines the texture to check against the material
  18295. * @returns a boolean specifying if the material uses the texture
  18296. */
  18297. hasTexture(texture: BaseTexture): boolean;
  18298. /**
  18299. * Makes a duplicate of the material, and gives it a new name
  18300. * @param name defines the new name for the duplicated material
  18301. * @returns the cloned material
  18302. */
  18303. clone(name: string): Nullable<Material>;
  18304. /**
  18305. * Gets the meshes bound to the material
  18306. * @returns an array of meshes bound to the material
  18307. */
  18308. getBindedMeshes(): AbstractMesh[];
  18309. /**
  18310. * Force shader compilation
  18311. * @param mesh defines the mesh associated with this material
  18312. * @param onCompiled defines a function to execute once the material is compiled
  18313. * @param options defines the options to configure the compilation
  18314. */
  18315. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18316. clipPlane: boolean;
  18317. }>): void;
  18318. /**
  18319. * Force shader compilation
  18320. * @param mesh defines the mesh that will use this material
  18321. * @param options defines additional options for compiling the shaders
  18322. * @returns a promise that resolves when the compilation completes
  18323. */
  18324. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18325. clipPlane: boolean;
  18326. }>): Promise<void>;
  18327. /**
  18328. * Marks a define in the material to indicate that it needs to be re-computed
  18329. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18330. */
  18331. markAsDirty(flag: number): void;
  18332. /**
  18333. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18334. * @param func defines a function which checks material defines against the submeshes
  18335. */
  18336. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18337. /**
  18338. * Indicates that image processing needs to be re-calculated for all submeshes
  18339. */
  18340. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18341. /**
  18342. * Indicates that textures need to be re-calculated for all submeshes
  18343. */
  18344. protected _markAllSubMeshesAsTexturesDirty(): void;
  18345. /**
  18346. * Indicates that fresnel needs to be re-calculated for all submeshes
  18347. */
  18348. protected _markAllSubMeshesAsFresnelDirty(): void;
  18349. /**
  18350. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18351. */
  18352. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18353. /**
  18354. * Indicates that lights need to be re-calculated for all submeshes
  18355. */
  18356. protected _markAllSubMeshesAsLightsDirty(): void;
  18357. /**
  18358. * Indicates that attributes need to be re-calculated for all submeshes
  18359. */
  18360. protected _markAllSubMeshesAsAttributesDirty(): void;
  18361. /**
  18362. * Indicates that misc needs to be re-calculated for all submeshes
  18363. */
  18364. protected _markAllSubMeshesAsMiscDirty(): void;
  18365. /**
  18366. * Indicates that textures and misc need to be re-calculated for all submeshes
  18367. */
  18368. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18369. /**
  18370. * Disposes the material
  18371. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18372. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18373. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18374. */
  18375. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18376. /** @hidden */
  18377. private releaseVertexArrayObject;
  18378. /**
  18379. * Serializes this material
  18380. * @returns the serialized material object
  18381. */
  18382. serialize(): any;
  18383. /**
  18384. * Creates a MultiMaterial from parsed MultiMaterial data.
  18385. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18386. * @param scene defines the hosting scene
  18387. * @returns a new MultiMaterial
  18388. */
  18389. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18390. /**
  18391. * Creates a material from parsed material data
  18392. * @param parsedMaterial defines parsed material data
  18393. * @param scene defines the hosting scene
  18394. * @param rootUrl defines the root URL to use to load textures
  18395. * @returns a new material
  18396. */
  18397. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18398. }
  18399. }
  18400. declare module BABYLON {
  18401. /**
  18402. * "Static Class" containing the most commonly used helper while dealing with material for
  18403. * rendering purpose.
  18404. *
  18405. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18406. *
  18407. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18408. */
  18409. class MaterialHelper {
  18410. /**
  18411. * Bind the current view position to an effect.
  18412. * @param effect The effect to be bound
  18413. * @param scene The scene the eyes position is used from
  18414. */
  18415. static BindEyePosition(effect: Effect, scene: Scene): void;
  18416. /**
  18417. * Helps preparing the defines values about the UVs in used in the effect.
  18418. * UVs are shared as much as we can accross channels in the shaders.
  18419. * @param texture The texture we are preparing the UVs for
  18420. * @param defines The defines to update
  18421. * @param key The channel key "diffuse", "specular"... used in the shader
  18422. */
  18423. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18424. /**
  18425. * Binds a texture matrix value to its corrsponding uniform
  18426. * @param texture The texture to bind the matrix for
  18427. * @param uniformBuffer The uniform buffer receivin the data
  18428. * @param key The channel key "diffuse", "specular"... used in the shader
  18429. */
  18430. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18431. /**
  18432. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18433. * @param mesh defines the current mesh
  18434. * @param scene defines the current scene
  18435. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18436. * @param pointsCloud defines if point cloud rendering has to be turned on
  18437. * @param fogEnabled defines if fog has to be turned on
  18438. * @param alphaTest defines if alpha testing has to be turned on
  18439. * @param defines defines the current list of defines
  18440. */
  18441. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18442. /**
  18443. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18444. * @param scene defines the current scene
  18445. * @param engine defines the current engine
  18446. * @param defines specifies the list of active defines
  18447. * @param useInstances defines if instances have to be turned on
  18448. * @param useClipPlane defines if clip plane have to be turned on
  18449. */
  18450. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18451. /**
  18452. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18453. * @param mesh The mesh containing the geometry data we will draw
  18454. * @param defines The defines to update
  18455. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18456. * @param useBones Precise whether bones should be used or not (override mesh info)
  18457. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18458. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18459. * @returns false if defines are considered not dirty and have not been checked
  18460. */
  18461. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18462. /**
  18463. * Prepares the defines related to the light information passed in parameter
  18464. * @param scene The scene we are intending to draw
  18465. * @param mesh The mesh the effect is compiling for
  18466. * @param defines The defines to update
  18467. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18468. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18469. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18470. * @returns true if normals will be required for the rest of the effect
  18471. */
  18472. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18473. /**
  18474. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18475. * that won t be acctive due to defines being turned off.
  18476. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18477. * @param samplersList The samplers list
  18478. * @param defines The defines helping in the list generation
  18479. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18480. */
  18481. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18482. /**
  18483. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18484. * @param defines The defines to update while falling back
  18485. * @param fallbacks The authorized effect fallbacks
  18486. * @param maxSimultaneousLights The maximum number of lights allowed
  18487. * @param rank the current rank of the Effect
  18488. * @returns The newly affected rank
  18489. */
  18490. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18491. /**
  18492. * Prepares the list of attributes required for morph targets according to the effect defines.
  18493. * @param attribs The current list of supported attribs
  18494. * @param mesh The mesh to prepare the morph targets attributes for
  18495. * @param defines The current Defines of the effect
  18496. */
  18497. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18498. /**
  18499. * Prepares the list of attributes required for bones according to the effect defines.
  18500. * @param attribs The current list of supported attribs
  18501. * @param mesh The mesh to prepare the bones attributes for
  18502. * @param defines The current Defines of the effect
  18503. * @param fallbacks The current efffect fallback strategy
  18504. */
  18505. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18506. /**
  18507. * Prepares the list of attributes required for instances according to the effect defines.
  18508. * @param attribs The current list of supported attribs
  18509. * @param defines The current Defines of the effect
  18510. */
  18511. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18512. /**
  18513. * Binds the light shadow information to the effect for the given mesh.
  18514. * @param light The light containing the generator
  18515. * @param scene The scene the lights belongs to
  18516. * @param mesh The mesh we are binding the information to render
  18517. * @param lightIndex The light index in the effect used to render the mesh
  18518. * @param effect The effect we are binding the data to
  18519. */
  18520. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18521. /**
  18522. * Binds the light information to the effect.
  18523. * @param light The light containing the generator
  18524. * @param effect The effect we are binding the data to
  18525. * @param lightIndex The light index in the effect used to render
  18526. */
  18527. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18528. /**
  18529. * Binds the lights information from the scene to the effect for the given mesh.
  18530. * @param scene The scene the lights belongs to
  18531. * @param mesh The mesh we are binding the information to render
  18532. * @param effect The effect we are binding the data to
  18533. * @param defines The generated defines for the effect
  18534. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18535. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18536. */
  18537. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18538. private static _tempFogColor;
  18539. /**
  18540. * Binds the fog information from the scene to the effect for the given mesh.
  18541. * @param scene The scene the lights belongs to
  18542. * @param mesh The mesh we are binding the information to render
  18543. * @param effect The effect we are binding the data to
  18544. * @param linearSpace Defines if the fog effect is applied in linear space
  18545. */
  18546. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18547. /**
  18548. * Binds the bones information from the mesh to the effect.
  18549. * @param mesh The mesh we are binding the information to render
  18550. * @param effect The effect we are binding the data to
  18551. */
  18552. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18553. /**
  18554. * Binds the morph targets information from the mesh to the effect.
  18555. * @param abstractMesh The mesh we are binding the information to render
  18556. * @param effect The effect we are binding the data to
  18557. */
  18558. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18559. /**
  18560. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18561. * @param defines The generated defines used in the effect
  18562. * @param effect The effect we are binding the data to
  18563. * @param scene The scene we are willing to render with logarithmic scale for
  18564. */
  18565. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18566. /**
  18567. * Binds the clip plane information from the scene to the effect.
  18568. * @param scene The scene the clip plane information are extracted from
  18569. * @param effect The effect we are binding the data to
  18570. */
  18571. static BindClipPlane(effect: Effect, scene: Scene): void;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18577. * separate meshes. This can be use to improve performances.
  18578. * @see http://doc.babylonjs.com/how_to/multi_materials
  18579. */
  18580. class MultiMaterial extends Material {
  18581. private _subMaterials;
  18582. /**
  18583. * Gets or Sets the list of Materials used within the multi material.
  18584. * They need to be ordered according to the submeshes order in the associated mesh
  18585. */
  18586. subMaterials: Nullable<Material>[];
  18587. /**
  18588. * Instantiates a new Multi Material
  18589. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18590. * separate meshes. This can be use to improve performances.
  18591. * @see http://doc.babylonjs.com/how_to/multi_materials
  18592. * @param name Define the name in the scene
  18593. * @param scene Define the scene the material belongs to
  18594. */
  18595. constructor(name: string, scene: Scene);
  18596. private _hookArray;
  18597. /**
  18598. * Get one of the submaterial by its index in the submaterials array
  18599. * @param index The index to look the sub material at
  18600. * @returns The Material if the index has been defined
  18601. */
  18602. getSubMaterial(index: number): Nullable<Material>;
  18603. /**
  18604. * Get the list of active textures for the whole sub materials list.
  18605. * @returns All the textures that will be used during the rendering
  18606. */
  18607. getActiveTextures(): BaseTexture[];
  18608. /**
  18609. * Gets the current class name of the material e.g. "MultiMaterial"
  18610. * Mainly use in serialization.
  18611. * @returns the class name
  18612. */
  18613. getClassName(): string;
  18614. /**
  18615. * Checks if the material is ready to render the requested sub mesh
  18616. * @param mesh Define the mesh the submesh belongs to
  18617. * @param subMesh Define the sub mesh to look readyness for
  18618. * @param useInstances Define whether or not the material is used with instances
  18619. * @returns true if ready, otherwise false
  18620. */
  18621. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18622. /**
  18623. * Clones the current material and its related sub materials
  18624. * @param name Define the name of the newly cloned material
  18625. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18626. * @returns the cloned material
  18627. */
  18628. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18629. /**
  18630. * Serializes the materials into a JSON representation.
  18631. * @returns the JSON representation
  18632. */
  18633. serialize(): any;
  18634. /**
  18635. * Dispose the material and release its associated resources
  18636. * @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)
  18637. * @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)
  18638. */
  18639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18640. }
  18641. }
  18642. declare module BABYLON {
  18643. /**
  18644. * Base class of materials working in push mode in babylon JS
  18645. * @hidden
  18646. */
  18647. class PushMaterial extends Material {
  18648. protected _activeEffect: Effect;
  18649. protected _normalMatrix: Matrix;
  18650. /**
  18651. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18652. * This means that the material can keep using a previous shader while a new one is being compiled.
  18653. * This is mostly used when shader parallel compilation is supported (true by default)
  18654. */
  18655. allowShaderHotSwapping: boolean;
  18656. constructor(name: string, scene: Scene);
  18657. getEffect(): Effect;
  18658. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18659. /**
  18660. * Binds the given world matrix to the active effect
  18661. *
  18662. * @param world the matrix to bind
  18663. */
  18664. bindOnlyWorldMatrix(world: Matrix): void;
  18665. /**
  18666. * Binds the given normal matrix to the active effect
  18667. *
  18668. * @param normalMatrix the matrix to bind
  18669. */
  18670. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18671. bind(world: Matrix, mesh?: Mesh): void;
  18672. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18673. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. /**
  18678. * Defines the options associated with the creation of a shader material.
  18679. */
  18680. interface IShaderMaterialOptions {
  18681. /**
  18682. * Does the material work in alpha blend mode
  18683. */
  18684. needAlphaBlending: boolean;
  18685. /**
  18686. * Does the material work in alpha test mode
  18687. */
  18688. needAlphaTesting: boolean;
  18689. /**
  18690. * The list of attribute names used in the shader
  18691. */
  18692. attributes: string[];
  18693. /**
  18694. * The list of unifrom names used in the shader
  18695. */
  18696. uniforms: string[];
  18697. /**
  18698. * The list of UBO names used in the shader
  18699. */
  18700. uniformBuffers: string[];
  18701. /**
  18702. * The list of sampler names used in the shader
  18703. */
  18704. samplers: string[];
  18705. /**
  18706. * The list of defines used in the shader
  18707. */
  18708. defines: string[];
  18709. }
  18710. /**
  18711. * 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.
  18712. *
  18713. * This returned material effects how the mesh will look based on the code in the shaders.
  18714. *
  18715. * @see http://doc.babylonjs.com/how_to/shader_material
  18716. */
  18717. class ShaderMaterial extends Material {
  18718. private _shaderPath;
  18719. private _options;
  18720. private _textures;
  18721. private _textureArrays;
  18722. private _floats;
  18723. private _ints;
  18724. private _floatsArrays;
  18725. private _colors3;
  18726. private _colors3Arrays;
  18727. private _colors4;
  18728. private _vectors2;
  18729. private _vectors3;
  18730. private _vectors4;
  18731. private _matrices;
  18732. private _matrices3x3;
  18733. private _matrices2x2;
  18734. private _vectors2Arrays;
  18735. private _vectors3Arrays;
  18736. private _cachedWorldViewMatrix;
  18737. private _renderId;
  18738. /**
  18739. * Instantiate a new shader material.
  18740. * 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.
  18741. * This returned material effects how the mesh will look based on the code in the shaders.
  18742. * @see http://doc.babylonjs.com/how_to/shader_material
  18743. * @param name Define the name of the material in the scene
  18744. * @param scene Define the scene the material belongs to
  18745. * @param shaderPath Defines the route to the shader code in one of three ways:
  18746. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18747. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18748. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18749. * @param options Define the options used to create the shader
  18750. */
  18751. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18752. /**
  18753. * Gets the current class name of the material e.g. "ShaderMaterial"
  18754. * Mainly use in serialization.
  18755. * @returns the class name
  18756. */
  18757. getClassName(): string;
  18758. /**
  18759. * Specifies if the material will require alpha blending
  18760. * @returns a boolean specifying if alpha blending is needed
  18761. */
  18762. needAlphaBlending(): boolean;
  18763. /**
  18764. * Specifies if this material should be rendered in alpha test mode
  18765. * @returns a boolean specifying if an alpha test is needed.
  18766. */
  18767. needAlphaTesting(): boolean;
  18768. private _checkUniform;
  18769. /**
  18770. * Set a texture in the shader.
  18771. * @param name Define the name of the uniform samplers as defined in the shader
  18772. * @param texture Define the texture to bind to this sampler
  18773. * @return the material itself allowing "fluent" like uniform updates
  18774. */
  18775. setTexture(name: string, texture: Texture): ShaderMaterial;
  18776. /**
  18777. * Set a texture array in the shader.
  18778. * @param name Define the name of the uniform sampler array as defined in the shader
  18779. * @param textures Define the list of textures to bind to this sampler
  18780. * @return the material itself allowing "fluent" like uniform updates
  18781. */
  18782. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18783. /**
  18784. * Set a float in the shader.
  18785. * @param name Define the name of the uniform as defined in the shader
  18786. * @param value Define the value to give to the uniform
  18787. * @return the material itself allowing "fluent" like uniform updates
  18788. */
  18789. setFloat(name: string, value: number): ShaderMaterial;
  18790. /**
  18791. * Set a int in the shader.
  18792. * @param name Define the name of the uniform as defined in the shader
  18793. * @param value Define the value to give to the uniform
  18794. * @return the material itself allowing "fluent" like uniform updates
  18795. */
  18796. setInt(name: string, value: number): ShaderMaterial;
  18797. /**
  18798. * Set an array of floats in the shader.
  18799. * @param name Define the name of the uniform as defined in the shader
  18800. * @param value Define the value to give to the uniform
  18801. * @return the material itself allowing "fluent" like uniform updates
  18802. */
  18803. setFloats(name: string, value: number[]): ShaderMaterial;
  18804. /**
  18805. * Set a vec3 in the shader from a Color3.
  18806. * @param name Define the name of the uniform as defined in the shader
  18807. * @param value Define the value to give to the uniform
  18808. * @return the material itself allowing "fluent" like uniform updates
  18809. */
  18810. setColor3(name: string, value: Color3): ShaderMaterial;
  18811. /**
  18812. * Set a vec3 array in the shader from a Color3 array.
  18813. * @param name Define the name of the uniform as defined in the shader
  18814. * @param value Define the value to give to the uniform
  18815. * @return the material itself allowing "fluent" like uniform updates
  18816. */
  18817. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18818. /**
  18819. * Set a vec4 in the shader from a Color4.
  18820. * @param name Define the name of the uniform as defined in the shader
  18821. * @param value Define the value to give to the uniform
  18822. * @return the material itself allowing "fluent" like uniform updates
  18823. */
  18824. setColor4(name: string, value: Color4): ShaderMaterial;
  18825. /**
  18826. * Set a vec2 in the shader from a Vector2.
  18827. * @param name Define the name of the uniform as defined in the shader
  18828. * @param value Define the value to give to the uniform
  18829. * @return the material itself allowing "fluent" like uniform updates
  18830. */
  18831. setVector2(name: string, value: Vector2): ShaderMaterial;
  18832. /**
  18833. * Set a vec3 in the shader from a Vector3.
  18834. * @param name Define the name of the uniform as defined in the shader
  18835. * @param value Define the value to give to the uniform
  18836. * @return the material itself allowing "fluent" like uniform updates
  18837. */
  18838. setVector3(name: string, value: Vector3): ShaderMaterial;
  18839. /**
  18840. * Set a vec4 in the shader from a Vector4.
  18841. * @param name Define the name of the uniform as defined in the shader
  18842. * @param value Define the value to give to the uniform
  18843. * @return the material itself allowing "fluent" like uniform updates
  18844. */
  18845. setVector4(name: string, value: Vector4): ShaderMaterial;
  18846. /**
  18847. * Set a mat4 in the shader from a Matrix.
  18848. * @param name Define the name of the uniform as defined in the shader
  18849. * @param value Define the value to give to the uniform
  18850. * @return the material itself allowing "fluent" like uniform updates
  18851. */
  18852. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18853. /**
  18854. * Set a mat3 in the shader from a Float32Array.
  18855. * @param name Define the name of the uniform as defined in the shader
  18856. * @param value Define the value to give to the uniform
  18857. * @return the material itself allowing "fluent" like uniform updates
  18858. */
  18859. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18860. /**
  18861. * Set a mat2 in the shader from a Float32Array.
  18862. * @param name Define the name of the uniform as defined in the shader
  18863. * @param value Define the value to give to the uniform
  18864. * @return the material itself allowing "fluent" like uniform updates
  18865. */
  18866. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18867. /**
  18868. * Set a vec2 array in the shader from a number array.
  18869. * @param name Define the name of the uniform as defined in the shader
  18870. * @param value Define the value to give to the uniform
  18871. * @return the material itself allowing "fluent" like uniform updates
  18872. */
  18873. setArray2(name: string, value: number[]): ShaderMaterial;
  18874. /**
  18875. * Set a vec3 array in the shader from a number array.
  18876. * @param name Define the name of the uniform as defined in the shader
  18877. * @param value Define the value to give to the uniform
  18878. * @return the material itself allowing "fluent" like uniform updates
  18879. */
  18880. setArray3(name: string, value: number[]): ShaderMaterial;
  18881. private _checkCache;
  18882. /**
  18883. * Checks if the material is ready to render the requested mesh
  18884. * @param mesh Define the mesh to render
  18885. * @param useInstances Define whether or not the material is used with instances
  18886. * @returns true if ready, otherwise false
  18887. */
  18888. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18889. /**
  18890. * Binds the world matrix to the material
  18891. * @param world defines the world transformation matrix
  18892. */
  18893. bindOnlyWorldMatrix(world: Matrix): void;
  18894. /**
  18895. * Binds the material to the mesh
  18896. * @param world defines the world transformation matrix
  18897. * @param mesh defines the mesh to bind the material to
  18898. */
  18899. bind(world: Matrix, mesh?: Mesh): void;
  18900. /**
  18901. * Gets the active textures from the material
  18902. * @returns an array of textures
  18903. */
  18904. getActiveTextures(): BaseTexture[];
  18905. /**
  18906. * Specifies if the material uses a texture
  18907. * @param texture defines the texture to check against the material
  18908. * @returns a boolean specifying if the material uses the texture
  18909. */
  18910. hasTexture(texture: BaseTexture): boolean;
  18911. /**
  18912. * Makes a duplicate of the material, and gives it a new name
  18913. * @param name defines the new name for the duplicated material
  18914. * @returns the cloned material
  18915. */
  18916. clone(name: string): ShaderMaterial;
  18917. /**
  18918. * Disposes the material
  18919. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18920. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18921. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18922. */
  18923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18924. /**
  18925. * Serializes this material in a JSON representation
  18926. * @returns the serialized material object
  18927. */
  18928. serialize(): any;
  18929. /**
  18930. * Creates a shader material from parsed shader material data
  18931. * @param source defines the JSON represnetation of the material
  18932. * @param scene defines the hosting scene
  18933. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18934. * @returns a new material
  18935. */
  18936. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18937. }
  18938. }
  18939. declare module BABYLON {
  18940. /** @hidden */
  18941. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  18942. MAINUV1: boolean;
  18943. MAINUV2: boolean;
  18944. DIFFUSE: boolean;
  18945. DIFFUSEDIRECTUV: number;
  18946. AMBIENT: boolean;
  18947. AMBIENTDIRECTUV: number;
  18948. OPACITY: boolean;
  18949. OPACITYDIRECTUV: number;
  18950. OPACITYRGB: boolean;
  18951. REFLECTION: boolean;
  18952. EMISSIVE: boolean;
  18953. EMISSIVEDIRECTUV: number;
  18954. SPECULAR: boolean;
  18955. SPECULARDIRECTUV: number;
  18956. BUMP: boolean;
  18957. BUMPDIRECTUV: number;
  18958. PARALLAX: boolean;
  18959. PARALLAXOCCLUSION: boolean;
  18960. SPECULAROVERALPHA: boolean;
  18961. CLIPPLANE: boolean;
  18962. CLIPPLANE2: boolean;
  18963. CLIPPLANE3: boolean;
  18964. CLIPPLANE4: boolean;
  18965. ALPHATEST: boolean;
  18966. DEPTHPREPASS: boolean;
  18967. ALPHAFROMDIFFUSE: boolean;
  18968. POINTSIZE: boolean;
  18969. FOG: boolean;
  18970. SPECULARTERM: boolean;
  18971. DIFFUSEFRESNEL: boolean;
  18972. OPACITYFRESNEL: boolean;
  18973. REFLECTIONFRESNEL: boolean;
  18974. REFRACTIONFRESNEL: boolean;
  18975. EMISSIVEFRESNEL: boolean;
  18976. FRESNEL: boolean;
  18977. NORMAL: boolean;
  18978. UV1: boolean;
  18979. UV2: boolean;
  18980. VERTEXCOLOR: boolean;
  18981. VERTEXALPHA: boolean;
  18982. NUM_BONE_INFLUENCERS: number;
  18983. BonesPerMesh: number;
  18984. INSTANCES: boolean;
  18985. GLOSSINESS: boolean;
  18986. ROUGHNESS: boolean;
  18987. EMISSIVEASILLUMINATION: boolean;
  18988. LINKEMISSIVEWITHDIFFUSE: boolean;
  18989. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18990. LIGHTMAP: boolean;
  18991. LIGHTMAPDIRECTUV: number;
  18992. OBJECTSPACE_NORMALMAP: boolean;
  18993. USELIGHTMAPASSHADOWMAP: boolean;
  18994. REFLECTIONMAP_3D: boolean;
  18995. REFLECTIONMAP_SPHERICAL: boolean;
  18996. REFLECTIONMAP_PLANAR: boolean;
  18997. REFLECTIONMAP_CUBIC: boolean;
  18998. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18999. REFLECTIONMAP_PROJECTION: boolean;
  19000. REFLECTIONMAP_SKYBOX: boolean;
  19001. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19002. REFLECTIONMAP_EXPLICIT: boolean;
  19003. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19004. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19005. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19006. INVERTCUBICMAP: boolean;
  19007. LOGARITHMICDEPTH: boolean;
  19008. REFRACTION: boolean;
  19009. REFRACTIONMAP_3D: boolean;
  19010. REFLECTIONOVERALPHA: boolean;
  19011. TWOSIDEDLIGHTING: boolean;
  19012. SHADOWFLOAT: boolean;
  19013. MORPHTARGETS: boolean;
  19014. MORPHTARGETS_NORMAL: boolean;
  19015. MORPHTARGETS_TANGENT: boolean;
  19016. NUM_MORPH_INFLUENCERS: number;
  19017. NONUNIFORMSCALING: boolean;
  19018. PREMULTIPLYALPHA: boolean;
  19019. IMAGEPROCESSING: boolean;
  19020. VIGNETTE: boolean;
  19021. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19022. VIGNETTEBLENDMODEOPAQUE: boolean;
  19023. TONEMAPPING: boolean;
  19024. TONEMAPPING_ACES: boolean;
  19025. CONTRAST: boolean;
  19026. COLORCURVES: boolean;
  19027. COLORGRADING: boolean;
  19028. COLORGRADING3D: boolean;
  19029. SAMPLER3DGREENDEPTH: boolean;
  19030. SAMPLER3DBGRMAP: boolean;
  19031. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19032. /**
  19033. * If the reflection texture on this material is in linear color space
  19034. * @hidden
  19035. */
  19036. IS_REFLECTION_LINEAR: boolean;
  19037. /**
  19038. * If the refraction texture on this material is in linear color space
  19039. * @hidden
  19040. */
  19041. IS_REFRACTION_LINEAR: boolean;
  19042. EXPOSURE: boolean;
  19043. constructor();
  19044. setReflectionMode(modeToEnable: string): void;
  19045. }
  19046. /**
  19047. * This is the default material used in Babylon. It is the best trade off between quality
  19048. * and performances.
  19049. * @see http://doc.babylonjs.com/babylon101/materials
  19050. */
  19051. class StandardMaterial extends PushMaterial {
  19052. private _diffuseTexture;
  19053. /**
  19054. * The basic texture of the material as viewed under a light.
  19055. */
  19056. diffuseTexture: Nullable<BaseTexture>;
  19057. private _ambientTexture;
  19058. /**
  19059. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19060. */
  19061. ambientTexture: Nullable<BaseTexture>;
  19062. private _opacityTexture;
  19063. /**
  19064. * Define the transparency of the material from a texture.
  19065. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19066. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19067. */
  19068. opacityTexture: Nullable<BaseTexture>;
  19069. private _reflectionTexture;
  19070. /**
  19071. * Define the texture used to display the reflection.
  19072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19073. */
  19074. reflectionTexture: Nullable<BaseTexture>;
  19075. private _emissiveTexture;
  19076. /**
  19077. * Define texture of the material as if self lit.
  19078. * This will be mixed in the final result even in the absence of light.
  19079. */
  19080. emissiveTexture: Nullable<BaseTexture>;
  19081. private _specularTexture;
  19082. /**
  19083. * Define how the color and intensity of the highlight given by the light in the material.
  19084. */
  19085. specularTexture: Nullable<BaseTexture>;
  19086. private _bumpTexture;
  19087. /**
  19088. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19089. * 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.
  19090. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19091. */
  19092. bumpTexture: Nullable<BaseTexture>;
  19093. private _lightmapTexture;
  19094. /**
  19095. * Complex lighting can be computationally expensive to compute at runtime.
  19096. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19097. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19098. */
  19099. lightmapTexture: Nullable<BaseTexture>;
  19100. private _refractionTexture;
  19101. /**
  19102. * Define the texture used to display the refraction.
  19103. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19104. */
  19105. refractionTexture: Nullable<BaseTexture>;
  19106. /**
  19107. * The color of the material lit by the environmental background lighting.
  19108. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19109. */
  19110. ambientColor: Color3;
  19111. /**
  19112. * The basic color of the material as viewed under a light.
  19113. */
  19114. diffuseColor: Color3;
  19115. /**
  19116. * Define how the color and intensity of the highlight given by the light in the material.
  19117. */
  19118. specularColor: Color3;
  19119. /**
  19120. * Define the color of the material as if self lit.
  19121. * This will be mixed in the final result even in the absence of light.
  19122. */
  19123. emissiveColor: Color3;
  19124. /**
  19125. * Defines how sharp are the highlights in the material.
  19126. * The bigger the value the sharper giving a more glossy feeling to the result.
  19127. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19128. */
  19129. specularPower: number;
  19130. private _useAlphaFromDiffuseTexture;
  19131. /**
  19132. * Does the transparency come from the diffuse texture alpha channel.
  19133. */
  19134. useAlphaFromDiffuseTexture: boolean;
  19135. private _useEmissiveAsIllumination;
  19136. /**
  19137. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19138. */
  19139. useEmissiveAsIllumination: boolean;
  19140. private _linkEmissiveWithDiffuse;
  19141. /**
  19142. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19143. * the emissive level when the final color is close to one.
  19144. */
  19145. linkEmissiveWithDiffuse: boolean;
  19146. private _useSpecularOverAlpha;
  19147. /**
  19148. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19149. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19150. */
  19151. useSpecularOverAlpha: boolean;
  19152. private _useReflectionOverAlpha;
  19153. /**
  19154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19156. */
  19157. useReflectionOverAlpha: boolean;
  19158. private _disableLighting;
  19159. /**
  19160. * Does lights from the scene impacts this material.
  19161. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19162. */
  19163. disableLighting: boolean;
  19164. private _useObjectSpaceNormalMap;
  19165. /**
  19166. * Allows using an object space normal map (instead of tangent space).
  19167. */
  19168. useObjectSpaceNormalMap: boolean;
  19169. private _useParallax;
  19170. /**
  19171. * Is parallax enabled or not.
  19172. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19173. */
  19174. useParallax: boolean;
  19175. private _useParallaxOcclusion;
  19176. /**
  19177. * Is parallax occlusion enabled or not.
  19178. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19179. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19180. */
  19181. useParallaxOcclusion: boolean;
  19182. /**
  19183. * 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.
  19184. */
  19185. parallaxScaleBias: number;
  19186. private _roughness;
  19187. /**
  19188. * Helps to define how blurry the reflections should appears in the material.
  19189. */
  19190. roughness: number;
  19191. /**
  19192. * In case of refraction, define the value of the indice of refraction.
  19193. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19194. */
  19195. indexOfRefraction: number;
  19196. /**
  19197. * Invert the refraction texture alongside the y axis.
  19198. * It can be usefull with procedural textures or probe for instance.
  19199. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19200. */
  19201. invertRefractionY: boolean;
  19202. /**
  19203. * Defines the alpha limits in alpha test mode.
  19204. */
  19205. alphaCutOff: number;
  19206. private _useLightmapAsShadowmap;
  19207. /**
  19208. * In case of light mapping, define whether the map contains light or shadow informations.
  19209. */
  19210. useLightmapAsShadowmap: boolean;
  19211. private _diffuseFresnelParameters;
  19212. /**
  19213. * Define the diffuse fresnel parameters of the material.
  19214. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19215. */
  19216. diffuseFresnelParameters: FresnelParameters;
  19217. private _opacityFresnelParameters;
  19218. /**
  19219. * Define the opacity fresnel parameters of the material.
  19220. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19221. */
  19222. opacityFresnelParameters: FresnelParameters;
  19223. private _reflectionFresnelParameters;
  19224. /**
  19225. * Define the reflection fresnel parameters of the material.
  19226. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19227. */
  19228. reflectionFresnelParameters: FresnelParameters;
  19229. private _refractionFresnelParameters;
  19230. /**
  19231. * Define the refraction fresnel parameters of the material.
  19232. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19233. */
  19234. refractionFresnelParameters: FresnelParameters;
  19235. private _emissiveFresnelParameters;
  19236. /**
  19237. * Define the emissive fresnel parameters of the material.
  19238. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19239. */
  19240. emissiveFresnelParameters: FresnelParameters;
  19241. private _useReflectionFresnelFromSpecular;
  19242. /**
  19243. * If true automatically deducts the fresnels values from the material specularity.
  19244. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19245. */
  19246. useReflectionFresnelFromSpecular: boolean;
  19247. private _useGlossinessFromSpecularMapAlpha;
  19248. /**
  19249. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19250. */
  19251. useGlossinessFromSpecularMapAlpha: boolean;
  19252. private _maxSimultaneousLights;
  19253. /**
  19254. * Defines the maximum number of lights that can be used in the material
  19255. */
  19256. maxSimultaneousLights: number;
  19257. private _invertNormalMapX;
  19258. /**
  19259. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19260. */
  19261. invertNormalMapX: boolean;
  19262. private _invertNormalMapY;
  19263. /**
  19264. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19265. */
  19266. invertNormalMapY: boolean;
  19267. private _twoSidedLighting;
  19268. /**
  19269. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19270. */
  19271. twoSidedLighting: boolean;
  19272. /**
  19273. * Default configuration related to image processing available in the standard Material.
  19274. */
  19275. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19276. /**
  19277. * Gets the image processing configuration used either in this material.
  19278. */
  19279. /**
  19280. * Sets the Default image processing configuration used either in the this material.
  19281. *
  19282. * If sets to null, the scene one is in use.
  19283. */
  19284. imageProcessingConfiguration: ImageProcessingConfiguration;
  19285. /**
  19286. * Keep track of the image processing observer to allow dispose and replace.
  19287. */
  19288. private _imageProcessingObserver;
  19289. /**
  19290. * Attaches a new image processing configuration to the Standard Material.
  19291. * @param configuration
  19292. */
  19293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19294. /**
  19295. * Gets wether the color curves effect is enabled.
  19296. */
  19297. /**
  19298. * Sets wether the color curves effect is enabled.
  19299. */
  19300. cameraColorCurvesEnabled: boolean;
  19301. /**
  19302. * Gets wether the color grading effect is enabled.
  19303. */
  19304. /**
  19305. * Gets wether the color grading effect is enabled.
  19306. */
  19307. cameraColorGradingEnabled: boolean;
  19308. /**
  19309. * Gets wether tonemapping is enabled or not.
  19310. */
  19311. /**
  19312. * Sets wether tonemapping is enabled or not
  19313. */
  19314. cameraToneMappingEnabled: boolean;
  19315. /**
  19316. * The camera exposure used on this material.
  19317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19318. * This corresponds to a photographic exposure.
  19319. */
  19320. /**
  19321. * The camera exposure used on this material.
  19322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19323. * This corresponds to a photographic exposure.
  19324. */
  19325. cameraExposure: number;
  19326. /**
  19327. * Gets The camera contrast used on this material.
  19328. */
  19329. /**
  19330. * Sets The camera contrast used on this material.
  19331. */
  19332. cameraContrast: number;
  19333. /**
  19334. * Gets the Color Grading 2D Lookup Texture.
  19335. */
  19336. /**
  19337. * Sets the Color Grading 2D Lookup Texture.
  19338. */
  19339. cameraColorGradingTexture: Nullable<BaseTexture>;
  19340. /**
  19341. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19342. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19343. * 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;
  19344. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19345. */
  19346. /**
  19347. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19348. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19349. * 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;
  19350. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19351. */
  19352. cameraColorCurves: Nullable<ColorCurves>;
  19353. /**
  19354. * Custom callback helping to override the default shader used in the material.
  19355. */
  19356. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19357. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19358. protected _worldViewProjectionMatrix: Matrix;
  19359. protected _globalAmbientColor: Color3;
  19360. protected _useLogarithmicDepth: boolean;
  19361. /**
  19362. * Instantiates a new standard material.
  19363. * This is the default material used in Babylon. It is the best trade off between quality
  19364. * and performances.
  19365. * @see http://doc.babylonjs.com/babylon101/materials
  19366. * @param name Define the name of the material in the scene
  19367. * @param scene Define the scene the material belong to
  19368. */
  19369. constructor(name: string, scene: Scene);
  19370. /**
  19371. * Gets a boolean indicating that current material needs to register RTT
  19372. */
  19373. readonly hasRenderTargetTextures: boolean;
  19374. /**
  19375. * Gets the current class name of the material e.g. "StandardMaterial"
  19376. * Mainly use in serialization.
  19377. * @returns the class name
  19378. */
  19379. getClassName(): string;
  19380. /**
  19381. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19382. * You can try switching to logarithmic depth.
  19383. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19384. */
  19385. useLogarithmicDepth: boolean;
  19386. /**
  19387. * Specifies if the material will require alpha blending
  19388. * @returns a boolean specifying if alpha blending is needed
  19389. */
  19390. needAlphaBlending(): boolean;
  19391. /**
  19392. * Specifies if this material should be rendered in alpha test mode
  19393. * @returns a boolean specifying if an alpha test is needed.
  19394. */
  19395. needAlphaTesting(): boolean;
  19396. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19397. /**
  19398. * Get the texture used for alpha test purpose.
  19399. * @returns the diffuse texture in case of the standard material.
  19400. */
  19401. getAlphaTestTexture(): Nullable<BaseTexture>;
  19402. /**
  19403. * Get if the submesh is ready to be used and all its information available.
  19404. * Child classes can use it to update shaders
  19405. * @param mesh defines the mesh to check
  19406. * @param subMesh defines which submesh to check
  19407. * @param useInstances specifies that instances should be used
  19408. * @returns a boolean indicating that the submesh is ready or not
  19409. */
  19410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19411. /**
  19412. * Builds the material UBO layouts.
  19413. * Used internally during the effect preparation.
  19414. */
  19415. buildUniformLayout(): void;
  19416. /**
  19417. * Unbinds the material from the mesh
  19418. */
  19419. unbind(): void;
  19420. /**
  19421. * Binds the submesh to this material by preparing the effect and shader to draw
  19422. * @param world defines the world transformation matrix
  19423. * @param mesh defines the mesh containing the submesh
  19424. * @param subMesh defines the submesh to bind the material to
  19425. */
  19426. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19427. /**
  19428. * Get the list of animatables in the material.
  19429. * @returns the list of animatables object used in the material
  19430. */
  19431. getAnimatables(): IAnimatable[];
  19432. /**
  19433. * Gets the active textures from the material
  19434. * @returns an array of textures
  19435. */
  19436. getActiveTextures(): BaseTexture[];
  19437. /**
  19438. * Specifies if the material uses a texture
  19439. * @param texture defines the texture to check against the material
  19440. * @returns a boolean specifying if the material uses the texture
  19441. */
  19442. hasTexture(texture: BaseTexture): boolean;
  19443. /**
  19444. * Disposes the material
  19445. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19446. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19447. */
  19448. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19449. /**
  19450. * Makes a duplicate of the material, and gives it a new name
  19451. * @param name defines the new name for the duplicated material
  19452. * @returns the cloned material
  19453. */
  19454. clone(name: string): StandardMaterial;
  19455. /**
  19456. * Serializes this material in a JSON representation
  19457. * @returns the serialized material object
  19458. */
  19459. serialize(): any;
  19460. /**
  19461. * Creates a standard material from parsed material data
  19462. * @param source defines the JSON represnetation of the material
  19463. * @param scene defines the hosting scene
  19464. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19465. * @returns a new material
  19466. */
  19467. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19468. private static _DiffuseTextureEnabled;
  19469. /**
  19470. * Are diffuse textures enabled in the application.
  19471. */
  19472. static DiffuseTextureEnabled: boolean;
  19473. private static _AmbientTextureEnabled;
  19474. /**
  19475. * Are ambient textures enabled in the application.
  19476. */
  19477. static AmbientTextureEnabled: boolean;
  19478. private static _OpacityTextureEnabled;
  19479. /**
  19480. * Are opacity textures enabled in the application.
  19481. */
  19482. static OpacityTextureEnabled: boolean;
  19483. private static _ReflectionTextureEnabled;
  19484. /**
  19485. * Are reflection textures enabled in the application.
  19486. */
  19487. static ReflectionTextureEnabled: boolean;
  19488. private static _EmissiveTextureEnabled;
  19489. /**
  19490. * Are emissive textures enabled in the application.
  19491. */
  19492. static EmissiveTextureEnabled: boolean;
  19493. private static _SpecularTextureEnabled;
  19494. /**
  19495. * Are specular textures enabled in the application.
  19496. */
  19497. static SpecularTextureEnabled: boolean;
  19498. private static _BumpTextureEnabled;
  19499. /**
  19500. * Are bump textures enabled in the application.
  19501. */
  19502. static BumpTextureEnabled: boolean;
  19503. private static _LightmapTextureEnabled;
  19504. /**
  19505. * Are lightmap textures enabled in the application.
  19506. */
  19507. static LightmapTextureEnabled: boolean;
  19508. private static _RefractionTextureEnabled;
  19509. /**
  19510. * Are refraction textures enabled in the application.
  19511. */
  19512. static RefractionTextureEnabled: boolean;
  19513. private static _ColorGradingTextureEnabled;
  19514. /**
  19515. * Are color grading textures enabled in the application.
  19516. */
  19517. static ColorGradingTextureEnabled: boolean;
  19518. private static _FresnelEnabled;
  19519. /**
  19520. * Are fresnels enabled in the application.
  19521. */
  19522. static FresnelEnabled: boolean;
  19523. }
  19524. }
  19525. declare module BABYLON {
  19526. /**
  19527. * Uniform buffer objects.
  19528. *
  19529. * Handles blocks of uniform on the GPU.
  19530. *
  19531. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19532. *
  19533. * For more information, please refer to :
  19534. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19535. */
  19536. class UniformBuffer {
  19537. private _engine;
  19538. private _buffer;
  19539. private _data;
  19540. private _bufferData;
  19541. private _dynamic?;
  19542. private _uniformLocations;
  19543. private _uniformSizes;
  19544. private _uniformLocationPointer;
  19545. private _needSync;
  19546. private _noUBO;
  19547. private _currentEffect;
  19548. private static _MAX_UNIFORM_SIZE;
  19549. private static _tempBuffer;
  19550. /**
  19551. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19552. * This is dynamic to allow compat with webgl 1 and 2.
  19553. * You will need to pass the name of the uniform as well as the value.
  19554. */
  19555. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19556. /**
  19557. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19558. * This is dynamic to allow compat with webgl 1 and 2.
  19559. * You will need to pass the name of the uniform as well as the value.
  19560. */
  19561. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19562. /**
  19563. * Lambda to Update a single float in a uniform buffer.
  19564. * This is dynamic to allow compat with webgl 1 and 2.
  19565. * You will need to pass the name of the uniform as well as the value.
  19566. */
  19567. updateFloat: (name: string, x: number) => void;
  19568. /**
  19569. * Lambda to Update a vec2 of float in a uniform buffer.
  19570. * This is dynamic to allow compat with webgl 1 and 2.
  19571. * You will need to pass the name of the uniform as well as the value.
  19572. */
  19573. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19574. /**
  19575. * Lambda to Update a vec3 of float in a uniform buffer.
  19576. * This is dynamic to allow compat with webgl 1 and 2.
  19577. * You will need to pass the name of the uniform as well as the value.
  19578. */
  19579. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19580. /**
  19581. * Lambda to Update a vec4 of float in a uniform buffer.
  19582. * This is dynamic to allow compat with webgl 1 and 2.
  19583. * You will need to pass the name of the uniform as well as the value.
  19584. */
  19585. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19586. /**
  19587. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19588. * This is dynamic to allow compat with webgl 1 and 2.
  19589. * You will need to pass the name of the uniform as well as the value.
  19590. */
  19591. updateMatrix: (name: string, mat: Matrix) => void;
  19592. /**
  19593. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19594. * This is dynamic to allow compat with webgl 1 and 2.
  19595. * You will need to pass the name of the uniform as well as the value.
  19596. */
  19597. updateVector3: (name: string, vector: Vector3) => void;
  19598. /**
  19599. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19600. * This is dynamic to allow compat with webgl 1 and 2.
  19601. * You will need to pass the name of the uniform as well as the value.
  19602. */
  19603. updateVector4: (name: string, vector: Vector4) => void;
  19604. /**
  19605. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19606. * This is dynamic to allow compat with webgl 1 and 2.
  19607. * You will need to pass the name of the uniform as well as the value.
  19608. */
  19609. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19610. /**
  19611. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19612. * This is dynamic to allow compat with webgl 1 and 2.
  19613. * You will need to pass the name of the uniform as well as the value.
  19614. */
  19615. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19616. /**
  19617. * Instantiates a new Uniform buffer objects.
  19618. *
  19619. * Handles blocks of uniform on the GPU.
  19620. *
  19621. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19622. *
  19623. * For more information, please refer to :
  19624. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19625. * @param engine Define the engine the buffer is associated with
  19626. * @param data Define the data contained in the buffer
  19627. * @param dynamic Define if the buffer is updatable
  19628. */
  19629. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19630. /**
  19631. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19632. * or just falling back on setUniformXXX calls.
  19633. */
  19634. readonly useUbo: boolean;
  19635. /**
  19636. * Indicates if the WebGL underlying uniform buffer is in sync
  19637. * with the javascript cache data.
  19638. */
  19639. readonly isSync: boolean;
  19640. /**
  19641. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19642. * Also, a dynamic UniformBuffer will disable cache verification and always
  19643. * update the underlying WebGL uniform buffer to the GPU.
  19644. * @returns if Dynamic, otherwise false
  19645. */
  19646. isDynamic(): boolean;
  19647. /**
  19648. * The data cache on JS side.
  19649. * @returns the underlying data as a float array
  19650. */
  19651. getData(): Float32Array;
  19652. /**
  19653. * The underlying WebGL Uniform buffer.
  19654. * @returns the webgl buffer
  19655. */
  19656. getBuffer(): Nullable<WebGLBuffer>;
  19657. /**
  19658. * std140 layout specifies how to align data within an UBO structure.
  19659. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19660. * for specs.
  19661. */
  19662. private _fillAlignment;
  19663. /**
  19664. * Adds an uniform in the buffer.
  19665. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19666. * for the layout to be correct !
  19667. * @param name Name of the uniform, as used in the uniform block in the shader.
  19668. * @param size Data size, or data directly.
  19669. */
  19670. addUniform(name: string, size: number | number[]): void;
  19671. /**
  19672. * Adds a Matrix 4x4 to the uniform buffer.
  19673. * @param name Name of the uniform, as used in the uniform block in the shader.
  19674. * @param mat A 4x4 matrix.
  19675. */
  19676. addMatrix(name: string, mat: Matrix): void;
  19677. /**
  19678. * Adds a vec2 to the uniform buffer.
  19679. * @param name Name of the uniform, as used in the uniform block in the shader.
  19680. * @param x Define the x component value of the vec2
  19681. * @param y Define the y component value of the vec2
  19682. */
  19683. addFloat2(name: string, x: number, y: number): void;
  19684. /**
  19685. * Adds a vec3 to the uniform buffer.
  19686. * @param name Name of the uniform, as used in the uniform block in the shader.
  19687. * @param x Define the x component value of the vec3
  19688. * @param y Define the y component value of the vec3
  19689. * @param z Define the z component value of the vec3
  19690. */
  19691. addFloat3(name: string, x: number, y: number, z: number): void;
  19692. /**
  19693. * Adds a vec3 to the uniform buffer.
  19694. * @param name Name of the uniform, as used in the uniform block in the shader.
  19695. * @param color Define the vec3 from a Color
  19696. */
  19697. addColor3(name: string, color: Color3): void;
  19698. /**
  19699. * Adds a vec4 to the uniform buffer.
  19700. * @param name Name of the uniform, as used in the uniform block in the shader.
  19701. * @param color Define the rgb components from a Color
  19702. * @param alpha Define the a component of the vec4
  19703. */
  19704. addColor4(name: string, color: Color3, alpha: number): void;
  19705. /**
  19706. * Adds a vec3 to the uniform buffer.
  19707. * @param name Name of the uniform, as used in the uniform block in the shader.
  19708. * @param vector Define the vec3 components from a Vector
  19709. */
  19710. addVector3(name: string, vector: Vector3): void;
  19711. /**
  19712. * Adds a Matrix 3x3 to the uniform buffer.
  19713. * @param name Name of the uniform, as used in the uniform block in the shader.
  19714. */
  19715. addMatrix3x3(name: string): void;
  19716. /**
  19717. * Adds a Matrix 2x2 to the uniform buffer.
  19718. * @param name Name of the uniform, as used in the uniform block in the shader.
  19719. */
  19720. addMatrix2x2(name: string): void;
  19721. /**
  19722. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19723. */
  19724. create(): void;
  19725. /** @hidden */
  19726. _rebuild(): void;
  19727. /**
  19728. * Updates the WebGL Uniform Buffer on the GPU.
  19729. * If the `dynamic` flag is set to true, no cache comparison is done.
  19730. * Otherwise, the buffer will be updated only if the cache differs.
  19731. */
  19732. update(): void;
  19733. /**
  19734. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19735. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19736. * @param data Define the flattened data
  19737. * @param size Define the size of the data.
  19738. */
  19739. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19740. private _updateMatrix3x3ForUniform;
  19741. private _updateMatrix3x3ForEffect;
  19742. private _updateMatrix2x2ForEffect;
  19743. private _updateMatrix2x2ForUniform;
  19744. private _updateFloatForEffect;
  19745. private _updateFloatForUniform;
  19746. private _updateFloat2ForEffect;
  19747. private _updateFloat2ForUniform;
  19748. private _updateFloat3ForEffect;
  19749. private _updateFloat3ForUniform;
  19750. private _updateFloat4ForEffect;
  19751. private _updateFloat4ForUniform;
  19752. private _updateMatrixForEffect;
  19753. private _updateMatrixForUniform;
  19754. private _updateVector3ForEffect;
  19755. private _updateVector3ForUniform;
  19756. private _updateVector4ForEffect;
  19757. private _updateVector4ForUniform;
  19758. private _updateColor3ForEffect;
  19759. private _updateColor3ForUniform;
  19760. private _updateColor4ForEffect;
  19761. private _updateColor4ForUniform;
  19762. /**
  19763. * Sets a sampler uniform on the effect.
  19764. * @param name Define the name of the sampler.
  19765. * @param texture Define the texture to set in the sampler
  19766. */
  19767. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19768. /**
  19769. * Directly updates the value of the uniform in the cache AND on the GPU.
  19770. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19771. * @param data Define the flattened data
  19772. */
  19773. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19774. /**
  19775. * Binds this uniform buffer to an effect.
  19776. * @param effect Define the effect to bind the buffer to
  19777. * @param name Name of the uniform block in the shader.
  19778. */
  19779. bindToEffect(effect: Effect, name: string): void;
  19780. /**
  19781. * Disposes the uniform buffer.
  19782. */
  19783. dispose(): void;
  19784. }
  19785. }
  19786. declare module BABYLON {
  19787. /**
  19788. * Scalar computation library
  19789. */
  19790. class Scalar {
  19791. /**
  19792. * Two pi constants convenient for computation.
  19793. */
  19794. static TwoPi: number;
  19795. /**
  19796. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19797. * @param a number
  19798. * @param b number
  19799. * @param epsilon (default = 1.401298E-45)
  19800. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  19801. */
  19802. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  19803. /**
  19804. * Returns a string : the upper case translation of the number i to hexadecimal.
  19805. * @param i number
  19806. * @returns the upper case translation of the number i to hexadecimal.
  19807. */
  19808. static ToHex(i: number): string;
  19809. /**
  19810. * Returns -1 if value is negative and +1 is value is positive.
  19811. * @param value the value
  19812. * @returns the value itself if it's equal to zero.
  19813. */
  19814. static Sign(value: number): number;
  19815. /**
  19816. * Returns the value itself if it's between min and max.
  19817. * Returns min if the value is lower than min.
  19818. * Returns max if the value is greater than max.
  19819. * @param value the value to clmap
  19820. * @param min the min value to clamp to (default: 0)
  19821. * @param max the max value to clamp to (default: 1)
  19822. * @returns the clamped value
  19823. */
  19824. static Clamp(value: number, min?: number, max?: number): number;
  19825. /**
  19826. * the log2 of value.
  19827. * @param value the value to compute log2 of
  19828. * @returns the log2 of value.
  19829. */
  19830. static Log2(value: number): number;
  19831. /**
  19832. * Loops the value, so that it is never larger than length and never smaller than 0.
  19833. *
  19834. * This is similar to the modulo operator but it works with floating point numbers.
  19835. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  19836. * With t = 5 and length = 2.5, the result would be 0.0.
  19837. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  19838. * @param value the value
  19839. * @param length the length
  19840. * @returns the looped value
  19841. */
  19842. static Repeat(value: number, length: number): number;
  19843. /**
  19844. * Normalize the value between 0.0 and 1.0 using min and max values
  19845. * @param value value to normalize
  19846. * @param min max to normalize between
  19847. * @param max min to normalize between
  19848. * @returns the normalized value
  19849. */
  19850. static Normalize(value: number, min: number, max: number): number;
  19851. /**
  19852. * Denormalize the value from 0.0 and 1.0 using min and max values
  19853. * @param normalized value to denormalize
  19854. * @param min max to denormalize between
  19855. * @param max min to denormalize between
  19856. * @returns the denormalized value
  19857. */
  19858. static Denormalize(normalized: number, min: number, max: number): number;
  19859. /**
  19860. * Calculates the shortest difference between two given angles given in degrees.
  19861. * @param current current angle in degrees
  19862. * @param target target angle in degrees
  19863. * @returns the delta
  19864. */
  19865. static DeltaAngle(current: number, target: number): number;
  19866. /**
  19867. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  19868. * @param tx value
  19869. * @param length length
  19870. * @returns The returned value will move back and forth between 0 and length
  19871. */
  19872. static PingPong(tx: number, length: number): number;
  19873. /**
  19874. * Interpolates between min and max with smoothing at the limits.
  19875. *
  19876. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  19877. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  19878. * @param from from
  19879. * @param to to
  19880. * @param tx value
  19881. * @returns the smooth stepped value
  19882. */
  19883. static SmoothStep(from: number, to: number, tx: number): number;
  19884. /**
  19885. * Moves a value current towards target.
  19886. *
  19887. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  19888. * Negative values of maxDelta pushes the value away from target.
  19889. * @param current current value
  19890. * @param target target value
  19891. * @param maxDelta max distance to move
  19892. * @returns resulting value
  19893. */
  19894. static MoveTowards(current: number, target: number, maxDelta: number): number;
  19895. /**
  19896. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19897. *
  19898. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  19899. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  19900. * @param current current value
  19901. * @param target target value
  19902. * @param maxDelta max distance to move
  19903. * @returns resulting angle
  19904. */
  19905. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  19906. /**
  19907. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  19908. * @param start start value
  19909. * @param end target value
  19910. * @param amount amount to lerp between
  19911. * @returns the lerped value
  19912. */
  19913. static Lerp(start: number, end: number, amount: number): number;
  19914. /**
  19915. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  19916. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  19917. * @param start start value
  19918. * @param end target value
  19919. * @param amount amount to lerp between
  19920. * @returns the lerped value
  19921. */
  19922. static LerpAngle(start: number, end: number, amount: number): number;
  19923. /**
  19924. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  19925. * @param a start value
  19926. * @param b target value
  19927. * @param value value between a and b
  19928. * @returns the inverseLerp value
  19929. */
  19930. static InverseLerp(a: number, b: number, value: number): number;
  19931. /**
  19932. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  19933. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  19934. * @param value1 spline value
  19935. * @param tangent1 spline value
  19936. * @param value2 spline value
  19937. * @param tangent2 spline value
  19938. * @param amount input value
  19939. * @returns hermite result
  19940. */
  19941. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  19942. /**
  19943. * Returns a random float number between and min and max values
  19944. * @param min min value of random
  19945. * @param max max value of random
  19946. * @returns random value
  19947. */
  19948. static RandomRange(min: number, max: number): number;
  19949. /**
  19950. * This function returns percentage of a number in a given range.
  19951. *
  19952. * RangeToPercent(40,20,60) will return 0.5 (50%)
  19953. * RangeToPercent(34,0,100) will return 0.34 (34%)
  19954. * @param number to convert to percentage
  19955. * @param min min range
  19956. * @param max max range
  19957. * @returns the percentage
  19958. */
  19959. static RangeToPercent(number: number, min: number, max: number): number;
  19960. /**
  19961. * This function returns number that corresponds to the percentage in a given range.
  19962. *
  19963. * PercentToRange(0.34,0,100) will return 34.
  19964. * @param percent to convert to number
  19965. * @param min min range
  19966. * @param max max range
  19967. * @returns the number
  19968. */
  19969. static PercentToRange(percent: number, min: number, max: number): number;
  19970. /**
  19971. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  19972. * @param angle The angle to normalize in radian.
  19973. * @return The converted angle.
  19974. */
  19975. static NormalizeRadians(angle: number): number;
  19976. }
  19977. }
  19978. declare module BABYLON {
  19979. /**
  19980. * Constant used to convert a value to gamma space
  19981. * @ignorenaming
  19982. */
  19983. const ToGammaSpace: number;
  19984. /**
  19985. * Constant used to convert a value to linear space
  19986. * @ignorenaming
  19987. */
  19988. const ToLinearSpace = 2.2;
  19989. /**
  19990. * Constant used to define the minimal number value in Babylon.js
  19991. * @ignorenaming
  19992. */
  19993. const Epsilon = 0.001;
  19994. /**
  19995. * Class used to hold a RBG color
  19996. */
  19997. class Color3 {
  19998. /**
  19999. * Defines the red component (between 0 and 1, default is 0)
  20000. */
  20001. r: number;
  20002. /**
  20003. * Defines the green component (between 0 and 1, default is 0)
  20004. */
  20005. g: number;
  20006. /**
  20007. * Defines the blue component (between 0 and 1, default is 0)
  20008. */
  20009. b: number;
  20010. /**
  20011. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20012. * @param r defines the red component (between 0 and 1, default is 0)
  20013. * @param g defines the green component (between 0 and 1, default is 0)
  20014. * @param b defines the blue component (between 0 and 1, default is 0)
  20015. */
  20016. constructor(
  20017. /**
  20018. * Defines the red component (between 0 and 1, default is 0)
  20019. */
  20020. r?: number,
  20021. /**
  20022. * Defines the green component (between 0 and 1, default is 0)
  20023. */
  20024. g?: number,
  20025. /**
  20026. * Defines the blue component (between 0 and 1, default is 0)
  20027. */
  20028. b?: number);
  20029. /**
  20030. * Creates a string with the Color3 current values
  20031. * @returns the string representation of the Color3 object
  20032. */
  20033. toString(): string;
  20034. /**
  20035. * Returns the string "Color3"
  20036. * @returns "Color3"
  20037. */
  20038. getClassName(): string;
  20039. /**
  20040. * Compute the Color3 hash code
  20041. * @returns an unique number that can be used to hash Color3 objects
  20042. */
  20043. getHashCode(): number;
  20044. /**
  20045. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20046. * @param array defines the array where to store the r,g,b components
  20047. * @param index defines an optional index in the target array to define where to start storing values
  20048. * @returns the current Color3 object
  20049. */
  20050. toArray(array: FloatArray, index?: number): Color3;
  20051. /**
  20052. * Returns a new Color4 object from the current Color3 and the given alpha
  20053. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20054. * @returns a new Color4 object
  20055. */
  20056. toColor4(alpha?: number): Color4;
  20057. /**
  20058. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20059. * @returns the new array
  20060. */
  20061. asArray(): number[];
  20062. /**
  20063. * Returns the luminance value
  20064. * @returns a float value
  20065. */
  20066. toLuminance(): number;
  20067. /**
  20068. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20069. * @param otherColor defines the second operand
  20070. * @returns the new Color3 object
  20071. */
  20072. multiply(otherColor: Color3): Color3;
  20073. /**
  20074. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20075. * @param otherColor defines the second operand
  20076. * @param result defines the Color3 object where to store the result
  20077. * @returns the current Color3
  20078. */
  20079. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  20080. /**
  20081. * Determines equality between Color3 objects
  20082. * @param otherColor defines the second operand
  20083. * @returns true if the rgb values are equal to the given ones
  20084. */
  20085. equals(otherColor: Color3): boolean;
  20086. /**
  20087. * Determines equality between the current Color3 object and a set of r,b,g values
  20088. * @param r defines the red component to check
  20089. * @param g defines the green component to check
  20090. * @param b defines the blue component to check
  20091. * @returns true if the rgb values are equal to the given ones
  20092. */
  20093. equalsFloats(r: number, g: number, b: number): boolean;
  20094. /**
  20095. * Multiplies in place each rgb value by scale
  20096. * @param scale defines the scaling factor
  20097. * @returns the updated Color3
  20098. */
  20099. scale(scale: number): Color3;
  20100. /**
  20101. * Multiplies the rgb values by scale and stores the result into "result"
  20102. * @param scale defines the scaling factor
  20103. * @param result defines the Color3 object where to store the result
  20104. * @returns the unmodified current Color3
  20105. */
  20106. scaleToRef(scale: number, result: Color3): Color3;
  20107. /**
  20108. * Scale the current Color3 values by a factor and add the result to a given Color3
  20109. * @param scale defines the scale factor
  20110. * @param result defines color to store the result into
  20111. * @returns the unmodified current Color3
  20112. */
  20113. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20114. /**
  20115. * Clamps the rgb values by the min and max values and stores the result into "result"
  20116. * @param min defines minimum clamping value (default is 0)
  20117. * @param max defines maximum clamping value (default is 1)
  20118. * @param result defines color to store the result into
  20119. * @returns the original Color3
  20120. */
  20121. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20122. /**
  20123. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20124. * @param otherColor defines the second operand
  20125. * @returns the new Color3
  20126. */
  20127. add(otherColor: Color3): Color3;
  20128. /**
  20129. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20130. * @param otherColor defines the second operand
  20131. * @param result defines Color3 object to store the result into
  20132. * @returns the unmodified current Color3
  20133. */
  20134. addToRef(otherColor: Color3, result: Color3): Color3;
  20135. /**
  20136. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20137. * @param otherColor defines the second operand
  20138. * @returns the new Color3
  20139. */
  20140. subtract(otherColor: Color3): Color3;
  20141. /**
  20142. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20143. * @param otherColor defines the second operand
  20144. * @param result defines Color3 object to store the result into
  20145. * @returns the unmodified current Color3
  20146. */
  20147. subtractToRef(otherColor: Color3, result: Color3): Color3;
  20148. /**
  20149. * Copy the current object
  20150. * @returns a new Color3 copied the current one
  20151. */
  20152. clone(): Color3;
  20153. /**
  20154. * Copies the rgb values from the source in the current Color3
  20155. * @param source defines the source Color3 object
  20156. * @returns the updated Color3 object
  20157. */
  20158. copyFrom(source: Color3): Color3;
  20159. /**
  20160. * Updates the Color3 rgb values from the given floats
  20161. * @param r defines the red component to read from
  20162. * @param g defines the green component to read from
  20163. * @param b defines the blue component to read from
  20164. * @returns the current Color3 object
  20165. */
  20166. copyFromFloats(r: number, g: number, b: number): Color3;
  20167. /**
  20168. * Updates the Color3 rgb values from the given floats
  20169. * @param r defines the red component to read from
  20170. * @param g defines the green component to read from
  20171. * @param b defines the blue component to read from
  20172. * @returns the current Color3 object
  20173. */
  20174. set(r: number, g: number, b: number): Color3;
  20175. /**
  20176. * Compute the Color3 hexadecimal code as a string
  20177. * @returns a string containing the hexadecimal representation of the Color3 object
  20178. */
  20179. toHexString(): string;
  20180. /**
  20181. * Computes a new Color3 converted from the current one to linear space
  20182. * @returns a new Color3 object
  20183. */
  20184. toLinearSpace(): Color3;
  20185. /**
  20186. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20187. * @param convertedColor defines the Color3 object where to store the linear space version
  20188. * @returns the unmodified Color3
  20189. */
  20190. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20191. /**
  20192. * Computes a new Color3 converted from the current one to gamma space
  20193. * @returns a new Color3 object
  20194. */
  20195. toGammaSpace(): Color3;
  20196. /**
  20197. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20198. * @param convertedColor defines the Color3 object where to store the gamma space version
  20199. * @returns the unmodified Color3
  20200. */
  20201. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20202. /**
  20203. * Creates a new Color3 from the string containing valid hexadecimal values
  20204. * @param hex defines a string containing valid hexadecimal values
  20205. * @returns a new Color3 object
  20206. */
  20207. static FromHexString(hex: string): Color3;
  20208. /**
  20209. * Creates a new Vector3 from the starting index of the given array
  20210. * @param array defines the source array
  20211. * @param offset defines an offset in the source array
  20212. * @returns a new Color3 object
  20213. */
  20214. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  20215. /**
  20216. * Creates a new Color3 from integer values (< 256)
  20217. * @param r defines the red component to read from (value between 0 and 255)
  20218. * @param g defines the green component to read from (value between 0 and 255)
  20219. * @param b defines the blue component to read from (value between 0 and 255)
  20220. * @returns a new Color3 object
  20221. */
  20222. static FromInts(r: number, g: number, b: number): Color3;
  20223. /**
  20224. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20225. * @param start defines the start Color3 value
  20226. * @param end defines the end Color3 value
  20227. * @param amount defines the gradient value between start and end
  20228. * @returns a new Color3 object
  20229. */
  20230. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  20231. /**
  20232. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20233. * @param left defines the start value
  20234. * @param right defines the end value
  20235. * @param amount defines the gradient factor
  20236. * @param result defines the Color3 object where to store the result
  20237. */
  20238. static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void;
  20239. /**
  20240. * Returns a Color3 value containing a red color
  20241. * @returns a new Color3 object
  20242. */
  20243. static Red(): Color3;
  20244. /**
  20245. * Returns a Color3 value containing a green color
  20246. * @returns a new Color3 object
  20247. */
  20248. static Green(): Color3;
  20249. /**
  20250. * Returns a Color3 value containing a blue color
  20251. * @returns a new Color3 object
  20252. */
  20253. static Blue(): Color3;
  20254. /**
  20255. * Returns a Color3 value containing a black color
  20256. * @returns a new Color3 object
  20257. */
  20258. static Black(): Color3;
  20259. /**
  20260. * Returns a Color3 value containing a white color
  20261. * @returns a new Color3 object
  20262. */
  20263. static White(): Color3;
  20264. /**
  20265. * Returns a Color3 value containing a purple color
  20266. * @returns a new Color3 object
  20267. */
  20268. static Purple(): Color3;
  20269. /**
  20270. * Returns a Color3 value containing a magenta color
  20271. * @returns a new Color3 object
  20272. */
  20273. static Magenta(): Color3;
  20274. /**
  20275. * Returns a Color3 value containing a yellow color
  20276. * @returns a new Color3 object
  20277. */
  20278. static Yellow(): Color3;
  20279. /**
  20280. * Returns a Color3 value containing a gray color
  20281. * @returns a new Color3 object
  20282. */
  20283. static Gray(): Color3;
  20284. /**
  20285. * Returns a Color3 value containing a teal color
  20286. * @returns a new Color3 object
  20287. */
  20288. static Teal(): Color3;
  20289. /**
  20290. * Returns a Color3 value containing a random color
  20291. * @returns a new Color3 object
  20292. */
  20293. static Random(): Color3;
  20294. }
  20295. /**
  20296. * Class used to hold a RBGA color
  20297. */
  20298. class Color4 {
  20299. /**
  20300. * Defines the red component (between 0 and 1, default is 0)
  20301. */
  20302. r: number;
  20303. /**
  20304. * Defines the green component (between 0 and 1, default is 0)
  20305. */
  20306. g: number;
  20307. /**
  20308. * Defines the blue component (between 0 and 1, default is 0)
  20309. */
  20310. b: number;
  20311. /**
  20312. * Defines the alpha component (between 0 and 1, default is 1)
  20313. */
  20314. a: number;
  20315. /**
  20316. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20317. * @param r defines the red component (between 0 and 1, default is 0)
  20318. * @param g defines the green component (between 0 and 1, default is 0)
  20319. * @param b defines the blue component (between 0 and 1, default is 0)
  20320. * @param a defines the alpha component (between 0 and 1, default is 1)
  20321. */
  20322. constructor(
  20323. /**
  20324. * Defines the red component (between 0 and 1, default is 0)
  20325. */
  20326. r?: number,
  20327. /**
  20328. * Defines the green component (between 0 and 1, default is 0)
  20329. */
  20330. g?: number,
  20331. /**
  20332. * Defines the blue component (between 0 and 1, default is 0)
  20333. */
  20334. b?: number,
  20335. /**
  20336. * Defines the alpha component (between 0 and 1, default is 1)
  20337. */
  20338. a?: number);
  20339. /**
  20340. * Adds in place the given Color4 values to the current Color4 object
  20341. * @param right defines the second operand
  20342. * @returns the current updated Color4 object
  20343. */
  20344. addInPlace(right: Color4): Color4;
  20345. /**
  20346. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20347. * @returns the new array
  20348. */
  20349. asArray(): number[];
  20350. /**
  20351. * Stores from the starting index in the given array the Color4 successive values
  20352. * @param array defines the array where to store the r,g,b components
  20353. * @param index defines an optional index in the target array to define where to start storing values
  20354. * @returns the current Color4 object
  20355. */
  20356. toArray(array: number[], index?: number): Color4;
  20357. /**
  20358. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20359. * @param right defines the second operand
  20360. * @returns a new Color4 object
  20361. */
  20362. add(right: Color4): Color4;
  20363. /**
  20364. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20365. * @param right defines the second operand
  20366. * @returns a new Color4 object
  20367. */
  20368. subtract(right: Color4): Color4;
  20369. /**
  20370. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20371. * @param right defines the second operand
  20372. * @param result defines the Color4 object where to store the result
  20373. * @returns the current Color4 object
  20374. */
  20375. subtractToRef(right: Color4, result: Color4): Color4;
  20376. /**
  20377. * Creates a new Color4 with the current Color4 values multiplied by scale
  20378. * @param scale defines the scaling factor to apply
  20379. * @returns a new Color4 object
  20380. */
  20381. scale(scale: number): Color4;
  20382. /**
  20383. * Multiplies the current Color4 values by scale and stores the result in "result"
  20384. * @param scale defines the scaling factor to apply
  20385. * @param result defines the Color4 object where to store the result
  20386. * @returns the current unmodified Color4
  20387. */
  20388. scaleToRef(scale: number, result: Color4): Color4;
  20389. /**
  20390. * Scale the current Color4 values by a factor and add the result to a given Color4
  20391. * @param scale defines the scale factor
  20392. * @param result defines the Color4 object where to store the result
  20393. * @returns the unmodified current Color4
  20394. */
  20395. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20396. /**
  20397. * Clamps the rgb values by the min and max values and stores the result into "result"
  20398. * @param min defines minimum clamping value (default is 0)
  20399. * @param max defines maximum clamping value (default is 1)
  20400. * @param result defines color to store the result into.
  20401. * @returns the cuurent Color4
  20402. */
  20403. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20404. /**
  20405. * Multipy an Color4 value by another and return a new Color4 object
  20406. * @param color defines the Color4 value to multiply by
  20407. * @returns a new Color4 object
  20408. */
  20409. multiply(color: Color4): Color4;
  20410. /**
  20411. * Multipy a Color4 value by another and push the result in a reference value
  20412. * @param color defines the Color4 value to multiply by
  20413. * @param result defines the Color4 to fill the result in
  20414. * @returns the result Color4
  20415. */
  20416. multiplyToRef(color: Color4, result: Color4): Color4;
  20417. /**
  20418. * Creates a string with the Color4 current values
  20419. * @returns the string representation of the Color4 object
  20420. */
  20421. toString(): string;
  20422. /**
  20423. * Returns the string "Color4"
  20424. * @returns "Color4"
  20425. */
  20426. getClassName(): string;
  20427. /**
  20428. * Compute the Color4 hash code
  20429. * @returns an unique number that can be used to hash Color4 objects
  20430. */
  20431. getHashCode(): number;
  20432. /**
  20433. * Creates a new Color4 copied from the current one
  20434. * @returns a new Color4 object
  20435. */
  20436. clone(): Color4;
  20437. /**
  20438. * Copies the given Color4 values into the current one
  20439. * @param source defines the source Color4 object
  20440. * @returns the current updated Color4 object
  20441. */
  20442. copyFrom(source: Color4): Color4;
  20443. /**
  20444. * Copies the given float values into the current one
  20445. * @param r defines the red component to read from
  20446. * @param g defines the green component to read from
  20447. * @param b defines the blue component to read from
  20448. * @param a defines the alpha component to read from
  20449. * @returns the current updated Color4 object
  20450. */
  20451. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20452. /**
  20453. * Copies the given float values into the current one
  20454. * @param r defines the red component to read from
  20455. * @param g defines the green component to read from
  20456. * @param b defines the blue component to read from
  20457. * @param a defines the alpha component to read from
  20458. * @returns the current updated Color4 object
  20459. */
  20460. set(r: number, g: number, b: number, a: number): Color4;
  20461. /**
  20462. * Compute the Color4 hexadecimal code as a string
  20463. * @returns a string containing the hexadecimal representation of the Color4 object
  20464. */
  20465. toHexString(): string;
  20466. /**
  20467. * Computes a new Color4 converted from the current one to linear space
  20468. * @returns a new Color4 object
  20469. */
  20470. toLinearSpace(): Color4;
  20471. /**
  20472. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20473. * @param convertedColor defines the Color4 object where to store the linear space version
  20474. * @returns the unmodified Color4
  20475. */
  20476. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20477. /**
  20478. * Computes a new Color4 converted from the current one to gamma space
  20479. * @returns a new Color4 object
  20480. */
  20481. toGammaSpace(): Color4;
  20482. /**
  20483. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20484. * @param convertedColor defines the Color4 object where to store the gamma space version
  20485. * @returns the unmodified Color4
  20486. */
  20487. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20488. /**
  20489. * Creates a new Color4 from the string containing valid hexadecimal values
  20490. * @param hex defines a string containing valid hexadecimal values
  20491. * @returns a new Color4 object
  20492. */
  20493. static FromHexString(hex: string): Color4;
  20494. /**
  20495. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20496. * @param left defines the start value
  20497. * @param right defines the end value
  20498. * @param amount defines the gradient factor
  20499. * @returns a new Color4 object
  20500. */
  20501. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  20502. /**
  20503. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20504. * @param left defines the start value
  20505. * @param right defines the end value
  20506. * @param amount defines the gradient factor
  20507. * @param result defines the Color4 object where to store data
  20508. */
  20509. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  20510. /**
  20511. * Creates a new Color4 from a Color3 and an alpha value
  20512. * @param color3 defines the source Color3 to read from
  20513. * @param alpha defines the alpha component (1.0 by default)
  20514. * @returns a new Color4 object
  20515. */
  20516. static FromColor3(color3: Color3, alpha?: number): Color4;
  20517. /**
  20518. * Creates a new Color4 from the starting index element of the given array
  20519. * @param array defines the source array to read from
  20520. * @param offset defines the offset in the source array
  20521. * @returns a new Color4 object
  20522. */
  20523. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  20524. /**
  20525. * Creates a new Color3 from integer values (< 256)
  20526. * @param r defines the red component to read from (value between 0 and 255)
  20527. * @param g defines the green component to read from (value between 0 and 255)
  20528. * @param b defines the blue component to read from (value between 0 and 255)
  20529. * @param a defines the alpha component to read from (value between 0 and 255)
  20530. * @returns a new Color3 object
  20531. */
  20532. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20533. /**
  20534. * Check the content of a given array and convert it to an array containing RGBA data
  20535. * If the original array was already containing count * 4 values then it is returned directly
  20536. * @param colors defines the array to check
  20537. * @param count defines the number of RGBA data to expect
  20538. * @returns an array containing count * 4 values (RGBA)
  20539. */
  20540. static CheckColors4(colors: number[], count: number): number[];
  20541. }
  20542. /**
  20543. * Class representing a vector containing 2 coordinates
  20544. */
  20545. class Vector2 {
  20546. /** defines the first coordinate */
  20547. x: number;
  20548. /** defines the second coordinate */
  20549. y: number;
  20550. /**
  20551. * Creates a new Vector2 from the given x and y coordinates
  20552. * @param x defines the first coordinate
  20553. * @param y defines the second coordinate
  20554. */
  20555. constructor(
  20556. /** defines the first coordinate */
  20557. x?: number,
  20558. /** defines the second coordinate */
  20559. y?: number);
  20560. /**
  20561. * Gets a string with the Vector2 coordinates
  20562. * @returns a string with the Vector2 coordinates
  20563. */
  20564. toString(): string;
  20565. /**
  20566. * Gets class name
  20567. * @returns the string "Vector2"
  20568. */
  20569. getClassName(): string;
  20570. /**
  20571. * Gets current vector hash code
  20572. * @returns the Vector2 hash code as a number
  20573. */
  20574. getHashCode(): number;
  20575. /**
  20576. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20577. * @param array defines the source array
  20578. * @param index defines the offset in source array
  20579. * @returns the current Vector2
  20580. */
  20581. toArray(array: FloatArray, index?: number): Vector2;
  20582. /**
  20583. * Copy the current vector to an array
  20584. * @returns a new array with 2 elements: the Vector2 coordinates.
  20585. */
  20586. asArray(): number[];
  20587. /**
  20588. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20589. * @param source defines the source Vector2
  20590. * @returns the current updated Vector2
  20591. */
  20592. copyFrom(source: Vector2): Vector2;
  20593. /**
  20594. * Sets the Vector2 coordinates with the given floats
  20595. * @param x defines the first coordinate
  20596. * @param y defines the second coordinate
  20597. * @returns the current updated Vector2
  20598. */
  20599. copyFromFloats(x: number, y: number): Vector2;
  20600. /**
  20601. * Sets the Vector2 coordinates with the given floats
  20602. * @param x defines the first coordinate
  20603. * @param y defines the second coordinate
  20604. * @returns the current updated Vector2
  20605. */
  20606. set(x: number, y: number): Vector2;
  20607. /**
  20608. * Add another vector with the current one
  20609. * @param otherVector defines the other vector
  20610. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20611. */
  20612. add(otherVector: Vector2): Vector2;
  20613. /**
  20614. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20615. * @param otherVector defines the other vector
  20616. * @param result defines the target vector
  20617. * @returns the unmodified current Vector2
  20618. */
  20619. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  20620. /**
  20621. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20622. * @param otherVector defines the other vector
  20623. * @returns the current updated Vector2
  20624. */
  20625. addInPlace(otherVector: Vector2): Vector2;
  20626. /**
  20627. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20628. * @param otherVector defines the other vector
  20629. * @returns a new Vector2
  20630. */
  20631. addVector3(otherVector: Vector3): Vector2;
  20632. /**
  20633. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20634. * @param otherVector defines the other vector
  20635. * @returns a new Vector2
  20636. */
  20637. subtract(otherVector: Vector2): Vector2;
  20638. /**
  20639. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20640. * @param otherVector defines the other vector
  20641. * @param result defines the target vector
  20642. * @returns the unmodified current Vector2
  20643. */
  20644. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  20645. /**
  20646. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20647. * @param otherVector defines the other vector
  20648. * @returns the current updated Vector2
  20649. */
  20650. subtractInPlace(otherVector: Vector2): Vector2;
  20651. /**
  20652. * Multiplies in place the current Vector2 coordinates by the given ones
  20653. * @param otherVector defines the other vector
  20654. * @returns the current updated Vector2
  20655. */
  20656. multiplyInPlace(otherVector: Vector2): Vector2;
  20657. /**
  20658. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20659. * @param otherVector defines the other vector
  20660. * @returns a new Vector2
  20661. */
  20662. multiply(otherVector: Vector2): Vector2;
  20663. /**
  20664. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20665. * @param otherVector defines the other vector
  20666. * @param result defines the target vector
  20667. * @returns the unmodified current Vector2
  20668. */
  20669. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  20670. /**
  20671. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20672. * @param x defines the first coordinate
  20673. * @param y defines the second coordinate
  20674. * @returns a new Vector2
  20675. */
  20676. multiplyByFloats(x: number, y: number): Vector2;
  20677. /**
  20678. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20679. * @param otherVector defines the other vector
  20680. * @returns a new Vector2
  20681. */
  20682. divide(otherVector: Vector2): Vector2;
  20683. /**
  20684. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20685. * @param otherVector defines the other vector
  20686. * @param result defines the target vector
  20687. * @returns the unmodified current Vector2
  20688. */
  20689. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  20690. /**
  20691. * Divides the current Vector2 coordinates by the given ones
  20692. * @param otherVector defines the other vector
  20693. * @returns the current updated Vector2
  20694. */
  20695. divideInPlace(otherVector: Vector2): Vector2;
  20696. /**
  20697. * Gets a new Vector2 with current Vector2 negated coordinates
  20698. * @returns a new Vector2
  20699. */
  20700. negate(): Vector2;
  20701. /**
  20702. * Multiply the Vector2 coordinates by scale
  20703. * @param scale defines the scaling factor
  20704. * @returns the current updated Vector2
  20705. */
  20706. scaleInPlace(scale: number): Vector2;
  20707. /**
  20708. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20709. * @param scale defines the scaling factor
  20710. * @returns a new Vector2
  20711. */
  20712. scale(scale: number): Vector2;
  20713. /**
  20714. * Scale the current Vector2 values by a factor to a given Vector2
  20715. * @param scale defines the scale factor
  20716. * @param result defines the Vector2 object where to store the result
  20717. * @returns the unmodified current Vector2
  20718. */
  20719. scaleToRef(scale: number, result: Vector2): Vector2;
  20720. /**
  20721. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20722. * @param scale defines the scale factor
  20723. * @param result defines the Vector2 object where to store the result
  20724. * @returns the unmodified current Vector2
  20725. */
  20726. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20727. /**
  20728. * Gets a boolean if two vectors are equals
  20729. * @param otherVector defines the other vector
  20730. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20731. */
  20732. equals(otherVector: Vector2): boolean;
  20733. /**
  20734. * Gets a boolean if two vectors are equals (using an epsilon value)
  20735. * @param otherVector defines the other vector
  20736. * @param epsilon defines the minimal distance to consider equality
  20737. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20738. */
  20739. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  20740. /**
  20741. * Gets a new Vector2 from current Vector2 floored values
  20742. * @returns a new Vector2
  20743. */
  20744. floor(): Vector2;
  20745. /**
  20746. * Gets a new Vector2 from current Vector2 floored values
  20747. * @returns a new Vector2
  20748. */
  20749. fract(): Vector2;
  20750. /**
  20751. * Gets the length of the vector
  20752. * @returns the vector length (float)
  20753. */
  20754. length(): number;
  20755. /**
  20756. * Gets the vector squared length
  20757. * @returns the vector squared length (float)
  20758. */
  20759. lengthSquared(): number;
  20760. /**
  20761. * Normalize the vector
  20762. * @returns the current updated Vector2
  20763. */
  20764. normalize(): Vector2;
  20765. /**
  20766. * Gets a new Vector2 copied from the Vector2
  20767. * @returns a new Vector2
  20768. */
  20769. clone(): Vector2;
  20770. /**
  20771. * Gets a new Vector2(0, 0)
  20772. * @returns a new Vector2
  20773. */
  20774. static Zero(): Vector2;
  20775. /**
  20776. * Gets a new Vector2(1, 1)
  20777. * @returns a new Vector2
  20778. */
  20779. static One(): Vector2;
  20780. /**
  20781. * Gets a new Vector2 set from the given index element of the given array
  20782. * @param array defines the data source
  20783. * @param offset defines the offset in the data source
  20784. * @returns a new Vector2
  20785. */
  20786. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  20787. /**
  20788. * Sets "result" from the given index element of the given array
  20789. * @param array defines the data source
  20790. * @param offset defines the offset in the data source
  20791. * @param result defines the target vector
  20792. */
  20793. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  20794. /**
  20795. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  20796. * @param value1 defines 1st point of control
  20797. * @param value2 defines 2nd point of control
  20798. * @param value3 defines 3rd point of control
  20799. * @param value4 defines 4th point of control
  20800. * @param amount defines the interpolation factor
  20801. * @returns a new Vector2
  20802. */
  20803. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  20804. /**
  20805. * 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".
  20806. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  20807. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  20808. * @param value defines the value to clamp
  20809. * @param min defines the lower limit
  20810. * @param max defines the upper limit
  20811. * @returns a new Vector2
  20812. */
  20813. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  20814. /**
  20815. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  20816. * @param value1 defines the 1st control point
  20817. * @param tangent1 defines the outgoing tangent
  20818. * @param value2 defines the 2nd control point
  20819. * @param tangent2 defines the incoming tangent
  20820. * @param amount defines the interpolation factor
  20821. * @returns a new Vector2
  20822. */
  20823. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  20824. /**
  20825. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  20826. * @param start defines the start vector
  20827. * @param end defines the end vector
  20828. * @param amount defines the interpolation factor
  20829. * @returns a new Vector2
  20830. */
  20831. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  20832. /**
  20833. * Gets the dot product of the vector "left" and the vector "right"
  20834. * @param left defines first vector
  20835. * @param right defines second vector
  20836. * @returns the dot product (float)
  20837. */
  20838. static Dot(left: Vector2, right: Vector2): number;
  20839. /**
  20840. * Returns a new Vector2 equal to the normalized given vector
  20841. * @param vector defines the vector to normalize
  20842. * @returns a new Vector2
  20843. */
  20844. static Normalize(vector: Vector2): Vector2;
  20845. /**
  20846. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  20847. * @param left defines 1st vector
  20848. * @param right defines 2nd vector
  20849. * @returns a new Vector2
  20850. */
  20851. static Minimize(left: Vector2, right: Vector2): Vector2;
  20852. /**
  20853. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  20854. * @param left defines 1st vector
  20855. * @param right defines 2nd vector
  20856. * @returns a new Vector2
  20857. */
  20858. static Maximize(left: Vector2, right: Vector2): Vector2;
  20859. /**
  20860. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  20861. * @param vector defines the vector to transform
  20862. * @param transformation defines the matrix to apply
  20863. * @returns a new Vector2
  20864. */
  20865. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  20866. /**
  20867. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  20868. * @param vector defines the vector to transform
  20869. * @param transformation defines the matrix to apply
  20870. * @param result defines the target vector
  20871. */
  20872. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  20873. /**
  20874. * Determines if a given vector is included in a triangle
  20875. * @param p defines the vector to test
  20876. * @param p0 defines 1st triangle point
  20877. * @param p1 defines 2nd triangle point
  20878. * @param p2 defines 3rd triangle point
  20879. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  20880. */
  20881. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  20882. /**
  20883. * Gets the distance between the vectors "value1" and "value2"
  20884. * @param value1 defines first vector
  20885. * @param value2 defines second vector
  20886. * @returns the distance between vectors
  20887. */
  20888. static Distance(value1: Vector2, value2: Vector2): number;
  20889. /**
  20890. * Returns the squared distance between the vectors "value1" and "value2"
  20891. * @param value1 defines first vector
  20892. * @param value2 defines second vector
  20893. * @returns the squared distance between vectors
  20894. */
  20895. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  20896. /**
  20897. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  20898. * @param value1 defines first vector
  20899. * @param value2 defines second vector
  20900. * @returns a new Vector2
  20901. */
  20902. static Center(value1: Vector2, value2: Vector2): Vector2;
  20903. /**
  20904. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  20905. * @param p defines the middle point
  20906. * @param segA defines one point of the segment
  20907. * @param segB defines the other point of the segment
  20908. * @returns the shortest distance
  20909. */
  20910. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  20911. }
  20912. /**
  20913. * Classed used to store (x,y,z) vector representation
  20914. * A Vector3 is the main object used in 3D geometry
  20915. * It can represent etiher the coordinates of a point the space, either a direction
  20916. * Reminder: Babylon.js uses a left handed forward facing system
  20917. */
  20918. class Vector3 {
  20919. /**
  20920. * Defines the first coordinates (on X axis)
  20921. */
  20922. x: number;
  20923. /**
  20924. * Defines the second coordinates (on Y axis)
  20925. */
  20926. y: number;
  20927. /**
  20928. * Defines the third coordinates (on Z axis)
  20929. */
  20930. z: number;
  20931. /**
  20932. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  20933. * @param x defines the first coordinates (on X axis)
  20934. * @param y defines the second coordinates (on Y axis)
  20935. * @param z defines the third coordinates (on Z axis)
  20936. */
  20937. constructor(
  20938. /**
  20939. * Defines the first coordinates (on X axis)
  20940. */
  20941. x?: number,
  20942. /**
  20943. * Defines the second coordinates (on Y axis)
  20944. */
  20945. y?: number,
  20946. /**
  20947. * Defines the third coordinates (on Z axis)
  20948. */
  20949. z?: number);
  20950. /**
  20951. * Creates a string representation of the Vector3
  20952. * @returns a string with the Vector3 coordinates.
  20953. */
  20954. toString(): string;
  20955. /**
  20956. * Gets the class name
  20957. * @returns the string "Vector3"
  20958. */
  20959. getClassName(): string;
  20960. /**
  20961. * Creates the Vector3 hash code
  20962. * @returns a number which tends to be unique between Vector3 instances
  20963. */
  20964. getHashCode(): number;
  20965. /**
  20966. * Creates an array containing three elements : the coordinates of the Vector3
  20967. * @returns a new array of numbers
  20968. */
  20969. asArray(): number[];
  20970. /**
  20971. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  20972. * @param array defines the destination array
  20973. * @param index defines the offset in the destination array
  20974. * @returns the current Vector3
  20975. */
  20976. toArray(array: FloatArray, index?: number): Vector3;
  20977. /**
  20978. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  20979. * @returns a new Quaternion object, computed from the Vector3 coordinates
  20980. */
  20981. toQuaternion(): Quaternion;
  20982. /**
  20983. * Adds the given vector to the current Vector3
  20984. * @param otherVector defines the second operand
  20985. * @returns the current updated Vector3
  20986. */
  20987. addInPlace(otherVector: Vector3): Vector3;
  20988. /**
  20989. * Adds the given coordinates to the current Vector3
  20990. * @param x defines the x coordinate of the operand
  20991. * @param y defines the y coordinate of the operand
  20992. * @param z defines the z coordinate of the operand
  20993. * @returns the current updated Vector3
  20994. */
  20995. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  20996. /**
  20997. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  20998. * @param otherVector defines the second operand
  20999. * @returns the resulting Vector3
  21000. */
  21001. add(otherVector: Vector3): Vector3;
  21002. /**
  21003. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21004. * @param otherVector defines the second operand
  21005. * @param result defines the Vector3 object where to store the result
  21006. * @returns the current Vector3
  21007. */
  21008. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  21009. /**
  21010. * Subtract the given vector from the current Vector3
  21011. * @param otherVector defines the second operand
  21012. * @returns the current updated Vector3
  21013. */
  21014. subtractInPlace(otherVector: Vector3): Vector3;
  21015. /**
  21016. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21017. * @param otherVector defines the second operand
  21018. * @returns the resulting Vector3
  21019. */
  21020. subtract(otherVector: Vector3): Vector3;
  21021. /**
  21022. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21023. * @param otherVector defines the second operand
  21024. * @param result defines the Vector3 object where to store the result
  21025. * @returns the current Vector3
  21026. */
  21027. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  21028. /**
  21029. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21030. * @param x defines the x coordinate of the operand
  21031. * @param y defines the y coordinate of the operand
  21032. * @param z defines the z coordinate of the operand
  21033. * @returns the resulting Vector3
  21034. */
  21035. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21036. /**
  21037. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21038. * @param x defines the x coordinate of the operand
  21039. * @param y defines the y coordinate of the operand
  21040. * @param z defines the z coordinate of the operand
  21041. * @param result defines the Vector3 object where to store the result
  21042. * @returns the current Vector3
  21043. */
  21044. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21045. /**
  21046. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21047. * @returns a new Vector3
  21048. */
  21049. negate(): Vector3;
  21050. /**
  21051. * Multiplies the Vector3 coordinates by the float "scale"
  21052. * @param scale defines the multiplier factor
  21053. * @returns the current updated Vector3
  21054. */
  21055. scaleInPlace(scale: number): Vector3;
  21056. /**
  21057. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21058. * @param scale defines the multiplier factor
  21059. * @returns a new Vector3
  21060. */
  21061. scale(scale: number): Vector3;
  21062. /**
  21063. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21064. * @param scale defines the multiplier factor
  21065. * @param result defines the Vector3 object where to store the result
  21066. * @returns the current Vector3
  21067. */
  21068. scaleToRef(scale: number, result: Vector3): Vector3;
  21069. /**
  21070. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21071. * @param scale defines the scale factor
  21072. * @param result defines the Vector3 object where to store the result
  21073. * @returns the unmodified current Vector3
  21074. */
  21075. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21076. /**
  21077. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21078. * @param otherVector defines the second operand
  21079. * @returns true if both vectors are equals
  21080. */
  21081. equals(otherVector: Vector3): boolean;
  21082. /**
  21083. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21084. * @param otherVector defines the second operand
  21085. * @param epsilon defines the minimal distance to define values as equals
  21086. * @returns true if both vectors are distant less than epsilon
  21087. */
  21088. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  21089. /**
  21090. * Returns true if the current Vector3 coordinates equals the given floats
  21091. * @param x defines the x coordinate of the operand
  21092. * @param y defines the y coordinate of the operand
  21093. * @param z defines the z coordinate of the operand
  21094. * @returns true if both vectors are equals
  21095. */
  21096. equalsToFloats(x: number, y: number, z: number): boolean;
  21097. /**
  21098. * Multiplies the current Vector3 coordinates by the given ones
  21099. * @param otherVector defines the second operand
  21100. * @returns the current updated Vector3
  21101. */
  21102. multiplyInPlace(otherVector: Vector3): Vector3;
  21103. /**
  21104. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21105. * @param otherVector defines the second operand
  21106. * @returns the new Vector3
  21107. */
  21108. multiply(otherVector: Vector3): Vector3;
  21109. /**
  21110. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21111. * @param otherVector defines the second operand
  21112. * @param result defines the Vector3 object where to store the result
  21113. * @returns the current Vector3
  21114. */
  21115. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  21116. /**
  21117. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21118. * @param x defines the x coordinate of the operand
  21119. * @param y defines the y coordinate of the operand
  21120. * @param z defines the z coordinate of the operand
  21121. * @returns the new Vector3
  21122. */
  21123. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21124. /**
  21125. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21126. * @param otherVector defines the second operand
  21127. * @returns the new Vector3
  21128. */
  21129. divide(otherVector: Vector3): Vector3;
  21130. /**
  21131. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21132. * @param otherVector defines the second operand
  21133. * @param result defines the Vector3 object where to store the result
  21134. * @returns the current Vector3
  21135. */
  21136. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  21137. /**
  21138. * Divides the current Vector3 coordinates by the given ones.
  21139. * @param otherVector defines the second operand
  21140. * @returns the current updated Vector3
  21141. */
  21142. divideInPlace(otherVector: Vector3): Vector3;
  21143. /**
  21144. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21145. * @param other defines the second operand
  21146. * @returns the current updated Vector3
  21147. */
  21148. minimizeInPlace(other: Vector3): Vector3;
  21149. /**
  21150. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21151. * @param other defines the second operand
  21152. * @returns the current updated Vector3
  21153. */
  21154. maximizeInPlace(other: Vector3): Vector3;
  21155. /**
  21156. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21157. * @param x defines the x coordinate of the operand
  21158. * @param y defines the y coordinate of the operand
  21159. * @param z defines the z coordinate of the operand
  21160. * @returns the current updated Vector3
  21161. */
  21162. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21163. /**
  21164. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21165. * @param x defines the x coordinate of the operand
  21166. * @param y defines the y coordinate of the operand
  21167. * @param z defines the z coordinate of the operand
  21168. * @returns the current updated Vector3
  21169. */
  21170. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21171. /**
  21172. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21173. */
  21174. readonly isNonUniform: boolean;
  21175. /**
  21176. * Gets a new Vector3 from current Vector3 floored values
  21177. * @returns a new Vector3
  21178. */
  21179. floor(): Vector3;
  21180. /**
  21181. * Gets a new Vector3 from current Vector3 floored values
  21182. * @returns a new Vector3
  21183. */
  21184. fract(): Vector3;
  21185. /**
  21186. * Gets the length of the Vector3
  21187. * @returns the length of the Vecto3
  21188. */
  21189. length(): number;
  21190. /**
  21191. * Gets the squared length of the Vector3
  21192. * @returns squared length of the Vector3
  21193. */
  21194. lengthSquared(): number;
  21195. /**
  21196. * Normalize the current Vector3.
  21197. * Please note that this is an in place operation.
  21198. * @returns the current updated Vector3
  21199. */
  21200. normalize(): Vector3;
  21201. /**
  21202. * Normalize the current Vector3 with the given input length.
  21203. * Please note that this is an in place operation.
  21204. * @param len the length of the vector
  21205. * @returns the current updated Vector3
  21206. */
  21207. normalizeFromLength(len: number): Vector3;
  21208. /**
  21209. * Normalize the current Vector3 to a new vector
  21210. * @returns the new Vector3
  21211. */
  21212. normalizeToNew(): Vector3;
  21213. /**
  21214. * Normalize the current Vector3 to the reference
  21215. * @param reference define the Vector3 to update
  21216. * @returns the updated Vector3
  21217. */
  21218. normalizeToRef(reference: Vector3): Vector3;
  21219. /**
  21220. * Creates a new Vector3 copied from the current Vector3
  21221. * @returns the new Vector3
  21222. */
  21223. clone(): Vector3;
  21224. /**
  21225. * Copies the given vector coordinates to the current Vector3 ones
  21226. * @param source defines the source Vector3
  21227. * @returns the current updated Vector3
  21228. */
  21229. copyFrom(source: Vector3): Vector3;
  21230. /**
  21231. * Copies the given floats to the current Vector3 coordinates
  21232. * @param x defines the x coordinate of the operand
  21233. * @param y defines the y coordinate of the operand
  21234. * @param z defines the z coordinate of the operand
  21235. * @returns the current updated Vector3
  21236. */
  21237. copyFromFloats(x: number, y: number, z: number): Vector3;
  21238. /**
  21239. * Copies the given floats to the current Vector3 coordinates
  21240. * @param x defines the x coordinate of the operand
  21241. * @param y defines the y coordinate of the operand
  21242. * @param z defines the z coordinate of the operand
  21243. * @returns the current updated Vector3
  21244. */
  21245. set(x: number, y: number, z: number): Vector3;
  21246. /**
  21247. * Copies the given float to the current Vector3 coordinates
  21248. * @param v defines the x, y and z coordinates of the operand
  21249. * @returns the current updated Vector3
  21250. */
  21251. setAll(v: number): Vector3;
  21252. /**
  21253. * Get the clip factor between two vectors
  21254. * @param vector0 defines the first operand
  21255. * @param vector1 defines the second operand
  21256. * @param axis defines the axis to use
  21257. * @param size defines the size along the axis
  21258. * @returns the clip factor
  21259. */
  21260. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  21261. /**
  21262. * Get angle between two vectors
  21263. * @param vector0 angle between vector0 and vector1
  21264. * @param vector1 angle between vector0 and vector1
  21265. * @param normal direction of the normal
  21266. * @return the angle between vector0 and vector1
  21267. */
  21268. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  21269. /**
  21270. * Returns a new Vector3 set from the index "offset" of the given array
  21271. * @param array defines the source array
  21272. * @param offset defines the offset in the source array
  21273. * @returns the new Vector3
  21274. */
  21275. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  21276. /**
  21277. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21278. * This function is deprecated. Use FromArray instead
  21279. * @param array defines the source array
  21280. * @param offset defines the offset in the source array
  21281. * @returns the new Vector3
  21282. */
  21283. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  21284. /**
  21285. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21286. * @param array defines the source array
  21287. * @param offset defines the offset in the source array
  21288. * @param result defines the Vector3 where to store the result
  21289. */
  21290. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  21291. /**
  21292. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21293. * This function is deprecated. Use FromArrayToRef instead.
  21294. * @param array defines the source array
  21295. * @param offset defines the offset in the source array
  21296. * @param result defines the Vector3 where to store the result
  21297. */
  21298. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  21299. /**
  21300. * Sets the given vector "result" with the given floats.
  21301. * @param x defines the x coordinate of the source
  21302. * @param y defines the y coordinate of the source
  21303. * @param z defines the z coordinate of the source
  21304. * @param result defines the Vector3 where to store the result
  21305. */
  21306. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21307. /**
  21308. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21309. * @returns a new empty Vector3
  21310. */
  21311. static Zero(): Vector3;
  21312. /**
  21313. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21314. * @returns a new unit Vector3
  21315. */
  21316. static One(): Vector3;
  21317. /**
  21318. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21319. * @returns a new up Vector3
  21320. */
  21321. static Up(): Vector3;
  21322. /**
  21323. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21324. * @returns a new down Vector3
  21325. */
  21326. static Down(): Vector3;
  21327. /**
  21328. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21329. * @returns a new forward Vector3
  21330. */
  21331. static Forward(): Vector3;
  21332. /**
  21333. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21334. * @returns a new forward Vector3
  21335. */
  21336. static Backward(): Vector3;
  21337. /**
  21338. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21339. * @returns a new right Vector3
  21340. */
  21341. static Right(): Vector3;
  21342. /**
  21343. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21344. * @returns a new left Vector3
  21345. */
  21346. static Left(): Vector3;
  21347. /**
  21348. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21349. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21350. * @param vector defines the Vector3 to transform
  21351. * @param transformation defines the transformation matrix
  21352. * @returns the transformed Vector3
  21353. */
  21354. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  21355. /**
  21356. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21357. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21358. * @param vector defines the Vector3 to transform
  21359. * @param transformation defines the transformation matrix
  21360. * @param result defines the Vector3 where to store the result
  21361. */
  21362. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21363. /**
  21364. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21365. * This method computes tranformed coordinates only, not transformed direction vectors
  21366. * @param x define the x coordinate of the source vector
  21367. * @param y define the y coordinate of the source vector
  21368. * @param z define the z coordinate of the source vector
  21369. * @param transformation defines the transformation matrix
  21370. * @param result defines the Vector3 where to store the result
  21371. */
  21372. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21373. /**
  21374. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21375. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21376. * @param vector defines the Vector3 to transform
  21377. * @param transformation defines the transformation matrix
  21378. * @returns the new Vector3
  21379. */
  21380. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  21381. /**
  21382. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21383. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21384. * @param vector defines the Vector3 to transform
  21385. * @param transformation defines the transformation matrix
  21386. * @param result defines the Vector3 where to store the result
  21387. */
  21388. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  21389. /**
  21390. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21391. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21392. * @param x define the x coordinate of the source vector
  21393. * @param y define the y coordinate of the source vector
  21394. * @param z define the z coordinate of the source vector
  21395. * @param transformation defines the transformation matrix
  21396. * @param result defines the Vector3 where to store the result
  21397. */
  21398. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  21399. /**
  21400. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21401. * @param value1 defines the first control point
  21402. * @param value2 defines the second control point
  21403. * @param value3 defines the third control point
  21404. * @param value4 defines the fourth control point
  21405. * @param amount defines the amount on the spline to use
  21406. * @returns the new Vector3
  21407. */
  21408. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  21409. /**
  21410. * 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"
  21411. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21412. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21413. * @param value defines the current value
  21414. * @param min defines the lower range value
  21415. * @param max defines the upper range value
  21416. * @returns the new Vector3
  21417. */
  21418. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  21419. /**
  21420. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21421. * @param value1 defines the first control point
  21422. * @param tangent1 defines the first tangent vector
  21423. * @param value2 defines the second control point
  21424. * @param tangent2 defines the second tangent vector
  21425. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21426. * @returns the new Vector3
  21427. */
  21428. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  21429. /**
  21430. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21431. * @param start defines the start value
  21432. * @param end defines the end value
  21433. * @param amount max defines amount between both (between 0 and 1)
  21434. * @returns the new Vector3
  21435. */
  21436. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  21437. /**
  21438. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21439. * @param start defines the start value
  21440. * @param end defines the end value
  21441. * @param amount max defines amount between both (between 0 and 1)
  21442. * @param result defines the Vector3 where to store the result
  21443. */
  21444. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  21445. /**
  21446. * Returns the dot product (float) between the vectors "left" and "right"
  21447. * @param left defines the left operand
  21448. * @param right defines the right operand
  21449. * @returns the dot product
  21450. */
  21451. static Dot(left: Vector3, right: Vector3): number;
  21452. /**
  21453. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21454. * The cross product is then orthogonal to both "left" and "right"
  21455. * @param left defines the left operand
  21456. * @param right defines the right operand
  21457. * @returns the cross product
  21458. */
  21459. static Cross(left: Vector3, right: Vector3): Vector3;
  21460. /**
  21461. * Sets the given vector "result" with the cross product of "left" and "right"
  21462. * The cross product is then orthogonal to both "left" and "right"
  21463. * @param left defines the left operand
  21464. * @param right defines the right operand
  21465. * @param result defines the Vector3 where to store the result
  21466. */
  21467. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21468. /**
  21469. * Returns a new Vector3 as the normalization of the given vector
  21470. * @param vector defines the Vector3 to normalize
  21471. * @returns the new Vector3
  21472. */
  21473. static Normalize(vector: Vector3): Vector3;
  21474. /**
  21475. * Sets the given vector "result" with the normalization of the given first vector
  21476. * @param vector defines the Vector3 to normalize
  21477. * @param result defines the Vector3 where to store the result
  21478. */
  21479. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  21480. private static _viewportMatrixCache;
  21481. /**
  21482. * Project a Vector3 onto screen space
  21483. * @param vector defines the Vector3 to project
  21484. * @param world defines the world matrix to use
  21485. * @param transform defines the transform (view x projection) matrix to use
  21486. * @param viewport defines the screen viewport to use
  21487. * @returns the new Vector3
  21488. */
  21489. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  21490. /**
  21491. * Unproject from screen space to object space
  21492. * @param source defines the screen space Vector3 to use
  21493. * @param viewportWidth defines the current width of the viewport
  21494. * @param viewportHeight defines the current height of the viewport
  21495. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21496. * @param transform defines the transform (view x projection) matrix to use
  21497. * @returns the new Vector3
  21498. */
  21499. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  21500. /**
  21501. * Unproject from screen space to object space
  21502. * @param source defines the screen space Vector3 to use
  21503. * @param viewportWidth defines the current width of the viewport
  21504. * @param viewportHeight defines the current height of the viewport
  21505. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21506. * @param view defines the view matrix to use
  21507. * @param projection defines the projection matrix to use
  21508. * @returns the new Vector3
  21509. */
  21510. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  21511. /**
  21512. * Unproject from screen space to object space
  21513. * @param source defines the screen space Vector3 to use
  21514. * @param viewportWidth defines the current width of the viewport
  21515. * @param viewportHeight defines the current height of the viewport
  21516. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21517. * @param view defines the view matrix to use
  21518. * @param projection defines the projection matrix to use
  21519. * @param result defines the Vector3 where to store the result
  21520. */
  21521. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21522. /**
  21523. * Unproject from screen space to object space
  21524. * @param sourceX defines the screen space x coordinate to use
  21525. * @param sourceY defines the screen space y coordinate to use
  21526. * @param sourceZ defines the screen space z coordinate to use
  21527. * @param viewportWidth defines the current width of the viewport
  21528. * @param viewportHeight defines the current height of the viewport
  21529. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21530. * @param view defines the view matrix to use
  21531. * @param projection defines the projection matrix to use
  21532. * @param result defines the Vector3 where to store the result
  21533. */
  21534. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  21535. /**
  21536. * Gets the minimal coordinate values between two Vector3
  21537. * @param left defines the first operand
  21538. * @param right defines the second operand
  21539. * @returns the new Vector3
  21540. */
  21541. static Minimize(left: Vector3, right: Vector3): Vector3;
  21542. /**
  21543. * Gets the maximal coordinate values between two Vector3
  21544. * @param left defines the first operand
  21545. * @param right defines the second operand
  21546. * @returns the new Vector3
  21547. */
  21548. static Maximize(left: Vector3, right: Vector3): Vector3;
  21549. /**
  21550. * Returns the distance between the vectors "value1" and "value2"
  21551. * @param value1 defines the first operand
  21552. * @param value2 defines the second operand
  21553. * @returns the distance
  21554. */
  21555. static Distance(value1: Vector3, value2: Vector3): number;
  21556. /**
  21557. * Returns the squared distance between the vectors "value1" and "value2"
  21558. * @param value1 defines the first operand
  21559. * @param value2 defines the second operand
  21560. * @returns the squared distance
  21561. */
  21562. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  21563. /**
  21564. * Returns a new Vector3 located at the center between "value1" and "value2"
  21565. * @param value1 defines the first operand
  21566. * @param value2 defines the second operand
  21567. * @returns the new Vector3
  21568. */
  21569. static Center(value1: Vector3, value2: Vector3): Vector3;
  21570. /**
  21571. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21572. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21573. * to something in order to rotate it from its local system to the given target system
  21574. * Note: axis1, axis2 and axis3 are normalized during this operation
  21575. * @param axis1 defines the first axis
  21576. * @param axis2 defines the second axis
  21577. * @param axis3 defines the third axis
  21578. * @returns a new Vector3
  21579. */
  21580. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  21581. /**
  21582. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21583. * @param axis1 defines the first axis
  21584. * @param axis2 defines the second axis
  21585. * @param axis3 defines the third axis
  21586. * @param ref defines the Vector3 where to store the result
  21587. */
  21588. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  21589. }
  21590. /**
  21591. * Vector4 class created for EulerAngle class conversion to Quaternion
  21592. */
  21593. class Vector4 {
  21594. /** x value of the vector */
  21595. x: number;
  21596. /** y value of the vector */
  21597. y: number;
  21598. /** z value of the vector */
  21599. z: number;
  21600. /** w value of the vector */
  21601. w: number;
  21602. /**
  21603. * Creates a Vector4 object from the given floats.
  21604. * @param x x value of the vector
  21605. * @param y y value of the vector
  21606. * @param z z value of the vector
  21607. * @param w w value of the vector
  21608. */
  21609. constructor(
  21610. /** x value of the vector */
  21611. x: number,
  21612. /** y value of the vector */
  21613. y: number,
  21614. /** z value of the vector */
  21615. z: number,
  21616. /** w value of the vector */
  21617. w: number);
  21618. /**
  21619. * Returns the string with the Vector4 coordinates.
  21620. * @returns a string containing all the vector values
  21621. */
  21622. toString(): string;
  21623. /**
  21624. * Returns the string "Vector4".
  21625. * @returns "Vector4"
  21626. */
  21627. getClassName(): string;
  21628. /**
  21629. * Returns the Vector4 hash code.
  21630. * @returns a unique hash code
  21631. */
  21632. getHashCode(): number;
  21633. /**
  21634. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21635. * @returns the resulting array
  21636. */
  21637. asArray(): number[];
  21638. /**
  21639. * Populates the given array from the given index with the Vector4 coordinates.
  21640. * @param array array to populate
  21641. * @param index index of the array to start at (default: 0)
  21642. * @returns the Vector4.
  21643. */
  21644. toArray(array: FloatArray, index?: number): Vector4;
  21645. /**
  21646. * Adds the given vector to the current Vector4.
  21647. * @param otherVector the vector to add
  21648. * @returns the updated Vector4.
  21649. */
  21650. addInPlace(otherVector: Vector4): Vector4;
  21651. /**
  21652. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21653. * @param otherVector the vector to add
  21654. * @returns the resulting vector
  21655. */
  21656. add(otherVector: Vector4): Vector4;
  21657. /**
  21658. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21659. * @param otherVector the vector to add
  21660. * @param result the vector to store the result
  21661. * @returns the current Vector4.
  21662. */
  21663. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  21664. /**
  21665. * Subtract in place the given vector from the current Vector4.
  21666. * @param otherVector the vector to subtract
  21667. * @returns the updated Vector4.
  21668. */
  21669. subtractInPlace(otherVector: Vector4): Vector4;
  21670. /**
  21671. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21672. * @param otherVector the vector to add
  21673. * @returns the new vector with the result
  21674. */
  21675. subtract(otherVector: Vector4): Vector4;
  21676. /**
  21677. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21678. * @param otherVector the vector to subtract
  21679. * @param result the vector to store the result
  21680. * @returns the current Vector4.
  21681. */
  21682. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  21683. /**
  21684. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21685. */
  21686. /**
  21687. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21688. * @param x value to subtract
  21689. * @param y value to subtract
  21690. * @param z value to subtract
  21691. * @param w value to subtract
  21692. * @returns new vector containing the result
  21693. */
  21694. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21695. /**
  21696. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21697. * @param x value to subtract
  21698. * @param y value to subtract
  21699. * @param z value to subtract
  21700. * @param w value to subtract
  21701. * @param result the vector to store the result in
  21702. * @returns the current Vector4.
  21703. */
  21704. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21705. /**
  21706. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21707. * @returns a new vector with the negated values
  21708. */
  21709. negate(): Vector4;
  21710. /**
  21711. * Multiplies the current Vector4 coordinates by scale (float).
  21712. * @param scale the number to scale with
  21713. * @returns the updated Vector4.
  21714. */
  21715. scaleInPlace(scale: number): Vector4;
  21716. /**
  21717. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21718. * @param scale the number to scale with
  21719. * @returns a new vector with the result
  21720. */
  21721. scale(scale: number): Vector4;
  21722. /**
  21723. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21724. * @param scale the number to scale with
  21725. * @param result a vector to store the result in
  21726. * @returns the current Vector4.
  21727. */
  21728. scaleToRef(scale: number, result: Vector4): Vector4;
  21729. /**
  21730. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21731. * @param scale defines the scale factor
  21732. * @param result defines the Vector4 object where to store the result
  21733. * @returns the unmodified current Vector4
  21734. */
  21735. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21736. /**
  21737. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21738. * @param otherVector the vector to compare against
  21739. * @returns true if they are equal
  21740. */
  21741. equals(otherVector: Vector4): boolean;
  21742. /**
  21743. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21744. * @param otherVector vector to compare against
  21745. * @param epsilon (Default: very small number)
  21746. * @returns true if they are equal
  21747. */
  21748. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  21749. /**
  21750. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  21751. * @param x x value to compare against
  21752. * @param y y value to compare against
  21753. * @param z z value to compare against
  21754. * @param w w value to compare against
  21755. * @returns true if equal
  21756. */
  21757. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  21758. /**
  21759. * Multiplies in place the current Vector4 by the given one.
  21760. * @param otherVector vector to multiple with
  21761. * @returns the updated Vector4.
  21762. */
  21763. multiplyInPlace(otherVector: Vector4): Vector4;
  21764. /**
  21765. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  21766. * @param otherVector vector to multiple with
  21767. * @returns resulting new vector
  21768. */
  21769. multiply(otherVector: Vector4): Vector4;
  21770. /**
  21771. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  21772. * @param otherVector vector to multiple with
  21773. * @param result vector to store the result
  21774. * @returns the current Vector4.
  21775. */
  21776. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  21777. /**
  21778. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  21779. * @param x x value multiply with
  21780. * @param y y value multiply with
  21781. * @param z z value multiply with
  21782. * @param w w value multiply with
  21783. * @returns resulting new vector
  21784. */
  21785. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  21786. /**
  21787. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  21788. * @param otherVector vector to devide with
  21789. * @returns resulting new vector
  21790. */
  21791. divide(otherVector: Vector4): Vector4;
  21792. /**
  21793. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  21794. * @param otherVector vector to devide with
  21795. * @param result vector to store the result
  21796. * @returns the current Vector4.
  21797. */
  21798. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  21799. /**
  21800. * Divides the current Vector3 coordinates by the given ones.
  21801. * @param otherVector vector to devide with
  21802. * @returns the updated Vector3.
  21803. */
  21804. divideInPlace(otherVector: Vector4): Vector4;
  21805. /**
  21806. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  21807. * @param other defines the second operand
  21808. * @returns the current updated Vector4
  21809. */
  21810. minimizeInPlace(other: Vector4): Vector4;
  21811. /**
  21812. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  21813. * @param other defines the second operand
  21814. * @returns the current updated Vector4
  21815. */
  21816. maximizeInPlace(other: Vector4): Vector4;
  21817. /**
  21818. * Gets a new Vector4 from current Vector4 floored values
  21819. * @returns a new Vector4
  21820. */
  21821. floor(): Vector4;
  21822. /**
  21823. * Gets a new Vector4 from current Vector3 floored values
  21824. * @returns a new Vector4
  21825. */
  21826. fract(): Vector4;
  21827. /**
  21828. * Returns the Vector4 length (float).
  21829. * @returns the length
  21830. */
  21831. length(): number;
  21832. /**
  21833. * Returns the Vector4 squared length (float).
  21834. * @returns the length squared
  21835. */
  21836. lengthSquared(): number;
  21837. /**
  21838. * Normalizes in place the Vector4.
  21839. * @returns the updated Vector4.
  21840. */
  21841. normalize(): Vector4;
  21842. /**
  21843. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  21844. * @returns this converted to a new vector3
  21845. */
  21846. toVector3(): Vector3;
  21847. /**
  21848. * Returns a new Vector4 copied from the current one.
  21849. * @returns the new cloned vector
  21850. */
  21851. clone(): Vector4;
  21852. /**
  21853. * Updates the current Vector4 with the given one coordinates.
  21854. * @param source the source vector to copy from
  21855. * @returns the updated Vector4.
  21856. */
  21857. copyFrom(source: Vector4): Vector4;
  21858. /**
  21859. * Updates the current Vector4 coordinates with the given floats.
  21860. * @param x float to copy from
  21861. * @param y float to copy from
  21862. * @param z float to copy from
  21863. * @param w float to copy from
  21864. * @returns the updated Vector4.
  21865. */
  21866. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21867. /**
  21868. * Updates the current Vector4 coordinates with the given floats.
  21869. * @param x float to set from
  21870. * @param y float to set from
  21871. * @param z float to set from
  21872. * @param w float to set from
  21873. * @returns the updated Vector4.
  21874. */
  21875. set(x: number, y: number, z: number, w: number): Vector4;
  21876. /**
  21877. * Copies the given float to the current Vector3 coordinates
  21878. * @param v defines the x, y, z and w coordinates of the operand
  21879. * @returns the current updated Vector3
  21880. */
  21881. setAll(v: number): Vector4;
  21882. /**
  21883. * Returns a new Vector4 set from the starting index of the given array.
  21884. * @param array the array to pull values from
  21885. * @param offset the offset into the array to start at
  21886. * @returns the new vector
  21887. */
  21888. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  21889. /**
  21890. * Updates the given vector "result" from the starting index of the given array.
  21891. * @param array the array to pull values from
  21892. * @param offset the offset into the array to start at
  21893. * @param result the vector to store the result in
  21894. */
  21895. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  21896. /**
  21897. * Updates the given vector "result" from the starting index of the given Float32Array.
  21898. * @param array the array to pull values from
  21899. * @param offset the offset into the array to start at
  21900. * @param result the vector to store the result in
  21901. */
  21902. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  21903. /**
  21904. * Updates the given vector "result" coordinates from the given floats.
  21905. * @param x float to set from
  21906. * @param y float to set from
  21907. * @param z float to set from
  21908. * @param w float to set from
  21909. * @param result the vector to the floats in
  21910. */
  21911. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  21912. /**
  21913. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  21914. * @returns the new vector
  21915. */
  21916. static Zero(): Vector4;
  21917. /**
  21918. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  21919. * @returns the new vector
  21920. */
  21921. static One(): Vector4;
  21922. /**
  21923. * Returns a new normalized Vector4 from the given one.
  21924. * @param vector the vector to normalize
  21925. * @returns the vector
  21926. */
  21927. static Normalize(vector: Vector4): Vector4;
  21928. /**
  21929. * Updates the given vector "result" from the normalization of the given one.
  21930. * @param vector the vector to normalize
  21931. * @param result the vector to store the result in
  21932. */
  21933. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  21934. /**
  21935. * Returns a vector with the minimum values from the left and right vectors
  21936. * @param left left vector to minimize
  21937. * @param right right vector to minimize
  21938. * @returns a new vector with the minimum of the left and right vector values
  21939. */
  21940. static Minimize(left: Vector4, right: Vector4): Vector4;
  21941. /**
  21942. * Returns a vector with the maximum values from the left and right vectors
  21943. * @param left left vector to maximize
  21944. * @param right right vector to maximize
  21945. * @returns a new vector with the maximum of the left and right vector values
  21946. */
  21947. static Maximize(left: Vector4, right: Vector4): Vector4;
  21948. /**
  21949. * Returns the distance (float) between the vectors "value1" and "value2".
  21950. * @param value1 value to calulate the distance between
  21951. * @param value2 value to calulate the distance between
  21952. * @return the distance between the two vectors
  21953. */
  21954. static Distance(value1: Vector4, value2: Vector4): number;
  21955. /**
  21956. * Returns the squared distance (float) between the vectors "value1" and "value2".
  21957. * @param value1 value to calulate the distance between
  21958. * @param value2 value to calulate the distance between
  21959. * @return the distance between the two vectors squared
  21960. */
  21961. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  21962. /**
  21963. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  21964. * @param value1 value to calulate the center between
  21965. * @param value2 value to calulate the center between
  21966. * @return the center between the two vectors
  21967. */
  21968. static Center(value1: Vector4, value2: Vector4): Vector4;
  21969. /**
  21970. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  21971. * This methods computes transformed normalized direction vectors only.
  21972. * @param vector the vector to transform
  21973. * @param transformation the transformation matrix to apply
  21974. * @returns the new vector
  21975. */
  21976. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  21977. /**
  21978. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  21979. * This methods computes transformed normalized direction vectors only.
  21980. * @param vector the vector to transform
  21981. * @param transformation the transformation matrix to apply
  21982. * @param result the vector to store the result in
  21983. */
  21984. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  21985. /**
  21986. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  21987. * This methods computes transformed normalized direction vectors only.
  21988. * @param x value to transform
  21989. * @param y value to transform
  21990. * @param z value to transform
  21991. * @param w value to transform
  21992. * @param transformation the transformation matrix to apply
  21993. * @param result the vector to store the results in
  21994. */
  21995. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  21996. }
  21997. /**
  21998. * Interface for the size containing width and height
  21999. */
  22000. interface ISize {
  22001. /**
  22002. * Width
  22003. */
  22004. width: number;
  22005. /**
  22006. * Heighht
  22007. */
  22008. height: number;
  22009. }
  22010. /**
  22011. * Size containing widht and height
  22012. */
  22013. class Size implements ISize {
  22014. /**
  22015. * Width
  22016. */
  22017. width: number;
  22018. /**
  22019. * Height
  22020. */
  22021. height: number;
  22022. /**
  22023. * Creates a Size object from the given width and height (floats).
  22024. * @param width width of the new size
  22025. * @param height height of the new size
  22026. */
  22027. constructor(width: number, height: number);
  22028. /**
  22029. * Returns a string with the Size width and height
  22030. * @returns a string with the Size width and height
  22031. */
  22032. toString(): string;
  22033. /**
  22034. * "Size"
  22035. * @returns the string "Size"
  22036. */
  22037. getClassName(): string;
  22038. /**
  22039. * Returns the Size hash code.
  22040. * @returns a hash code for a unique width and height
  22041. */
  22042. getHashCode(): number;
  22043. /**
  22044. * Updates the current size from the given one.
  22045. * @param src the given size
  22046. */
  22047. copyFrom(src: Size): void;
  22048. /**
  22049. * Updates in place the current Size from the given floats.
  22050. * @param width width of the new size
  22051. * @param height height of the new size
  22052. * @returns the updated Size.
  22053. */
  22054. copyFromFloats(width: number, height: number): Size;
  22055. /**
  22056. * Updates in place the current Size from the given floats.
  22057. * @param width width to set
  22058. * @param height height to set
  22059. * @returns the updated Size.
  22060. */
  22061. set(width: number, height: number): Size;
  22062. /**
  22063. * Multiplies the width and height by numbers
  22064. * @param w factor to multiple the width by
  22065. * @param h factor to multiple the height by
  22066. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22067. */
  22068. multiplyByFloats(w: number, h: number): Size;
  22069. /**
  22070. * Clones the size
  22071. * @returns a new Size copied from the given one.
  22072. */
  22073. clone(): Size;
  22074. /**
  22075. * True if the current Size and the given one width and height are strictly equal.
  22076. * @param other the other size to compare against
  22077. * @returns True if the current Size and the given one width and height are strictly equal.
  22078. */
  22079. equals(other: Size): boolean;
  22080. /**
  22081. * The surface of the Size : width * height (float).
  22082. */
  22083. readonly surface: number;
  22084. /**
  22085. * Create a new size of zero
  22086. * @returns a new Size set to (0.0, 0.0)
  22087. */
  22088. static Zero(): Size;
  22089. /**
  22090. * Sums the width and height of two sizes
  22091. * @param otherSize size to add to this size
  22092. * @returns a new Size set as the addition result of the current Size and the given one.
  22093. */
  22094. add(otherSize: Size): Size;
  22095. /**
  22096. * Subtracts the width and height of two
  22097. * @param otherSize size to subtract to this size
  22098. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22099. */
  22100. subtract(otherSize: Size): Size;
  22101. /**
  22102. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22103. * @param start starting size to lerp between
  22104. * @param end end size to lerp between
  22105. * @param amount amount to lerp between the start and end values
  22106. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22107. */
  22108. static Lerp(start: Size, end: Size, amount: number): Size;
  22109. }
  22110. /**
  22111. * Class used to store quaternion data
  22112. * @see https://en.wikipedia.org/wiki/Quaternion
  22113. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22114. */
  22115. class Quaternion {
  22116. /** defines the first component (0 by default) */
  22117. x: number;
  22118. /** defines the second component (0 by default) */
  22119. y: number;
  22120. /** defines the third component (0 by default) */
  22121. z: number;
  22122. /** defines the fourth component (1.0 by default) */
  22123. w: number;
  22124. /**
  22125. * Creates a new Quaternion from the given floats
  22126. * @param x defines the first component (0 by default)
  22127. * @param y defines the second component (0 by default)
  22128. * @param z defines the third component (0 by default)
  22129. * @param w defines the fourth component (1.0 by default)
  22130. */
  22131. constructor(
  22132. /** defines the first component (0 by default) */
  22133. x?: number,
  22134. /** defines the second component (0 by default) */
  22135. y?: number,
  22136. /** defines the third component (0 by default) */
  22137. z?: number,
  22138. /** defines the fourth component (1.0 by default) */
  22139. w?: number);
  22140. /**
  22141. * Gets a string representation for the current quaternion
  22142. * @returns a string with the Quaternion coordinates
  22143. */
  22144. toString(): string;
  22145. /**
  22146. * Gets the class name of the quaternion
  22147. * @returns the string "Quaternion"
  22148. */
  22149. getClassName(): string;
  22150. /**
  22151. * Gets a hash code for this quaternion
  22152. * @returns the quaternion hash code
  22153. */
  22154. getHashCode(): number;
  22155. /**
  22156. * Copy the quaternion to an array
  22157. * @returns a new array populated with 4 elements from the quaternion coordinates
  22158. */
  22159. asArray(): number[];
  22160. /**
  22161. * Check if two quaternions are equals
  22162. * @param otherQuaternion defines the second operand
  22163. * @return true if the current quaternion and the given one coordinates are strictly equals
  22164. */
  22165. equals(otherQuaternion: Quaternion): boolean;
  22166. /**
  22167. * Clone the current quaternion
  22168. * @returns a new quaternion copied from the current one
  22169. */
  22170. clone(): Quaternion;
  22171. /**
  22172. * Copy a quaternion to the current one
  22173. * @param other defines the other quaternion
  22174. * @returns the updated current quaternion
  22175. */
  22176. copyFrom(other: Quaternion): Quaternion;
  22177. /**
  22178. * Updates the current quaternion with the given float coordinates
  22179. * @param x defines the x coordinate
  22180. * @param y defines the y coordinate
  22181. * @param z defines the z coordinate
  22182. * @param w defines the w coordinate
  22183. * @returns the updated current quaternion
  22184. */
  22185. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22186. /**
  22187. * Updates the current quaternion from the given float coordinates
  22188. * @param x defines the x coordinate
  22189. * @param y defines the y coordinate
  22190. * @param z defines the z coordinate
  22191. * @param w defines the w coordinate
  22192. * @returns the updated current quaternion
  22193. */
  22194. set(x: number, y: number, z: number, w: number): Quaternion;
  22195. /**
  22196. * Adds two quaternions
  22197. * @param other defines the second operand
  22198. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22199. */
  22200. add(other: Quaternion): Quaternion;
  22201. /**
  22202. * Add a quaternion to the current one
  22203. * @param other defines the quaternion to add
  22204. * @returns the current quaternion
  22205. */
  22206. addInPlace(other: Quaternion): Quaternion;
  22207. /**
  22208. * Subtract two quaternions
  22209. * @param other defines the second operand
  22210. * @returns a new quaternion as the subtraction result of the given one from the current one
  22211. */
  22212. subtract(other: Quaternion): Quaternion;
  22213. /**
  22214. * Multiplies the current quaternion by a scale factor
  22215. * @param value defines the scale factor
  22216. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22217. */
  22218. scale(value: number): Quaternion;
  22219. /**
  22220. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22221. * @param scale defines the scale factor
  22222. * @param result defines the Quaternion object where to store the result
  22223. * @returns the unmodified current quaternion
  22224. */
  22225. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22226. /**
  22227. * Multiplies in place the current quaternion by a scale factor
  22228. * @param value defines the scale factor
  22229. * @returns the current modified quaternion
  22230. */
  22231. scaleInPlace(value: number): Quaternion;
  22232. /**
  22233. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22234. * @param scale defines the scale factor
  22235. * @param result defines the Quaternion object where to store the result
  22236. * @returns the unmodified current quaternion
  22237. */
  22238. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22239. /**
  22240. * Multiplies two quaternions
  22241. * @param q1 defines the second operand
  22242. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22243. */
  22244. multiply(q1: Quaternion): Quaternion;
  22245. /**
  22246. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22247. * @param q1 defines the second operand
  22248. * @param result defines the target quaternion
  22249. * @returns the current quaternion
  22250. */
  22251. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  22252. /**
  22253. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22254. * @param q1 defines the second operand
  22255. * @returns the currentupdated quaternion
  22256. */
  22257. multiplyInPlace(q1: Quaternion): Quaternion;
  22258. /**
  22259. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22260. * @param ref defines the target quaternion
  22261. * @returns the current quaternion
  22262. */
  22263. conjugateToRef(ref: Quaternion): Quaternion;
  22264. /**
  22265. * Conjugates in place (1-q) the current quaternion
  22266. * @returns the current updated quaternion
  22267. */
  22268. conjugateInPlace(): Quaternion;
  22269. /**
  22270. * Conjugates in place (1-q) the current quaternion
  22271. * @returns a new quaternion
  22272. */
  22273. conjugate(): Quaternion;
  22274. /**
  22275. * Gets length of current quaternion
  22276. * @returns the quaternion length (float)
  22277. */
  22278. length(): number;
  22279. /**
  22280. * Normalize in place the current quaternion
  22281. * @returns the current updated quaternion
  22282. */
  22283. normalize(): Quaternion;
  22284. /**
  22285. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22286. * @param order is a reserved parameter and is ignore for now
  22287. * @returns a new Vector3 containing the Euler angles
  22288. */
  22289. toEulerAngles(order?: string): Vector3;
  22290. /**
  22291. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22292. * @param result defines the vector which will be filled with the Euler angles
  22293. * @param order is a reserved parameter and is ignore for now
  22294. * @returns the current unchanged quaternion
  22295. */
  22296. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22297. /**
  22298. * Updates the given rotation matrix with the current quaternion values
  22299. * @param result defines the target matrix
  22300. * @returns the current unchanged quaternion
  22301. */
  22302. toRotationMatrix(result: Matrix): Quaternion;
  22303. /**
  22304. * Updates the current quaternion from the given rotation matrix values
  22305. * @param matrix defines the source matrix
  22306. * @returns the current updated quaternion
  22307. */
  22308. fromRotationMatrix(matrix: Matrix): Quaternion;
  22309. /**
  22310. * Creates a new quaternion from a rotation matrix
  22311. * @param matrix defines the source matrix
  22312. * @returns a new quaternion created from the given rotation matrix values
  22313. */
  22314. static FromRotationMatrix(matrix: Matrix): Quaternion;
  22315. /**
  22316. * Updates the given quaternion with the given rotation matrix values
  22317. * @param matrix defines the source matrix
  22318. * @param result defines the target quaternion
  22319. */
  22320. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  22321. /**
  22322. * Returns the dot product (float) between the quaternions "left" and "right"
  22323. * @param left defines the left operand
  22324. * @param right defines the right operand
  22325. * @returns the dot product
  22326. */
  22327. static Dot(left: Quaternion, right: Quaternion): number;
  22328. /**
  22329. * Checks if the two quaternions are close to each other
  22330. * @param quat0 defines the first quaternion to check
  22331. * @param quat1 defines the second quaternion to check
  22332. * @returns true if the two quaternions are close to each other
  22333. */
  22334. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  22335. /**
  22336. * Creates an empty quaternion
  22337. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22338. */
  22339. static Zero(): Quaternion;
  22340. /**
  22341. * Inverse a given quaternion
  22342. * @param q defines the source quaternion
  22343. * @returns a new quaternion as the inverted current quaternion
  22344. */
  22345. static Inverse(q: Quaternion): Quaternion;
  22346. /**
  22347. * Creates an identity quaternion
  22348. * @returns the identity quaternion
  22349. */
  22350. static Identity(): Quaternion;
  22351. /**
  22352. * Gets a boolean indicating if the given quaternion is identity
  22353. * @param quaternion defines the quaternion to check
  22354. * @returns true if the quaternion is identity
  22355. */
  22356. static IsIdentity(quaternion: Quaternion): boolean;
  22357. /**
  22358. * Creates a quaternion from a rotation around an axis
  22359. * @param axis defines the axis to use
  22360. * @param angle defines the angle to use
  22361. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22362. */
  22363. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  22364. /**
  22365. * Creates a rotation around an axis and stores it into the given quaternion
  22366. * @param axis defines the axis to use
  22367. * @param angle defines the angle to use
  22368. * @param result defines the target quaternion
  22369. * @returns the target quaternion
  22370. */
  22371. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  22372. /**
  22373. * Creates a new quaternion from data stored into an array
  22374. * @param array defines the data source
  22375. * @param offset defines the offset in the source array where the data starts
  22376. * @returns a new quaternion
  22377. */
  22378. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  22379. /**
  22380. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22381. * @param yaw defines the rotation around Y axis
  22382. * @param pitch defines the rotation around X axis
  22383. * @param roll defines the rotation around Z axis
  22384. * @returns the new quaternion
  22385. */
  22386. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22387. /**
  22388. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22389. * @param yaw defines the rotation around Y axis
  22390. * @param pitch defines the rotation around X axis
  22391. * @param roll defines the rotation around Z axis
  22392. * @param result defines the target quaternion
  22393. */
  22394. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22395. /**
  22396. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22397. * @param alpha defines the rotation around first axis
  22398. * @param beta defines the rotation around second axis
  22399. * @param gamma defines the rotation around third axis
  22400. * @returns the new quaternion
  22401. */
  22402. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22403. /**
  22404. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22405. * @param alpha defines the rotation around first axis
  22406. * @param beta defines the rotation around second axis
  22407. * @param gamma defines the rotation around third axis
  22408. * @param result defines the target quaternion
  22409. */
  22410. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22411. /**
  22412. * 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)
  22413. * @param axis1 defines the first axis
  22414. * @param axis2 defines the second axis
  22415. * @param axis3 defines the third axis
  22416. * @returns the new quaternion
  22417. */
  22418. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  22419. /**
  22420. * 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
  22421. * @param axis1 defines the first axis
  22422. * @param axis2 defines the second axis
  22423. * @param axis3 defines the third axis
  22424. * @param ref defines the target quaternion
  22425. */
  22426. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  22427. /**
  22428. * Interpolates between two quaternions
  22429. * @param left defines first quaternion
  22430. * @param right defines second quaternion
  22431. * @param amount defines the gradient to use
  22432. * @returns the new interpolated quaternion
  22433. */
  22434. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  22435. /**
  22436. * Interpolates between two quaternions and stores it into a target quaternion
  22437. * @param left defines first quaternion
  22438. * @param right defines second quaternion
  22439. * @param amount defines the gradient to use
  22440. * @param result defines the target quaternion
  22441. */
  22442. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  22443. /**
  22444. * Interpolate between two quaternions using Hermite interpolation
  22445. * @param value1 defines first quaternion
  22446. * @param tangent1 defines the incoming tangent
  22447. * @param value2 defines second quaternion
  22448. * @param tangent2 defines the outgoing tangent
  22449. * @param amount defines the target quaternion
  22450. * @returns the new interpolated quaternion
  22451. */
  22452. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  22453. }
  22454. /**
  22455. * Class used to store matrix data (4x4)
  22456. */
  22457. class Matrix {
  22458. private static _tempQuaternion;
  22459. private static _xAxis;
  22460. private static _yAxis;
  22461. private static _zAxis;
  22462. private static _updateFlagSeed;
  22463. private static _identityReadOnly;
  22464. private _isIdentity;
  22465. private _isIdentityDirty;
  22466. /**
  22467. * Gets the update flag of the matrix which is an unique number for the matrix.
  22468. * It will be incremented every time the matrix data change.
  22469. * You can use it to speed the comparison between two versions of the same matrix.
  22470. */
  22471. updateFlag: number;
  22472. /**
  22473. * Gets or sets the internal data of the matrix
  22474. */
  22475. m: Float32Array;
  22476. /** @hidden */
  22477. _markAsUpdated(): void;
  22478. /**
  22479. * Creates an empty matrix (filled with zeros)
  22480. */
  22481. constructor();
  22482. /**
  22483. * Check if the current matrix is indentity
  22484. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  22485. * @returns true is the matrix is the identity matrix
  22486. */
  22487. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  22488. /**
  22489. * Gets the determinant of the matrix
  22490. * @returns the matrix determinant
  22491. */
  22492. determinant(): number;
  22493. /**
  22494. * Returns the matrix as a Float32Array
  22495. * @returns the matrix underlying array
  22496. */
  22497. toArray(): Float32Array;
  22498. /**
  22499. * Returns the matrix as a Float32Array
  22500. * @returns the matrix underlying array.
  22501. */
  22502. asArray(): Float32Array;
  22503. /**
  22504. * Inverts the current matrix in place
  22505. * @returns the current inverted matrix
  22506. */
  22507. invert(): Matrix;
  22508. /**
  22509. * Sets all the matrix elements to zero
  22510. * @returns the current matrix
  22511. */
  22512. reset(): Matrix;
  22513. /**
  22514. * Adds the current matrix with a second one
  22515. * @param other defines the matrix to add
  22516. * @returns a new matrix as the addition of the current matrix and the given one
  22517. */
  22518. add(other: Matrix): Matrix;
  22519. /**
  22520. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22521. * @param other defines the matrix to add
  22522. * @param result defines the target matrix
  22523. * @returns the current matrix
  22524. */
  22525. addToRef(other: Matrix, result: Matrix): Matrix;
  22526. /**
  22527. * Adds in place the given matrix to the current matrix
  22528. * @param other defines the second operand
  22529. * @returns the current updated matrix
  22530. */
  22531. addToSelf(other: Matrix): Matrix;
  22532. /**
  22533. * Sets the given matrix to the current inverted Matrix
  22534. * @param other defines the target matrix
  22535. * @returns the unmodified current matrix
  22536. */
  22537. invertToRef(other: Matrix): Matrix;
  22538. /**
  22539. * Inserts the translation vector (using 3 floats) in the current matrix
  22540. * @param x defines the 1st component of the translation
  22541. * @param y defines the 2nd component of the translation
  22542. * @param z defines the 3rd component of the translation
  22543. * @returns the current updated matrix
  22544. */
  22545. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22546. /**
  22547. * Inserts the translation vector in the current matrix
  22548. * @param vector3 defines the translation to insert
  22549. * @returns the current updated matrix
  22550. */
  22551. setTranslation(vector3: Vector3): Matrix;
  22552. /**
  22553. * Gets the translation value of the current matrix
  22554. * @returns a new Vector3 as the extracted translation from the matrix
  22555. */
  22556. getTranslation(): Vector3;
  22557. /**
  22558. * Fill a Vector3 with the extracted translation from the matrix
  22559. * @param result defines the Vector3 where to store the translation
  22560. * @returns the current matrix
  22561. */
  22562. getTranslationToRef(result: Vector3): Matrix;
  22563. /**
  22564. * Remove rotation and scaling part from the matrix
  22565. * @returns the updated matrix
  22566. */
  22567. removeRotationAndScaling(): Matrix;
  22568. /**
  22569. * Multiply two matrices
  22570. * @param other defines the second operand
  22571. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22572. */
  22573. multiply(other: Matrix): Matrix;
  22574. /**
  22575. * Copy the current matrix from the given one
  22576. * @param other defines the source matrix
  22577. * @returns the current updated matrix
  22578. */
  22579. copyFrom(other: Matrix): Matrix;
  22580. /**
  22581. * Populates the given array from the starting index with the current matrix values
  22582. * @param array defines the target array
  22583. * @param offset defines the offset in the target array where to start storing values
  22584. * @returns the current matrix
  22585. */
  22586. copyToArray(array: Float32Array, offset?: number): Matrix;
  22587. /**
  22588. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22589. * @param other defines the second operand
  22590. * @param result defines the matrix where to store the multiplication
  22591. * @returns the current matrix
  22592. */
  22593. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  22594. /**
  22595. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22596. * @param other defines the second operand
  22597. * @param result defines the array where to store the multiplication
  22598. * @param offset defines the offset in the target array where to start storing values
  22599. * @returns the current matrix
  22600. */
  22601. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  22602. /**
  22603. * Check equality between this matrix and a second one
  22604. * @param value defines the second matrix to compare
  22605. * @returns true is the current matrix and the given one values are strictly equal
  22606. */
  22607. equals(value: Matrix): boolean;
  22608. /**
  22609. * Clone the current matrix
  22610. * @returns a new matrix from the current matrix
  22611. */
  22612. clone(): Matrix;
  22613. /**
  22614. * Returns the name of the current matrix class
  22615. * @returns the string "Matrix"
  22616. */
  22617. getClassName(): string;
  22618. /**
  22619. * Gets the hash code of the current matrix
  22620. * @returns the hash code
  22621. */
  22622. getHashCode(): number;
  22623. /**
  22624. * Decomposes the current Matrix into a translation, rotation and scaling components
  22625. * @param scale defines the scale vector3 given as a reference to update
  22626. * @param rotation defines the rotation quaternion given as a reference to update
  22627. * @param translation defines the translation vector3 given as a reference to update
  22628. * @returns true if operation was successful
  22629. */
  22630. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22631. /**
  22632. * Gets specific row of the matrix
  22633. * @param index defines the number of the row to get
  22634. * @returns the index-th row of the current matrix as a new Vector4
  22635. */
  22636. getRow(index: number): Nullable<Vector4>;
  22637. /**
  22638. * Sets the index-th row of the current matrix to the vector4 values
  22639. * @param index defines the number of the row to set
  22640. * @param row defines the target vector4
  22641. * @returns the updated current matrix
  22642. */
  22643. setRow(index: number, row: Vector4): Matrix;
  22644. /**
  22645. * Compute the transpose of the matrix
  22646. * @returns the new transposed matrix
  22647. */
  22648. transpose(): Matrix;
  22649. /**
  22650. * Compute the transpose of the matrix and store it in a given matrix
  22651. * @param result defines the target matrix
  22652. * @returns the current matrix
  22653. */
  22654. transposeToRef(result: Matrix): Matrix;
  22655. /**
  22656. * Sets the index-th row of the current matrix with the given 4 x float values
  22657. * @param index defines the row index
  22658. * @param x defines the x component to set
  22659. * @param y defines the y component to set
  22660. * @param z defines the z component to set
  22661. * @param w defines the w component to set
  22662. * @returns the updated current matrix
  22663. */
  22664. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22665. /**
  22666. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22667. * @param scale defines the scale factor
  22668. * @returns a new matrix
  22669. */
  22670. scale(scale: number): Matrix;
  22671. /**
  22672. * Scale the current matrix values by a factor to a given result matrix
  22673. * @param scale defines the scale factor
  22674. * @param result defines the matrix to store the result
  22675. * @returns the current matrix
  22676. */
  22677. scaleToRef(scale: number, result: Matrix): Matrix;
  22678. /**
  22679. * Scale the current matrix values by a factor and add the result to a given matrix
  22680. * @param scale defines the scale factor
  22681. * @param result defines the Matrix to store the result
  22682. * @returns the current matrix
  22683. */
  22684. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22685. /**
  22686. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22687. * @param ref matrix to store the result
  22688. */
  22689. toNormalMatrix(ref: Matrix): void;
  22690. /**
  22691. * Gets only rotation part of the current matrix
  22692. * @returns a new matrix sets to the extracted rotation matrix from the current one
  22693. */
  22694. getRotationMatrix(): Matrix;
  22695. /**
  22696. * Extracts the rotation matrix from the current one and sets it as the given "result"
  22697. * @param result defines the target matrix to store data to
  22698. * @returns the current matrix
  22699. */
  22700. getRotationMatrixToRef(result: Matrix): Matrix;
  22701. /**
  22702. * Creates a matrix from an array
  22703. * @param array defines the source array
  22704. * @param offset defines an offset in the source array
  22705. * @returns a new Matrix set from the starting index of the given array
  22706. */
  22707. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  22708. /**
  22709. * Copy the content of an array into a given matrix
  22710. * @param array defines the source array
  22711. * @param offset defines an offset in the source array
  22712. * @param result defines the target matrix
  22713. */
  22714. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  22715. /**
  22716. * Stores an array into a matrix after having multiplied each component by a given factor
  22717. * @param array defines the source array
  22718. * @param offset defines the offset in the source array
  22719. * @param scale defines the scaling factor
  22720. * @param result defines the target matrix
  22721. */
  22722. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  22723. /**
  22724. * Stores a list of values (16) inside a given matrix
  22725. * @param initialM11 defines 1st value of 1st row
  22726. * @param initialM12 defines 2nd value of 1st row
  22727. * @param initialM13 defines 3rd value of 1st row
  22728. * @param initialM14 defines 4th value of 1st row
  22729. * @param initialM21 defines 1st value of 2nd row
  22730. * @param initialM22 defines 2nd value of 2nd row
  22731. * @param initialM23 defines 3rd value of 2nd row
  22732. * @param initialM24 defines 4th value of 2nd row
  22733. * @param initialM31 defines 1st value of 3rd row
  22734. * @param initialM32 defines 2nd value of 3rd row
  22735. * @param initialM33 defines 3rd value of 3rd row
  22736. * @param initialM34 defines 4th value of 3rd row
  22737. * @param initialM41 defines 1st value of 4th row
  22738. * @param initialM42 defines 2nd value of 4th row
  22739. * @param initialM43 defines 3rd value of 4th row
  22740. * @param initialM44 defines 4th value of 4th row
  22741. * @param result defines the target matrix
  22742. */
  22743. 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;
  22744. /**
  22745. * Gets an identity matrix that must not be updated
  22746. */
  22747. static readonly IdentityReadOnly: Matrix;
  22748. /**
  22749. * Creates new matrix from a list of values (16)
  22750. * @param initialM11 defines 1st value of 1st row
  22751. * @param initialM12 defines 2nd value of 1st row
  22752. * @param initialM13 defines 3rd value of 1st row
  22753. * @param initialM14 defines 4th value of 1st row
  22754. * @param initialM21 defines 1st value of 2nd row
  22755. * @param initialM22 defines 2nd value of 2nd row
  22756. * @param initialM23 defines 3rd value of 2nd row
  22757. * @param initialM24 defines 4th value of 2nd row
  22758. * @param initialM31 defines 1st value of 3rd row
  22759. * @param initialM32 defines 2nd value of 3rd row
  22760. * @param initialM33 defines 3rd value of 3rd row
  22761. * @param initialM34 defines 4th value of 3rd row
  22762. * @param initialM41 defines 1st value of 4th row
  22763. * @param initialM42 defines 2nd value of 4th row
  22764. * @param initialM43 defines 3rd value of 4th row
  22765. * @param initialM44 defines 4th value of 4th row
  22766. * @returns the new matrix
  22767. */
  22768. 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;
  22769. /**
  22770. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22771. * @param scale defines the scale vector3
  22772. * @param rotation defines the rotation quaternion
  22773. * @param translation defines the translation vector3
  22774. * @returns a new matrix
  22775. */
  22776. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  22777. /**
  22778. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  22779. * @param scale defines the scale vector3
  22780. * @param rotation defines the rotation quaternion
  22781. * @param translation defines the translation vector3
  22782. * @param result defines the target matrix
  22783. */
  22784. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  22785. /**
  22786. * Creates a new identity matrix
  22787. * @returns a new identity matrix
  22788. */
  22789. static Identity(): Matrix;
  22790. /**
  22791. * Creates a new identity matrix and stores the result in a given matrix
  22792. * @param result defines the target matrix
  22793. */
  22794. static IdentityToRef(result: Matrix): void;
  22795. /**
  22796. * Creates a new zero matrix
  22797. * @returns a new zero matrix
  22798. */
  22799. static Zero(): Matrix;
  22800. /**
  22801. * Creates a new rotation matrix for "angle" radians around the X axis
  22802. * @param angle defines the angle (in radians) to use
  22803. * @return the new matrix
  22804. */
  22805. static RotationX(angle: number): Matrix;
  22806. /**
  22807. * Creates a new matrix as the invert of a given matrix
  22808. * @param source defines the source matrix
  22809. * @returns the new matrix
  22810. */
  22811. static Invert(source: Matrix): Matrix;
  22812. /**
  22813. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  22814. * @param angle defines the angle (in radians) to use
  22815. * @param result defines the target matrix
  22816. */
  22817. static RotationXToRef(angle: number, result: Matrix): void;
  22818. /**
  22819. * Creates a new rotation matrix for "angle" radians around the Y axis
  22820. * @param angle defines the angle (in radians) to use
  22821. * @return the new matrix
  22822. */
  22823. static RotationY(angle: number): Matrix;
  22824. /**
  22825. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  22826. * @param angle defines the angle (in radians) to use
  22827. * @param result defines the target matrix
  22828. */
  22829. static RotationYToRef(angle: number, result: Matrix): void;
  22830. /**
  22831. * Creates a new rotation matrix for "angle" radians around the Z axis
  22832. * @param angle defines the angle (in radians) to use
  22833. * @return the new matrix
  22834. */
  22835. static RotationZ(angle: number): Matrix;
  22836. /**
  22837. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  22838. * @param angle defines the angle (in radians) to use
  22839. * @param result defines the target matrix
  22840. */
  22841. static RotationZToRef(angle: number, result: Matrix): void;
  22842. /**
  22843. * Creates a new rotation matrix for "angle" radians around the given axis
  22844. * @param axis defines the axis to use
  22845. * @param angle defines the angle (in radians) to use
  22846. * @return the new matrix
  22847. */
  22848. static RotationAxis(axis: Vector3, angle: number): Matrix;
  22849. /**
  22850. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  22851. * @param axis defines the axis to use
  22852. * @param angle defines the angle (in radians) to use
  22853. * @param result defines the target matrix
  22854. */
  22855. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  22856. /**
  22857. * Creates a rotation matrix
  22858. * @param yaw defines the yaw angle in radians (Y axis)
  22859. * @param pitch defines the pitch angle in radians (X axis)
  22860. * @param roll defines the roll angle in radians (X axis)
  22861. * @returns the new rotation matrix
  22862. */
  22863. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  22864. /**
  22865. * Creates a rotation matrix and stores it in a given matrix
  22866. * @param yaw defines the yaw angle in radians (Y axis)
  22867. * @param pitch defines the pitch angle in radians (X axis)
  22868. * @param roll defines the roll angle in radians (X axis)
  22869. * @param result defines the target matrix
  22870. */
  22871. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  22872. /**
  22873. * Creates a scaling matrix
  22874. * @param x defines the scale factor on X axis
  22875. * @param y defines the scale factor on Y axis
  22876. * @param z defines the scale factor on Z axis
  22877. * @returns the new matrix
  22878. */
  22879. static Scaling(x: number, y: number, z: number): Matrix;
  22880. /**
  22881. * Creates a scaling matrix and stores it in a given matrix
  22882. * @param x defines the scale factor on X axis
  22883. * @param y defines the scale factor on Y axis
  22884. * @param z defines the scale factor on Z axis
  22885. * @param result defines the target matrix
  22886. */
  22887. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  22888. /**
  22889. * Creates a translation matrix
  22890. * @param x defines the translation on X axis
  22891. * @param y defines the translation on Y axis
  22892. * @param z defines the translationon Z axis
  22893. * @returns the new matrix
  22894. */
  22895. static Translation(x: number, y: number, z: number): Matrix;
  22896. /**
  22897. * Creates a translation matrix and stores it in a given matrix
  22898. * @param x defines the translation on X axis
  22899. * @param y defines the translation on Y axis
  22900. * @param z defines the translationon Z axis
  22901. * @param result defines the target matrix
  22902. */
  22903. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  22904. /**
  22905. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22906. * @param startValue defines the start value
  22907. * @param endValue defines the end value
  22908. * @param gradient defines the gradient factor
  22909. * @returns the new matrix
  22910. */
  22911. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22912. /**
  22913. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  22914. * @param startValue defines the start value
  22915. * @param endValue defines the end value
  22916. * @param gradient defines the gradient factor
  22917. * @param result defines the Matrix object where to store data
  22918. */
  22919. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22920. /**
  22921. * Builds a new matrix whose values are computed by:
  22922. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22923. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22924. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22925. * @param startValue defines the first matrix
  22926. * @param endValue defines the second matrix
  22927. * @param gradient defines the gradient between the two matrices
  22928. * @returns the new matrix
  22929. */
  22930. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  22931. /**
  22932. * Update a matrix to values which are computed by:
  22933. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  22934. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  22935. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  22936. * @param startValue defines the first matrix
  22937. * @param endValue defines the second matrix
  22938. * @param gradient defines the gradient between the two matrices
  22939. * @param result defines the target matrix
  22940. */
  22941. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  22942. /**
  22943. * 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"
  22944. * This function works in left handed mode
  22945. * @param eye defines the final position of the entity
  22946. * @param target defines where the entity should look at
  22947. * @param up defines the up vector for the entity
  22948. * @returns the new matrix
  22949. */
  22950. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22951. /**
  22952. * 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".
  22953. * This function works in left handed mode
  22954. * @param eye defines the final position of the entity
  22955. * @param target defines where the entity should look at
  22956. * @param up defines the up vector for the entity
  22957. * @param result defines the target matrix
  22958. */
  22959. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22960. /**
  22961. * 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"
  22962. * This function works in right handed mode
  22963. * @param eye defines the final position of the entity
  22964. * @param target defines where the entity should look at
  22965. * @param up defines the up vector for the entity
  22966. * @returns the new matrix
  22967. */
  22968. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  22969. /**
  22970. * 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".
  22971. * This function works in right handed mode
  22972. * @param eye defines the final position of the entity
  22973. * @param target defines where the entity should look at
  22974. * @param up defines the up vector for the entity
  22975. * @param result defines the target matrix
  22976. */
  22977. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  22978. /**
  22979. * Create a left-handed orthographic projection matrix
  22980. * @param width defines the viewport width
  22981. * @param height defines the viewport height
  22982. * @param znear defines the near clip plane
  22983. * @param zfar defines the far clip plane
  22984. * @returns a new matrix as a left-handed orthographic projection matrix
  22985. */
  22986. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  22987. /**
  22988. * Store a left-handed orthographic projection to a given matrix
  22989. * @param width defines the viewport width
  22990. * @param height defines the viewport height
  22991. * @param znear defines the near clip plane
  22992. * @param zfar defines the far clip plane
  22993. * @param result defines the target matrix
  22994. */
  22995. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  22996. /**
  22997. * Create a left-handed orthographic projection matrix
  22998. * @param left defines the viewport left coordinate
  22999. * @param right defines the viewport right coordinate
  23000. * @param bottom defines the viewport bottom coordinate
  23001. * @param top defines the viewport top coordinate
  23002. * @param znear defines the near clip plane
  23003. * @param zfar defines the far clip plane
  23004. * @returns a new matrix as a left-handed orthographic projection matrix
  23005. */
  23006. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23007. /**
  23008. * Stores a left-handed orthographic projection into a given matrix
  23009. * @param left defines the viewport left coordinate
  23010. * @param right defines the viewport right coordinate
  23011. * @param bottom defines the viewport bottom coordinate
  23012. * @param top defines the viewport top coordinate
  23013. * @param znear defines the near clip plane
  23014. * @param zfar defines the far clip plane
  23015. * @param result defines the target matrix
  23016. */
  23017. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23018. /**
  23019. * Creates a right-handed orthographic projection matrix
  23020. * @param left defines the viewport left coordinate
  23021. * @param right defines the viewport right coordinate
  23022. * @param bottom defines the viewport bottom coordinate
  23023. * @param top defines the viewport top coordinate
  23024. * @param znear defines the near clip plane
  23025. * @param zfar defines the far clip plane
  23026. * @returns a new matrix as a right-handed orthographic projection matrix
  23027. */
  23028. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23029. /**
  23030. * Stores a right-handed orthographic projection into a given matrix
  23031. * @param left defines the viewport left coordinate
  23032. * @param right defines the viewport right coordinate
  23033. * @param bottom defines the viewport bottom coordinate
  23034. * @param top defines the viewport top coordinate
  23035. * @param znear defines the near clip plane
  23036. * @param zfar defines the far clip plane
  23037. * @param result defines the target matrix
  23038. */
  23039. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23040. /**
  23041. * Creates a left-handed perspective projection matrix
  23042. * @param width defines the viewport width
  23043. * @param height defines the viewport height
  23044. * @param znear defines the near clip plane
  23045. * @param zfar defines the far clip plane
  23046. * @returns a new matrix as a left-handed perspective projection matrix
  23047. */
  23048. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23049. /**
  23050. * Creates a left-handed perspective projection matrix
  23051. * @param fov defines the horizontal field of view
  23052. * @param aspect defines the aspect ratio
  23053. * @param znear defines the near clip plane
  23054. * @param zfar defines the far clip plane
  23055. * @returns a new matrix as a left-handed perspective projection matrix
  23056. */
  23057. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23058. /**
  23059. * Stores a left-handed perspective projection into a given matrix
  23060. * @param fov defines the horizontal field of view
  23061. * @param aspect defines the aspect ratio
  23062. * @param znear defines the near clip plane
  23063. * @param zfar defines the far clip plane
  23064. * @param result defines the target matrix
  23065. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23066. */
  23067. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23068. /**
  23069. * Creates a right-handed perspective projection matrix
  23070. * @param fov defines the horizontal field of view
  23071. * @param aspect defines the aspect ratio
  23072. * @param znear defines the near clip plane
  23073. * @param zfar defines the far clip plane
  23074. * @returns a new matrix as a right-handed perspective projection matrix
  23075. */
  23076. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23077. /**
  23078. * Stores a right-handed perspective projection into a given matrix
  23079. * @param fov defines the horizontal field of view
  23080. * @param aspect defines the aspect ratio
  23081. * @param znear defines the near clip plane
  23082. * @param zfar defines the far clip plane
  23083. * @param result defines the target matrix
  23084. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23085. */
  23086. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23087. /**
  23088. * Stores a perspective projection for WebVR info a given matrix
  23089. * @param fov defines the field of view
  23090. * @param znear defines the near clip plane
  23091. * @param zfar defines the far clip plane
  23092. * @param result defines the target matrix
  23093. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23094. */
  23095. static PerspectiveFovWebVRToRef(fov: {
  23096. upDegrees: number;
  23097. downDegrees: number;
  23098. leftDegrees: number;
  23099. rightDegrees: number;
  23100. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23101. /**
  23102. * Computes a complete transformation matrix
  23103. * @param viewport defines the viewport to use
  23104. * @param world defines the world matrix
  23105. * @param view defines the view matrix
  23106. * @param projection defines the projection matrix
  23107. * @param zmin defines the near clip plane
  23108. * @param zmax defines the far clip plane
  23109. * @returns the transformation matrix
  23110. */
  23111. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  23112. /**
  23113. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23114. * @param matrix defines the matrix to use
  23115. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23116. */
  23117. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  23118. /**
  23119. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23120. * @param matrix defines the matrix to use
  23121. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23122. */
  23123. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  23124. /**
  23125. * Compute the transpose of a given matrix
  23126. * @param matrix defines the matrix to transpose
  23127. * @returns the new matrix
  23128. */
  23129. static Transpose(matrix: Matrix): Matrix;
  23130. /**
  23131. * Compute the transpose of a matrix and store it in a target matrix
  23132. * @param matrix defines the matrix to transpose
  23133. * @param result defines the target matrix
  23134. */
  23135. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  23136. /**
  23137. * Computes a reflection matrix from a plane
  23138. * @param plane defines the reflection plane
  23139. * @returns a new matrix
  23140. */
  23141. static Reflection(plane: Plane): Matrix;
  23142. /**
  23143. * Computes a reflection matrix from a plane
  23144. * @param plane defines the reflection plane
  23145. * @param result defines the target matrix
  23146. */
  23147. static ReflectionToRef(plane: Plane, result: Matrix): void;
  23148. /**
  23149. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23150. * @param xaxis defines the value of the 1st axis
  23151. * @param yaxis defines the value of the 2nd axis
  23152. * @param zaxis defines the value of the 3rd axis
  23153. * @param result defines the target matrix
  23154. */
  23155. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  23156. /**
  23157. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23158. * @param quat defines the quaternion to use
  23159. * @param result defines the target matrix
  23160. */
  23161. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  23162. }
  23163. /**
  23164. * Represens a plane by the equation ax + by + cz + d = 0
  23165. */
  23166. class Plane {
  23167. /**
  23168. * Normal of the plane (a,b,c)
  23169. */
  23170. normal: Vector3;
  23171. /**
  23172. * d component of the plane
  23173. */
  23174. d: number;
  23175. /**
  23176. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23177. * @param a a component of the plane
  23178. * @param b b component of the plane
  23179. * @param c c component of the plane
  23180. * @param d d component of the plane
  23181. */
  23182. constructor(a: number, b: number, c: number, d: number);
  23183. /**
  23184. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23185. */
  23186. asArray(): number[];
  23187. /**
  23188. * @returns a new plane copied from the current Plane.
  23189. */
  23190. clone(): Plane;
  23191. /**
  23192. * @returns the string "Plane".
  23193. */
  23194. getClassName(): string;
  23195. /**
  23196. * @returns the Plane hash code.
  23197. */
  23198. getHashCode(): number;
  23199. /**
  23200. * Normalize the current Plane in place.
  23201. * @returns the updated Plane.
  23202. */
  23203. normalize(): Plane;
  23204. /**
  23205. * Applies a transformation the plane and returns the result
  23206. * @param transformation the transformation matrix to be applied to the plane
  23207. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23208. */
  23209. transform(transformation: Matrix): Plane;
  23210. /**
  23211. * Calcualtte the dot product between the point and the plane normal
  23212. * @param point point to calculate the dot product with
  23213. * @returns the dot product (float) of the point coordinates and the plane normal.
  23214. */
  23215. dotCoordinate(point: Vector3): number;
  23216. /**
  23217. * Updates the current Plane from the plane defined by the three given points.
  23218. * @param point1 one of the points used to contruct the plane
  23219. * @param point2 one of the points used to contruct the plane
  23220. * @param point3 one of the points used to contruct the plane
  23221. * @returns the updated Plane.
  23222. */
  23223. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23224. /**
  23225. * Checks if the plane is facing a given direction
  23226. * @param direction the direction to check if the plane is facing
  23227. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23228. * @returns True is the vector "direction" is the same side than the plane normal.
  23229. */
  23230. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  23231. /**
  23232. * Calculates the distance to a point
  23233. * @param point point to calculate distance to
  23234. * @returns the signed distance (float) from the given point to the Plane.
  23235. */
  23236. signedDistanceTo(point: Vector3): number;
  23237. /**
  23238. * Creates a plane from an array
  23239. * @param array the array to create a plane from
  23240. * @returns a new Plane from the given array.
  23241. */
  23242. static FromArray(array: ArrayLike<number>): Plane;
  23243. /**
  23244. * Creates a plane from three points
  23245. * @param point1 point used to create the plane
  23246. * @param point2 point used to create the plane
  23247. * @param point3 point used to create the plane
  23248. * @returns a new Plane defined by the three given points.
  23249. */
  23250. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  23251. /**
  23252. * Creates a plane from an origin point and a normal
  23253. * @param origin origin of the plane to be constructed
  23254. * @param normal normal of the plane to be constructed
  23255. * @returns a new Plane the normal vector to this plane at the given origin point.
  23256. * Note : the vector "normal" is updated because normalized.
  23257. */
  23258. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  23259. /**
  23260. * Calculates the distance from a plane and a point
  23261. * @param origin origin of the plane to be constructed
  23262. * @param normal normal of the plane to be constructed
  23263. * @param point point to calculate distance to
  23264. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23265. */
  23266. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  23267. }
  23268. /**
  23269. * Class used to represent a viewport on screen
  23270. */
  23271. class Viewport {
  23272. /** viewport left coordinate */
  23273. x: number;
  23274. /** viewport top coordinate */
  23275. y: number;
  23276. /**viewport width */
  23277. width: number;
  23278. /** viewport height */
  23279. height: number;
  23280. /**
  23281. * Creates a Viewport object located at (x, y) and sized (width, height)
  23282. * @param x defines viewport left coordinate
  23283. * @param y defines viewport top coordinate
  23284. * @param width defines the viewport width
  23285. * @param height defines the viewport height
  23286. */
  23287. constructor(
  23288. /** viewport left coordinate */
  23289. x: number,
  23290. /** viewport top coordinate */
  23291. y: number,
  23292. /**viewport width */
  23293. width: number,
  23294. /** viewport height */
  23295. height: number);
  23296. /**
  23297. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23298. * @param renderWidthOrEngine defines either an engine or the rendering width
  23299. * @param renderHeight defines the rendering height
  23300. * @returns a new Viewport
  23301. */
  23302. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23303. /**
  23304. * Returns a new Viewport copied from the current one
  23305. * @returns a new Viewport
  23306. */
  23307. clone(): Viewport;
  23308. }
  23309. /**
  23310. * Reprasents a camera frustum
  23311. */
  23312. class Frustum {
  23313. /**
  23314. * Gets the planes representing the frustum
  23315. * @param transform matrix to be applied to the returned planes
  23316. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23317. */
  23318. static GetPlanes(transform: Matrix): Plane[];
  23319. /**
  23320. * Gets the near frustum plane transformed by the transform matrix
  23321. * @param transform transformation matrix to be applied to the resulting frustum plane
  23322. * @param frustumPlane the resuling frustum plane
  23323. */
  23324. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23325. /**
  23326. * Gets the far frustum plane transformed by the transform matrix
  23327. * @param transform transformation matrix to be applied to the resulting frustum plane
  23328. * @param frustumPlane the resuling frustum plane
  23329. */
  23330. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23331. /**
  23332. * Gets the left frustum plane transformed by the transform matrix
  23333. * @param transform transformation matrix to be applied to the resulting frustum plane
  23334. * @param frustumPlane the resuling frustum plane
  23335. */
  23336. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23337. /**
  23338. * Gets the right frustum plane transformed by the transform matrix
  23339. * @param transform transformation matrix to be applied to the resulting frustum plane
  23340. * @param frustumPlane the resuling frustum plane
  23341. */
  23342. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23343. /**
  23344. * Gets the top frustum plane transformed by the transform matrix
  23345. * @param transform transformation matrix to be applied to the resulting frustum plane
  23346. * @param frustumPlane the resuling frustum plane
  23347. */
  23348. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23349. /**
  23350. * Gets the bottom frustum plane transformed by the transform matrix
  23351. * @param transform transformation matrix to be applied to the resulting frustum plane
  23352. * @param frustumPlane the resuling frustum plane
  23353. */
  23354. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  23355. /**
  23356. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23357. * @param transform transformation matrix to be applied to the resulting frustum planes
  23358. * @param frustumPlanes the resuling frustum planes
  23359. */
  23360. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  23361. }
  23362. /** Defines supported spaces */
  23363. enum Space {
  23364. /** Local (object) space */
  23365. LOCAL = 0,
  23366. /** World space */
  23367. WORLD = 1,
  23368. /** Bone space */
  23369. BONE = 2
  23370. }
  23371. /** Defines the 3 main axes */
  23372. class Axis {
  23373. /** X axis */
  23374. static X: Vector3;
  23375. /** Y axis */
  23376. static Y: Vector3;
  23377. /** Z axis */
  23378. static Z: Vector3;
  23379. }
  23380. /** Class used to represent a Bezier curve */
  23381. class BezierCurve {
  23382. /**
  23383. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23384. * @param t defines the time
  23385. * @param x1 defines the left coordinate on X axis
  23386. * @param y1 defines the left coordinate on Y axis
  23387. * @param x2 defines the right coordinate on X axis
  23388. * @param y2 defines the right coordinate on Y axis
  23389. * @returns the interpolated value
  23390. */
  23391. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23392. }
  23393. /**
  23394. * Defines potential orientation for back face culling
  23395. */
  23396. enum Orientation {
  23397. /**
  23398. * Clockwise
  23399. */
  23400. CW = 0,
  23401. /** Counter clockwise */
  23402. CCW = 1
  23403. }
  23404. /**
  23405. * Defines angle representation
  23406. */
  23407. class Angle {
  23408. private _radians;
  23409. /**
  23410. * Creates an Angle object of "radians" radians (float).
  23411. */
  23412. constructor(radians: number);
  23413. /**
  23414. * Get value in degrees
  23415. * @returns the Angle value in degrees (float)
  23416. */
  23417. degrees(): number;
  23418. /**
  23419. * Get value in radians
  23420. * @returns the Angle value in radians (float)
  23421. */
  23422. radians(): number;
  23423. /**
  23424. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23425. * @param a defines first vector
  23426. * @param b defines second vector
  23427. * @returns a new Angle
  23428. */
  23429. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  23430. /**
  23431. * Gets a new Angle object from the given float in radians
  23432. * @param radians defines the angle value in radians
  23433. * @returns a new Angle
  23434. */
  23435. static FromRadians(radians: number): Angle;
  23436. /**
  23437. * Gets a new Angle object from the given float in degrees
  23438. * @param degrees defines the angle value in degrees
  23439. * @returns a new Angle
  23440. */
  23441. static FromDegrees(degrees: number): Angle;
  23442. }
  23443. /**
  23444. * This represents an arc in a 2d space.
  23445. */
  23446. class Arc2 {
  23447. /** Defines the start point of the arc */
  23448. startPoint: Vector2;
  23449. /** Defines the mid point of the arc */
  23450. midPoint: Vector2;
  23451. /** Defines the end point of the arc */
  23452. endPoint: Vector2;
  23453. /**
  23454. * Defines the center point of the arc.
  23455. */
  23456. centerPoint: Vector2;
  23457. /**
  23458. * Defines the radius of the arc.
  23459. */
  23460. radius: number;
  23461. /**
  23462. * Defines the angle of the arc (from mid point to end point).
  23463. */
  23464. angle: Angle;
  23465. /**
  23466. * Defines the start angle of the arc (from start point to middle point).
  23467. */
  23468. startAngle: Angle;
  23469. /**
  23470. * Defines the orientation of the arc (clock wise/counter clock wise).
  23471. */
  23472. orientation: Orientation;
  23473. /**
  23474. * Creates an Arc object from the three given points : start, middle and end.
  23475. * @param startPoint Defines the start point of the arc
  23476. * @param midPoint Defines the midlle point of the arc
  23477. * @param endPoint Defines the end point of the arc
  23478. */
  23479. constructor(
  23480. /** Defines the start point of the arc */
  23481. startPoint: Vector2,
  23482. /** Defines the mid point of the arc */
  23483. midPoint: Vector2,
  23484. /** Defines the end point of the arc */
  23485. endPoint: Vector2);
  23486. }
  23487. /**
  23488. * Represents a 2D path made up of multiple 2D points
  23489. */
  23490. class Path2 {
  23491. private _points;
  23492. private _length;
  23493. /**
  23494. * If the path start and end point are the same
  23495. */
  23496. closed: boolean;
  23497. /**
  23498. * Creates a Path2 object from the starting 2D coordinates x and y.
  23499. * @param x the starting points x value
  23500. * @param y the starting points y value
  23501. */
  23502. constructor(x: number, y: number);
  23503. /**
  23504. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23505. * @param x the added points x value
  23506. * @param y the added points y value
  23507. * @returns the updated Path2.
  23508. */
  23509. addLineTo(x: number, y: number): Path2;
  23510. /**
  23511. * 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.
  23512. * @param midX middle point x value
  23513. * @param midY middle point y value
  23514. * @param endX end point x value
  23515. * @param endY end point y value
  23516. * @param numberOfSegments (default: 36)
  23517. * @returns the updated Path2.
  23518. */
  23519. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23520. /**
  23521. * Closes the Path2.
  23522. * @returns the Path2.
  23523. */
  23524. close(): Path2;
  23525. /**
  23526. * Gets the sum of the distance between each sequential point in the path
  23527. * @returns the Path2 total length (float).
  23528. */
  23529. length(): number;
  23530. /**
  23531. * Gets the points which construct the path
  23532. * @returns the Path2 internal array of points.
  23533. */
  23534. getPoints(): Vector2[];
  23535. /**
  23536. * Retreives the point at the distance aways from the starting point
  23537. * @param normalizedLengthPosition the length along the path to retreive the point from
  23538. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23539. */
  23540. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23541. /**
  23542. * Creates a new path starting from an x and y position
  23543. * @param x starting x value
  23544. * @param y starting y value
  23545. * @returns a new Path2 starting at the coordinates (x, y).
  23546. */
  23547. static StartingAt(x: number, y: number): Path2;
  23548. }
  23549. /**
  23550. * Represents a 3D path made up of multiple 3D points
  23551. */
  23552. class Path3D {
  23553. /**
  23554. * an array of Vector3, the curve axis of the Path3D
  23555. */
  23556. path: Vector3[];
  23557. private _curve;
  23558. private _distances;
  23559. private _tangents;
  23560. private _normals;
  23561. private _binormals;
  23562. private _raw;
  23563. /**
  23564. * new Path3D(path, normal, raw)
  23565. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23566. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23567. * @param path an array of Vector3, the curve axis of the Path3D
  23568. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23569. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23570. */
  23571. constructor(
  23572. /**
  23573. * an array of Vector3, the curve axis of the Path3D
  23574. */
  23575. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23576. /**
  23577. * Returns the Path3D array of successive Vector3 designing its curve.
  23578. * @returns the Path3D array of successive Vector3 designing its curve.
  23579. */
  23580. getCurve(): Vector3[];
  23581. /**
  23582. * Returns an array populated with tangent vectors on each Path3D curve point.
  23583. * @returns an array populated with tangent vectors on each Path3D curve point.
  23584. */
  23585. getTangents(): Vector3[];
  23586. /**
  23587. * Returns an array populated with normal vectors on each Path3D curve point.
  23588. * @returns an array populated with normal vectors on each Path3D curve point.
  23589. */
  23590. getNormals(): Vector3[];
  23591. /**
  23592. * Returns an array populated with binormal vectors on each Path3D curve point.
  23593. * @returns an array populated with binormal vectors on each Path3D curve point.
  23594. */
  23595. getBinormals(): Vector3[];
  23596. /**
  23597. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23598. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23599. */
  23600. getDistances(): number[];
  23601. /**
  23602. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23603. * @param path path which all values are copied into the curves points
  23604. * @param firstNormal which should be projected onto the curve
  23605. * @returns the same object updated.
  23606. */
  23607. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23608. private _compute;
  23609. private _getFirstNonNullVector;
  23610. private _getLastNonNullVector;
  23611. private _normalVector;
  23612. }
  23613. /**
  23614. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23615. * A Curve3 is designed from a series of successive Vector3.
  23616. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23617. */
  23618. class Curve3 {
  23619. private _points;
  23620. private _length;
  23621. /**
  23622. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23623. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23624. * @param v1 (Vector3) the control point
  23625. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23626. * @param nbPoints (integer) the wanted number of points in the curve
  23627. * @returns the created Curve3
  23628. */
  23629. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  23630. /**
  23631. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23632. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23633. * @param v1 (Vector3) the first control point
  23634. * @param v2 (Vector3) the second control point
  23635. * @param v3 (Vector3) the end point of the Cubic Bezier
  23636. * @param nbPoints (integer) the wanted number of points in the curve
  23637. * @returns the created Curve3
  23638. */
  23639. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  23640. /**
  23641. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23642. * @param p1 (Vector3) the origin point of the Hermite Spline
  23643. * @param t1 (Vector3) the tangent vector at the origin point
  23644. * @param p2 (Vector3) the end point of the Hermite Spline
  23645. * @param t2 (Vector3) the tangent vector at the end point
  23646. * @param nbPoints (integer) the wanted number of points in the curve
  23647. * @returns the created Curve3
  23648. */
  23649. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  23650. /**
  23651. * Returns a Curve3 object along a CatmullRom Spline curve :
  23652. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23653. * @param nbPoints (integer) the wanted number of points between each curve control points
  23654. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23655. * @returns the created Curve3
  23656. */
  23657. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  23658. /**
  23659. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23660. * A Curve3 is designed from a series of successive Vector3.
  23661. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23662. * @param points points which make up the curve
  23663. */
  23664. constructor(points: Vector3[]);
  23665. /**
  23666. * @returns the Curve3 stored array of successive Vector3
  23667. */
  23668. getPoints(): Vector3[];
  23669. /**
  23670. * @returns the computed length (float) of the curve.
  23671. */
  23672. length(): number;
  23673. /**
  23674. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23675. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23676. * curveA and curveB keep unchanged.
  23677. * @param curve the curve to continue from this curve
  23678. * @returns the newly constructed curve
  23679. */
  23680. continue(curve: Curve3): Curve3;
  23681. private _computeLength;
  23682. }
  23683. /**
  23684. * Contains position and normal vectors for a vertex
  23685. */
  23686. class PositionNormalVertex {
  23687. /** the position of the vertex (defaut: 0,0,0) */
  23688. position: Vector3;
  23689. /** the normal of the vertex (defaut: 0,1,0) */
  23690. normal: Vector3;
  23691. /**
  23692. * Creates a PositionNormalVertex
  23693. * @param position the position of the vertex (defaut: 0,0,0)
  23694. * @param normal the normal of the vertex (defaut: 0,1,0)
  23695. */
  23696. constructor(
  23697. /** the position of the vertex (defaut: 0,0,0) */
  23698. position?: Vector3,
  23699. /** the normal of the vertex (defaut: 0,1,0) */
  23700. normal?: Vector3);
  23701. /**
  23702. * Clones the PositionNormalVertex
  23703. * @returns the cloned PositionNormalVertex
  23704. */
  23705. clone(): PositionNormalVertex;
  23706. }
  23707. /**
  23708. * Contains position, normal and uv vectors for a vertex
  23709. */
  23710. class PositionNormalTextureVertex {
  23711. /** the position of the vertex (defaut: 0,0,0) */
  23712. position: Vector3;
  23713. /** the normal of the vertex (defaut: 0,1,0) */
  23714. normal: Vector3;
  23715. /** the uv of the vertex (default: 0,0) */
  23716. uv: Vector2;
  23717. /**
  23718. * Creates a PositionNormalTextureVertex
  23719. * @param position the position of the vertex (defaut: 0,0,0)
  23720. * @param normal the normal of the vertex (defaut: 0,1,0)
  23721. * @param uv the uv of the vertex (default: 0,0)
  23722. */
  23723. constructor(
  23724. /** the position of the vertex (defaut: 0,0,0) */
  23725. position?: Vector3,
  23726. /** the normal of the vertex (defaut: 0,1,0) */
  23727. normal?: Vector3,
  23728. /** the uv of the vertex (default: 0,0) */
  23729. uv?: Vector2);
  23730. /**
  23731. * Clones the PositionNormalTextureVertex
  23732. * @returns the cloned PositionNormalTextureVertex
  23733. */
  23734. clone(): PositionNormalTextureVertex;
  23735. }
  23736. /**
  23737. * @hidden
  23738. */
  23739. class Tmp {
  23740. static Color3: Color3[];
  23741. static Color4: Color4[];
  23742. static Vector2: Vector2[];
  23743. static Vector3: Vector3[];
  23744. static Vector4: Vector4[];
  23745. static Quaternion: Quaternion[];
  23746. static Matrix: Matrix[];
  23747. }
  23748. }
  23749. declare module BABYLON {
  23750. /**
  23751. * Class representing spherical polynomial coefficients to the 3rd degree
  23752. */
  23753. class SphericalPolynomial {
  23754. /**
  23755. * The x coefficients of the spherical polynomial
  23756. */
  23757. x: Vector3;
  23758. /**
  23759. * The y coefficients of the spherical polynomial
  23760. */
  23761. y: Vector3;
  23762. /**
  23763. * The z coefficients of the spherical polynomial
  23764. */
  23765. z: Vector3;
  23766. /**
  23767. * The xx coefficients of the spherical polynomial
  23768. */
  23769. xx: Vector3;
  23770. /**
  23771. * The yy coefficients of the spherical polynomial
  23772. */
  23773. yy: Vector3;
  23774. /**
  23775. * The zz coefficients of the spherical polynomial
  23776. */
  23777. zz: Vector3;
  23778. /**
  23779. * The xy coefficients of the spherical polynomial
  23780. */
  23781. xy: Vector3;
  23782. /**
  23783. * The yz coefficients of the spherical polynomial
  23784. */
  23785. yz: Vector3;
  23786. /**
  23787. * The zx coefficients of the spherical polynomial
  23788. */
  23789. zx: Vector3;
  23790. /**
  23791. * Adds an ambient color to the spherical polynomial
  23792. * @param color the color to add
  23793. */
  23794. addAmbient(color: Color3): void;
  23795. /**
  23796. * Scales the spherical polynomial by the given amount
  23797. * @param scale the amount to scale
  23798. */
  23799. scale(scale: number): void;
  23800. /**
  23801. * Gets the spherical polynomial from harmonics
  23802. * @param harmonics the spherical harmonics
  23803. * @returns the spherical polynomial
  23804. */
  23805. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  23806. /**
  23807. * Constructs a spherical polynomial from an array.
  23808. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  23809. * @returns the spherical polynomial
  23810. */
  23811. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  23812. }
  23813. /**
  23814. * Class representing spherical harmonics coefficients to the 3rd degree
  23815. */
  23816. class SphericalHarmonics {
  23817. /**
  23818. * The l0,0 coefficients of the spherical harmonics
  23819. */
  23820. l00: Vector3;
  23821. /**
  23822. * The l1,-1 coefficients of the spherical harmonics
  23823. */
  23824. l1_1: Vector3;
  23825. /**
  23826. * The l1,0 coefficients of the spherical harmonics
  23827. */
  23828. l10: Vector3;
  23829. /**
  23830. * The l1,1 coefficients of the spherical harmonics
  23831. */
  23832. l11: Vector3;
  23833. /**
  23834. * The l2,-2 coefficients of the spherical harmonics
  23835. */
  23836. l2_2: Vector3;
  23837. /**
  23838. * The l2,-1 coefficients of the spherical harmonics
  23839. */
  23840. l2_1: Vector3;
  23841. /**
  23842. * The l2,0 coefficients of the spherical harmonics
  23843. */
  23844. l20: Vector3;
  23845. /**
  23846. * The l2,1 coefficients of the spherical harmonics
  23847. */
  23848. l21: Vector3;
  23849. /**
  23850. * The l2,2 coefficients of the spherical harmonics
  23851. */
  23852. lL22: Vector3;
  23853. /**
  23854. * Adds a light to the spherical harmonics
  23855. * @param direction the direction of the light
  23856. * @param color the color of the light
  23857. * @param deltaSolidAngle the delta solid angle of the light
  23858. */
  23859. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  23860. /**
  23861. * Scales the spherical harmonics by the given amount
  23862. * @param scale the amount to scale
  23863. */
  23864. scale(scale: number): void;
  23865. /**
  23866. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  23867. *
  23868. * ```
  23869. * E_lm = A_l * L_lm
  23870. * ```
  23871. *
  23872. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  23873. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  23874. * the scaling factors are given in equation 9.
  23875. */
  23876. convertIncidentRadianceToIrradiance(): void;
  23877. /**
  23878. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  23879. *
  23880. * ```
  23881. * L = (1/pi) * E * rho
  23882. * ```
  23883. *
  23884. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  23885. */
  23886. convertIrradianceToLambertianRadiance(): void;
  23887. /**
  23888. * Gets the spherical harmonics from polynomial
  23889. * @param polynomial the spherical polynomial
  23890. * @returns the spherical harmonics
  23891. */
  23892. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  23893. /**
  23894. * Constructs a spherical harmonics from an array.
  23895. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  23896. * @returns the spherical harmonics
  23897. */
  23898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  23899. }
  23900. }
  23901. declare module BABYLON {
  23902. /**
  23903. * Class used to store all common mesh properties
  23904. */
  23905. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23906. /** No occlusion */
  23907. static OCCLUSION_TYPE_NONE: number;
  23908. /** Occlusion set to optimisitic */
  23909. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23910. /** Occlusion set to strict */
  23911. static OCCLUSION_TYPE_STRICT: number;
  23912. /** Use an accurante occlusion algorithm */
  23913. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23914. /** Use a conservative occlusion algorithm */
  23915. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23916. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  23917. static readonly CULLINGSTRATEGY_STANDARD: number;
  23918. /** Culling strategy with bounding sphere only and then frustum culling */
  23919. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23920. /**
  23921. * No billboard
  23922. */
  23923. static readonly BILLBOARDMODE_NONE: number;
  23924. /** Billboard on X axis */
  23925. static readonly BILLBOARDMODE_X: number;
  23926. /** Billboard on Y axis */
  23927. static readonly BILLBOARDMODE_Y: number;
  23928. /** Billboard on Z axis */
  23929. static readonly BILLBOARDMODE_Z: number;
  23930. /** Billboard on all axes */
  23931. static readonly BILLBOARDMODE_ALL: number;
  23932. private _facetData;
  23933. /** Gets ot sets the culling strategy to use to find visible meshes */
  23934. cullingStrategy: number;
  23935. /**
  23936. * Gets the number of facets in the mesh
  23937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23938. */
  23939. readonly facetNb: number;
  23940. /**
  23941. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23943. */
  23944. partitioningSubdivisions: number;
  23945. /**
  23946. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23947. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23949. */
  23950. partitioningBBoxRatio: number;
  23951. /**
  23952. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23953. * Works only for updatable meshes.
  23954. * Doesn't work with multi-materials
  23955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23956. */
  23957. mustDepthSortFacets: boolean;
  23958. /**
  23959. * The location (Vector3) where the facet depth sort must be computed from.
  23960. * By default, the active camera position.
  23961. * Used only when facet depth sort is enabled
  23962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23963. */
  23964. facetDepthSortFrom: Vector3;
  23965. /**
  23966. * gets a boolean indicating if facetData is enabled
  23967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23968. */
  23969. readonly isFacetDataEnabled: boolean;
  23970. /** @hidden */
  23971. _updateNonUniformScalingState(value: boolean): boolean;
  23972. /**
  23973. * An event triggered when this mesh collides with another one
  23974. */
  23975. onCollideObservable: Observable<AbstractMesh>;
  23976. private _onCollideObserver;
  23977. /** Set a function to call when this mesh collides with another one */
  23978. onCollide: () => void;
  23979. /**
  23980. * An event triggered when the collision's position changes
  23981. */
  23982. onCollisionPositionChangeObservable: Observable<Vector3>;
  23983. private _onCollisionPositionChangeObserver;
  23984. /** Set a function to call when the collision's position changes */
  23985. onCollisionPositionChange: () => void;
  23986. /**
  23987. * An event triggered when material is changed
  23988. */
  23989. onMaterialChangedObservable: Observable<AbstractMesh>;
  23990. /**
  23991. * Gets or sets the orientation for POV movement & rotation
  23992. */
  23993. definedFacingForward: boolean;
  23994. /** @hidden */
  23995. _occlusionQuery: Nullable<WebGLQuery>;
  23996. private _visibility;
  23997. /**
  23998. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23999. */
  24000. /**
  24001. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24002. */
  24003. visibility: number;
  24004. /** Gets or sets the alpha index used to sort transparent meshes
  24005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24006. */
  24007. alphaIndex: number;
  24008. /**
  24009. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24010. */
  24011. isVisible: boolean;
  24012. /**
  24013. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24014. */
  24015. isPickable: boolean;
  24016. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24017. showSubMeshesBoundingBox: boolean;
  24018. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24020. */
  24021. isBlocker: boolean;
  24022. /**
  24023. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24024. */
  24025. enablePointerMoveEvents: boolean;
  24026. /**
  24027. * Specifies the rendering group id for this mesh (0 by default)
  24028. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24029. */
  24030. renderingGroupId: number;
  24031. private _material;
  24032. /** Gets or sets current material */
  24033. material: Nullable<Material>;
  24034. private _receiveShadows;
  24035. /**
  24036. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24037. * @see http://doc.babylonjs.com/babylon101/shadows
  24038. */
  24039. receiveShadows: boolean;
  24040. /** Defines color to use when rendering outline */
  24041. outlineColor: Color3;
  24042. /** Define width to use when rendering outline */
  24043. outlineWidth: number;
  24044. /** Defines color to use when rendering overlay */
  24045. overlayColor: Color3;
  24046. /** Defines alpha to use when rendering overlay */
  24047. overlayAlpha: number;
  24048. private _hasVertexAlpha;
  24049. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24050. hasVertexAlpha: boolean;
  24051. private _useVertexColors;
  24052. /** 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) */
  24053. useVertexColors: boolean;
  24054. private _computeBonesUsingShaders;
  24055. /**
  24056. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24057. */
  24058. computeBonesUsingShaders: boolean;
  24059. private _numBoneInfluencers;
  24060. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24061. numBoneInfluencers: number;
  24062. private _applyFog;
  24063. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24064. applyFog: boolean;
  24065. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24066. useOctreeForRenderingSelection: boolean;
  24067. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24068. useOctreeForPicking: boolean;
  24069. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24070. useOctreeForCollisions: boolean;
  24071. private _layerMask;
  24072. /**
  24073. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24074. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24075. */
  24076. layerMask: number;
  24077. /**
  24078. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24079. */
  24080. alwaysSelectAsActiveMesh: boolean;
  24081. /**
  24082. * Gets or sets the current action manager
  24083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24084. */
  24085. actionManager: Nullable<ActionManager>;
  24086. private _checkCollisions;
  24087. private _collisionMask;
  24088. private _collisionGroup;
  24089. /**
  24090. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24092. */
  24093. ellipsoid: Vector3;
  24094. /**
  24095. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24097. */
  24098. ellipsoidOffset: Vector3;
  24099. private _collider;
  24100. private _oldPositionForCollisions;
  24101. private _diffPositionForCollisions;
  24102. /**
  24103. * Gets or sets a collision mask used to mask collisions (default is -1).
  24104. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24105. */
  24106. collisionMask: number;
  24107. /**
  24108. * Gets or sets the current collision group mask (-1 by default).
  24109. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24110. */
  24111. collisionGroup: number;
  24112. /**
  24113. * Defines edge width used when edgesRenderer is enabled
  24114. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24115. */
  24116. edgesWidth: number;
  24117. /**
  24118. * Defines edge color used when edgesRenderer is enabled
  24119. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24120. */
  24121. edgesColor: Color4;
  24122. /** @hidden */
  24123. _edgesRenderer: Nullable<IEdgesRenderer>;
  24124. /** @hidden */
  24125. _masterMesh: Nullable<AbstractMesh>;
  24126. /** @hidden */
  24127. _boundingInfo: Nullable<BoundingInfo>;
  24128. /** @hidden */
  24129. _renderId: number;
  24130. /**
  24131. * Gets or sets the list of subMeshes
  24132. * @see http://doc.babylonjs.com/how_to/multi_materials
  24133. */
  24134. subMeshes: SubMesh[];
  24135. /** @hidden */
  24136. _intersectionsInProgress: AbstractMesh[];
  24137. /** @hidden */
  24138. _unIndexed: boolean;
  24139. /** @hidden */
  24140. _lightSources: Light[];
  24141. /** @hidden */
  24142. readonly _positions: Nullable<Vector3[]>;
  24143. /** @hidden */
  24144. _waitingActions: any;
  24145. /** @hidden */
  24146. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24147. private _skeleton;
  24148. /** @hidden */
  24149. _bonesTransformMatrices: Nullable<Float32Array>;
  24150. /**
  24151. * Gets or sets a skeleton to apply skining transformations
  24152. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24153. */
  24154. skeleton: Nullable<Skeleton>;
  24155. /**
  24156. * An event triggered when the mesh is rebuilt.
  24157. */
  24158. onRebuildObservable: Observable<AbstractMesh>;
  24159. /**
  24160. * Creates a new AbstractMesh
  24161. * @param name defines the name of the mesh
  24162. * @param scene defines the hosting scene
  24163. */
  24164. constructor(name: string, scene?: Nullable<Scene>);
  24165. /**
  24166. * Returns the string "AbstractMesh"
  24167. * @returns "AbstractMesh"
  24168. */
  24169. getClassName(): string;
  24170. /**
  24171. * Gets a string representation of the current mesh
  24172. * @param fullDetails defines a boolean indicating if full details must be included
  24173. * @returns a string representation of the current mesh
  24174. */
  24175. toString(fullDetails?: boolean): string;
  24176. /** @hidden */
  24177. _rebuild(): void;
  24178. /** @hidden */
  24179. _resyncLightSources(): void;
  24180. /** @hidden */
  24181. _resyncLighSource(light: Light): void;
  24182. /** @hidden */
  24183. _unBindEffect(): void;
  24184. /** @hidden */
  24185. _removeLightSource(light: Light): void;
  24186. private _markSubMeshesAsDirty;
  24187. /** @hidden */
  24188. _markSubMeshesAsLightDirty(): void;
  24189. /** @hidden */
  24190. _markSubMeshesAsAttributesDirty(): void;
  24191. /** @hidden */
  24192. _markSubMeshesAsMiscDirty(): void;
  24193. /**
  24194. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24195. */
  24196. scaling: Vector3;
  24197. /**
  24198. * Returns true if the mesh is blocked. Implemented by child classes
  24199. */
  24200. readonly isBlocked: boolean;
  24201. /**
  24202. * Returns the mesh itself by default. Implemented by child classes
  24203. * @param camera defines the camera to use to pick the right LOD level
  24204. * @returns the currentAbstractMesh
  24205. */
  24206. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24207. /**
  24208. * Returns 0 by default. Implemented by child classes
  24209. * @returns an integer
  24210. */
  24211. getTotalVertices(): number;
  24212. /**
  24213. * Returns null by default. Implemented by child classes
  24214. * @returns null
  24215. */
  24216. getIndices(): Nullable<IndicesArray>;
  24217. /**
  24218. * Returns the array of the requested vertex data kind. Implemented by child classes
  24219. * @param kind defines the vertex data kind to use
  24220. * @returns null
  24221. */
  24222. getVerticesData(kind: string): Nullable<FloatArray>;
  24223. /**
  24224. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24225. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24226. * Note that a new underlying VertexBuffer object is created each call.
  24227. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24228. * @param kind defines vertex data kind:
  24229. * * BABYLON.VertexBuffer.PositionKind
  24230. * * BABYLON.VertexBuffer.UVKind
  24231. * * BABYLON.VertexBuffer.UV2Kind
  24232. * * BABYLON.VertexBuffer.UV3Kind
  24233. * * BABYLON.VertexBuffer.UV4Kind
  24234. * * BABYLON.VertexBuffer.UV5Kind
  24235. * * BABYLON.VertexBuffer.UV6Kind
  24236. * * BABYLON.VertexBuffer.ColorKind
  24237. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24238. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24239. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24240. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24241. * @param data defines the data source
  24242. * @param updatable defines if the data must be flagged as updatable (or static)
  24243. * @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
  24244. * @returns the current mesh
  24245. */
  24246. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24247. /**
  24248. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24249. * If the mesh has no geometry, it is simply returned as it is.
  24250. * @param kind defines vertex data kind:
  24251. * * BABYLON.VertexBuffer.PositionKind
  24252. * * BABYLON.VertexBuffer.UVKind
  24253. * * BABYLON.VertexBuffer.UV2Kind
  24254. * * BABYLON.VertexBuffer.UV3Kind
  24255. * * BABYLON.VertexBuffer.UV4Kind
  24256. * * BABYLON.VertexBuffer.UV5Kind
  24257. * * BABYLON.VertexBuffer.UV6Kind
  24258. * * BABYLON.VertexBuffer.ColorKind
  24259. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24260. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24261. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24262. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24263. * @param data defines the data source
  24264. * @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
  24265. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24266. * @returns the current mesh
  24267. */
  24268. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24269. /**
  24270. * Sets the mesh indices,
  24271. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24272. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24273. * @param totalVertices Defines the total number of vertices
  24274. * @returns the current mesh
  24275. */
  24276. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24277. /**
  24278. * Gets a boolean indicating if specific vertex data is present
  24279. * @param kind defines the vertex data kind to use
  24280. * @returns true is data kind is present
  24281. */
  24282. isVerticesDataPresent(kind: string): boolean;
  24283. /**
  24284. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24285. * @returns a BoundingInfo
  24286. */
  24287. getBoundingInfo(): BoundingInfo;
  24288. /**
  24289. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24290. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24291. * @returns the current mesh
  24292. */
  24293. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24294. /**
  24295. * Overwrite the current bounding info
  24296. * @param boundingInfo defines the new bounding info
  24297. * @returns the current mesh
  24298. */
  24299. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24300. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24301. readonly useBones: boolean;
  24302. /** @hidden */
  24303. _preActivate(): void;
  24304. /** @hidden */
  24305. _preActivateForIntermediateRendering(renderId: number): void;
  24306. /** @hidden */
  24307. _activate(renderId: number): void;
  24308. /**
  24309. * Gets the current world matrix
  24310. * @returns a Matrix
  24311. */
  24312. getWorldMatrix(): Matrix;
  24313. /** @hidden */
  24314. _getWorldMatrixDeterminant(): number;
  24315. /**
  24316. * Perform relative position change from the point of view of behind the front of the mesh.
  24317. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24318. * Supports definition of mesh facing forward or backward
  24319. * @param amountRight defines the distance on the right axis
  24320. * @param amountUp defines the distance on the up axis
  24321. * @param amountForward defines the distance on the forward axis
  24322. * @returns the current mesh
  24323. */
  24324. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24325. /**
  24326. * Calculate relative position change from the point of view of behind the front of the mesh.
  24327. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24328. * Supports definition of mesh facing forward or backward
  24329. * @param amountRight defines the distance on the right axis
  24330. * @param amountUp defines the distance on the up axis
  24331. * @param amountForward defines the distance on the forward axis
  24332. * @returns the new displacement vector
  24333. */
  24334. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24335. /**
  24336. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24337. * Supports definition of mesh facing forward or backward
  24338. * @param flipBack defines the flip
  24339. * @param twirlClockwise defines the twirl
  24340. * @param tiltRight defines the tilt
  24341. * @returns the current mesh
  24342. */
  24343. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24344. /**
  24345. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24346. * Supports definition of mesh facing forward or backward.
  24347. * @param flipBack defines the flip
  24348. * @param twirlClockwise defines the twirl
  24349. * @param tiltRight defines the tilt
  24350. * @returns the new rotation vector
  24351. */
  24352. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24353. /**
  24354. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24355. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24356. * @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
  24357. * @returns the new bounding vectors
  24358. */
  24359. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24360. min: Vector3;
  24361. max: Vector3;
  24362. };
  24363. /** @hidden */
  24364. _updateBoundingInfo(): AbstractMesh;
  24365. /** @hidden */
  24366. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24367. /** @hidden */
  24368. protected _afterComputeWorldMatrix(): void;
  24369. /**
  24370. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24371. * A mesh is in the frustum if its bounding box intersects the frustum
  24372. * @param frustumPlanes defines the frustum to test
  24373. * @returns true if the mesh is in the frustum planes
  24374. */
  24375. isInFrustum(frustumPlanes: Plane[]): boolean;
  24376. /**
  24377. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24378. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24379. * @param frustumPlanes defines the frustum to test
  24380. * @returns true if the mesh is completely in the frustum planes
  24381. */
  24382. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24383. /**
  24384. * True if the mesh intersects another mesh or a SolidParticle object
  24385. * @param mesh defines a target mesh or SolidParticle to test
  24386. * @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)
  24387. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24388. * @returns true if there is an intersection
  24389. */
  24390. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24391. /**
  24392. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24393. * @param point defines the point to test
  24394. * @returns true if there is an intersection
  24395. */
  24396. intersectsPoint(point: Vector3): boolean;
  24397. /**
  24398. * Gets the position of the current mesh in camera space
  24399. * @param camera defines the camera to use
  24400. * @returns a position
  24401. */
  24402. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  24403. /**
  24404. * Returns the distance from the mesh to the active camera
  24405. * @param camera defines the camera to use
  24406. * @returns the distance
  24407. */
  24408. getDistanceToCamera(camera?: Nullable<Camera>): number;
  24409. /**
  24410. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24412. */
  24413. checkCollisions: boolean;
  24414. /**
  24415. * Gets Collider object used to compute collisions (not physics)
  24416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24417. */
  24418. readonly collider: Collider;
  24419. /**
  24420. * Move the mesh using collision engine
  24421. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24422. * @param displacement defines the requested displacement vector
  24423. * @returns the current mesh
  24424. */
  24425. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24426. private _onCollisionPositionChange;
  24427. /** @hidden */
  24428. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24429. /** @hidden */
  24430. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24431. /** @hidden */
  24432. _checkCollision(collider: Collider): AbstractMesh;
  24433. /** @hidden */
  24434. _generatePointsArray(): boolean;
  24435. /**
  24436. * Checks if the passed Ray intersects with the mesh
  24437. * @param ray defines the ray to use
  24438. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24439. * @returns the picking info
  24440. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24441. */
  24442. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24443. /**
  24444. * Clones the current mesh
  24445. * @param name defines the mesh name
  24446. * @param newParent defines the new mesh parent
  24447. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24448. * @returns the new mesh
  24449. */
  24450. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24451. /**
  24452. * Disposes all the submeshes of the current meshnp
  24453. * @returns the current mesh
  24454. */
  24455. releaseSubMeshes(): AbstractMesh;
  24456. /**
  24457. * Releases resources associated with this abstract mesh.
  24458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24460. */
  24461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24462. /**
  24463. * Adds the passed mesh as a child to the current mesh
  24464. * @param mesh defines the child mesh
  24465. * @returns the current mesh
  24466. */
  24467. addChild(mesh: AbstractMesh): AbstractMesh;
  24468. /**
  24469. * Removes the passed mesh from the current mesh children list
  24470. * @param mesh defines the child mesh
  24471. * @returns the current mesh
  24472. */
  24473. removeChild(mesh: AbstractMesh): AbstractMesh;
  24474. /** @hidden */
  24475. private _initFacetData;
  24476. /**
  24477. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24478. * This method can be called within the render loop.
  24479. * 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
  24480. * @returns the current mesh
  24481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24482. */
  24483. updateFacetData(): AbstractMesh;
  24484. /**
  24485. * Returns the facetLocalNormals array.
  24486. * The normals are expressed in the mesh local spac
  24487. * @returns an array of Vector3
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getFacetLocalNormals(): Vector3[];
  24491. /**
  24492. * Returns the facetLocalPositions array.
  24493. * The facet positions are expressed in the mesh local space
  24494. * @returns an array of Vector3
  24495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24496. */
  24497. getFacetLocalPositions(): Vector3[];
  24498. /**
  24499. * Returns the facetLocalPartioning array
  24500. * @returns an array of array of numbers
  24501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24502. */
  24503. getFacetLocalPartitioning(): number[][];
  24504. /**
  24505. * Returns the i-th facet position in the world system.
  24506. * This method allocates a new Vector3 per call
  24507. * @param i defines the facet index
  24508. * @returns a new Vector3
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24510. */
  24511. getFacetPosition(i: number): Vector3;
  24512. /**
  24513. * Sets the reference Vector3 with the i-th facet position in the world system
  24514. * @param i defines the facet index
  24515. * @param ref defines the target vector
  24516. * @returns the current mesh
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24520. /**
  24521. * Returns the i-th facet normal in the world system.
  24522. * This method allocates a new Vector3 per call
  24523. * @param i defines the facet index
  24524. * @returns a new Vector3
  24525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24526. */
  24527. getFacetNormal(i: number): Vector3;
  24528. /**
  24529. * Sets the reference Vector3 with the i-th facet normal in the world system
  24530. * @param i defines the facet index
  24531. * @param ref defines the target vector
  24532. * @returns the current mesh
  24533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24534. */
  24535. getFacetNormalToRef(i: number, ref: Vector3): this;
  24536. /**
  24537. * 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)
  24538. * @param x defines x coordinate
  24539. * @param y defines y coordinate
  24540. * @param z defines z coordinate
  24541. * @returns the array of facet indexes
  24542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24543. */
  24544. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24545. /**
  24546. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24547. * @param projected sets as the (x,y,z) world projection on the facet
  24548. * @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
  24549. * @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
  24550. * @param x defines x coordinate
  24551. * @param y defines y coordinate
  24552. * @param z defines z coordinate
  24553. * @returns the face index if found (or null instead)
  24554. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24555. */
  24556. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24557. /**
  24558. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24559. * @param projected sets as the (x,y,z) local projection on the facet
  24560. * @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
  24561. * @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
  24562. * @param x defines x coordinate
  24563. * @param y defines y coordinate
  24564. * @param z defines z coordinate
  24565. * @returns the face index if found (or null instead)
  24566. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24567. */
  24568. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24569. /**
  24570. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24571. * @returns the parameters
  24572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24573. */
  24574. getFacetDataParameters(): any;
  24575. /**
  24576. * Disables the feature FacetData and frees the related memory
  24577. * @returns the current mesh
  24578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24579. */
  24580. disableFacetData(): AbstractMesh;
  24581. /**
  24582. * Updates the AbstractMesh indices array
  24583. * @param indices defines the data source
  24584. * @returns the current mesh
  24585. */
  24586. updateIndices(indices: IndicesArray): AbstractMesh;
  24587. /**
  24588. * Creates new normals data for the mesh
  24589. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24590. * @returns the current mesh
  24591. */
  24592. createNormals(updatable: boolean): AbstractMesh;
  24593. /**
  24594. * Align the mesh with a normal
  24595. * @param normal defines the normal to use
  24596. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24597. * @returns the current mesh
  24598. */
  24599. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24600. /** @hidden */
  24601. _checkOcclusionQuery(): boolean;
  24602. }
  24603. }
  24604. declare module BABYLON {
  24605. /**
  24606. * Class used to store data that will be store in GPU memory
  24607. */
  24608. class Buffer {
  24609. private _engine;
  24610. private _buffer;
  24611. /** @hidden */
  24612. _data: Nullable<DataArray>;
  24613. private _updatable;
  24614. private _instanced;
  24615. /**
  24616. * Gets the byte stride.
  24617. */
  24618. readonly byteStride: number;
  24619. /**
  24620. * Constructor
  24621. * @param engine the engine
  24622. * @param data the data to use for this buffer
  24623. * @param updatable whether the data is updatable
  24624. * @param stride the stride (optional)
  24625. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  24626. * @param instanced whether the buffer is instanced (optional)
  24627. * @param useBytes set to true if the stride in in bytes (optional)
  24628. */
  24629. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  24630. /**
  24631. * Create a new VertexBuffer based on the current buffer
  24632. * @param kind defines the vertex buffer kind (position, normal, etc.)
  24633. * @param offset defines offset in the buffer (0 by default)
  24634. * @param size defines the size in floats of attributes (position is 3 for instance)
  24635. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  24636. * @param instanced defines if the vertex buffer contains indexed data
  24637. * @param useBytes defines if the offset and stride are in bytes
  24638. * @returns the new vertex buffer
  24639. */
  24640. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  24641. /**
  24642. * Gets a boolean indicating if the Buffer is updatable?
  24643. * @returns true if the buffer is updatable
  24644. */
  24645. isUpdatable(): boolean;
  24646. /**
  24647. * Gets current buffer's data
  24648. * @returns a DataArray or null
  24649. */
  24650. getData(): Nullable<DataArray>;
  24651. /**
  24652. * Gets underlying native buffer
  24653. * @returns underlying native buffer
  24654. */
  24655. getBuffer(): Nullable<WebGLBuffer>;
  24656. /**
  24657. * Gets the stride in float32 units (i.e. byte stride / 4).
  24658. * May not be an integer if the byte stride is not divisible by 4.
  24659. * DEPRECATED. Use byteStride instead.
  24660. * @returns the stride in float32 units
  24661. */
  24662. getStrideSize(): number;
  24663. /**
  24664. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  24665. * @param data defines the data to store
  24666. */
  24667. create(data?: Nullable<DataArray>): void;
  24668. /** @hidden */
  24669. _rebuild(): void;
  24670. /**
  24671. * Update current buffer data
  24672. * @param data defines the data to store
  24673. */
  24674. update(data: DataArray): void;
  24675. /**
  24676. * Updates the data directly.
  24677. * @param data the new data
  24678. * @param offset the new offset
  24679. * @param vertexCount the vertex count (optional)
  24680. * @param useBytes set to true if the offset is in bytes
  24681. */
  24682. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  24683. /**
  24684. * Release all resources
  24685. */
  24686. dispose(): void;
  24687. }
  24688. }
  24689. declare module BABYLON {
  24690. /**
  24691. * Class for building Constructive Solid Geometry
  24692. */
  24693. class CSG {
  24694. private polygons;
  24695. /**
  24696. * The world matrix
  24697. */
  24698. matrix: Matrix;
  24699. /**
  24700. * Stores the position
  24701. */
  24702. position: Vector3;
  24703. /**
  24704. * Stores the rotation
  24705. */
  24706. rotation: Vector3;
  24707. /**
  24708. * Stores the rotation quaternion
  24709. */
  24710. rotationQuaternion: Nullable<Quaternion>;
  24711. /**
  24712. * Stores the scaling vector
  24713. */
  24714. scaling: Vector3;
  24715. /**
  24716. * Convert the BABYLON.Mesh to BABYLON.CSG
  24717. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  24718. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  24719. */
  24720. static FromMesh(mesh: Mesh): CSG;
  24721. /**
  24722. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  24723. * @param polygons Polygons used to construct a BABYLON.CSG solid
  24724. */
  24725. private static FromPolygons;
  24726. /**
  24727. * Clones, or makes a deep copy, of the BABYLON.CSG
  24728. * @returns A new BABYLON.CSG
  24729. */
  24730. clone(): CSG;
  24731. /**
  24732. * Unions this CSG with another CSG
  24733. * @param csg The CSG to union against this CSG
  24734. * @returns The unioned CSG
  24735. */
  24736. union(csg: CSG): CSG;
  24737. /**
  24738. * Unions this CSG with another CSG in place
  24739. * @param csg The CSG to union against this CSG
  24740. */
  24741. unionInPlace(csg: CSG): void;
  24742. /**
  24743. * Subtracts this CSG with another CSG
  24744. * @param csg The CSG to subtract against this CSG
  24745. * @returns A new BABYLON.CSG
  24746. */
  24747. subtract(csg: CSG): CSG;
  24748. /**
  24749. * Subtracts this CSG with another CSG in place
  24750. * @param csg The CSG to subtact against this CSG
  24751. */
  24752. subtractInPlace(csg: CSG): void;
  24753. /**
  24754. * Intersect this CSG with another CSG
  24755. * @param csg The CSG to intersect against this CSG
  24756. * @returns A new BABYLON.CSG
  24757. */
  24758. intersect(csg: CSG): CSG;
  24759. /**
  24760. * Intersects this CSG with another CSG in place
  24761. * @param csg The CSG to intersect against this CSG
  24762. */
  24763. intersectInPlace(csg: CSG): void;
  24764. /**
  24765. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  24766. * not modified.
  24767. * @returns A new BABYLON.CSG solid with solid and empty space switched
  24768. */
  24769. inverse(): CSG;
  24770. /**
  24771. * Inverses the BABYLON.CSG in place
  24772. */
  24773. inverseInPlace(): void;
  24774. /**
  24775. * This is used to keep meshes transformations so they can be restored
  24776. * when we build back a Babylon Mesh
  24777. * NB : All CSG operations are performed in world coordinates
  24778. * @param csg The BABYLON.CSG to copy the transform attributes from
  24779. * @returns This BABYLON.CSG
  24780. */
  24781. copyTransformAttributes(csg: CSG): CSG;
  24782. /**
  24783. * Build Raw mesh from CSG
  24784. * Coordinates here are in world space
  24785. * @param name The name of the mesh geometry
  24786. * @param scene The BABYLON.Scene
  24787. * @param keepSubMeshes Specifies if the submeshes should be kept
  24788. * @returns A new BABYLON.Mesh
  24789. */
  24790. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  24791. /**
  24792. * Build Mesh from CSG taking material and transforms into account
  24793. * @param name The name of the BABYLON.Mesh
  24794. * @param material The material of the BABYLON.Mesh
  24795. * @param scene The BABYLON.Scene
  24796. * @param keepSubMeshes Specifies if submeshes should be kept
  24797. * @returns The new BABYLON.Mesh
  24798. */
  24799. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  24800. }
  24801. }
  24802. declare module BABYLON {
  24803. /**
  24804. * Class used to store geometry data (vertex buffers + index buffer)
  24805. */
  24806. class Geometry implements IGetSetVerticesData {
  24807. /**
  24808. * Gets or sets the unique ID of the geometry
  24809. */
  24810. id: string;
  24811. /**
  24812. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24813. */
  24814. delayLoadState: number;
  24815. /**
  24816. * Gets the file containing the data to load when running in delay load state
  24817. */
  24818. delayLoadingFile: Nullable<string>;
  24819. /**
  24820. * Callback called when the geometry is updated
  24821. */
  24822. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24823. private _scene;
  24824. private _engine;
  24825. private _meshes;
  24826. private _totalVertices;
  24827. /** @hidden */
  24828. _indices: IndicesArray;
  24829. /** @hidden */
  24830. _vertexBuffers: {
  24831. [key: string]: VertexBuffer;
  24832. };
  24833. private _isDisposed;
  24834. private _extend;
  24835. private _boundingBias;
  24836. /** @hidden */
  24837. _delayInfo: Array<string>;
  24838. private _indexBuffer;
  24839. private _indexBufferIsUpdatable;
  24840. /** @hidden */
  24841. _boundingInfo: Nullable<BoundingInfo>;
  24842. /** @hidden */
  24843. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24844. /** @hidden */
  24845. _softwareSkinningFrameId: number;
  24846. private _vertexArrayObjects;
  24847. private _updatable;
  24848. /** @hidden */
  24849. _positions: Nullable<Vector3[]>;
  24850. /**
  24851. * 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
  24852. */
  24853. /**
  24854. * 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
  24855. */
  24856. boundingBias: Vector2;
  24857. /**
  24858. * Static function used to attach a new empty geometry to a mesh
  24859. * @param mesh defines the mesh to attach the geometry to
  24860. * @returns the new Geometry
  24861. */
  24862. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24863. /**
  24864. * Creates a new geometry
  24865. * @param id defines the unique ID
  24866. * @param scene defines the hosting scene
  24867. * @param vertexData defines the VertexData used to get geometry data
  24868. * @param updatable defines if geometry must be updatable (false by default)
  24869. * @param mesh defines the mesh that will be associated with the geometry
  24870. */
  24871. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24872. /**
  24873. * Gets the current extend of the geometry
  24874. */
  24875. readonly extend: {
  24876. minimum: Vector3;
  24877. maximum: Vector3;
  24878. };
  24879. /**
  24880. * Gets the hosting scene
  24881. * @returns the hosting Scene
  24882. */
  24883. getScene(): Scene;
  24884. /**
  24885. * Gets the hosting engine
  24886. * @returns the hosting Engine
  24887. */
  24888. getEngine(): Engine;
  24889. /**
  24890. * Defines if the geometry is ready to use
  24891. * @returns true if the geometry is ready to be used
  24892. */
  24893. isReady(): boolean;
  24894. /**
  24895. * Gets a value indicating that the geometry should not be serialized
  24896. */
  24897. readonly doNotSerialize: boolean;
  24898. /** @hidden */
  24899. _rebuild(): void;
  24900. /**
  24901. * Affects all geometry data in one call
  24902. * @param vertexData defines the geometry data
  24903. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24904. */
  24905. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24906. /**
  24907. * Set specific vertex data
  24908. * @param kind defines the data kind (Position, normal, etc...)
  24909. * @param data defines the vertex data to use
  24910. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24911. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24912. */
  24913. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24914. /**
  24915. * Removes a specific vertex data
  24916. * @param kind defines the data kind (Position, normal, etc...)
  24917. */
  24918. removeVerticesData(kind: string): void;
  24919. /**
  24920. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24921. * @param buffer defines the vertex buffer to use
  24922. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24923. */
  24924. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24925. /**
  24926. * Update a specific vertex buffer
  24927. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  24928. * It will do nothing if the buffer is not updatable
  24929. * @param kind defines the data kind (Position, normal, etc...)
  24930. * @param data defines the data to use
  24931. * @param offset defines the offset in the target buffer where to store the data
  24932. * @param useBytes set to true if the offset is in bytes
  24933. */
  24934. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24935. /**
  24936. * Update a specific vertex buffer
  24937. * This function will create a new buffer if the current one is not updatable
  24938. * @param kind defines the data kind (Position, normal, etc...)
  24939. * @param data defines the data to use
  24940. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24941. */
  24942. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24943. private _updateBoundingInfo;
  24944. /** @hidden */
  24945. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  24946. /**
  24947. * Gets total number of vertices
  24948. * @returns the total number of vertices
  24949. */
  24950. getTotalVertices(): number;
  24951. /**
  24952. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24953. * @param kind defines the data kind (Position, normal, etc...)
  24954. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24956. * @returns a float array containing vertex data
  24957. */
  24958. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24959. /**
  24960. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24961. * @param kind defines the data kind (Position, normal, etc...)
  24962. * @returns true if the vertex buffer with the specified kind is updatable
  24963. */
  24964. isVertexBufferUpdatable(kind: string): boolean;
  24965. /**
  24966. * Gets a specific vertex buffer
  24967. * @param kind defines the data kind (Position, normal, etc...)
  24968. * @returns a VertexBuffer
  24969. */
  24970. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24971. /**
  24972. * Returns all vertex buffers
  24973. * @return an object holding all vertex buffers indexed by kind
  24974. */
  24975. getVertexBuffers(): Nullable<{
  24976. [key: string]: VertexBuffer;
  24977. }>;
  24978. /**
  24979. * Gets a boolean indicating if specific vertex buffer is present
  24980. * @param kind defines the data kind (Position, normal, etc...)
  24981. * @returns true if data is present
  24982. */
  24983. isVerticesDataPresent(kind: string): boolean;
  24984. /**
  24985. * Gets a list of all attached data kinds (Position, normal, etc...)
  24986. * @returns a list of string containing all kinds
  24987. */
  24988. getVerticesDataKinds(): string[];
  24989. /**
  24990. * Update index buffer
  24991. * @param indices defines the indices to store in the index buffer
  24992. * @param offset defines the offset in the target buffer where to store the data
  24993. */
  24994. updateIndices(indices: IndicesArray, offset?: number): void;
  24995. /**
  24996. * Creates a new index buffer
  24997. * @param indices defines the indices to store in the index buffer
  24998. * @param totalVertices defines the total number of vertices (could be null)
  24999. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25000. */
  25001. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25002. /**
  25003. * Return the total number of indices
  25004. * @returns the total number of indices
  25005. */
  25006. getTotalIndices(): number;
  25007. /**
  25008. * Gets the index buffer array
  25009. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25010. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25011. * @returns the index buffer array
  25012. */
  25013. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25014. /**
  25015. * Gets the index buffer
  25016. * @return the index buffer
  25017. */
  25018. getIndexBuffer(): Nullable<WebGLBuffer>;
  25019. /** @hidden */
  25020. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25021. /**
  25022. * Release the associated resources for a specific mesh
  25023. * @param mesh defines the source mesh
  25024. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25025. */
  25026. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25027. /**
  25028. * Apply current geometry to a given mesh
  25029. * @param mesh defines the mesh to apply geometry to
  25030. */
  25031. applyToMesh(mesh: Mesh): void;
  25032. private _updateExtend;
  25033. private _applyToMesh;
  25034. private notifyUpdate;
  25035. /**
  25036. * Load the geometry if it was flagged as delay loaded
  25037. * @param scene defines the hosting scene
  25038. * @param onLoaded defines a callback called when the geometry is loaded
  25039. */
  25040. load(scene: Scene, onLoaded?: () => void): void;
  25041. private _queueLoad;
  25042. /**
  25043. * Invert the geometry to move from a right handed system to a left handed one.
  25044. */
  25045. toLeftHanded(): void;
  25046. /** @hidden */
  25047. _resetPointsArrayCache(): void;
  25048. /** @hidden */
  25049. _generatePointsArray(): boolean;
  25050. /**
  25051. * Gets a value indicating if the geometry is disposed
  25052. * @returns true if the geometry was disposed
  25053. */
  25054. isDisposed(): boolean;
  25055. private _disposeVertexArrayObjects;
  25056. /**
  25057. * Free all associated resources
  25058. */
  25059. dispose(): void;
  25060. /**
  25061. * Clone the current geometry into a new geometry
  25062. * @param id defines the unique ID of the new geometry
  25063. * @returns a new geometry object
  25064. */
  25065. copy(id: string): Geometry;
  25066. /**
  25067. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25068. * @return a JSON representation of the current geometry data (without the vertices data)
  25069. */
  25070. serialize(): any;
  25071. private toNumberArray;
  25072. /**
  25073. * Serialize all vertices data into a JSON oject
  25074. * @returns a JSON representation of the current geometry data
  25075. */
  25076. serializeVerticeData(): any;
  25077. /**
  25078. * Extracts a clone of a mesh geometry
  25079. * @param mesh defines the source mesh
  25080. * @param id defines the unique ID of the new geometry object
  25081. * @returns the new geometry object
  25082. */
  25083. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25084. /**
  25085. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25086. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25087. * Be aware Math.random() could cause collisions, but:
  25088. * "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"
  25089. * @returns a string containing a new GUID
  25090. */
  25091. static RandomId(): string;
  25092. /** @hidden */
  25093. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25094. private static _CleanMatricesWeights;
  25095. /**
  25096. * Create a new geometry from persisted data (Using .babylon file format)
  25097. * @param parsedVertexData defines the persisted data
  25098. * @param scene defines the hosting scene
  25099. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25100. * @returns the new geometry object
  25101. */
  25102. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25103. }
  25104. /**
  25105. * Abstract class used to provide common services for all typed geometries
  25106. * @hidden
  25107. */
  25108. class _PrimitiveGeometry extends Geometry {
  25109. private _canBeRegenerated;
  25110. private _beingRegenerated;
  25111. /**
  25112. * Creates a new typed geometry
  25113. * @param id defines the unique ID of the geometry
  25114. * @param scene defines the hosting scene
  25115. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25116. * @param mesh defines the hosting mesh (can be null)
  25117. */
  25118. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25119. /**
  25120. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25121. * @returns true if the geometry can be regenerated
  25122. */
  25123. canBeRegenerated(): boolean;
  25124. /**
  25125. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25126. */
  25127. regenerate(): void;
  25128. /**
  25129. * Clone the geometry
  25130. * @param id defines the unique ID of the new geometry
  25131. * @returns the new geometry
  25132. */
  25133. asNewGeometry(id: string): Geometry;
  25134. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25135. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25136. /** @hidden */
  25137. _regenerateVertexData(): VertexData;
  25138. copy(id: string): Geometry;
  25139. serialize(): any;
  25140. }
  25141. /**
  25142. * Creates a ribbon geometry
  25143. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25144. */
  25145. class RibbonGeometry extends _PrimitiveGeometry {
  25146. /**
  25147. * Defines the array of paths to use
  25148. */
  25149. pathArray: Vector3[][];
  25150. /**
  25151. * Defines if the last and first points of each path in your pathArray must be joined
  25152. */
  25153. closeArray: boolean;
  25154. /**
  25155. * Defines if the last and first points of each path in your pathArray must be joined
  25156. */
  25157. closePath: boolean;
  25158. /**
  25159. * Defines the offset between points
  25160. */
  25161. offset: number;
  25162. /**
  25163. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25164. */
  25165. side: number;
  25166. /**
  25167. * Creates a ribbon geometry
  25168. * @param id defines the unique ID of the geometry
  25169. * @param scene defines the hosting scene
  25170. * @param pathArray defines the array of paths to use
  25171. * @param closeArray defines if the last path and the first path must be joined
  25172. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25173. * @param offset defines the offset between points
  25174. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25175. * @param mesh defines the hosting mesh (can be null)
  25176. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25177. */
  25178. constructor(id: string, scene: Scene,
  25179. /**
  25180. * Defines the array of paths to use
  25181. */
  25182. pathArray: Vector3[][],
  25183. /**
  25184. * Defines if the last and first points of each path in your pathArray must be joined
  25185. */
  25186. closeArray: boolean,
  25187. /**
  25188. * Defines if the last and first points of each path in your pathArray must be joined
  25189. */
  25190. closePath: boolean,
  25191. /**
  25192. * Defines the offset between points
  25193. */
  25194. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25195. /**
  25196. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25197. */
  25198. side?: number);
  25199. /** @hidden */
  25200. _regenerateVertexData(): VertexData;
  25201. copy(id: string): Geometry;
  25202. }
  25203. /**
  25204. * Creates a box geometry
  25205. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25206. */
  25207. class BoxGeometry extends _PrimitiveGeometry {
  25208. /**
  25209. * Defines the zise of the box (width, height and depth are the same)
  25210. */
  25211. size: number;
  25212. /**
  25213. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25214. */
  25215. side: number;
  25216. /**
  25217. * Creates a box geometry
  25218. * @param id defines the unique ID of the geometry
  25219. * @param scene defines the hosting scene
  25220. * @param size defines the zise of the box (width, height and depth are the same)
  25221. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25222. * @param mesh defines the hosting mesh (can be null)
  25223. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25224. */
  25225. constructor(id: string, scene: Scene,
  25226. /**
  25227. * Defines the zise of the box (width, height and depth are the same)
  25228. */
  25229. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25230. /**
  25231. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25232. */
  25233. side?: number);
  25234. /** @hidden */
  25235. _regenerateVertexData(): VertexData;
  25236. copy(id: string): Geometry;
  25237. serialize(): any;
  25238. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25239. }
  25240. /**
  25241. * Creates a sphere geometry
  25242. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25243. */
  25244. class SphereGeometry extends _PrimitiveGeometry {
  25245. /**
  25246. * Defines the number of segments to use to create the sphere
  25247. */
  25248. segments: number;
  25249. /**
  25250. * Defines the diameter of the sphere
  25251. */
  25252. diameter: number;
  25253. /**
  25254. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25255. */
  25256. side: number;
  25257. /**
  25258. * Create a new sphere geometry
  25259. * @param id defines the unique ID of the geometry
  25260. * @param scene defines the hosting scene
  25261. * @param segments defines the number of segments to use to create the sphere
  25262. * @param diameter defines the diameter of the sphere
  25263. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25264. * @param mesh defines the hosting mesh (can be null)
  25265. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25266. */
  25267. constructor(id: string, scene: Scene,
  25268. /**
  25269. * Defines the number of segments to use to create the sphere
  25270. */
  25271. segments: number,
  25272. /**
  25273. * Defines the diameter of the sphere
  25274. */
  25275. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25276. /**
  25277. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25278. */
  25279. side?: number);
  25280. /** @hidden */
  25281. _regenerateVertexData(): VertexData;
  25282. copy(id: string): Geometry;
  25283. serialize(): any;
  25284. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25285. }
  25286. /**
  25287. * Creates a disc geometry
  25288. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25289. */
  25290. class DiscGeometry extends _PrimitiveGeometry {
  25291. /**
  25292. * Defines the radius of the disc
  25293. */
  25294. radius: number;
  25295. /**
  25296. * Defines the tesselation factor to apply to the disc
  25297. */
  25298. tessellation: number;
  25299. /**
  25300. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25301. */
  25302. side: number;
  25303. /**
  25304. * Creates a new disc geometry
  25305. * @param id defines the unique ID of the geometry
  25306. * @param scene defines the hosting scene
  25307. * @param radius defines the radius of the disc
  25308. * @param tessellation defines the tesselation factor to apply to the disc
  25309. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25310. * @param mesh defines the hosting mesh (can be null)
  25311. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25312. */
  25313. constructor(id: string, scene: Scene,
  25314. /**
  25315. * Defines the radius of the disc
  25316. */
  25317. radius: number,
  25318. /**
  25319. * Defines the tesselation factor to apply to the disc
  25320. */
  25321. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25322. /**
  25323. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25324. */
  25325. side?: number);
  25326. /** @hidden */
  25327. _regenerateVertexData(): VertexData;
  25328. copy(id: string): Geometry;
  25329. }
  25330. /**
  25331. * Creates a new cylinder geometry
  25332. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25333. */
  25334. class CylinderGeometry extends _PrimitiveGeometry {
  25335. /**
  25336. * Defines the height of the cylinder
  25337. */
  25338. height: number;
  25339. /**
  25340. * Defines the diameter of the cylinder's top cap
  25341. */
  25342. diameterTop: number;
  25343. /**
  25344. * Defines the diameter of the cylinder's bottom cap
  25345. */
  25346. diameterBottom: number;
  25347. /**
  25348. * Defines the tessellation factor to apply to the cylinder
  25349. */
  25350. tessellation: number;
  25351. /**
  25352. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25353. */
  25354. subdivisions: number;
  25355. /**
  25356. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25357. */
  25358. side: number;
  25359. /**
  25360. * Creates a new cylinder geometry
  25361. * @param id defines the unique ID of the geometry
  25362. * @param scene defines the hosting scene
  25363. * @param height defines the height of the cylinder
  25364. * @param diameterTop defines the diameter of the cylinder's top cap
  25365. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25366. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25367. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25368. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25369. * @param mesh defines the hosting mesh (can be null)
  25370. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25371. */
  25372. constructor(id: string, scene: Scene,
  25373. /**
  25374. * Defines the height of the cylinder
  25375. */
  25376. height: number,
  25377. /**
  25378. * Defines the diameter of the cylinder's top cap
  25379. */
  25380. diameterTop: number,
  25381. /**
  25382. * Defines the diameter of the cylinder's bottom cap
  25383. */
  25384. diameterBottom: number,
  25385. /**
  25386. * Defines the tessellation factor to apply to the cylinder
  25387. */
  25388. tessellation: number,
  25389. /**
  25390. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25391. */
  25392. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25393. /**
  25394. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25395. */
  25396. side?: number);
  25397. /** @hidden */
  25398. _regenerateVertexData(): VertexData;
  25399. copy(id: string): Geometry;
  25400. serialize(): any;
  25401. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25402. }
  25403. /**
  25404. * Creates a new torus geometry
  25405. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25406. */
  25407. class TorusGeometry extends _PrimitiveGeometry {
  25408. /**
  25409. * Defines the diameter of the torus
  25410. */
  25411. diameter: number;
  25412. /**
  25413. * Defines the thickness of the torus (ie. internal diameter)
  25414. */
  25415. thickness: number;
  25416. /**
  25417. * Defines the tesselation factor to apply to the torus
  25418. */
  25419. tessellation: number;
  25420. /**
  25421. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25422. */
  25423. side: number;
  25424. /**
  25425. * Creates a new torus geometry
  25426. * @param id defines the unique ID of the geometry
  25427. * @param scene defines the hosting scene
  25428. * @param diameter defines the diameter of the torus
  25429. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25430. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25431. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25432. * @param mesh defines the hosting mesh (can be null)
  25433. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25434. */
  25435. constructor(id: string, scene: Scene,
  25436. /**
  25437. * Defines the diameter of the torus
  25438. */
  25439. diameter: number,
  25440. /**
  25441. * Defines the thickness of the torus (ie. internal diameter)
  25442. */
  25443. thickness: number,
  25444. /**
  25445. * Defines the tesselation factor to apply to the torus
  25446. */
  25447. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25448. /**
  25449. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25450. */
  25451. side?: number);
  25452. /** @hidden */
  25453. _regenerateVertexData(): VertexData;
  25454. copy(id: string): Geometry;
  25455. serialize(): any;
  25456. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25457. }
  25458. /**
  25459. * Creates a new ground geometry
  25460. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25461. */
  25462. class GroundGeometry extends _PrimitiveGeometry {
  25463. /**
  25464. * Defines the width of the ground
  25465. */
  25466. width: number;
  25467. /**
  25468. * Defines the height of the ground
  25469. */
  25470. height: number;
  25471. /**
  25472. * Defines the subdivisions to apply to the ground
  25473. */
  25474. subdivisions: number;
  25475. /**
  25476. * Creates a new ground geometry
  25477. * @param id defines the unique ID of the geometry
  25478. * @param scene defines the hosting scene
  25479. * @param width defines the width of the ground
  25480. * @param height defines the height of the ground
  25481. * @param subdivisions defines the subdivisions to apply to the ground
  25482. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25483. * @param mesh defines the hosting mesh (can be null)
  25484. */
  25485. constructor(id: string, scene: Scene,
  25486. /**
  25487. * Defines the width of the ground
  25488. */
  25489. width: number,
  25490. /**
  25491. * Defines the height of the ground
  25492. */
  25493. height: number,
  25494. /**
  25495. * Defines the subdivisions to apply to the ground
  25496. */
  25497. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25498. /** @hidden */
  25499. _regenerateVertexData(): VertexData;
  25500. copy(id: string): Geometry;
  25501. serialize(): any;
  25502. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25503. }
  25504. /**
  25505. * Creates a tiled ground geometry
  25506. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25507. */
  25508. class TiledGroundGeometry extends _PrimitiveGeometry {
  25509. /**
  25510. * Defines the minimum value on X axis
  25511. */
  25512. xmin: number;
  25513. /**
  25514. * Defines the minimum value on Z axis
  25515. */
  25516. zmin: number;
  25517. /**
  25518. * Defines the maximum value on X axis
  25519. */
  25520. xmax: number;
  25521. /**
  25522. * Defines the maximum value on Z axis
  25523. */
  25524. zmax: number;
  25525. /**
  25526. * Defines the subdivisions to apply to the ground
  25527. */
  25528. subdivisions: {
  25529. w: number;
  25530. h: number;
  25531. };
  25532. /**
  25533. * Defines the precision to use when computing the tiles
  25534. */
  25535. precision: {
  25536. w: number;
  25537. h: number;
  25538. };
  25539. /**
  25540. * Creates a tiled ground geometry
  25541. * @param id defines the unique ID of the geometry
  25542. * @param scene defines the hosting scene
  25543. * @param xmin defines the minimum value on X axis
  25544. * @param zmin defines the minimum value on Z axis
  25545. * @param xmax defines the maximum value on X axis
  25546. * @param zmax defines the maximum value on Z axis
  25547. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  25548. * @param precision defines the precision to use when computing the tiles
  25549. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25550. * @param mesh defines the hosting mesh (can be null)
  25551. */
  25552. constructor(id: string, scene: Scene,
  25553. /**
  25554. * Defines the minimum value on X axis
  25555. */
  25556. xmin: number,
  25557. /**
  25558. * Defines the minimum value on Z axis
  25559. */
  25560. zmin: number,
  25561. /**
  25562. * Defines the maximum value on X axis
  25563. */
  25564. xmax: number,
  25565. /**
  25566. * Defines the maximum value on Z axis
  25567. */
  25568. zmax: number,
  25569. /**
  25570. * Defines the subdivisions to apply to the ground
  25571. */
  25572. subdivisions: {
  25573. w: number;
  25574. h: number;
  25575. },
  25576. /**
  25577. * Defines the precision to use when computing the tiles
  25578. */
  25579. precision: {
  25580. w: number;
  25581. h: number;
  25582. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25583. /** @hidden */
  25584. _regenerateVertexData(): VertexData;
  25585. copy(id: string): Geometry;
  25586. }
  25587. /**
  25588. * Creates a plane geometry
  25589. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  25590. */
  25591. class PlaneGeometry extends _PrimitiveGeometry {
  25592. /**
  25593. * Defines the size of the plane (width === height)
  25594. */
  25595. size: number;
  25596. /**
  25597. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25598. */
  25599. side: number;
  25600. /**
  25601. * Creates a plane geometry
  25602. * @param id defines the unique ID of the geometry
  25603. * @param scene defines the hosting scene
  25604. * @param size defines the size of the plane (width === height)
  25605. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25606. * @param mesh defines the hosting mesh (can be null)
  25607. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25608. */
  25609. constructor(id: string, scene: Scene,
  25610. /**
  25611. * Defines the size of the plane (width === height)
  25612. */
  25613. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25614. /**
  25615. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25616. */
  25617. side?: number);
  25618. /** @hidden */
  25619. _regenerateVertexData(): VertexData;
  25620. copy(id: string): Geometry;
  25621. serialize(): any;
  25622. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  25623. }
  25624. /**
  25625. * Creates a torus knot geometry
  25626. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  25627. */
  25628. class TorusKnotGeometry extends _PrimitiveGeometry {
  25629. /**
  25630. * Defines the radius of the torus knot
  25631. */
  25632. radius: number;
  25633. /**
  25634. * Defines the thickness of the torus knot tube
  25635. */
  25636. tube: number;
  25637. /**
  25638. * Defines the number of radial segments
  25639. */
  25640. radialSegments: number;
  25641. /**
  25642. * Defines the number of tubular segments
  25643. */
  25644. tubularSegments: number;
  25645. /**
  25646. * Defines the first number of windings
  25647. */
  25648. p: number;
  25649. /**
  25650. * Defines the second number of windings
  25651. */
  25652. q: number;
  25653. /**
  25654. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25655. */
  25656. side: number;
  25657. /**
  25658. * Creates a torus knot geometry
  25659. * @param id defines the unique ID of the geometry
  25660. * @param scene defines the hosting scene
  25661. * @param radius defines the radius of the torus knot
  25662. * @param tube defines the thickness of the torus knot tube
  25663. * @param radialSegments defines the number of radial segments
  25664. * @param tubularSegments defines the number of tubular segments
  25665. * @param p defines the first number of windings
  25666. * @param q defines the second number of windings
  25667. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25668. * @param mesh defines the hosting mesh (can be null)
  25669. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25670. */
  25671. constructor(id: string, scene: Scene,
  25672. /**
  25673. * Defines the radius of the torus knot
  25674. */
  25675. radius: number,
  25676. /**
  25677. * Defines the thickness of the torus knot tube
  25678. */
  25679. tube: number,
  25680. /**
  25681. * Defines the number of radial segments
  25682. */
  25683. radialSegments: number,
  25684. /**
  25685. * Defines the number of tubular segments
  25686. */
  25687. tubularSegments: number,
  25688. /**
  25689. * Defines the first number of windings
  25690. */
  25691. p: number,
  25692. /**
  25693. * Defines the second number of windings
  25694. */
  25695. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25696. /**
  25697. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25698. */
  25699. side?: number);
  25700. /** @hidden */
  25701. _regenerateVertexData(): VertexData;
  25702. copy(id: string): Geometry;
  25703. serialize(): any;
  25704. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  25705. }
  25706. }
  25707. declare module BABYLON {
  25708. /**
  25709. * Mesh representing the gorund
  25710. */
  25711. class GroundMesh extends Mesh {
  25712. /** If octree should be generated */
  25713. generateOctree: boolean;
  25714. private _heightQuads;
  25715. /** @hidden */
  25716. _subdivisionsX: number;
  25717. /** @hidden */
  25718. _subdivisionsY: number;
  25719. /** @hidden */
  25720. _width: number;
  25721. /** @hidden */
  25722. _height: number;
  25723. /** @hidden */
  25724. _minX: number;
  25725. /** @hidden */
  25726. _maxX: number;
  25727. /** @hidden */
  25728. _minZ: number;
  25729. /** @hidden */
  25730. _maxZ: number;
  25731. constructor(name: string, scene: Scene);
  25732. /**
  25733. * "GroundMesh"
  25734. * @returns "GroundMesh"
  25735. */
  25736. getClassName(): string;
  25737. /**
  25738. * The minimum of x and y subdivisions
  25739. */
  25740. readonly subdivisions: number;
  25741. /**
  25742. * X subdivisions
  25743. */
  25744. readonly subdivisionsX: number;
  25745. /**
  25746. * Y subdivisions
  25747. */
  25748. readonly subdivisionsY: number;
  25749. /**
  25750. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25751. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25752. * @param chunksCount the number of subdivisions for x and y
  25753. * @param octreeBlocksSize (Default: 32)
  25754. */
  25755. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25756. /**
  25757. * Returns a height (y) value in the Worl system :
  25758. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25759. * @param x x coordinate
  25760. * @param z z coordinate
  25761. * @returns the ground y position if (x, z) are outside the ground surface.
  25762. */
  25763. getHeightAtCoordinates(x: number, z: number): number;
  25764. /**
  25765. * Returns a normalized vector (Vector3) orthogonal to the ground
  25766. * at the ground coordinates (x, z) expressed in the World system.
  25767. * @param x x coordinate
  25768. * @param z z coordinate
  25769. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25770. */
  25771. getNormalAtCoordinates(x: number, z: number): Vector3;
  25772. /**
  25773. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25774. * at the ground coordinates (x, z) expressed in the World system.
  25775. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25776. * @param x x coordinate
  25777. * @param z z coordinate
  25778. * @param ref vector to store the result
  25779. * @returns the GroundMesh.
  25780. */
  25781. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25782. /**
  25783. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25784. * if the ground has been updated.
  25785. * This can be used in the render loop.
  25786. * @returns the GroundMesh.
  25787. */
  25788. updateCoordinateHeights(): GroundMesh;
  25789. private _getFacetAt;
  25790. private _initHeightQuads;
  25791. private _computeHeightQuads;
  25792. /**
  25793. * Serializes this ground mesh
  25794. * @param serializationObject object to write serialization to
  25795. */
  25796. serialize(serializationObject: any): void;
  25797. /**
  25798. * Parses a serialized ground mesh
  25799. * @param parsedMesh the serialized mesh
  25800. * @param scene the scene to create the ground mesh in
  25801. * @returns the created ground mesh
  25802. */
  25803. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25804. }
  25805. }
  25806. declare module BABYLON {
  25807. /**
  25808. * Creates an instance based on a source mesh.
  25809. */
  25810. class InstancedMesh extends AbstractMesh {
  25811. private _sourceMesh;
  25812. private _currentLOD;
  25813. /** @hidden */
  25814. _indexInSourceMeshInstanceArray: number;
  25815. constructor(name: string, source: Mesh);
  25816. /**
  25817. * Returns the string "InstancedMesh".
  25818. */
  25819. getClassName(): string;
  25820. /**
  25821. * If the source mesh receives shadows
  25822. */
  25823. readonly receiveShadows: boolean;
  25824. /**
  25825. * The material of the source mesh
  25826. */
  25827. readonly material: Nullable<Material>;
  25828. /**
  25829. * Visibility of the source mesh
  25830. */
  25831. readonly visibility: number;
  25832. /**
  25833. * Skeleton of the source mesh
  25834. */
  25835. readonly skeleton: Nullable<Skeleton>;
  25836. /**
  25837. * Rendering ground id of the source mesh
  25838. */
  25839. renderingGroupId: number;
  25840. /**
  25841. * Returns the total number of vertices (integer).
  25842. */
  25843. getTotalVertices(): number;
  25844. /**
  25845. * The source mesh of the instance
  25846. */
  25847. readonly sourceMesh: Mesh;
  25848. /**
  25849. * Is this node ready to be used/rendered
  25850. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25851. * @return {boolean} is it ready
  25852. */
  25853. isReady(completeCheck?: boolean): boolean;
  25854. /**
  25855. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25856. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  25857. * @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.
  25858. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  25859. */
  25860. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  25861. /**
  25862. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25863. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25864. * The `data` are either a numeric array either a Float32Array.
  25865. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  25866. * 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).
  25867. * Note that a new underlying VertexBuffer object is created each call.
  25868. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25869. *
  25870. * Possible `kind` values :
  25871. * - BABYLON.VertexBuffer.PositionKind
  25872. * - BABYLON.VertexBuffer.UVKind
  25873. * - BABYLON.VertexBuffer.UV2Kind
  25874. * - BABYLON.VertexBuffer.UV3Kind
  25875. * - BABYLON.VertexBuffer.UV4Kind
  25876. * - BABYLON.VertexBuffer.UV5Kind
  25877. * - BABYLON.VertexBuffer.UV6Kind
  25878. * - BABYLON.VertexBuffer.ColorKind
  25879. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25880. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25881. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25882. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25883. *
  25884. * Returns the Mesh.
  25885. */
  25886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  25887. /**
  25888. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25889. * If the mesh has no geometry, it is simply returned as it is.
  25890. * The `data` are either a numeric array either a Float32Array.
  25891. * No new underlying VertexBuffer object is created.
  25892. * 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.
  25893. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  25894. *
  25895. * Possible `kind` values :
  25896. * - BABYLON.VertexBuffer.PositionKind
  25897. * - BABYLON.VertexBuffer.UVKind
  25898. * - BABYLON.VertexBuffer.UV2Kind
  25899. * - BABYLON.VertexBuffer.UV3Kind
  25900. * - BABYLON.VertexBuffer.UV4Kind
  25901. * - BABYLON.VertexBuffer.UV5Kind
  25902. * - BABYLON.VertexBuffer.UV6Kind
  25903. * - BABYLON.VertexBuffer.ColorKind
  25904. * - BABYLON.VertexBuffer.MatricesIndicesKind
  25905. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  25906. * - BABYLON.VertexBuffer.MatricesWeightsKind
  25907. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  25908. *
  25909. * Returns the Mesh.
  25910. */
  25911. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  25912. /**
  25913. * Sets the mesh indices.
  25914. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  25915. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25916. * This method creates a new index buffer each call.
  25917. * Returns the Mesh.
  25918. */
  25919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  25920. /**
  25921. * Boolean : True if the mesh owns the requested kind of data.
  25922. */
  25923. isVerticesDataPresent(kind: string): boolean;
  25924. /**
  25925. * Returns an array of indices (IndicesArray).
  25926. */
  25927. getIndices(): Nullable<IndicesArray>;
  25928. readonly _positions: Nullable<Vector3[]>;
  25929. /**
  25930. * Sets a new updated BoundingInfo to the mesh.
  25931. * @returns the mesh.
  25932. */
  25933. refreshBoundingInfo(): InstancedMesh;
  25934. /** @hidden */
  25935. _preActivate(): InstancedMesh;
  25936. /** @hidden */
  25937. _activate(renderId: number): InstancedMesh;
  25938. /**
  25939. * Returns the current associated LOD AbstractMesh.
  25940. */
  25941. getLOD(camera: Camera): AbstractMesh;
  25942. /** @hidden */
  25943. _syncSubMeshes(): InstancedMesh;
  25944. /** @hidden */
  25945. _generatePointsArray(): boolean;
  25946. /**
  25947. * Creates a new InstancedMesh from the current mesh.
  25948. * - name (string) : the cloned mesh name
  25949. * - newParent (optional Node) : the optional Node to parent the clone to.
  25950. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  25951. *
  25952. * Returns the clone.
  25953. */
  25954. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  25955. /**
  25956. * Disposes the InstancedMesh.
  25957. * Returns nothing.
  25958. */
  25959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25960. }
  25961. }
  25962. declare module BABYLON {
  25963. /**
  25964. * Line mesh
  25965. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  25966. */
  25967. class LinesMesh extends Mesh {
  25968. /**
  25969. * If vertex color should be applied to the mesh
  25970. */
  25971. useVertexColor?: boolean | undefined;
  25972. /**
  25973. * If vertex alpha should be applied to the mesh
  25974. */
  25975. useVertexAlpha?: boolean | undefined;
  25976. /**
  25977. * Color of the line (Default: White)
  25978. */
  25979. color: Color3;
  25980. /**
  25981. * Alpha of the line (Default: 1)
  25982. */
  25983. alpha: number;
  25984. /**
  25985. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25986. * This margin is expressed in world space coordinates, so its value may vary.
  25987. * Default value is 0.1
  25988. * @returns the intersection Threshold value.
  25989. */
  25990. /**
  25991. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  25992. * This margin is expressed in world space coordinates, so its value may vary.
  25993. */
  25994. intersectionThreshold: number;
  25995. private _intersectionThreshold;
  25996. private _colorShader;
  25997. /**
  25998. * Creates a new LinesMesh
  25999. * @param name defines the name
  26000. * @param scene defines the hosting scene
  26001. * @param parent defines the parent mesh if any
  26002. * @param source defines the optional source LinesMesh used to clone data from
  26003. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26004. * When false, achieved by calling a clone(), also passing False.
  26005. * This will make creation of children, recursive.
  26006. * @param useVertexColor defines if this LinesMesh supports vertex color
  26007. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26008. */
  26009. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26010. /**
  26011. * If vertex color should be applied to the mesh
  26012. */
  26013. useVertexColor?: boolean | undefined,
  26014. /**
  26015. * If vertex alpha should be applied to the mesh
  26016. */
  26017. useVertexAlpha?: boolean | undefined);
  26018. /**
  26019. * Returns the string "LineMesh"
  26020. */
  26021. getClassName(): string;
  26022. /**
  26023. * @hidden
  26024. */
  26025. /**
  26026. * @hidden
  26027. */
  26028. material: Material;
  26029. /**
  26030. * @hidden
  26031. */
  26032. readonly checkCollisions: boolean;
  26033. /** @hidden */
  26034. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26035. /** @hidden */
  26036. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26037. /**
  26038. * Disposes of the line mesh
  26039. * @param doNotRecurse If children should be disposed
  26040. */
  26041. dispose(doNotRecurse?: boolean): void;
  26042. /**
  26043. * Returns a new LineMesh object cloned from the current one.
  26044. */
  26045. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26046. }
  26047. }
  26048. declare module BABYLON {
  26049. /**
  26050. * @hidden
  26051. **/
  26052. class _CreationDataStorage {
  26053. closePath?: boolean;
  26054. closeArray?: boolean;
  26055. idx: number[];
  26056. dashSize: number;
  26057. gapSize: number;
  26058. path3D: Path3D;
  26059. pathArray: Vector3[][];
  26060. arc: number;
  26061. radius: number;
  26062. cap: number;
  26063. tessellation: number;
  26064. }
  26065. /**
  26066. * @hidden
  26067. **/
  26068. class _InstanceDataStorage {
  26069. visibleInstances: any;
  26070. renderIdForInstances: number[];
  26071. batchCache: _InstancesBatch;
  26072. instancesBufferSize: number;
  26073. instancesBuffer: Nullable<Buffer>;
  26074. instancesData: Float32Array;
  26075. overridenInstanceCount: number;
  26076. }
  26077. /**
  26078. * @hidden
  26079. **/
  26080. class _InstancesBatch {
  26081. mustReturn: boolean;
  26082. visibleInstances: Nullable<InstancedMesh[]>[];
  26083. renderSelf: boolean[];
  26084. }
  26085. /**
  26086. * Class used to represent renderable models
  26087. */
  26088. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26089. /**
  26090. * Mesh side orientation : usually the external or front surface
  26091. */
  26092. static readonly FRONTSIDE: number;
  26093. /**
  26094. * Mesh side orientation : usually the internal or back surface
  26095. */
  26096. static readonly BACKSIDE: number;
  26097. /**
  26098. * Mesh side orientation : both internal and external or front and back surfaces
  26099. */
  26100. static readonly DOUBLESIDE: number;
  26101. /**
  26102. * Mesh side orientation : by default, `FRONTSIDE`
  26103. */
  26104. static readonly DEFAULTSIDE: number;
  26105. /**
  26106. * Mesh cap setting : no cap
  26107. */
  26108. static readonly NO_CAP: number;
  26109. /**
  26110. * Mesh cap setting : one cap at the beginning of the mesh
  26111. */
  26112. static readonly CAP_START: number;
  26113. /**
  26114. * Mesh cap setting : one cap at the end of the mesh
  26115. */
  26116. static readonly CAP_END: number;
  26117. /**
  26118. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26119. */
  26120. static readonly CAP_ALL: number;
  26121. private _onBeforeRenderObservable;
  26122. private _onAfterRenderObservable;
  26123. private _onBeforeDrawObservable;
  26124. /**
  26125. * An event triggered before rendering the mesh
  26126. */
  26127. readonly onBeforeRenderObservable: Observable<Mesh>;
  26128. /**
  26129. * An event triggered after rendering the mesh
  26130. */
  26131. readonly onAfterRenderObservable: Observable<Mesh>;
  26132. /**
  26133. * An event triggered before drawing the mesh
  26134. */
  26135. readonly onBeforeDrawObservable: Observable<Mesh>;
  26136. private _onBeforeDrawObserver;
  26137. /**
  26138. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26139. */
  26140. onBeforeDraw: () => void;
  26141. /**
  26142. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26143. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26144. */
  26145. delayLoadState: number;
  26146. /**
  26147. * Gets the list of instances created from this mesh
  26148. * it is not supposed to be modified manually.
  26149. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26151. */
  26152. instances: InstancedMesh[];
  26153. /**
  26154. * Gets the file containing delay loading data for this mesh
  26155. */
  26156. delayLoadingFile: string;
  26157. /** @hidden */
  26158. _binaryInfo: any;
  26159. private _LODLevels;
  26160. /**
  26161. * User defined function used to change how LOD level selection is done
  26162. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26163. */
  26164. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26165. private _morphTargetManager;
  26166. /**
  26167. * Gets or sets the morph target manager
  26168. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26169. */
  26170. morphTargetManager: Nullable<MorphTargetManager>;
  26171. /** @hidden */
  26172. _creationDataStorage: Nullable<_CreationDataStorage>;
  26173. /** @hidden */
  26174. _geometry: Nullable<Geometry>;
  26175. /** @hidden */
  26176. _delayInfo: Array<string>;
  26177. /** @hidden */
  26178. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26179. /** @hidden */
  26180. _instanceDataStorage: _InstanceDataStorage;
  26181. private _effectiveMaterial;
  26182. /** @hidden */
  26183. _shouldGenerateFlatShading: boolean;
  26184. private _preActivateId;
  26185. /** @hidden */
  26186. _originalBuilderSideOrientation: number;
  26187. /**
  26188. * Use this property to change the original side orientation defined at construction time
  26189. */
  26190. overrideMaterialSideOrientation: Nullable<number>;
  26191. private _areNormalsFrozen;
  26192. private _sourcePositions;
  26193. private _sourceNormals;
  26194. private _source;
  26195. private meshMap;
  26196. /**
  26197. * Gets the source mesh (the one used to clone this one from)
  26198. */
  26199. readonly source: Nullable<Mesh>;
  26200. /**
  26201. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26202. */
  26203. isUnIndexed: boolean;
  26204. /**
  26205. * @constructor
  26206. * @param name The value used by scene.getMeshByName() to do a lookup.
  26207. * @param scene The scene to add this mesh to.
  26208. * @param parent The parent of this mesh, if it has one
  26209. * @param source An optional Mesh from which geometry is shared, cloned.
  26210. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26211. * When false, achieved by calling a clone(), also passing False.
  26212. * This will make creation of children, recursive.
  26213. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26214. */
  26215. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26216. /**
  26217. * Gets the class name
  26218. * @returns the string "Mesh".
  26219. */
  26220. getClassName(): string;
  26221. /**
  26222. * Returns a description of this mesh
  26223. * @param fullDetails define if full details about this mesh must be used
  26224. * @returns a descriptive string representing this mesh
  26225. */
  26226. toString(fullDetails?: boolean): string;
  26227. /** @hidden */
  26228. _unBindEffect(): void;
  26229. /**
  26230. * Gets a boolean indicating if this mesh has LOD
  26231. */
  26232. readonly hasLODLevels: boolean;
  26233. /**
  26234. * Gets the list of MeshLODLevel associated with the current mesh
  26235. * @returns an array of MeshLODLevel
  26236. */
  26237. getLODLevels(): MeshLODLevel[];
  26238. private _sortLODLevels;
  26239. /**
  26240. * Add a mesh as LOD level triggered at the given distance.
  26241. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26242. * @param distance The distance from the center of the object to show this level
  26243. * @param mesh The mesh to be added as LOD level (can be null)
  26244. * @return This mesh (for chaining)
  26245. */
  26246. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26247. /**
  26248. * Returns the LOD level mesh at the passed distance or null if not found.
  26249. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26250. * @param distance The distance from the center of the object to show this level
  26251. * @returns a Mesh or `null`
  26252. */
  26253. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26254. /**
  26255. * Remove a mesh from the LOD array
  26256. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26257. * @param mesh defines the mesh to be removed
  26258. * @return This mesh (for chaining)
  26259. */
  26260. removeLODLevel(mesh: Mesh): Mesh;
  26261. /**
  26262. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26263. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26264. * @param camera defines the camera to use to compute distance
  26265. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26266. * @return This mesh (for chaining)
  26267. */
  26268. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26269. /**
  26270. * Gets the mesh internal Geometry object
  26271. */
  26272. readonly geometry: Nullable<Geometry>;
  26273. /**
  26274. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26275. * @returns the total number of vertices
  26276. */
  26277. getTotalVertices(): number;
  26278. /**
  26279. * Returns the content of an associated vertex buffer
  26280. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26281. * - BABYLON.VertexBuffer.PositionKind
  26282. * - BABYLON.VertexBuffer.UVKind
  26283. * - BABYLON.VertexBuffer.UV2Kind
  26284. * - BABYLON.VertexBuffer.UV3Kind
  26285. * - BABYLON.VertexBuffer.UV4Kind
  26286. * - BABYLON.VertexBuffer.UV5Kind
  26287. * - BABYLON.VertexBuffer.UV6Kind
  26288. * - BABYLON.VertexBuffer.ColorKind
  26289. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26290. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26291. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26292. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26293. * @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
  26294. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26295. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26296. */
  26297. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26298. /**
  26299. * Returns the mesh VertexBuffer object from the requested `kind`
  26300. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26301. * - BABYLON.VertexBuffer.PositionKind
  26302. * - BABYLON.VertexBuffer.UVKind
  26303. * - BABYLON.VertexBuffer.UV2Kind
  26304. * - BABYLON.VertexBuffer.UV3Kind
  26305. * - BABYLON.VertexBuffer.UV4Kind
  26306. * - BABYLON.VertexBuffer.UV5Kind
  26307. * - BABYLON.VertexBuffer.UV6Kind
  26308. * - BABYLON.VertexBuffer.ColorKind
  26309. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26310. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26311. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26312. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26313. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26314. */
  26315. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26316. /**
  26317. * Tests if a specific vertex buffer is associated with this mesh
  26318. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26319. * - BABYLON.VertexBuffer.PositionKind
  26320. * - BABYLON.VertexBuffer.UVKind
  26321. * - BABYLON.VertexBuffer.UV2Kind
  26322. * - BABYLON.VertexBuffer.UV3Kind
  26323. * - BABYLON.VertexBuffer.UV4Kind
  26324. * - BABYLON.VertexBuffer.UV5Kind
  26325. * - BABYLON.VertexBuffer.UV6Kind
  26326. * - BABYLON.VertexBuffer.ColorKind
  26327. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26328. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26329. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26330. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26331. * @returns a boolean
  26332. */
  26333. isVerticesDataPresent(kind: string): boolean;
  26334. /**
  26335. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26336. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26337. * - BABYLON.VertexBuffer.PositionKind
  26338. * - BABYLON.VertexBuffer.UVKind
  26339. * - BABYLON.VertexBuffer.UV2Kind
  26340. * - BABYLON.VertexBuffer.UV3Kind
  26341. * - BABYLON.VertexBuffer.UV4Kind
  26342. * - BABYLON.VertexBuffer.UV5Kind
  26343. * - BABYLON.VertexBuffer.UV6Kind
  26344. * - BABYLON.VertexBuffer.ColorKind
  26345. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26346. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26347. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26348. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26349. * @returns a boolean
  26350. */
  26351. isVertexBufferUpdatable(kind: string): boolean;
  26352. /**
  26353. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26354. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26355. * - BABYLON.VertexBuffer.PositionKind
  26356. * - BABYLON.VertexBuffer.UVKind
  26357. * - BABYLON.VertexBuffer.UV2Kind
  26358. * - BABYLON.VertexBuffer.UV3Kind
  26359. * - BABYLON.VertexBuffer.UV4Kind
  26360. * - BABYLON.VertexBuffer.UV5Kind
  26361. * - BABYLON.VertexBuffer.UV6Kind
  26362. * - BABYLON.VertexBuffer.ColorKind
  26363. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26364. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26365. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26366. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26367. * @returns an array of strings
  26368. */
  26369. getVerticesDataKinds(): string[];
  26370. /**
  26371. * Returns a positive integer : the total number of indices in this mesh geometry.
  26372. * @returns the numner of indices or zero if the mesh has no geometry.
  26373. */
  26374. getTotalIndices(): number;
  26375. /**
  26376. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26377. * @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.
  26378. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26379. * @returns the indices array or an empty array if the mesh has no geometry
  26380. */
  26381. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26382. readonly isBlocked: boolean;
  26383. /**
  26384. * Determine if the current mesh is ready to be rendered
  26385. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26386. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26387. * @returns true if all associated assets are ready (material, textures, shaders)
  26388. */
  26389. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26390. /**
  26391. * 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.
  26392. */
  26393. readonly areNormalsFrozen: boolean;
  26394. /**
  26395. * 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.
  26396. * @returns the current mesh
  26397. */
  26398. freezeNormals(): Mesh;
  26399. /**
  26400. * 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
  26401. * @returns the current mesh
  26402. */
  26403. unfreezeNormals(): Mesh;
  26404. /**
  26405. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26406. */
  26407. overridenInstanceCount: number;
  26408. /** @hidden */
  26409. _preActivate(): Mesh;
  26410. /** @hidden */
  26411. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26412. /** @hidden */
  26413. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26414. /**
  26415. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26416. * This means the mesh underlying bounding box and sphere are recomputed.
  26417. * @returns the current mesh
  26418. */
  26419. refreshBoundingInfo(): Mesh;
  26420. /** @hidden */
  26421. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  26422. private _getPositionData;
  26423. /** @hidden */
  26424. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26425. /**
  26426. * This function will subdivide the mesh into multiple submeshes
  26427. * @param count defines the expected number of submeshes
  26428. */
  26429. subdivide(count: number): void;
  26430. /**
  26431. * Copy a FloatArray into a specific associated vertex buffer
  26432. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26433. * - BABYLON.VertexBuffer.PositionKind
  26434. * - BABYLON.VertexBuffer.UVKind
  26435. * - BABYLON.VertexBuffer.UV2Kind
  26436. * - BABYLON.VertexBuffer.UV3Kind
  26437. * - BABYLON.VertexBuffer.UV4Kind
  26438. * - BABYLON.VertexBuffer.UV5Kind
  26439. * - BABYLON.VertexBuffer.UV6Kind
  26440. * - BABYLON.VertexBuffer.ColorKind
  26441. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26442. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26443. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26444. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26445. * @param data defines the data source
  26446. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26447. * @param stride defines the data stride size (can be null)
  26448. * @returns the current mesh
  26449. */
  26450. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26451. /**
  26452. * Flags an associated vertex buffer as updatable
  26453. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26454. * - BABYLON.VertexBuffer.PositionKind
  26455. * - BABYLON.VertexBuffer.UVKind
  26456. * - BABYLON.VertexBuffer.UV2Kind
  26457. * - BABYLON.VertexBuffer.UV3Kind
  26458. * - BABYLON.VertexBuffer.UV4Kind
  26459. * - BABYLON.VertexBuffer.UV5Kind
  26460. * - BABYLON.VertexBuffer.UV6Kind
  26461. * - BABYLON.VertexBuffer.ColorKind
  26462. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26463. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26464. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26465. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26466. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26467. */
  26468. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26469. /**
  26470. * Sets the mesh global Vertex Buffer
  26471. * @param buffer defines the buffer to use
  26472. * @returns the current mesh
  26473. */
  26474. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26475. /**
  26476. * Update a specific associated vertex buffer
  26477. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26478. * - BABYLON.VertexBuffer.PositionKind
  26479. * - BABYLON.VertexBuffer.UVKind
  26480. * - BABYLON.VertexBuffer.UV2Kind
  26481. * - BABYLON.VertexBuffer.UV3Kind
  26482. * - BABYLON.VertexBuffer.UV4Kind
  26483. * - BABYLON.VertexBuffer.UV5Kind
  26484. * - BABYLON.VertexBuffer.UV6Kind
  26485. * - BABYLON.VertexBuffer.ColorKind
  26486. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26487. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26488. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26489. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26490. * @param data defines the data source
  26491. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26492. * @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)
  26493. * @returns the current mesh
  26494. */
  26495. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26496. /**
  26497. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26498. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26499. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26500. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26501. * @returns the current mesh
  26502. */
  26503. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26504. /**
  26505. * Creates a un-shared specific occurence of the geometry for the mesh.
  26506. * @returns the current mesh
  26507. */
  26508. makeGeometryUnique(): Mesh;
  26509. /**
  26510. * Set the index buffer of this mesh
  26511. * @param indices defines the source data
  26512. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  26513. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  26514. * @returns the current mesh
  26515. */
  26516. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  26517. /**
  26518. * Update the current index buffer
  26519. * @param indices defines the source data
  26520. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26521. * @returns the current mesh
  26522. */
  26523. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  26524. /**
  26525. * Invert the geometry to move from a right handed system to a left handed one.
  26526. * @returns the current mesh
  26527. */
  26528. toLeftHanded(): Mesh;
  26529. /** @hidden */
  26530. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  26531. /** @hidden */
  26532. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  26533. /**
  26534. * Registers for this mesh a javascript function called just before the rendering process
  26535. * @param func defines the function to call before rendering this mesh
  26536. * @returns the current mesh
  26537. */
  26538. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26539. /**
  26540. * Disposes a previously registered javascript function called before the rendering
  26541. * @param func defines the function to remove
  26542. * @returns the current mesh
  26543. */
  26544. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  26545. /**
  26546. * Registers for this mesh a javascript function called just after the rendering is complete
  26547. * @param func defines the function to call after rendering this mesh
  26548. * @returns the current mesh
  26549. */
  26550. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26551. /**
  26552. * Disposes a previously registered javascript function called after the rendering.
  26553. * @param func defines the function to remove
  26554. * @returns the current mesh
  26555. */
  26556. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  26557. /** @hidden */
  26558. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  26559. /** @hidden */
  26560. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  26561. /** @hidden */
  26562. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  26563. /**
  26564. * 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
  26565. * @param subMesh defines the subMesh to render
  26566. * @param enableAlphaMode defines if alpha mode can be changed
  26567. * @returns the current mesh
  26568. */
  26569. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  26570. private _onBeforeDraw;
  26571. /**
  26572. * Renormalize the mesh and patch it up if there are no weights
  26573. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  26574. * However in the case of zero weights then we set just a single influence to 1.
  26575. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  26576. */
  26577. cleanMatrixWeights(): void;
  26578. private normalizeSkinFourWeights;
  26579. private normalizeSkinWeightsAndExtra;
  26580. /**
  26581. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  26582. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  26583. * the user know there was an issue with importing the mesh
  26584. * @returns a validation object with skinned, valid and report string
  26585. */
  26586. validateSkinning(): {
  26587. skinned: boolean;
  26588. valid: boolean;
  26589. report: string;
  26590. };
  26591. /** @hidden */
  26592. _checkDelayState(): Mesh;
  26593. private _queueLoad;
  26594. /**
  26595. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26596. * A mesh is in the frustum if its bounding box intersects the frustum
  26597. * @param frustumPlanes defines the frustum to test
  26598. * @returns true if the mesh is in the frustum planes
  26599. */
  26600. isInFrustum(frustumPlanes: Plane[]): boolean;
  26601. /**
  26602. * Sets the mesh material by the material or multiMaterial `id` property
  26603. * @param id is a string identifying the material or the multiMaterial
  26604. * @returns the current mesh
  26605. */
  26606. setMaterialByID(id: string): Mesh;
  26607. /**
  26608. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  26609. * @returns an array of IAnimatable
  26610. */
  26611. getAnimatables(): IAnimatable[];
  26612. /**
  26613. * Modifies the mesh geometry according to the passed transformation matrix.
  26614. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  26615. * The mesh normals are modified using the same transformation.
  26616. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26617. * @param transform defines the transform matrix to use
  26618. * @see http://doc.babylonjs.com/resources/baking_transformations
  26619. * @returns the current mesh
  26620. */
  26621. bakeTransformIntoVertices(transform: Matrix): Mesh;
  26622. /**
  26623. * Modifies the mesh geometry according to its own current World Matrix.
  26624. * The mesh World Matrix is then reset.
  26625. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  26626. * Note that, under the hood, this method sets a new VertexBuffer each call.
  26627. * @see http://doc.babylonjs.com/resources/baking_transformations
  26628. * @returns the current mesh
  26629. */
  26630. bakeCurrentTransformIntoVertices(): Mesh;
  26631. /** @hidden */
  26632. readonly _positions: Nullable<Vector3[]>;
  26633. /** @hidden */
  26634. _resetPointsArrayCache(): Mesh;
  26635. /** @hidden */
  26636. _generatePointsArray(): boolean;
  26637. /**
  26638. * Returns a new Mesh object generated from the current mesh properties.
  26639. * This method must not get confused with createInstance()
  26640. * @param name is a string, the name given to the new mesh
  26641. * @param newParent can be any Node object (default `null`)
  26642. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  26643. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  26644. * @returns a new mesh
  26645. */
  26646. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  26647. /**
  26648. * Releases resources associated with this mesh.
  26649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26651. */
  26652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26653. /**
  26654. * Modifies the mesh geometry according to a displacement map.
  26655. * 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.
  26656. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26657. * @param url is a string, the URL from the image file is to be downloaded.
  26658. * @param minHeight is the lower limit of the displacement.
  26659. * @param maxHeight is the upper limit of the displacement.
  26660. * @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.
  26661. * @param uvOffset is an optional vector2 used to offset UV.
  26662. * @param uvScale is an optional vector2 used to scale UV.
  26663. * @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.
  26664. * @returns the Mesh.
  26665. */
  26666. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26667. /**
  26668. * Modifies the mesh geometry according to a displacementMap buffer.
  26669. * 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.
  26670. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  26671. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  26672. * @param heightMapWidth is the width of the buffer image.
  26673. * @param heightMapHeight is the height of the buffer image.
  26674. * @param minHeight is the lower limit of the displacement.
  26675. * @param maxHeight is the upper limit of the displacement.
  26676. * @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.
  26677. * @param uvOffset is an optional vector2 used to offset UV.
  26678. * @param uvScale is an optional vector2 used to scale UV.
  26679. * @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.
  26680. * @returns the Mesh.
  26681. */
  26682. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  26683. /**
  26684. * Modify the mesh to get a flat shading rendering.
  26685. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  26686. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  26687. * @returns current mesh
  26688. */
  26689. convertToFlatShadedMesh(): Mesh;
  26690. /**
  26691. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  26692. * In other words, more vertices, no more indices and a single bigger VBO.
  26693. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  26694. * @returns current mesh
  26695. */
  26696. convertToUnIndexedMesh(): Mesh;
  26697. /**
  26698. * Inverses facet orientations.
  26699. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  26700. * @param flipNormals will also inverts the normals
  26701. * @returns current mesh
  26702. */
  26703. flipFaces(flipNormals?: boolean): Mesh;
  26704. /**
  26705. * Creates a new InstancedMesh object from the mesh model.
  26706. * Warning : this method is not supported for Line mesh and LineSystem
  26707. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26708. * @param name defines the name of the new instance
  26709. * @returns a new InstancedMesh
  26710. */
  26711. createInstance(name: string): InstancedMesh;
  26712. /**
  26713. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  26714. * After this call, all the mesh instances have the same submeshes than the current mesh.
  26715. * @returns the current mesh
  26716. */
  26717. synchronizeInstances(): Mesh;
  26718. /**
  26719. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  26720. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  26721. * This should be used together with the simplification to avoid disappearing triangles.
  26722. * @param successCallback an optional success callback to be called after the optimization finished.
  26723. * @returns the current mesh
  26724. */
  26725. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  26726. /**
  26727. * Serialize current mesh
  26728. * @param serializationObject defines the object which will receive the serialization data
  26729. */
  26730. serialize(serializationObject: any): void;
  26731. /** @hidden */
  26732. _syncGeometryWithMorphTargetManager(): void;
  26733. /**
  26734. * Returns a new Mesh object parsed from the source provided.
  26735. * @param parsedMesh is the source
  26736. * @param scene defines the hosting scene
  26737. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  26738. * @returns a new Mesh
  26739. */
  26740. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  26741. /**
  26742. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  26743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26744. * @param name defines the name of the mesh to create
  26745. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  26746. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  26747. * @param closePath creates a seam between the first and the last points of each path of the path array
  26748. * @param offset is taken in account only if the `pathArray` is containing a single path
  26749. * @param scene defines the hosting scene
  26750. * @param updatable defines if the mesh must be flagged as updatable
  26751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26752. * @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)
  26753. * @returns a new Mesh
  26754. */
  26755. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26756. /**
  26757. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  26758. * @param name defines the name of the mesh to create
  26759. * @param radius sets the radius size (float) of the polygon (default 0.5)
  26760. * @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
  26761. * @param scene defines the hosting scene
  26762. * @param updatable defines if the mesh must be flagged as updatable
  26763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26764. * @returns a new Mesh
  26765. */
  26766. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26767. /**
  26768. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  26769. * @param name defines the name of the mesh to create
  26770. * @param size sets the size (float) of each box side (default 1)
  26771. * @param scene defines the hosting scene
  26772. * @param updatable defines if the mesh must be flagged as updatable
  26773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26774. * @returns a new Mesh
  26775. */
  26776. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26777. /**
  26778. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26779. * @param name defines the name of the mesh to create
  26780. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26781. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26782. * @param scene defines the hosting scene
  26783. * @param updatable defines if the mesh must be flagged as updatable
  26784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26785. * @returns a new Mesh
  26786. */
  26787. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26788. /**
  26789. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26790. * @param name defines the name of the mesh to create
  26791. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26792. * @param diameterTop set the top cap diameter (floats, default 1)
  26793. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26794. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26795. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26796. * @param scene defines the hosting scene
  26797. * @param updatable defines if the mesh must be flagged as updatable
  26798. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26799. * @returns a new Mesh
  26800. */
  26801. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26802. /**
  26803. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26804. * @param name defines the name of the mesh to create
  26805. * @param diameter sets the diameter size (float) of the torus (default 1)
  26806. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26807. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26808. * @param scene defines the hosting scene
  26809. * @param updatable defines if the mesh must be flagged as updatable
  26810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26811. * @returns a new Mesh
  26812. */
  26813. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26814. /**
  26815. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26816. * @param name defines the name of the mesh to create
  26817. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26818. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26819. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26820. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26821. * @param p the number of windings on X axis (positive integers, default 2)
  26822. * @param q the number of windings on Y axis (positive integers, default 3)
  26823. * @param scene defines the hosting scene
  26824. * @param updatable defines if the mesh must be flagged as updatable
  26825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26826. * @returns a new Mesh
  26827. */
  26828. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26829. /**
  26830. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26831. * @param name defines the name of the mesh to create
  26832. * @param points is an array successive Vector3
  26833. * @param scene defines the hosting scene
  26834. * @param updatable defines if the mesh must be flagged as updatable
  26835. * @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).
  26836. * @returns a new Mesh
  26837. */
  26838. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26839. /**
  26840. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26841. * @param name defines the name of the mesh to create
  26842. * @param points is an array successive Vector3
  26843. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26844. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26845. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26846. * @param scene defines the hosting scene
  26847. * @param updatable defines if the mesh must be flagged as updatable
  26848. * @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)
  26849. * @returns a new Mesh
  26850. */
  26851. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26852. /**
  26853. * Creates a polygon mesh.
  26854. * Please consider using the same method from the MeshBuilder class instead.
  26855. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26856. * 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.
  26857. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26858. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26859. * Remember you can only change the shape positions, not their number when updating a polygon.
  26860. */
  26861. /**
  26862. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26863. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26864. * @param name defines the name of the mesh to create
  26865. * @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
  26866. * @param scene defines the hosting scene
  26867. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26868. * @param updatable defines if the mesh must be flagged as updatable
  26869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26870. * @returns a new Mesh
  26871. */
  26872. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26873. /**
  26874. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26875. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26876. * @param name defines the name of the mesh to create
  26877. * @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
  26878. * @param depth defines the height of extrusion
  26879. * @param scene defines the hosting scene
  26880. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26881. * @param updatable defines if the mesh must be flagged as updatable
  26882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26883. * @returns a new Mesh
  26884. */
  26885. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  26886. /**
  26887. * Creates an extruded shape mesh.
  26888. * 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
  26889. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26890. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26891. * @param name defines the name of the mesh to create
  26892. * @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
  26893. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26894. * @param scale is the value to scale the shape
  26895. * @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
  26896. * @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
  26897. * @param scene defines the hosting scene
  26898. * @param updatable defines if the mesh must be flagged as updatable
  26899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26900. * @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)
  26901. * @returns a new Mesh
  26902. */
  26903. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26904. /**
  26905. * Creates an custom extruded shape mesh.
  26906. * The custom extrusion is a parametric shape.
  26907. * It has no predefined shape. Its final shape will depend on the input parameters.
  26908. * Please consider using the same method from the MeshBuilder class instead
  26909. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26910. * @param name defines the name of the mesh to create
  26911. * @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
  26912. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26913. * @param scaleFunction is a custom Javascript function called on each path point
  26914. * @param rotationFunction is a custom Javascript function called on each path point
  26915. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26916. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26917. * @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
  26918. * @param scene defines the hosting scene
  26919. * @param updatable defines if the mesh must be flagged as updatable
  26920. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26921. * @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)
  26922. * @returns a new Mesh
  26923. */
  26924. 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;
  26925. /**
  26926. * Creates lathe mesh.
  26927. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26928. * Please consider using the same method from the MeshBuilder class instead
  26929. * @param name defines the name of the mesh to create
  26930. * @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
  26931. * @param radius is the radius value of the lathe
  26932. * @param tessellation is the side number of the lathe.
  26933. * @param scene defines the hosting scene
  26934. * @param updatable defines if the mesh must be flagged as updatable
  26935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26936. * @returns a new Mesh
  26937. */
  26938. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26939. /**
  26940. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26941. * @param name defines the name of the mesh to create
  26942. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26943. * @param scene defines the hosting scene
  26944. * @param updatable defines if the mesh must be flagged as updatable
  26945. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26946. * @returns a new Mesh
  26947. */
  26948. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26949. /**
  26950. * Creates a ground mesh.
  26951. * Please consider using the same method from the MeshBuilder class instead
  26952. * @param name defines the name of the mesh to create
  26953. * @param width set the width of the ground
  26954. * @param height set the height of the ground
  26955. * @param subdivisions sets the number of subdivisions per side
  26956. * @param scene defines the hosting scene
  26957. * @param updatable defines if the mesh must be flagged as updatable
  26958. * @returns a new Mesh
  26959. */
  26960. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26961. /**
  26962. * Creates a tiled ground mesh.
  26963. * Please consider using the same method from the MeshBuilder class instead
  26964. * @param name defines the name of the mesh to create
  26965. * @param xmin set the ground minimum X coordinate
  26966. * @param zmin set the ground minimum Y coordinate
  26967. * @param xmax set the ground maximum X coordinate
  26968. * @param zmax set the ground maximum Z coordinate
  26969. * @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
  26970. * @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
  26971. * @param scene defines the hosting scene
  26972. * @param updatable defines if the mesh must be flagged as updatable
  26973. * @returns a new Mesh
  26974. */
  26975. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26976. w: number;
  26977. h: number;
  26978. }, precision: {
  26979. w: number;
  26980. h: number;
  26981. }, scene: Scene, updatable?: boolean): Mesh;
  26982. /**
  26983. * Creates a ground mesh from a height map.
  26984. * Please consider using the same method from the MeshBuilder class instead
  26985. * @see http://doc.babylonjs.com/babylon101/height_map
  26986. * @param name defines the name of the mesh to create
  26987. * @param url sets the URL of the height map image resource
  26988. * @param width set the ground width size
  26989. * @param height set the ground height size
  26990. * @param subdivisions sets the number of subdivision per side
  26991. * @param minHeight is the minimum altitude on the ground
  26992. * @param maxHeight is the maximum altitude on the ground
  26993. * @param scene defines the hosting scene
  26994. * @param updatable defines if the mesh must be flagged as updatable
  26995. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26996. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26997. * @returns a new Mesh
  26998. */
  26999. 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;
  27000. /**
  27001. * Creates a tube mesh.
  27002. * The tube is a parametric shape.
  27003. * It has no predefined shape. Its final shape will depend on the input parameters.
  27004. * Please consider using the same method from the MeshBuilder class instead
  27005. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27006. * @param name defines the name of the mesh to create
  27007. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27008. * @param radius sets the tube radius size
  27009. * @param tessellation is the number of sides on the tubular surface
  27010. * @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
  27011. * @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
  27012. * @param scene defines the hosting scene
  27013. * @param updatable defines if the mesh must be flagged as updatable
  27014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27015. * @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)
  27016. * @returns a new Mesh
  27017. */
  27018. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27019. (i: number, distance: number): number;
  27020. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27021. /**
  27022. * Creates a polyhedron mesh.
  27023. * Please consider using the same method from the MeshBuilder class instead.
  27024. * * 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
  27025. * * The parameter `size` (positive float, default 1) sets the polygon size
  27026. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27027. * * 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`
  27028. * * 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
  27029. * * 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)`)
  27030. * * 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
  27031. * * 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
  27032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27033. * * 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
  27034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27035. * @param name defines the name of the mesh to create
  27036. * @param options defines the options used to create the mesh
  27037. * @param scene defines the hosting scene
  27038. * @returns a new Mesh
  27039. */
  27040. static CreatePolyhedron(name: string, options: {
  27041. type?: number;
  27042. size?: number;
  27043. sizeX?: number;
  27044. sizeY?: number;
  27045. sizeZ?: number;
  27046. custom?: any;
  27047. faceUV?: Vector4[];
  27048. faceColors?: Color4[];
  27049. updatable?: boolean;
  27050. sideOrientation?: number;
  27051. }, scene: Scene): Mesh;
  27052. /**
  27053. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27054. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27055. * * 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`)
  27056. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27057. * * 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
  27058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27059. * * 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
  27060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27061. * @param name defines the name of the mesh
  27062. * @param options defines the options used to create the mesh
  27063. * @param scene defines the hosting scene
  27064. * @returns a new Mesh
  27065. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27066. */
  27067. static CreateIcoSphere(name: string, options: {
  27068. radius?: number;
  27069. flat?: boolean;
  27070. subdivisions?: number;
  27071. sideOrientation?: number;
  27072. updatable?: boolean;
  27073. }, scene: Scene): Mesh;
  27074. /**
  27075. * Creates a decal mesh.
  27076. * Please consider using the same method from the MeshBuilder class instead.
  27077. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27078. * @param name defines the name of the mesh
  27079. * @param sourceMesh defines the mesh receiving the decal
  27080. * @param position sets the position of the decal in world coordinates
  27081. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27082. * @param size sets the decal scaling
  27083. * @param angle sets the angle to rotate the decal
  27084. * @returns a new Mesh
  27085. */
  27086. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27087. /**
  27088. * Prepare internal position array for software CPU skinning
  27089. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27090. */
  27091. setPositionsForCPUSkinning(): Float32Array;
  27092. /**
  27093. * Prepare internal normal array for software CPU skinning
  27094. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27095. */
  27096. setNormalsForCPUSkinning(): Float32Array;
  27097. /**
  27098. * Updates the vertex buffer by applying transformation from the bones
  27099. * @param skeleton defines the skeleton to apply to current mesh
  27100. * @returns the current mesh
  27101. */
  27102. applySkeleton(skeleton: Skeleton): Mesh;
  27103. /**
  27104. * 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
  27105. * @param meshes defines the list of meshes to scan
  27106. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27107. */
  27108. static MinMax(meshes: AbstractMesh[]): {
  27109. min: Vector3;
  27110. max: Vector3;
  27111. };
  27112. /**
  27113. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27114. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27115. * @returns a vector3
  27116. */
  27117. static Center(meshesOrMinMaxVector: {
  27118. min: Vector3;
  27119. max: Vector3;
  27120. } | AbstractMesh[]): Vector3;
  27121. /**
  27122. * Merge the array of meshes into a single mesh for performance reasons.
  27123. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27124. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27125. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27126. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27127. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27128. * @returns a new mesh
  27129. */
  27130. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27131. /** @hidden */
  27132. addInstance(instance: InstancedMesh): void;
  27133. /** @hidden */
  27134. removeInstance(instance: InstancedMesh): void;
  27135. }
  27136. }
  27137. declare module BABYLON {
  27138. /**
  27139. * Define an interface for all classes that will get and set the data on vertices
  27140. */
  27141. interface IGetSetVerticesData {
  27142. /**
  27143. * Gets a boolean indicating if specific vertex data is present
  27144. * @param kind defines the vertex data kind to use
  27145. * @returns true is data kind is present
  27146. */
  27147. isVerticesDataPresent(kind: string): boolean;
  27148. /**
  27149. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27150. * @param kind defines the data kind (Position, normal, etc...)
  27151. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27152. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27153. * @returns a float array containing vertex data
  27154. */
  27155. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27156. /**
  27157. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27158. * @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.
  27159. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27160. * @returns the indices array or an empty array if the mesh has no geometry
  27161. */
  27162. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27163. /**
  27164. * Set specific vertex data
  27165. * @param kind defines the data kind (Position, normal, etc...)
  27166. * @param data defines the vertex data to use
  27167. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27168. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27169. */
  27170. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27171. /**
  27172. * Update a specific associated vertex buffer
  27173. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27174. * - BABYLON.VertexBuffer.PositionKind
  27175. * - BABYLON.VertexBuffer.UVKind
  27176. * - BABYLON.VertexBuffer.UV2Kind
  27177. * - BABYLON.VertexBuffer.UV3Kind
  27178. * - BABYLON.VertexBuffer.UV4Kind
  27179. * - BABYLON.VertexBuffer.UV5Kind
  27180. * - BABYLON.VertexBuffer.UV6Kind
  27181. * - BABYLON.VertexBuffer.ColorKind
  27182. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27183. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27184. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27185. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27186. * @param data defines the data source
  27187. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27188. * @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)
  27189. */
  27190. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27191. /**
  27192. * Creates a new index buffer
  27193. * @param indices defines the indices to store in the index buffer
  27194. * @param totalVertices defines the total number of vertices (could be null)
  27195. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27196. */
  27197. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27198. }
  27199. /**
  27200. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27201. */
  27202. class VertexData {
  27203. /**
  27204. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27205. */
  27206. positions: Nullable<FloatArray>;
  27207. /**
  27208. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27209. */
  27210. normals: Nullable<FloatArray>;
  27211. /**
  27212. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27213. */
  27214. tangents: Nullable<FloatArray>;
  27215. /**
  27216. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27217. */
  27218. uvs: Nullable<FloatArray>;
  27219. /**
  27220. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27221. */
  27222. uvs2: Nullable<FloatArray>;
  27223. /**
  27224. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27225. */
  27226. uvs3: Nullable<FloatArray>;
  27227. /**
  27228. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27229. */
  27230. uvs4: Nullable<FloatArray>;
  27231. /**
  27232. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27233. */
  27234. uvs5: Nullable<FloatArray>;
  27235. /**
  27236. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27237. */
  27238. uvs6: Nullable<FloatArray>;
  27239. /**
  27240. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27241. */
  27242. colors: Nullable<FloatArray>;
  27243. /**
  27244. * 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).
  27245. */
  27246. matricesIndices: Nullable<FloatArray>;
  27247. /**
  27248. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27249. */
  27250. matricesWeights: Nullable<FloatArray>;
  27251. /**
  27252. * An array extending the number of possible indices
  27253. */
  27254. matricesIndicesExtra: Nullable<FloatArray>;
  27255. /**
  27256. * An array extending the number of possible weights when the number of indices is extended
  27257. */
  27258. matricesWeightsExtra: Nullable<FloatArray>;
  27259. /**
  27260. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27261. */
  27262. indices: Nullable<IndicesArray>;
  27263. /**
  27264. * Uses the passed data array to set the set the values for the specified kind of data
  27265. * @param data a linear array of floating numbers
  27266. * @param kind the type of data that is being set, eg positions, colors etc
  27267. */
  27268. set(data: FloatArray, kind: string): void;
  27269. /**
  27270. * Associates the vertexData to the passed Mesh.
  27271. * Sets it as updatable or not (default `false`)
  27272. * @param mesh the mesh the vertexData is applied to
  27273. * @param updatable when used and having the value true allows new data to update the vertexData
  27274. * @returns the VertexData
  27275. */
  27276. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27277. /**
  27278. * Associates the vertexData to the passed Geometry.
  27279. * Sets it as updatable or not (default `false`)
  27280. * @param geometry the geometry the vertexData is applied to
  27281. * @param updatable when used and having the value true allows new data to update the vertexData
  27282. * @returns VertexData
  27283. */
  27284. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27285. /**
  27286. * Updates the associated mesh
  27287. * @param mesh the mesh to be updated
  27288. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27289. * @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
  27290. * @returns VertexData
  27291. */
  27292. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27293. /**
  27294. * Updates the associated geometry
  27295. * @param geometry the geometry to be updated
  27296. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27297. * @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
  27298. * @returns VertexData.
  27299. */
  27300. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27301. private _applyTo;
  27302. private _update;
  27303. /**
  27304. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27305. * @param matrix the transforming matrix
  27306. * @returns the VertexData
  27307. */
  27308. transform(matrix: Matrix): VertexData;
  27309. /**
  27310. * Merges the passed VertexData into the current one
  27311. * @param other the VertexData to be merged into the current one
  27312. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27313. * @returns the modified VertexData
  27314. */
  27315. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27316. private _mergeElement;
  27317. private _validate;
  27318. /**
  27319. * Serializes the VertexData
  27320. * @returns a serialized object
  27321. */
  27322. serialize(): any;
  27323. /**
  27324. * Extracts the vertexData from a mesh
  27325. * @param mesh the mesh from which to extract the VertexData
  27326. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27327. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27328. * @returns the object VertexData associated to the passed mesh
  27329. */
  27330. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27331. /**
  27332. * Extracts the vertexData from the geometry
  27333. * @param geometry the geometry from which to extract the VertexData
  27334. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27335. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27336. * @returns the object VertexData associated to the passed mesh
  27337. */
  27338. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27339. private static _ExtractFrom;
  27340. /**
  27341. * Creates the VertexData for a Ribbon
  27342. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27343. * * pathArray array of paths, each of which an array of successive Vector3
  27344. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27345. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27346. * * 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
  27347. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27348. * * 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)
  27349. * * 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)
  27350. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27351. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27352. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27353. * @returns the VertexData of the ribbon
  27354. */
  27355. static CreateRibbon(options: {
  27356. pathArray: Vector3[][];
  27357. closeArray?: boolean;
  27358. closePath?: boolean;
  27359. offset?: number;
  27360. sideOrientation?: number;
  27361. frontUVs?: Vector4;
  27362. backUVs?: Vector4;
  27363. invertUV?: boolean;
  27364. uvs?: Vector2[];
  27365. colors?: Color4[];
  27366. }): VertexData;
  27367. /**
  27368. * Creates the VertexData for a box
  27369. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27370. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27371. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27372. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27373. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27374. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27375. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27376. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27377. * * 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)
  27378. * * 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)
  27379. * @returns the VertexData of the box
  27380. */
  27381. static CreateBox(options: {
  27382. size?: number;
  27383. width?: number;
  27384. height?: number;
  27385. depth?: number;
  27386. faceUV?: Vector4[];
  27387. faceColors?: Color4[];
  27388. sideOrientation?: number;
  27389. frontUVs?: Vector4;
  27390. backUVs?: Vector4;
  27391. }): VertexData;
  27392. /**
  27393. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27394. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27395. * * segments sets the number of horizontal strips optional, default 32
  27396. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27397. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27398. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27399. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27400. * * 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
  27401. * * 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
  27402. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27403. * * 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)
  27404. * * 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)
  27405. * @returns the VertexData of the ellipsoid
  27406. */
  27407. static CreateSphere(options: {
  27408. segments?: number;
  27409. diameter?: number;
  27410. diameterX?: number;
  27411. diameterY?: number;
  27412. diameterZ?: number;
  27413. arc?: number;
  27414. slice?: number;
  27415. sideOrientation?: number;
  27416. frontUVs?: Vector4;
  27417. backUVs?: Vector4;
  27418. }): VertexData;
  27419. /**
  27420. * Creates the VertexData for a cylinder, cone or prism
  27421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27422. * * height sets the height (y direction) of the cylinder, optional, default 2
  27423. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27424. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27425. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27426. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27427. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27428. * * 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
  27429. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27430. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27431. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27432. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27433. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27434. * * 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)
  27435. * * 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)
  27436. * @returns the VertexData of the cylinder, cone or prism
  27437. */
  27438. static CreateCylinder(options: {
  27439. height?: number;
  27440. diameterTop?: number;
  27441. diameterBottom?: number;
  27442. diameter?: number;
  27443. tessellation?: number;
  27444. subdivisions?: number;
  27445. arc?: number;
  27446. faceColors?: Color4[];
  27447. faceUV?: Vector4[];
  27448. hasRings?: boolean;
  27449. enclose?: boolean;
  27450. sideOrientation?: number;
  27451. frontUVs?: Vector4;
  27452. backUVs?: Vector4;
  27453. }): VertexData;
  27454. /**
  27455. * Creates the VertexData for a torus
  27456. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27457. * * diameter the diameter of the torus, optional default 1
  27458. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27459. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27460. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27461. * * 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)
  27462. * * 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)
  27463. * @returns the VertexData of the torus
  27464. */
  27465. static CreateTorus(options: {
  27466. diameter?: number;
  27467. thickness?: number;
  27468. tessellation?: number;
  27469. sideOrientation?: number;
  27470. frontUVs?: Vector4;
  27471. backUVs?: Vector4;
  27472. }): VertexData;
  27473. /**
  27474. * Creates the VertexData of the LineSystem
  27475. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27476. * - lines an array of lines, each line being an array of successive Vector3
  27477. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27478. * @returns the VertexData of the LineSystem
  27479. */
  27480. static CreateLineSystem(options: {
  27481. lines: Vector3[][];
  27482. colors?: Nullable<Color4[][]>;
  27483. }): VertexData;
  27484. /**
  27485. * Create the VertexData for a DashedLines
  27486. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27487. * - points an array successive Vector3
  27488. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27489. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27490. * - dashNb the intended total number of dashes, optional, default 200
  27491. * @returns the VertexData for the DashedLines
  27492. */
  27493. static CreateDashedLines(options: {
  27494. points: Vector3[];
  27495. dashSize?: number;
  27496. gapSize?: number;
  27497. dashNb?: number;
  27498. }): VertexData;
  27499. /**
  27500. * Creates the VertexData for a Ground
  27501. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27502. * - width the width (x direction) of the ground, optional, default 1
  27503. * - height the height (z direction) of the ground, optional, default 1
  27504. * - subdivisions the number of subdivisions per side, optional, default 1
  27505. * @returns the VertexData of the Ground
  27506. */
  27507. static CreateGround(options: {
  27508. width?: number;
  27509. height?: number;
  27510. subdivisions?: number;
  27511. subdivisionsX?: number;
  27512. subdivisionsY?: number;
  27513. }): VertexData;
  27514. /**
  27515. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27516. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27517. * * xmin the ground minimum X coordinate, optional, default -1
  27518. * * zmin the ground minimum Z coordinate, optional, default -1
  27519. * * xmax the ground maximum X coordinate, optional, default 1
  27520. * * zmax the ground maximum Z coordinate, optional, default 1
  27521. * * 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}
  27522. * * 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}
  27523. * @returns the VertexData of the TiledGround
  27524. */
  27525. static CreateTiledGround(options: {
  27526. xmin: number;
  27527. zmin: number;
  27528. xmax: number;
  27529. zmax: number;
  27530. subdivisions?: {
  27531. w: number;
  27532. h: number;
  27533. };
  27534. precision?: {
  27535. w: number;
  27536. h: number;
  27537. };
  27538. }): VertexData;
  27539. /**
  27540. * Creates the VertexData of the Ground designed from a heightmap
  27541. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27542. * * width the width (x direction) of the ground
  27543. * * height the height (z direction) of the ground
  27544. * * subdivisions the number of subdivisions per side
  27545. * * minHeight the minimum altitude on the ground, optional, default 0
  27546. * * maxHeight the maximum altitude on the ground, optional default 1
  27547. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27548. * * buffer the array holding the image color data
  27549. * * bufferWidth the width of image
  27550. * * bufferHeight the height of image
  27551. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27552. * @returns the VertexData of the Ground designed from a heightmap
  27553. */
  27554. static CreateGroundFromHeightMap(options: {
  27555. width: number;
  27556. height: number;
  27557. subdivisions: number;
  27558. minHeight: number;
  27559. maxHeight: number;
  27560. colorFilter: Color3;
  27561. buffer: Uint8Array;
  27562. bufferWidth: number;
  27563. bufferHeight: number;
  27564. alphaFilter: number;
  27565. }): VertexData;
  27566. /**
  27567. * Creates the VertexData for a Plane
  27568. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27569. * * size sets the width and height of the plane to the value of size, optional default 1
  27570. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27571. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27572. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27573. * * 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)
  27574. * * 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)
  27575. * @returns the VertexData of the box
  27576. */
  27577. static CreatePlane(options: {
  27578. size?: number;
  27579. width?: number;
  27580. height?: number;
  27581. sideOrientation?: number;
  27582. frontUVs?: Vector4;
  27583. backUVs?: Vector4;
  27584. }): VertexData;
  27585. /**
  27586. * Creates the VertexData of the Disc or regular Polygon
  27587. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27588. * * radius the radius of the disc, optional default 0.5
  27589. * * tessellation the number of polygon sides, optional, default 64
  27590. * * 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
  27591. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27592. * * 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)
  27593. * * 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)
  27594. * @returns the VertexData of the box
  27595. */
  27596. static CreateDisc(options: {
  27597. radius?: number;
  27598. tessellation?: number;
  27599. arc?: number;
  27600. sideOrientation?: number;
  27601. frontUVs?: Vector4;
  27602. backUVs?: Vector4;
  27603. }): VertexData;
  27604. /**
  27605. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27606. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27607. * @param polygon a mesh built from polygonTriangulation.build()
  27608. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27609. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27610. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27611. * @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)
  27612. * @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)
  27613. * @returns the VertexData of the Polygon
  27614. */
  27615. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  27616. /**
  27617. * Creates the VertexData of the IcoSphere
  27618. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27619. * * radius the radius of the IcoSphere, optional default 1
  27620. * * radiusX allows stretching in the x direction, optional, default radius
  27621. * * radiusY allows stretching in the y direction, optional, default radius
  27622. * * radiusZ allows stretching in the z direction, optional, default radius
  27623. * * flat when true creates a flat shaded mesh, optional, default true
  27624. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27625. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27626. * * 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)
  27627. * * 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)
  27628. * @returns the VertexData of the IcoSphere
  27629. */
  27630. static CreateIcoSphere(options: {
  27631. radius?: number;
  27632. radiusX?: number;
  27633. radiusY?: number;
  27634. radiusZ?: number;
  27635. flat?: boolean;
  27636. subdivisions?: number;
  27637. sideOrientation?: number;
  27638. frontUVs?: Vector4;
  27639. backUVs?: Vector4;
  27640. }): VertexData;
  27641. /**
  27642. * Creates the VertexData for a Polyhedron
  27643. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27644. * * type provided types are:
  27645. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27646. * * 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)
  27647. * * size the size of the IcoSphere, optional default 1
  27648. * * sizeX allows stretching in the x direction, optional, default size
  27649. * * sizeY allows stretching in the y direction, optional, default size
  27650. * * sizeZ allows stretching in the z direction, optional, default size
  27651. * * 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
  27652. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27653. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27654. * * flat when true creates a flat shaded mesh, optional, default true
  27655. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 Polyhedron
  27660. */
  27661. static CreatePolyhedron(options: {
  27662. type?: number;
  27663. size?: number;
  27664. sizeX?: number;
  27665. sizeY?: number;
  27666. sizeZ?: number;
  27667. custom?: any;
  27668. faceUV?: Vector4[];
  27669. faceColors?: Color4[];
  27670. flat?: boolean;
  27671. sideOrientation?: number;
  27672. frontUVs?: Vector4;
  27673. backUVs?: Vector4;
  27674. }): VertexData;
  27675. /**
  27676. * Creates the VertexData for a TorusKnot
  27677. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27678. * * radius the radius of the torus knot, optional, default 2
  27679. * * tube the thickness of the tube, optional, default 0.5
  27680. * * radialSegments the number of sides on each tube segments, optional, default 32
  27681. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27682. * * p the number of windings around the z axis, optional, default 2
  27683. * * q the number of windings around the x axis, optional, default 3
  27684. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27685. * * 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)
  27686. * * 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)
  27687. * @returns the VertexData of the Torus Knot
  27688. */
  27689. static CreateTorusKnot(options: {
  27690. radius?: number;
  27691. tube?: number;
  27692. radialSegments?: number;
  27693. tubularSegments?: number;
  27694. p?: number;
  27695. q?: number;
  27696. sideOrientation?: number;
  27697. frontUVs?: Vector4;
  27698. backUVs?: Vector4;
  27699. }): VertexData;
  27700. /**
  27701. * Compute normals for given positions and indices
  27702. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27703. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27704. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27705. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27706. * * facetNormals : optional array of facet normals (vector3)
  27707. * * facetPositions : optional array of facet positions (vector3)
  27708. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27709. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27710. * * bInfo : optional bounding info, required for facetPartitioning computation
  27711. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27712. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27713. * * useRightHandedSystem: optional boolean to for right handed system computation
  27714. * * depthSort : optional boolean to enable the facet depth sort computation
  27715. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27716. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27717. */
  27718. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27719. facetNormals?: any;
  27720. facetPositions?: any;
  27721. facetPartitioning?: any;
  27722. ratio?: number;
  27723. bInfo?: any;
  27724. bbSize?: Vector3;
  27725. subDiv?: any;
  27726. useRightHandedSystem?: boolean;
  27727. depthSort?: boolean;
  27728. distanceTo?: Vector3;
  27729. depthSortedFacets?: any;
  27730. }): void;
  27731. private static _ComputeSides;
  27732. /**
  27733. * Applies VertexData created from the imported parameters to the geometry
  27734. * @param parsedVertexData the parsed data from an imported file
  27735. * @param geometry the geometry to apply the VertexData to
  27736. */
  27737. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27738. }
  27739. }
  27740. declare module BABYLON {
  27741. /**
  27742. * Class containing static functions to help procedurally build meshes
  27743. */
  27744. class MeshBuilder {
  27745. private static updateSideOrientation;
  27746. /**
  27747. * Creates a box mesh
  27748. * * The parameter `size` sets the size (float) of each box side (default 1)
  27749. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  27750. * * 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)
  27751. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27753. * * 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
  27754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27755. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  27756. * @param name defines the name of the mesh
  27757. * @param options defines the options used to create the mesh
  27758. * @param scene defines the hosting scene
  27759. * @returns the box mesh
  27760. */
  27761. static CreateBox(name: string, options: {
  27762. size?: number;
  27763. width?: number;
  27764. height?: number;
  27765. depth?: number;
  27766. faceUV?: Vector4[];
  27767. faceColors?: Color4[];
  27768. sideOrientation?: number;
  27769. frontUVs?: Vector4;
  27770. backUVs?: Vector4;
  27771. updatable?: boolean;
  27772. }, scene?: Nullable<Scene>): Mesh;
  27773. /**
  27774. * Creates a sphere mesh
  27775. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  27776. * * 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`)
  27777. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  27778. * * 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
  27779. * * 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)
  27780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27781. * * 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
  27782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27783. * @param name defines the name of the mesh
  27784. * @param options defines the options used to create the mesh
  27785. * @param scene defines the hosting scene
  27786. * @returns the sphere mesh
  27787. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  27788. */
  27789. static CreateSphere(name: string, options: {
  27790. segments?: number;
  27791. diameter?: number;
  27792. diameterX?: number;
  27793. diameterY?: number;
  27794. diameterZ?: number;
  27795. arc?: number;
  27796. slice?: number;
  27797. sideOrientation?: number;
  27798. frontUVs?: Vector4;
  27799. backUVs?: Vector4;
  27800. updatable?: boolean;
  27801. }, scene: any): Mesh;
  27802. /**
  27803. * Creates a plane polygonal mesh. By default, this is a disc
  27804. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  27805. * * 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
  27806. * * 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
  27807. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27808. * * 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
  27809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27810. * @param name defines the name of the mesh
  27811. * @param options defines the options used to create the mesh
  27812. * @param scene defines the hosting scene
  27813. * @returns the plane polygonal mesh
  27814. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  27815. */
  27816. static CreateDisc(name: string, options: {
  27817. radius?: number;
  27818. tessellation?: number;
  27819. arc?: number;
  27820. updatable?: boolean;
  27821. sideOrientation?: number;
  27822. frontUVs?: Vector4;
  27823. backUVs?: Vector4;
  27824. }, scene?: Nullable<Scene>): Mesh;
  27825. /**
  27826. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27827. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27828. * * 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`)
  27829. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27830. * * 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
  27831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27832. * * 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
  27833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27834. * @param name defines the name of the mesh
  27835. * @param options defines the options used to create the mesh
  27836. * @param scene defines the hosting scene
  27837. * @returns the icosahedron mesh
  27838. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27839. */
  27840. static CreateIcoSphere(name: string, options: {
  27841. radius?: number;
  27842. radiusX?: number;
  27843. radiusY?: number;
  27844. radiusZ?: number;
  27845. flat?: boolean;
  27846. subdivisions?: number;
  27847. sideOrientation?: number;
  27848. frontUVs?: Vector4;
  27849. backUVs?: Vector4;
  27850. updatable?: boolean;
  27851. }, scene: Scene): Mesh;
  27852. /**
  27853. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  27854. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  27855. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  27856. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  27857. * * 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
  27858. * * 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
  27859. * * 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
  27860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27861. * * 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
  27862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  27863. * * 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
  27864. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  27865. * * 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
  27866. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  27867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27868. * @param name defines the name of the mesh
  27869. * @param options defines the options used to create the mesh
  27870. * @param scene defines the hosting scene
  27871. * @returns the ribbon mesh
  27872. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  27873. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  27874. */
  27875. static CreateRibbon(name: string, options: {
  27876. pathArray: Vector3[][];
  27877. closeArray?: boolean;
  27878. closePath?: boolean;
  27879. offset?: number;
  27880. updatable?: boolean;
  27881. sideOrientation?: number;
  27882. frontUVs?: Vector4;
  27883. backUVs?: Vector4;
  27884. instance?: Mesh;
  27885. invertUV?: boolean;
  27886. uvs?: Vector2[];
  27887. colors?: Color4[];
  27888. }, scene?: Nullable<Scene>): Mesh;
  27889. /**
  27890. * Creates a cylinder or a cone mesh
  27891. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  27892. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  27893. * * 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.
  27894. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  27895. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  27896. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  27897. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  27898. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  27899. * * 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).
  27900. * * 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
  27901. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  27902. * * 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
  27903. * * 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.
  27904. * * If `enclose` is false, a ring surface is one element.
  27905. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  27906. * * 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
  27907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27908. * * 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
  27909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27910. * @param name defines the name of the mesh
  27911. * @param options defines the options used to create the mesh
  27912. * @param scene defines the hosting scene
  27913. * @returns the cylinder mesh
  27914. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  27915. */
  27916. static CreateCylinder(name: string, options: {
  27917. height?: number;
  27918. diameterTop?: number;
  27919. diameterBottom?: number;
  27920. diameter?: number;
  27921. tessellation?: number;
  27922. subdivisions?: number;
  27923. arc?: number;
  27924. faceColors?: Color4[];
  27925. faceUV?: Vector4[];
  27926. updatable?: boolean;
  27927. hasRings?: boolean;
  27928. enclose?: boolean;
  27929. sideOrientation?: number;
  27930. frontUVs?: Vector4;
  27931. backUVs?: Vector4;
  27932. }, scene: any): Mesh;
  27933. /**
  27934. * Creates a torus mesh
  27935. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  27936. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  27937. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  27938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27939. * * 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
  27940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27941. * @param name defines the name of the mesh
  27942. * @param options defines the options used to create the mesh
  27943. * @param scene defines the hosting scene
  27944. * @returns the torus mesh
  27945. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  27946. */
  27947. static CreateTorus(name: string, options: {
  27948. diameter?: number;
  27949. thickness?: number;
  27950. tessellation?: number;
  27951. updatable?: boolean;
  27952. sideOrientation?: number;
  27953. frontUVs?: Vector4;
  27954. backUVs?: Vector4;
  27955. }, scene: any): Mesh;
  27956. /**
  27957. * Creates a torus knot mesh
  27958. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  27959. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  27960. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  27961. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  27962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27963. * * 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
  27964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27965. * @param name defines the name of the mesh
  27966. * @param options defines the options used to create the mesh
  27967. * @param scene defines the hosting scene
  27968. * @returns the torus knot mesh
  27969. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  27970. */
  27971. static CreateTorusKnot(name: string, options: {
  27972. radius?: number;
  27973. tube?: number;
  27974. radialSegments?: number;
  27975. tubularSegments?: number;
  27976. p?: number;
  27977. q?: number;
  27978. updatable?: boolean;
  27979. sideOrientation?: number;
  27980. frontUVs?: Vector4;
  27981. backUVs?: Vector4;
  27982. }, scene: any): Mesh;
  27983. /**
  27984. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  27985. * * 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
  27986. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  27987. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  27988. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  27989. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  27990. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  27991. * * 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
  27992. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  27993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27994. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  27995. * @param name defines the name of the new line system
  27996. * @param options defines the options used to create the line system
  27997. * @param scene defines the hosting scene
  27998. * @returns a new line system mesh
  27999. */
  28000. static CreateLineSystem(name: string, options: {
  28001. lines: Vector3[][];
  28002. updatable?: boolean;
  28003. instance?: Nullable<LinesMesh>;
  28004. colors?: Nullable<Color4[][]>;
  28005. useVertexAlpha?: boolean;
  28006. }, scene: Nullable<Scene>): LinesMesh;
  28007. /**
  28008. * Creates a line mesh
  28009. * 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
  28010. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28011. * * The parameter `points` is an array successive Vector3
  28012. * * 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
  28013. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28014. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28015. * * When updating an instance, remember that only point positions can change, not the number of points
  28016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28017. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28018. * @param name defines the name of the new line system
  28019. * @param options defines the options used to create the line system
  28020. * @param scene defines the hosting scene
  28021. * @returns a new line mesh
  28022. */
  28023. static CreateLines(name: string, options: {
  28024. points: Vector3[];
  28025. updatable?: boolean;
  28026. instance?: Nullable<LinesMesh>;
  28027. colors?: Color4[];
  28028. useVertexAlpha?: boolean;
  28029. }, scene?: Nullable<Scene>): LinesMesh;
  28030. /**
  28031. * Creates a dashed line mesh
  28032. * * 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
  28033. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28034. * * The parameter `points` is an array successive Vector3
  28035. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28036. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28037. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28038. * * 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
  28039. * * When updating an instance, remember that only point positions can change, not the number of points
  28040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28041. * @param name defines the name of the mesh
  28042. * @param options defines the options used to create the mesh
  28043. * @param scene defines the hosting scene
  28044. * @returns the dashed line mesh
  28045. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28046. */
  28047. static CreateDashedLines(name: string, options: {
  28048. points: Vector3[];
  28049. dashSize?: number;
  28050. gapSize?: number;
  28051. dashNb?: number;
  28052. updatable?: boolean;
  28053. instance?: LinesMesh;
  28054. }, scene?: Nullable<Scene>): LinesMesh;
  28055. /**
  28056. * 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.
  28057. * * 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.
  28058. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28059. * * 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.
  28060. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28061. * * 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
  28062. * * 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
  28063. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28065. * * 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
  28066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28068. * @param name defines the name of the mesh
  28069. * @param options defines the options used to create the mesh
  28070. * @param scene defines the hosting scene
  28071. * @returns the extruded shape mesh
  28072. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28074. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28075. */
  28076. static ExtrudeShape(name: string, options: {
  28077. shape: Vector3[];
  28078. path: Vector3[];
  28079. scale?: number;
  28080. rotation?: number;
  28081. cap?: number;
  28082. updatable?: boolean;
  28083. sideOrientation?: number;
  28084. frontUVs?: Vector4;
  28085. backUVs?: Vector4;
  28086. instance?: Mesh;
  28087. invertUV?: boolean;
  28088. }, scene?: Nullable<Scene>): Mesh;
  28089. /**
  28090. * Creates an custom extruded shape mesh.
  28091. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28092. * * 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.
  28093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28094. * * 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
  28095. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28096. * * 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
  28097. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28098. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28099. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28100. * * 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
  28101. * * 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
  28102. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28104. * * 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
  28105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28107. * @param name defines the name of the mesh
  28108. * @param options defines the options used to create the mesh
  28109. * @param scene defines the hosting scene
  28110. * @returns the custom extruded shape mesh
  28111. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28112. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28114. */
  28115. static ExtrudeShapeCustom(name: string, options: {
  28116. shape: Vector3[];
  28117. path: Vector3[];
  28118. scaleFunction?: any;
  28119. rotationFunction?: any;
  28120. ribbonCloseArray?: boolean;
  28121. ribbonClosePath?: boolean;
  28122. cap?: number;
  28123. updatable?: boolean;
  28124. sideOrientation?: number;
  28125. frontUVs?: Vector4;
  28126. backUVs?: Vector4;
  28127. instance?: Mesh;
  28128. invertUV?: boolean;
  28129. }, scene: Scene): Mesh;
  28130. /**
  28131. * Creates lathe mesh.
  28132. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28133. * * 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
  28134. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28135. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28136. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28137. * * 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
  28138. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28139. * * 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
  28140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28141. * * 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
  28142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28144. * @param name defines the name of the mesh
  28145. * @param options defines the options used to create the mesh
  28146. * @param scene defines the hosting scene
  28147. * @returns the lathe mesh
  28148. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28149. */
  28150. static CreateLathe(name: string, options: {
  28151. shape: Vector3[];
  28152. radius?: number;
  28153. tessellation?: number;
  28154. clip?: number;
  28155. arc?: number;
  28156. closed?: boolean;
  28157. updatable?: boolean;
  28158. sideOrientation?: number;
  28159. frontUVs?: Vector4;
  28160. backUVs?: Vector4;
  28161. cap?: number;
  28162. invertUV?: boolean;
  28163. }, scene: Scene): Mesh;
  28164. /**
  28165. * Creates a plane mesh
  28166. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28167. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28168. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28172. * @param name defines the name of the mesh
  28173. * @param options defines the options used to create the mesh
  28174. * @param scene defines the hosting scene
  28175. * @returns the plane mesh
  28176. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28177. */
  28178. static CreatePlane(name: string, options: {
  28179. size?: number;
  28180. width?: number;
  28181. height?: number;
  28182. sideOrientation?: number;
  28183. frontUVs?: Vector4;
  28184. backUVs?: Vector4;
  28185. updatable?: boolean;
  28186. sourcePlane?: Plane;
  28187. }, scene: Scene): Mesh;
  28188. /**
  28189. * Creates a ground mesh
  28190. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28191. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28193. * @param name defines the name of the mesh
  28194. * @param options defines the options used to create the mesh
  28195. * @param scene defines the hosting scene
  28196. * @returns the ground mesh
  28197. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28198. */
  28199. static CreateGround(name: string, options: {
  28200. width?: number;
  28201. height?: number;
  28202. subdivisions?: number;
  28203. subdivisionsX?: number;
  28204. subdivisionsY?: number;
  28205. updatable?: boolean;
  28206. }, scene: any): Mesh;
  28207. /**
  28208. * Creates a tiled ground mesh
  28209. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28210. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28211. * * 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
  28212. * * 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
  28213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28214. * @param name defines the name of the mesh
  28215. * @param options defines the options used to create the mesh
  28216. * @param scene defines the hosting scene
  28217. * @returns the tiled ground mesh
  28218. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28219. */
  28220. static CreateTiledGround(name: string, options: {
  28221. xmin: number;
  28222. zmin: number;
  28223. xmax: number;
  28224. zmax: number;
  28225. subdivisions?: {
  28226. w: number;
  28227. h: number;
  28228. };
  28229. precision?: {
  28230. w: number;
  28231. h: number;
  28232. };
  28233. updatable?: boolean;
  28234. }, scene: Scene): Mesh;
  28235. /**
  28236. * Creates a ground mesh from a height map
  28237. * * The parameter `url` sets the URL of the height map image resource.
  28238. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28239. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28240. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28241. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28242. * * 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.
  28243. * * 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).
  28244. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28246. * @param name defines the name of the mesh
  28247. * @param url defines the url to the height map
  28248. * @param options defines the options used to create the mesh
  28249. * @param scene defines the hosting scene
  28250. * @returns the ground mesh
  28251. * @see http://doc.babylonjs.com/babylon101/height_map
  28252. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28253. */
  28254. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28255. width?: number;
  28256. height?: number;
  28257. subdivisions?: number;
  28258. minHeight?: number;
  28259. maxHeight?: number;
  28260. colorFilter?: Color3;
  28261. alphaFilter?: number;
  28262. updatable?: boolean;
  28263. onReady?: (mesh: GroundMesh) => void;
  28264. }, scene: Scene): GroundMesh;
  28265. /**
  28266. * Creates a polygon mesh
  28267. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28268. * * 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
  28269. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  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. * * 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)
  28272. * * Remember you can only change the shape positions, not their number when updating a polygon
  28273. * @param name defines the name of the mesh
  28274. * @param options defines the options used to create the mesh
  28275. * @param scene defines the hosting scene
  28276. * @returns the polygon mesh
  28277. */
  28278. static CreatePolygon(name: string, options: {
  28279. shape: Vector3[];
  28280. holes?: Vector3[][];
  28281. depth?: number;
  28282. faceUV?: Vector4[];
  28283. faceColors?: Color4[];
  28284. updatable?: boolean;
  28285. sideOrientation?: number;
  28286. frontUVs?: Vector4;
  28287. backUVs?: Vector4;
  28288. }, scene: Scene): Mesh;
  28289. /**
  28290. * Creates an extruded polygon mesh, with depth in the Y direction.
  28291. * * 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)
  28292. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28293. * @param name defines the name of the mesh
  28294. * @param options defines the options used to create the mesh
  28295. * @param scene defines the hosting scene
  28296. * @returns the polygon mesh
  28297. */
  28298. static ExtrudePolygon(name: string, options: {
  28299. shape: Vector3[];
  28300. holes?: Vector3[][];
  28301. depth?: number;
  28302. faceUV?: Vector4[];
  28303. faceColors?: Color4[];
  28304. updatable?: boolean;
  28305. sideOrientation?: number;
  28306. frontUVs?: Vector4;
  28307. backUVs?: Vector4;
  28308. }, scene: Scene): Mesh;
  28309. /**
  28310. * Creates a tube mesh.
  28311. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28312. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28313. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28314. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28315. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28316. * * 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)
  28317. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28318. * * 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
  28319. * * 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
  28320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28321. * * 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
  28322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28324. * @param name defines the name of the mesh
  28325. * @param options defines the options used to create the mesh
  28326. * @param scene defines the hosting scene
  28327. * @returns the tube mesh
  28328. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28329. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28330. */
  28331. static CreateTube(name: string, options: {
  28332. path: Vector3[];
  28333. radius?: number;
  28334. tessellation?: number;
  28335. radiusFunction?: {
  28336. (i: number, distance: number): number;
  28337. };
  28338. cap?: number;
  28339. arc?: number;
  28340. updatable?: boolean;
  28341. sideOrientation?: number;
  28342. frontUVs?: Vector4;
  28343. backUVs?: Vector4;
  28344. instance?: Mesh;
  28345. invertUV?: boolean;
  28346. }, scene: Scene): Mesh;
  28347. /**
  28348. * Creates a polyhedron mesh
  28349. * * 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
  28350. * * The parameter `size` (positive float, default 1) sets the polygon size
  28351. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28352. * * 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`
  28353. * * 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
  28354. * * 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)`)
  28355. * * 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
  28356. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28360. * @param name defines the name of the mesh
  28361. * @param options defines the options used to create the mesh
  28362. * @param scene defines the hosting scene
  28363. * @returns the polyhedron mesh
  28364. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28365. */
  28366. static CreatePolyhedron(name: string, options: {
  28367. type?: number;
  28368. size?: number;
  28369. sizeX?: number;
  28370. sizeY?: number;
  28371. sizeZ?: number;
  28372. custom?: any;
  28373. faceUV?: Vector4[];
  28374. faceColors?: Color4[];
  28375. flat?: boolean;
  28376. updatable?: boolean;
  28377. sideOrientation?: number;
  28378. frontUVs?: Vector4;
  28379. backUVs?: Vector4;
  28380. }, scene: Scene): Mesh;
  28381. /**
  28382. * Creates a decal mesh.
  28383. * 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
  28384. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28385. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28386. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28387. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28388. * @param name defines the name of the mesh
  28389. * @param sourceMesh defines the mesh where the decal must be applied
  28390. * @param options defines the options used to create the mesh
  28391. * @param scene defines the hosting scene
  28392. * @returns the decal mesh
  28393. * @see http://doc.babylonjs.com/how_to/decals
  28394. */
  28395. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28396. position?: Vector3;
  28397. normal?: Vector3;
  28398. size?: Vector3;
  28399. angle?: number;
  28400. }): Mesh;
  28401. private static _ExtrudeShapeGeneric;
  28402. }
  28403. }
  28404. declare module BABYLON {
  28405. /**
  28406. * Class used to represent a specific level of detail of a mesh
  28407. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28408. */
  28409. class MeshLODLevel {
  28410. /** Defines the distance where this level should star being displayed */
  28411. distance: number;
  28412. /** Defines the mesh to use to render this level */
  28413. mesh: Nullable<Mesh>;
  28414. /**
  28415. * Creates a new LOD level
  28416. * @param distance defines the distance where this level should star being displayed
  28417. * @param mesh defines the mesh to use to render this level
  28418. */
  28419. constructor(
  28420. /** Defines the distance where this level should star being displayed */
  28421. distance: number,
  28422. /** Defines the mesh to use to render this level */
  28423. mesh: Nullable<Mesh>);
  28424. }
  28425. }
  28426. declare module BABYLON {
  28427. /**
  28428. * A simplifier interface for future simplification implementations
  28429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28430. */
  28431. interface ISimplifier {
  28432. /**
  28433. * Simplification of a given mesh according to the given settings.
  28434. * Since this requires computation, it is assumed that the function runs async.
  28435. * @param settings The settings of the simplification, including quality and distance
  28436. * @param successCallback A callback that will be called after the mesh was simplified.
  28437. * @param errorCallback in case of an error, this callback will be called. optional.
  28438. */
  28439. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28440. }
  28441. /**
  28442. * Expected simplification settings.
  28443. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28444. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28445. */
  28446. interface ISimplificationSettings {
  28447. /**
  28448. * Gets or sets the expected quality
  28449. */
  28450. quality: number;
  28451. /**
  28452. * Gets or sets the distance when this optimized version should be used
  28453. */
  28454. distance: number;
  28455. /**
  28456. * Gets an already optimized mesh
  28457. */
  28458. optimizeMesh?: boolean;
  28459. }
  28460. /**
  28461. * Class used to specify simplification options
  28462. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28463. */
  28464. class SimplificationSettings implements ISimplificationSettings {
  28465. /** expected quality */
  28466. quality: number;
  28467. /** distance when this optimized version should be used */
  28468. distance: number;
  28469. /** already optimized mesh */
  28470. optimizeMesh?: boolean | undefined;
  28471. /**
  28472. * Creates a SimplificationSettings
  28473. * @param quality expected quality
  28474. * @param distance distance when this optimized version should be used
  28475. * @param optimizeMesh already optimized mesh
  28476. */
  28477. constructor(
  28478. /** expected quality */
  28479. quality: number,
  28480. /** distance when this optimized version should be used */
  28481. distance: number,
  28482. /** already optimized mesh */
  28483. optimizeMesh?: boolean | undefined);
  28484. }
  28485. /**
  28486. * Interface used to define a simplification task
  28487. */
  28488. interface ISimplificationTask {
  28489. /**
  28490. * Array of settings
  28491. */
  28492. settings: Array<ISimplificationSettings>;
  28493. /**
  28494. * Simplification type
  28495. */
  28496. simplificationType: SimplificationType;
  28497. /**
  28498. * Mesh to simplify
  28499. */
  28500. mesh: Mesh;
  28501. /**
  28502. * Callback called on success
  28503. */
  28504. successCallback?: () => void;
  28505. /**
  28506. * Defines if parallel processing can be used
  28507. */
  28508. parallelProcessing: boolean;
  28509. }
  28510. /**
  28511. * Queue used to order the simplification tasks
  28512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28513. */
  28514. class SimplificationQueue {
  28515. private _simplificationArray;
  28516. /**
  28517. * Gets a boolean indicating that the process is still running
  28518. */
  28519. running: boolean;
  28520. /**
  28521. * Creates a new queue
  28522. */
  28523. constructor();
  28524. /**
  28525. * Adds a new simplification task
  28526. * @param task defines a task to add
  28527. */
  28528. addTask(task: ISimplificationTask): void;
  28529. /**
  28530. * Execute next task
  28531. */
  28532. executeNext(): void;
  28533. /**
  28534. * Execute a simplification task
  28535. * @param task defines the task to run
  28536. */
  28537. runSimplification(task: ISimplificationTask): void;
  28538. private getSimplifier;
  28539. }
  28540. /**
  28541. * The implemented types of simplification
  28542. * At the moment only Quadratic Error Decimation is implemented
  28543. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28544. */
  28545. enum SimplificationType {
  28546. /** Quadratic error decimation */
  28547. QUADRATIC = 0
  28548. }
  28549. }
  28550. declare module BABYLON {
  28551. interface Scene {
  28552. /** @hidden (Backing field) */
  28553. _simplificationQueue: SimplificationQueue;
  28554. /**
  28555. * Gets or sets the simplification queue attached to the scene
  28556. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28557. */
  28558. simplificationQueue: SimplificationQueue;
  28559. }
  28560. interface Mesh {
  28561. /**
  28562. * Simplify the mesh according to the given array of settings.
  28563. * Function will return immediately and will simplify async
  28564. * @param settings a collection of simplification settings
  28565. * @param parallelProcessing should all levels calculate parallel or one after the other
  28566. * @param simplificationType the type of simplification to run
  28567. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  28568. * @returns the current mesh
  28569. */
  28570. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  28571. }
  28572. /**
  28573. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  28574. * created in a scene
  28575. */
  28576. class SimplicationQueueSceneComponent implements ISceneComponent {
  28577. /**
  28578. * The component name helpfull to identify the component in the list of scene components.
  28579. */
  28580. readonly name: string;
  28581. /**
  28582. * The scene the component belongs to.
  28583. */
  28584. scene: Scene;
  28585. /**
  28586. * Creates a new instance of the component for the given scene
  28587. * @param scene Defines the scene to register the component in
  28588. */
  28589. constructor(scene: Scene);
  28590. /**
  28591. * Registers the component in a given scene
  28592. */
  28593. register(): void;
  28594. /**
  28595. * Rebuilds the elements related to this component in case of
  28596. * context lost for instance.
  28597. */
  28598. rebuild(): void;
  28599. /**
  28600. * Disposes the component and the associated ressources
  28601. */
  28602. dispose(): void;
  28603. private _beforeCameraUpdate;
  28604. }
  28605. }
  28606. declare module BABYLON {
  28607. /**
  28608. * Polygon
  28609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28610. */
  28611. class Polygon {
  28612. /**
  28613. * Creates a rectangle
  28614. * @param xmin bottom X coord
  28615. * @param ymin bottom Y coord
  28616. * @param xmax top X coord
  28617. * @param ymax top Y coord
  28618. * @returns points that make the resulting rectation
  28619. */
  28620. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  28621. /**
  28622. * Creates a circle
  28623. * @param radius radius of circle
  28624. * @param cx scale in x
  28625. * @param cy scale in y
  28626. * @param numberOfSides number of sides that make up the circle
  28627. * @returns points that make the resulting circle
  28628. */
  28629. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  28630. /**
  28631. * Creates a polygon from input string
  28632. * @param input Input polygon data
  28633. * @returns the parsed points
  28634. */
  28635. static Parse(input: string): Vector2[];
  28636. /**
  28637. * Starts building a polygon from x and y coordinates
  28638. * @param x x coordinate
  28639. * @param y y coordinate
  28640. * @returns the started path2
  28641. */
  28642. static StartingAt(x: number, y: number): Path2;
  28643. }
  28644. /**
  28645. * Builds a polygon
  28646. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  28647. */
  28648. class PolygonMeshBuilder {
  28649. private _points;
  28650. private _outlinepoints;
  28651. private _holes;
  28652. private _name;
  28653. private _scene;
  28654. private _epoints;
  28655. private _eholes;
  28656. private _addToepoint;
  28657. /**
  28658. * Creates a PolygonMeshBuilder
  28659. * @param name name of the builder
  28660. * @param contours Path of the polygon
  28661. * @param scene scene to add to
  28662. */
  28663. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  28664. /**
  28665. * Adds a whole within the polygon
  28666. * @param hole Array of points defining the hole
  28667. * @returns this
  28668. */
  28669. addHole(hole: Vector2[]): PolygonMeshBuilder;
  28670. /**
  28671. * Creates the polygon
  28672. * @param updatable If the mesh should be updatable
  28673. * @param depth The depth of the mesh created
  28674. * @returns the created mesh
  28675. */
  28676. build(updatable?: boolean, depth?: number): Mesh;
  28677. /**
  28678. * Adds a side to the polygon
  28679. * @param positions points that make the polygon
  28680. * @param normals normals of the polygon
  28681. * @param uvs uvs of the polygon
  28682. * @param indices indices of the polygon
  28683. * @param bounds bounds of the polygon
  28684. * @param points points of the polygon
  28685. * @param depth depth of the polygon
  28686. * @param flip flip of the polygon
  28687. */
  28688. private addSide;
  28689. }
  28690. }
  28691. declare module BABYLON {
  28692. /**
  28693. * Base class for submeshes
  28694. */
  28695. class BaseSubMesh {
  28696. /** @hidden */
  28697. _materialDefines: Nullable<MaterialDefines>;
  28698. /** @hidden */
  28699. _materialEffect: Nullable<Effect>;
  28700. /**
  28701. * Gets associated effect
  28702. */
  28703. readonly effect: Nullable<Effect>;
  28704. /**
  28705. * Sets associated effect (effect used to render this submesh)
  28706. * @param effect defines the effect to associate with
  28707. * @param defines defines the set of defines used to compile this effect
  28708. */
  28709. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  28710. }
  28711. /**
  28712. * Defines a subdivision inside a mesh
  28713. */
  28714. class SubMesh extends BaseSubMesh implements ICullable {
  28715. /** the material index to use */
  28716. materialIndex: number;
  28717. /** vertex index start */
  28718. verticesStart: number;
  28719. /** vertices count */
  28720. verticesCount: number;
  28721. /** index start */
  28722. indexStart: number;
  28723. /** indices count */
  28724. indexCount: number;
  28725. /** @hidden */
  28726. _linesIndexCount: number;
  28727. private _mesh;
  28728. private _renderingMesh;
  28729. private _boundingInfo;
  28730. private _linesIndexBuffer;
  28731. /** @hidden */
  28732. _lastColliderWorldVertices: Nullable<Vector3[]>;
  28733. /** @hidden */
  28734. _trianglePlanes: Plane[];
  28735. /** @hidden */
  28736. _lastColliderTransformMatrix: Matrix;
  28737. /** @hidden */
  28738. _renderId: number;
  28739. /** @hidden */
  28740. _alphaIndex: number;
  28741. /** @hidden */
  28742. _distanceToCamera: number;
  28743. /** @hidden */
  28744. _id: number;
  28745. private _currentMaterial;
  28746. /**
  28747. * Add a new submesh to a mesh
  28748. * @param materialIndex defines the material index to use
  28749. * @param verticesStart defines vertex index start
  28750. * @param verticesCount defines vertices count
  28751. * @param indexStart defines index start
  28752. * @param indexCount defines indices count
  28753. * @param mesh defines the parent mesh
  28754. * @param renderingMesh defines an optional rendering mesh
  28755. * @param createBoundingBox defines if bounding box should be created for this submesh
  28756. * @returns the new submesh
  28757. */
  28758. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  28759. /**
  28760. * Creates a new submesh
  28761. * @param materialIndex defines the material index to use
  28762. * @param verticesStart defines vertex index start
  28763. * @param verticesCount defines vertices count
  28764. * @param indexStart defines index start
  28765. * @param indexCount defines indices count
  28766. * @param mesh defines the parent mesh
  28767. * @param renderingMesh defines an optional rendering mesh
  28768. * @param createBoundingBox defines if bounding box should be created for this submesh
  28769. */
  28770. constructor(
  28771. /** the material index to use */
  28772. materialIndex: number,
  28773. /** vertex index start */
  28774. verticesStart: number,
  28775. /** vertices count */
  28776. verticesCount: number,
  28777. /** index start */
  28778. indexStart: number,
  28779. /** indices count */
  28780. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  28781. /**
  28782. * Returns true if this submesh covers the entire parent mesh
  28783. * @ignorenaming
  28784. */
  28785. readonly IsGlobal: boolean;
  28786. /**
  28787. * Returns the submesh BoudingInfo object
  28788. * @returns current bounding info (or mesh's one if the submesh is global)
  28789. */
  28790. getBoundingInfo(): BoundingInfo;
  28791. /**
  28792. * Sets the submesh BoundingInfo
  28793. * @param boundingInfo defines the new bounding info to use
  28794. * @returns the SubMesh
  28795. */
  28796. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  28797. /**
  28798. * Returns the mesh of the current submesh
  28799. * @return the parent mesh
  28800. */
  28801. getMesh(): AbstractMesh;
  28802. /**
  28803. * Returns the rendering mesh of the submesh
  28804. * @returns the rendering mesh (could be different from parent mesh)
  28805. */
  28806. getRenderingMesh(): Mesh;
  28807. /**
  28808. * Returns the submesh material
  28809. * @returns null or the current material
  28810. */
  28811. getMaterial(): Nullable<Material>;
  28812. /**
  28813. * Sets a new updated BoundingInfo object to the submesh
  28814. * @returns the SubMesh
  28815. */
  28816. refreshBoundingInfo(): SubMesh;
  28817. /** @hidden */
  28818. _checkCollision(collider: Collider): boolean;
  28819. /**
  28820. * Updates the submesh BoundingInfo
  28821. * @param world defines the world matrix to use to update the bounding info
  28822. * @returns the submesh
  28823. */
  28824. updateBoundingInfo(world: Matrix): SubMesh;
  28825. /**
  28826. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  28827. * @param frustumPlanes defines the frustum planes
  28828. * @returns true if the submesh is intersecting with the frustum
  28829. */
  28830. isInFrustum(frustumPlanes: Plane[]): boolean;
  28831. /**
  28832. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  28833. * @param frustumPlanes defines the frustum planes
  28834. * @returns true if the submesh is inside the frustum
  28835. */
  28836. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28837. /**
  28838. * Renders the submesh
  28839. * @param enableAlphaMode defines if alpha needs to be used
  28840. * @returns the submesh
  28841. */
  28842. render(enableAlphaMode: boolean): SubMesh;
  28843. /**
  28844. * @hidden
  28845. */
  28846. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  28847. /**
  28848. * Checks if the submesh intersects with a ray
  28849. * @param ray defines the ray to test
  28850. * @returns true is the passed ray intersects the submesh bounding box
  28851. */
  28852. canIntersects(ray: Ray): boolean;
  28853. /**
  28854. * Intersects current submesh with a ray
  28855. * @param ray defines the ray to test
  28856. * @param positions defines mesh's positions array
  28857. * @param indices defines mesh's indices array
  28858. * @param fastCheck defines if only bounding info should be used
  28859. * @returns intersection info or null if no intersection
  28860. */
  28861. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  28862. /** @hidden */
  28863. private _intersectLines;
  28864. /** @hidden */
  28865. private _intersectTriangles;
  28866. /** @hidden */
  28867. _rebuild(): void;
  28868. /**
  28869. * Creates a new submesh from the passed mesh
  28870. * @param newMesh defines the new hosting mesh
  28871. * @param newRenderingMesh defines an optional rendering mesh
  28872. * @returns the new submesh
  28873. */
  28874. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  28875. /**
  28876. * Release associated resources
  28877. */
  28878. dispose(): void;
  28879. /**
  28880. * Creates a new submesh from indices data
  28881. * @param materialIndex the index of the main mesh material
  28882. * @param startIndex the index where to start the copy in the mesh indices array
  28883. * @param indexCount the number of indices to copy then from the startIndex
  28884. * @param mesh the main mesh to create the submesh from
  28885. * @param renderingMesh the optional rendering mesh
  28886. * @returns a new submesh
  28887. */
  28888. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  28889. }
  28890. }
  28891. declare module BABYLON {
  28892. /**
  28893. * 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.
  28894. * @see https://doc.babylonjs.com/how_to/transformnode
  28895. */
  28896. class TransformNode extends Node {
  28897. /**
  28898. * Object will not rotate to face the camera
  28899. */
  28900. static BILLBOARDMODE_NONE: number;
  28901. /**
  28902. * Object will rotate to face the camera but only on the x axis
  28903. */
  28904. static BILLBOARDMODE_X: number;
  28905. /**
  28906. * Object will rotate to face the camera but only on the y axis
  28907. */
  28908. static BILLBOARDMODE_Y: number;
  28909. /**
  28910. * Object will rotate to face the camera but only on the z axis
  28911. */
  28912. static BILLBOARDMODE_Z: number;
  28913. /**
  28914. * Object will rotate to face the camera
  28915. */
  28916. static BILLBOARDMODE_ALL: number;
  28917. private _forward;
  28918. private _forwardInverted;
  28919. private _up;
  28920. private _right;
  28921. private _rightInverted;
  28922. private _position;
  28923. private _rotation;
  28924. private _rotationQuaternion;
  28925. protected _scaling: Vector3;
  28926. protected _isDirty: boolean;
  28927. private _transformToBoneReferal;
  28928. /**
  28929. * Set the billboard mode. Default is 0.
  28930. *
  28931. * | Value | Type | Description |
  28932. * | --- | --- | --- |
  28933. * | 0 | BILLBOARDMODE_NONE | |
  28934. * | 1 | BILLBOARDMODE_X | |
  28935. * | 2 | BILLBOARDMODE_Y | |
  28936. * | 4 | BILLBOARDMODE_Z | |
  28937. * | 7 | BILLBOARDMODE_ALL | |
  28938. *
  28939. */
  28940. billboardMode: number;
  28941. /**
  28942. * 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
  28943. */
  28944. scalingDeterminant: number;
  28945. /**
  28946. * Sets the distance of the object to max, often used by skybox
  28947. */
  28948. infiniteDistance: boolean;
  28949. /**
  28950. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  28951. * By default the system will update normals to compensate
  28952. */
  28953. ignoreNonUniformScaling: boolean;
  28954. /** @hidden */
  28955. _poseMatrix: Matrix;
  28956. private _localWorld;
  28957. private _absolutePosition;
  28958. private _pivotMatrix;
  28959. private _pivotMatrixInverse;
  28960. private _postMultiplyPivotMatrix;
  28961. protected _isWorldMatrixFrozen: boolean;
  28962. /** @hidden */
  28963. _indexInSceneTransformNodesArray: number;
  28964. /**
  28965. * An event triggered after the world matrix is updated
  28966. */
  28967. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  28968. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  28969. /**
  28970. * Gets a string identifying the name of the class
  28971. * @returns "TransformNode" string
  28972. */
  28973. getClassName(): string;
  28974. /**
  28975. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  28976. */
  28977. position: Vector3;
  28978. /**
  28979. * 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)).
  28980. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  28981. */
  28982. rotation: Vector3;
  28983. /**
  28984. * 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)).
  28985. */
  28986. scaling: Vector3;
  28987. /**
  28988. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  28989. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  28990. */
  28991. rotationQuaternion: Nullable<Quaternion>;
  28992. /**
  28993. * The forward direction of that transform in world space.
  28994. */
  28995. readonly forward: Vector3;
  28996. /**
  28997. * The up direction of that transform in world space.
  28998. */
  28999. readonly up: Vector3;
  29000. /**
  29001. * The right direction of that transform in world space.
  29002. */
  29003. readonly right: Vector3;
  29004. /**
  29005. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29006. * @param matrix the matrix to copy the pose from
  29007. * @returns this TransformNode.
  29008. */
  29009. updatePoseMatrix(matrix: Matrix): TransformNode;
  29010. /**
  29011. * Returns the mesh Pose matrix.
  29012. * @returns the pose matrix
  29013. */
  29014. getPoseMatrix(): Matrix;
  29015. /** @hidden */
  29016. _isSynchronized(): boolean;
  29017. /** @hidden */
  29018. _initCache(): void;
  29019. /**
  29020. * Flag the transform node as dirty (Forcing it to update everything)
  29021. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29022. * @returns this transform node
  29023. */
  29024. markAsDirty(property: string): TransformNode;
  29025. /**
  29026. * Returns the current mesh absolute position.
  29027. * Returns a Vector3.
  29028. */
  29029. readonly absolutePosition: Vector3;
  29030. /**
  29031. * Sets a new matrix to apply before all other transformation
  29032. * @param matrix defines the transform matrix
  29033. * @returns the current TransformNode
  29034. */
  29035. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29036. /**
  29037. * Sets a new pivot matrix to the current node
  29038. * @param matrix defines the new pivot matrix to use
  29039. * @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
  29040. * @returns the current TransformNode
  29041. */
  29042. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  29043. /**
  29044. * Returns the mesh pivot matrix.
  29045. * Default : Identity.
  29046. * @returns the matrix
  29047. */
  29048. getPivotMatrix(): Matrix;
  29049. /**
  29050. * Prevents the World matrix to be computed any longer.
  29051. * @returns the TransformNode.
  29052. */
  29053. freezeWorldMatrix(): TransformNode;
  29054. /**
  29055. * Allows back the World matrix computation.
  29056. * @returns the TransformNode.
  29057. */
  29058. unfreezeWorldMatrix(): this;
  29059. /**
  29060. * True if the World matrix has been frozen.
  29061. */
  29062. readonly isWorldMatrixFrozen: boolean;
  29063. /**
  29064. * Retuns the mesh absolute position in the World.
  29065. * @returns a Vector3.
  29066. */
  29067. getAbsolutePosition(): Vector3;
  29068. /**
  29069. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29070. * @param absolutePosition the absolute position to set
  29071. * @returns the TransformNode.
  29072. */
  29073. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29074. /**
  29075. * Sets the mesh position in its local space.
  29076. * @param vector3 the position to set in localspace
  29077. * @returns the TransformNode.
  29078. */
  29079. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29080. /**
  29081. * Returns the mesh position in the local space from the current World matrix values.
  29082. * @returns a new Vector3.
  29083. */
  29084. getPositionExpressedInLocalSpace(): Vector3;
  29085. /**
  29086. * Translates the mesh along the passed Vector3 in its local space.
  29087. * @param vector3 the distance to translate in localspace
  29088. * @returns the TransformNode.
  29089. */
  29090. locallyTranslate(vector3: Vector3): TransformNode;
  29091. private static _lookAtVectorCache;
  29092. /**
  29093. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29094. * @param targetPoint the position (must be in same space as current mesh) to look at
  29095. * @param yawCor optional yaw (y-axis) correction in radians
  29096. * @param pitchCor optional pitch (x-axis) correction in radians
  29097. * @param rollCor optional roll (z-axis) correction in radians
  29098. * @param space the choosen space of the target
  29099. * @returns the TransformNode.
  29100. */
  29101. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29102. /**
  29103. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29104. * This Vector3 is expressed in the World space.
  29105. * @param localAxis axis to rotate
  29106. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29107. */
  29108. getDirection(localAxis: Vector3): Vector3;
  29109. /**
  29110. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29111. * localAxis is expressed in the mesh local space.
  29112. * result is computed in the Wordl space from the mesh World matrix.
  29113. * @param localAxis axis to rotate
  29114. * @param result the resulting transformnode
  29115. * @returns this TransformNode.
  29116. */
  29117. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29118. /**
  29119. * Sets a new pivot point to the current node
  29120. * @param point defines the new pivot point to use
  29121. * @param space defines if the point is in world or local space (local by default)
  29122. * @returns the current TransformNode
  29123. */
  29124. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29125. /**
  29126. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29127. * @returns the pivot point
  29128. */
  29129. getPivotPoint(): Vector3;
  29130. /**
  29131. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29132. * @param result the vector3 to store the result
  29133. * @returns this TransformNode.
  29134. */
  29135. getPivotPointToRef(result: Vector3): TransformNode;
  29136. /**
  29137. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29138. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29139. */
  29140. getAbsolutePivotPoint(): Vector3;
  29141. /**
  29142. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29143. * @param result vector3 to store the result
  29144. * @returns this TransformNode.
  29145. */
  29146. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29147. /**
  29148. * Defines the passed node as the parent of the current node.
  29149. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29150. * @param node the node ot set as the parent
  29151. * @returns this TransformNode.
  29152. */
  29153. setParent(node: Nullable<Node>): TransformNode;
  29154. private _nonUniformScaling;
  29155. /**
  29156. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29157. */
  29158. readonly nonUniformScaling: boolean;
  29159. /** @hidden */
  29160. _updateNonUniformScalingState(value: boolean): boolean;
  29161. /**
  29162. * Attach the current TransformNode to another TransformNode associated with a bone
  29163. * @param bone Bone affecting the TransformNode
  29164. * @param affectedTransformNode TransformNode associated with the bone
  29165. * @returns this object
  29166. */
  29167. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29168. /**
  29169. * Detach the transform node if its associated with a bone
  29170. * @returns this object
  29171. */
  29172. detachFromBone(): TransformNode;
  29173. private static _rotationAxisCache;
  29174. /**
  29175. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29176. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29177. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29178. * The passed axis is also normalized.
  29179. * @param axis the axis to rotate around
  29180. * @param amount the amount to rotate in radians
  29181. * @param space Space to rotate in (Default: local)
  29182. * @returns the TransformNode.
  29183. */
  29184. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29185. /**
  29186. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29187. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29188. * The passed axis is also normalized. .
  29189. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29190. * @param point the point to rotate around
  29191. * @param axis the axis to rotate around
  29192. * @param amount the amount to rotate in radians
  29193. * @returns the TransformNode
  29194. */
  29195. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29196. /**
  29197. * Translates the mesh along the axis vector for the passed distance in the given space.
  29198. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29199. * @param axis the axis to translate in
  29200. * @param distance the distance to translate
  29201. * @param space Space to rotate in (Default: local)
  29202. * @returns the TransformNode.
  29203. */
  29204. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29205. /**
  29206. * Adds a rotation step to the mesh current rotation.
  29207. * x, y, z are Euler angles expressed in radians.
  29208. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29209. * This means this rotation is made in the mesh local space only.
  29210. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29211. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29212. * ```javascript
  29213. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29214. * ```
  29215. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29216. * 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.
  29217. * @param x Rotation to add
  29218. * @param y Rotation to add
  29219. * @param z Rotation to add
  29220. * @returns the TransformNode.
  29221. */
  29222. addRotation(x: number, y: number, z: number): TransformNode;
  29223. /**
  29224. * Computes the world matrix of the node
  29225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29226. * @returns the world matrix
  29227. */
  29228. computeWorldMatrix(force?: boolean): Matrix;
  29229. protected _afterComputeWorldMatrix(): void;
  29230. /**
  29231. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29232. * @param func callback function to add
  29233. *
  29234. * @returns the TransformNode.
  29235. */
  29236. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29237. /**
  29238. * Removes a registered callback function.
  29239. * @param func callback function to remove
  29240. * @returns the TransformNode.
  29241. */
  29242. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29243. /**
  29244. * Clone the current transform node
  29245. * @param name Name of the new clone
  29246. * @param newParent New parent for the clone
  29247. * @param doNotCloneChildren Do not clone children hierarchy
  29248. * @returns the new transform node
  29249. */
  29250. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29251. /**
  29252. * Serializes the objects information.
  29253. * @param currentSerializationObject defines the object to serialize in
  29254. * @returns the serialized object
  29255. */
  29256. serialize(currentSerializationObject?: any): any;
  29257. /**
  29258. * Returns a new TransformNode object parsed from the source provided.
  29259. * @param parsedTransformNode is the source.
  29260. * @param scene the scne the object belongs to
  29261. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29262. * @returns a new TransformNode object parsed from the source provided.
  29263. */
  29264. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29265. /**
  29266. * Releases resources associated with this transform node.
  29267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29269. */
  29270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29271. }
  29272. }
  29273. declare module BABYLON {
  29274. /**
  29275. * Specialized buffer used to store vertex data
  29276. */
  29277. class VertexBuffer {
  29278. /** @hidden */
  29279. _buffer: Buffer;
  29280. private _kind;
  29281. private _size;
  29282. private _ownsBuffer;
  29283. private _instanced;
  29284. private _instanceDivisor;
  29285. /**
  29286. * The byte type.
  29287. */
  29288. static readonly BYTE: number;
  29289. /**
  29290. * The unsigned byte type.
  29291. */
  29292. static readonly UNSIGNED_BYTE: number;
  29293. /**
  29294. * The short type.
  29295. */
  29296. static readonly SHORT: number;
  29297. /**
  29298. * The unsigned short type.
  29299. */
  29300. static readonly UNSIGNED_SHORT: number;
  29301. /**
  29302. * The integer type.
  29303. */
  29304. static readonly INT: number;
  29305. /**
  29306. * The unsigned integer type.
  29307. */
  29308. static readonly UNSIGNED_INT: number;
  29309. /**
  29310. * The float type.
  29311. */
  29312. static readonly FLOAT: number;
  29313. /**
  29314. * Gets or sets the instance divisor when in instanced mode
  29315. */
  29316. instanceDivisor: number;
  29317. /**
  29318. * Gets the byte stride.
  29319. */
  29320. readonly byteStride: number;
  29321. /**
  29322. * Gets the byte offset.
  29323. */
  29324. readonly byteOffset: number;
  29325. /**
  29326. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29327. */
  29328. readonly normalized: boolean;
  29329. /**
  29330. * Gets the data type of each component in the array.
  29331. */
  29332. readonly type: number;
  29333. /**
  29334. * Constructor
  29335. * @param engine the engine
  29336. * @param data the data to use for this vertex buffer
  29337. * @param kind the vertex buffer kind
  29338. * @param updatable whether the data is updatable
  29339. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29340. * @param stride the stride (optional)
  29341. * @param instanced whether the buffer is instanced (optional)
  29342. * @param offset the offset of the data (optional)
  29343. * @param size the number of components (optional)
  29344. * @param type the type of the component (optional)
  29345. * @param normalized whether the data contains normalized data (optional)
  29346. * @param useBytes set to true if stride and offset are in bytes (optional)
  29347. */
  29348. 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);
  29349. /** @hidden */
  29350. _rebuild(): void;
  29351. /**
  29352. * Returns the kind of the VertexBuffer (string)
  29353. * @returns a string
  29354. */
  29355. getKind(): string;
  29356. /**
  29357. * Gets a boolean indicating if the VertexBuffer is updatable?
  29358. * @returns true if the buffer is updatable
  29359. */
  29360. isUpdatable(): boolean;
  29361. /**
  29362. * Gets current buffer's data
  29363. * @returns a DataArray or null
  29364. */
  29365. getData(): Nullable<DataArray>;
  29366. /**
  29367. * Gets underlying native buffer
  29368. * @returns underlying native buffer
  29369. */
  29370. getBuffer(): Nullable<WebGLBuffer>;
  29371. /**
  29372. * Gets the stride in float32 units (i.e. byte stride / 4).
  29373. * May not be an integer if the byte stride is not divisible by 4.
  29374. * DEPRECATED. Use byteStride instead.
  29375. * @returns the stride in float32 units
  29376. */
  29377. getStrideSize(): number;
  29378. /**
  29379. * Returns the offset as a multiple of the type byte length.
  29380. * DEPRECATED. Use byteOffset instead.
  29381. * @returns the offset in bytes
  29382. */
  29383. getOffset(): number;
  29384. /**
  29385. * Returns the number of components per vertex attribute (integer)
  29386. * @returns the size in float
  29387. */
  29388. getSize(): number;
  29389. /**
  29390. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29391. * @returns true if this buffer is instanced
  29392. */
  29393. getIsInstanced(): boolean;
  29394. /**
  29395. * Returns the instancing divisor, zero for non-instanced (integer).
  29396. * @returns a number
  29397. */
  29398. getInstanceDivisor(): number;
  29399. /**
  29400. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29401. * @param data defines the data to store
  29402. */
  29403. create(data?: DataArray): void;
  29404. /**
  29405. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29406. * This function will create a new buffer if the current one is not updatable
  29407. * @param data defines the data to store
  29408. */
  29409. update(data: DataArray): void;
  29410. /**
  29411. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29412. * Returns the directly updated WebGLBuffer.
  29413. * @param data the new data
  29414. * @param offset the new offset
  29415. * @param useBytes set to true if the offset is in bytes
  29416. */
  29417. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29418. /**
  29419. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29420. */
  29421. dispose(): void;
  29422. /**
  29423. * Enumerates each value of this vertex buffer as numbers.
  29424. * @param count the number of values to enumerate
  29425. * @param callback the callback function called for each value
  29426. */
  29427. forEach(count: number, callback: (value: number, index: number) => void): void;
  29428. /**
  29429. * Positions
  29430. */
  29431. static readonly PositionKind: string;
  29432. /**
  29433. * Normals
  29434. */
  29435. static readonly NormalKind: string;
  29436. /**
  29437. * Tangents
  29438. */
  29439. static readonly TangentKind: string;
  29440. /**
  29441. * Texture coordinates
  29442. */
  29443. static readonly UVKind: string;
  29444. /**
  29445. * Texture coordinates 2
  29446. */
  29447. static readonly UV2Kind: string;
  29448. /**
  29449. * Texture coordinates 3
  29450. */
  29451. static readonly UV3Kind: string;
  29452. /**
  29453. * Texture coordinates 4
  29454. */
  29455. static readonly UV4Kind: string;
  29456. /**
  29457. * Texture coordinates 5
  29458. */
  29459. static readonly UV5Kind: string;
  29460. /**
  29461. * Texture coordinates 6
  29462. */
  29463. static readonly UV6Kind: string;
  29464. /**
  29465. * Colors
  29466. */
  29467. static readonly ColorKind: string;
  29468. /**
  29469. * Matrix indices (for bones)
  29470. */
  29471. static readonly MatricesIndicesKind: string;
  29472. /**
  29473. * Matrix weights (for bones)
  29474. */
  29475. static readonly MatricesWeightsKind: string;
  29476. /**
  29477. * Additional matrix indices (for bones)
  29478. */
  29479. static readonly MatricesIndicesExtraKind: string;
  29480. /**
  29481. * Additional matrix weights (for bones)
  29482. */
  29483. static readonly MatricesWeightsExtraKind: string;
  29484. /**
  29485. * Deduces the stride given a kind.
  29486. * @param kind The kind string to deduce
  29487. * @returns The deduced stride
  29488. */
  29489. static DeduceStride(kind: string): number;
  29490. /**
  29491. * Gets the byte length of the given type.
  29492. * @param type the type
  29493. * @returns the number of bytes
  29494. */
  29495. static GetTypeByteLength(type: number): number;
  29496. /**
  29497. * Enumerates each value of the given parameters as numbers.
  29498. * @param data the data to enumerate
  29499. * @param byteOffset the byte offset of the data
  29500. * @param byteStride the byte stride of the data
  29501. * @param componentCount the number of components per element
  29502. * @param componentType the type of the component
  29503. * @param count the total number of components
  29504. * @param normalized whether the data is normalized
  29505. * @param callback the callback function called for each value
  29506. */
  29507. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  29508. private static _GetFloatValue;
  29509. }
  29510. }
  29511. declare module BABYLON {
  29512. /**
  29513. * Class used to enable access to IndexedDB
  29514. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29515. */
  29516. class Database implements IOfflineProvider {
  29517. private _callbackManifestChecked;
  29518. private _currentSceneUrl;
  29519. private _db;
  29520. private _enableSceneOffline;
  29521. private _enableTexturesOffline;
  29522. private _manifestVersionFound;
  29523. private _mustUpdateRessources;
  29524. private _hasReachedQuota;
  29525. private _isSupported;
  29526. private _idbFactory;
  29527. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  29528. private static IsUASupportingBlobStorage;
  29529. /**
  29530. * Gets a boolean indicating if Database storate is enabled (off by default)
  29531. */
  29532. static IDBStorageEnabled: boolean;
  29533. /**
  29534. * Gets a boolean indicating if scene must be saved in the database
  29535. */
  29536. readonly enableSceneOffline: boolean;
  29537. /**
  29538. * Gets a boolean indicating if textures must be saved in the database
  29539. */
  29540. readonly enableTexturesOffline: boolean;
  29541. /**
  29542. * Creates a new Database
  29543. * @param urlToScene defines the url to load the scene
  29544. * @param callbackManifestChecked defines the callback to use when manifest is checked
  29545. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  29546. */
  29547. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  29548. private static _ParseURL;
  29549. private static _ReturnFullUrlLocation;
  29550. private _checkManifestFile;
  29551. /**
  29552. * Open the database and make it available
  29553. * @param successCallback defines the callback to call on success
  29554. * @param errorCallback defines the callback to call on error
  29555. */
  29556. open(successCallback: () => void, errorCallback: () => void): void;
  29557. /**
  29558. * Loads an image from the database
  29559. * @param url defines the url to load from
  29560. * @param image defines the target DOM image
  29561. */
  29562. loadImage(url: string, image: HTMLImageElement): void;
  29563. private _loadImageFromDBAsync;
  29564. private _saveImageIntoDBAsync;
  29565. private _checkVersionFromDB;
  29566. private _loadVersionFromDBAsync;
  29567. private _saveVersionIntoDBAsync;
  29568. /**
  29569. * Loads a file from database
  29570. * @param url defines the URL to load from
  29571. * @param sceneLoaded defines a callback to call on success
  29572. * @param progressCallBack defines a callback to call when progress changed
  29573. * @param errorCallback defines a callback to call on error
  29574. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29575. */
  29576. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29577. private _loadFileAsync;
  29578. private _saveFileAsync;
  29579. }
  29580. }
  29581. declare module BABYLON {
  29582. /**
  29583. * Class used to enable access to offline support
  29584. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  29585. */
  29586. interface IOfflineProvider {
  29587. /**
  29588. * Gets a boolean indicating if scene must be saved in the database
  29589. */
  29590. enableSceneOffline: boolean;
  29591. /**
  29592. * Gets a boolean indicating if textures must be saved in the database
  29593. */
  29594. enableTexturesOffline: boolean;
  29595. /**
  29596. * Open the offline support and make it available
  29597. * @param successCallback defines the callback to call on success
  29598. * @param errorCallback defines the callback to call on error
  29599. */
  29600. open(successCallback: () => void, errorCallback: () => void): void;
  29601. /**
  29602. * Loads an image from the offline support
  29603. * @param url defines the url to load from
  29604. * @param image defines the target DOM image
  29605. */
  29606. loadImage(url: string, image: HTMLImageElement): void;
  29607. /**
  29608. * Loads a file from offline support
  29609. * @param url defines the URL to load from
  29610. * @param sceneLoaded defines a callback to call on success
  29611. * @param progressCallBack defines a callback to call when progress changed
  29612. * @param errorCallback defines a callback to call on error
  29613. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  29614. */
  29615. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  29616. }
  29617. }
  29618. declare module BABYLON {
  29619. /**
  29620. * Defines a target to use with MorphTargetManager
  29621. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29622. */
  29623. class MorphTarget implements IAnimatable {
  29624. /** defines the name of the target */
  29625. name: string;
  29626. /**
  29627. * Gets or sets the list of animations
  29628. */
  29629. animations: Animation[];
  29630. private _scene;
  29631. private _positions;
  29632. private _normals;
  29633. private _tangents;
  29634. private _influence;
  29635. /**
  29636. * Observable raised when the influence changes
  29637. */
  29638. onInfluenceChanged: Observable<boolean>;
  29639. /** @hidden */
  29640. _onDataLayoutChanged: Observable<void>;
  29641. /**
  29642. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  29643. */
  29644. influence: number;
  29645. private _animationPropertiesOverride;
  29646. /**
  29647. * Gets or sets the animation properties override
  29648. */
  29649. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29650. /**
  29651. * Creates a new MorphTarget
  29652. * @param name defines the name of the target
  29653. * @param influence defines the influence to use
  29654. */
  29655. constructor(
  29656. /** defines the name of the target */
  29657. name: string, influence?: number, scene?: Nullable<Scene>);
  29658. /**
  29659. * Gets a boolean defining if the target contains position data
  29660. */
  29661. readonly hasPositions: boolean;
  29662. /**
  29663. * Gets a boolean defining if the target contains normal data
  29664. */
  29665. readonly hasNormals: boolean;
  29666. /**
  29667. * Gets a boolean defining if the target contains tangent data
  29668. */
  29669. readonly hasTangents: boolean;
  29670. /**
  29671. * Affects position data to this target
  29672. * @param data defines the position data to use
  29673. */
  29674. setPositions(data: Nullable<FloatArray>): void;
  29675. /**
  29676. * Gets the position data stored in this target
  29677. * @returns a FloatArray containing the position data (or null if not present)
  29678. */
  29679. getPositions(): Nullable<FloatArray>;
  29680. /**
  29681. * Affects normal data to this target
  29682. * @param data defines the normal data to use
  29683. */
  29684. setNormals(data: Nullable<FloatArray>): void;
  29685. /**
  29686. * Gets the normal data stored in this target
  29687. * @returns a FloatArray containing the normal data (or null if not present)
  29688. */
  29689. getNormals(): Nullable<FloatArray>;
  29690. /**
  29691. * Affects tangent data to this target
  29692. * @param data defines the tangent data to use
  29693. */
  29694. setTangents(data: Nullable<FloatArray>): void;
  29695. /**
  29696. * Gets the tangent data stored in this target
  29697. * @returns a FloatArray containing the tangent data (or null if not present)
  29698. */
  29699. getTangents(): Nullable<FloatArray>;
  29700. /**
  29701. * Serializes the current target into a Serialization object
  29702. * @returns the serialized object
  29703. */
  29704. serialize(): any;
  29705. /**
  29706. * Creates a new target from serialized data
  29707. * @param serializationObject defines the serialized data to use
  29708. * @returns a new MorphTarget
  29709. */
  29710. static Parse(serializationObject: any): MorphTarget;
  29711. /**
  29712. * Creates a MorphTarget from mesh data
  29713. * @param mesh defines the source mesh
  29714. * @param name defines the name to use for the new target
  29715. * @param influence defines the influence to attach to the target
  29716. * @returns a new MorphTarget
  29717. */
  29718. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  29719. }
  29720. }
  29721. declare module BABYLON {
  29722. /**
  29723. * This class is used to deform meshes using morphing between different targets
  29724. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29725. */
  29726. class MorphTargetManager {
  29727. private _targets;
  29728. private _targetInfluenceChangedObservers;
  29729. private _targetDataLayoutChangedObservers;
  29730. private _activeTargets;
  29731. private _scene;
  29732. private _influences;
  29733. private _supportsNormals;
  29734. private _supportsTangents;
  29735. private _vertexCount;
  29736. private _uniqueId;
  29737. private _tempInfluences;
  29738. /**
  29739. * Creates a new MorphTargetManager
  29740. * @param scene defines the current scene
  29741. */
  29742. constructor(scene?: Nullable<Scene>);
  29743. /**
  29744. * Gets the unique ID of this manager
  29745. */
  29746. readonly uniqueId: number;
  29747. /**
  29748. * Gets the number of vertices handled by this manager
  29749. */
  29750. readonly vertexCount: number;
  29751. /**
  29752. * Gets a boolean indicating if this manager supports morphing of normals
  29753. */
  29754. readonly supportsNormals: boolean;
  29755. /**
  29756. * Gets a boolean indicating if this manager supports morphing of tangents
  29757. */
  29758. readonly supportsTangents: boolean;
  29759. /**
  29760. * Gets the number of targets stored in this manager
  29761. */
  29762. readonly numTargets: number;
  29763. /**
  29764. * Gets the number of influencers (ie. the number of targets with influences > 0)
  29765. */
  29766. readonly numInfluencers: number;
  29767. /**
  29768. * Gets the list of influences (one per target)
  29769. */
  29770. readonly influences: Float32Array;
  29771. /**
  29772. * Gets the active target at specified index. An active target is a target with an influence > 0
  29773. * @param index defines the index to check
  29774. * @returns the requested target
  29775. */
  29776. getActiveTarget(index: number): MorphTarget;
  29777. /**
  29778. * Gets the target at specified index
  29779. * @param index defines the index to check
  29780. * @returns the requested target
  29781. */
  29782. getTarget(index: number): MorphTarget;
  29783. /**
  29784. * Add a new target to this manager
  29785. * @param target defines the target to add
  29786. */
  29787. addTarget(target: MorphTarget): void;
  29788. /**
  29789. * Removes a target from the manager
  29790. * @param target defines the target to remove
  29791. */
  29792. removeTarget(target: MorphTarget): void;
  29793. /**
  29794. * Serializes the current manager into a Serialization object
  29795. * @returns the serialized object
  29796. */
  29797. serialize(): any;
  29798. private _syncActiveTargets;
  29799. /**
  29800. * Syncrhonize the targets with all the meshes using this morph target manager
  29801. */
  29802. synchronize(): void;
  29803. /**
  29804. * Creates a new MorphTargetManager from serialized data
  29805. * @param serializationObject defines the serialized data
  29806. * @param scene defines the hosting scene
  29807. * @returns the new MorphTargetManager
  29808. */
  29809. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  29810. }
  29811. }
  29812. declare module BABYLON {
  29813. /**
  29814. * This represents the base class for particle system in Babylon.
  29815. * 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.
  29816. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  29817. * @example https://doc.babylonjs.com/babylon101/particles
  29818. */
  29819. class BaseParticleSystem {
  29820. /**
  29821. * Source color is added to the destination color without alpha affecting the result
  29822. */
  29823. static BLENDMODE_ONEONE: number;
  29824. /**
  29825. * Blend current color and particle color using particle’s alpha
  29826. */
  29827. static BLENDMODE_STANDARD: number;
  29828. /**
  29829. * Add current color and particle color multiplied by particle’s alpha
  29830. */
  29831. static BLENDMODE_ADD: number;
  29832. /**
  29833. * Multiply current color with particle color
  29834. */
  29835. static BLENDMODE_MULTIPLY: number;
  29836. /**
  29837. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  29838. */
  29839. static BLENDMODE_MULTIPLYADD: number;
  29840. /**
  29841. * List of animations used by the particle system.
  29842. */
  29843. animations: Animation[];
  29844. /**
  29845. * The id of the Particle system.
  29846. */
  29847. id: string;
  29848. /**
  29849. * The friendly name of the Particle system.
  29850. */
  29851. name: string;
  29852. /**
  29853. * The rendering group used by the Particle system to chose when to render.
  29854. */
  29855. renderingGroupId: number;
  29856. /**
  29857. * The emitter represents the Mesh or position we are attaching the particle system to.
  29858. */
  29859. emitter: Nullable<AbstractMesh | Vector3>;
  29860. /**
  29861. * The maximum number of particles to emit per frame
  29862. */
  29863. emitRate: number;
  29864. /**
  29865. * If you want to launch only a few particles at once, that can be done, as well.
  29866. */
  29867. manualEmitCount: number;
  29868. /**
  29869. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  29870. */
  29871. updateSpeed: number;
  29872. /**
  29873. * The amount of time the particle system is running (depends of the overall update speed).
  29874. */
  29875. targetStopDuration: number;
  29876. /**
  29877. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  29878. */
  29879. disposeOnStop: boolean;
  29880. /**
  29881. * Minimum power of emitting particles.
  29882. */
  29883. minEmitPower: number;
  29884. /**
  29885. * Maximum power of emitting particles.
  29886. */
  29887. maxEmitPower: number;
  29888. /**
  29889. * Minimum life time of emitting particles.
  29890. */
  29891. minLifeTime: number;
  29892. /**
  29893. * Maximum life time of emitting particles.
  29894. */
  29895. maxLifeTime: number;
  29896. /**
  29897. * Minimum Size of emitting particles.
  29898. */
  29899. minSize: number;
  29900. /**
  29901. * Maximum Size of emitting particles.
  29902. */
  29903. maxSize: number;
  29904. /**
  29905. * Minimum scale of emitting particles on X axis.
  29906. */
  29907. minScaleX: number;
  29908. /**
  29909. * Maximum scale of emitting particles on X axis.
  29910. */
  29911. maxScaleX: number;
  29912. /**
  29913. * Minimum scale of emitting particles on Y axis.
  29914. */
  29915. minScaleY: number;
  29916. /**
  29917. * Maximum scale of emitting particles on Y axis.
  29918. */
  29919. maxScaleY: number;
  29920. /**
  29921. * Gets or sets the minimal initial rotation in radians.
  29922. */
  29923. minInitialRotation: number;
  29924. /**
  29925. * Gets or sets the maximal initial rotation in radians.
  29926. */
  29927. maxInitialRotation: number;
  29928. /**
  29929. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  29930. */
  29931. minAngularSpeed: number;
  29932. /**
  29933. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  29934. */
  29935. maxAngularSpeed: number;
  29936. /**
  29937. * The texture used to render each particle. (this can be a spritesheet)
  29938. */
  29939. particleTexture: Nullable<Texture>;
  29940. /**
  29941. * The layer mask we are rendering the particles through.
  29942. */
  29943. layerMask: number;
  29944. /**
  29945. * This can help using your own shader to render the particle system.
  29946. * The according effect will be created
  29947. */
  29948. customShader: any;
  29949. /**
  29950. * By default particle system starts as soon as they are created. This prevents the
  29951. * automatic start to happen and let you decide when to start emitting particles.
  29952. */
  29953. preventAutoStart: boolean;
  29954. /**
  29955. * Gets or sets a texture used to add random noise to particle positions
  29956. */
  29957. noiseTexture: Nullable<ProceduralTexture>;
  29958. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  29959. noiseStrength: Vector3;
  29960. /**
  29961. * Callback triggered when the particle animation is ending.
  29962. */
  29963. onAnimationEnd: Nullable<() => void>;
  29964. /**
  29965. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  29966. */
  29967. blendMode: number;
  29968. /**
  29969. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  29970. * to override the particles.
  29971. */
  29972. forceDepthWrite: boolean;
  29973. /** 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 */
  29974. preWarmCycles: number;
  29975. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  29976. preWarmStepOffset: number;
  29977. /**
  29978. * 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)
  29979. */
  29980. spriteCellChangeSpeed: number;
  29981. /**
  29982. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  29983. */
  29984. startSpriteCellID: number;
  29985. /**
  29986. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  29987. */
  29988. endSpriteCellID: number;
  29989. /**
  29990. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  29991. */
  29992. spriteCellWidth: number;
  29993. /**
  29994. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  29995. */
  29996. spriteCellHeight: number;
  29997. /**
  29998. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  29999. */
  30000. spriteRandomStartCell: boolean;
  30001. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30002. translationPivot: Vector2;
  30003. /** @hidden */
  30004. protected _isAnimationSheetEnabled: boolean;
  30005. /**
  30006. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30007. */
  30008. beginAnimationOnStart: boolean;
  30009. /**
  30010. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30011. */
  30012. beginAnimationFrom: number;
  30013. /**
  30014. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30015. */
  30016. beginAnimationTo: number;
  30017. /**
  30018. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30019. */
  30020. beginAnimationLoop: boolean;
  30021. /**
  30022. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30023. */
  30024. isAnimationSheetEnabled: boolean;
  30025. /**
  30026. * Get hosting scene
  30027. * @returns the scene
  30028. */
  30029. getScene(): Scene;
  30030. /**
  30031. * You can use gravity if you want to give an orientation to your particles.
  30032. */
  30033. gravity: Vector3;
  30034. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30035. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30036. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30037. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30038. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30039. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30040. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30041. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30042. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30043. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30044. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30045. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30046. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30047. /**
  30048. * Defines the delay in milliseconds before starting the system (0 by default)
  30049. */
  30050. startDelay: number;
  30051. /**
  30052. * Gets the current list of drag gradients.
  30053. * You must use addDragGradient and removeDragGradient to udpate this list
  30054. * @returns the list of drag gradients
  30055. */
  30056. getDragGradients(): Nullable<Array<FactorGradient>>;
  30057. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30058. limitVelocityDamping: number;
  30059. /**
  30060. * Gets the current list of limit velocity gradients.
  30061. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30062. * @returns the list of limit velocity gradients
  30063. */
  30064. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30065. /**
  30066. * Gets the current list of color gradients.
  30067. * You must use addColorGradient and removeColorGradient to udpate this list
  30068. * @returns the list of color gradients
  30069. */
  30070. getColorGradients(): Nullable<Array<ColorGradient>>;
  30071. /**
  30072. * Gets the current list of size gradients.
  30073. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30074. * @returns the list of size gradients
  30075. */
  30076. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30077. /**
  30078. * Gets the current list of color remap gradients.
  30079. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30080. * @returns the list of color remap gradients
  30081. */
  30082. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30083. /**
  30084. * Gets the current list of alpha remap gradients.
  30085. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30086. * @returns the list of alpha remap gradients
  30087. */
  30088. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30089. /**
  30090. * Gets the current list of life time gradients.
  30091. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30092. * @returns the list of life time gradients
  30093. */
  30094. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30095. /**
  30096. * Gets the current list of angular speed gradients.
  30097. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30098. * @returns the list of angular speed gradients
  30099. */
  30100. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30101. /**
  30102. * Gets the current list of velocity gradients.
  30103. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30104. * @returns the list of velocity gradients
  30105. */
  30106. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30107. /**
  30108. * Gets the current list of start size gradients.
  30109. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30110. * @returns the list of start size gradients
  30111. */
  30112. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30113. /**
  30114. * Gets the current list of emit rate gradients.
  30115. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30116. * @returns the list of emit rate gradients
  30117. */
  30118. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30119. /**
  30120. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30121. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30122. */
  30123. direction1: Vector3;
  30124. /**
  30125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30126. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30127. */
  30128. direction2: Vector3;
  30129. /**
  30130. * 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.
  30131. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30132. */
  30133. minEmitBox: Vector3;
  30134. /**
  30135. * 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.
  30136. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30137. */
  30138. maxEmitBox: Vector3;
  30139. /**
  30140. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30141. */
  30142. color1: Color4;
  30143. /**
  30144. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30145. */
  30146. color2: Color4;
  30147. /**
  30148. * Color the particle will have at the end of its lifetime
  30149. */
  30150. colorDead: Color4;
  30151. /**
  30152. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30153. */
  30154. textureMask: Color4;
  30155. /**
  30156. * The particle emitter type defines the emitter used by the particle system.
  30157. * It can be for example box, sphere, or cone...
  30158. */
  30159. particleEmitterType: IParticleEmitterType;
  30160. /** @hidden */
  30161. _isSubEmitter: boolean;
  30162. /**
  30163. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30164. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30165. */
  30166. billboardMode: number;
  30167. protected _isBillboardBased: boolean;
  30168. /**
  30169. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30170. */
  30171. isBillboardBased: boolean;
  30172. /**
  30173. * The scene the particle system belongs to.
  30174. */
  30175. protected _scene: Scene;
  30176. /**
  30177. * Local cache of defines for image processing.
  30178. */
  30179. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30180. /**
  30181. * Default configuration related to image processing available in the standard Material.
  30182. */
  30183. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30184. /**
  30185. * Gets the image processing configuration used either in this material.
  30186. */
  30187. /**
  30188. * Sets the Default image processing configuration used either in the this material.
  30189. *
  30190. * If sets to null, the scene one is in use.
  30191. */
  30192. imageProcessingConfiguration: ImageProcessingConfiguration;
  30193. /**
  30194. * Attaches a new image processing configuration to the Standard Material.
  30195. * @param configuration
  30196. */
  30197. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30198. /** @hidden */
  30199. protected _reset(): void;
  30200. /** @hidden */
  30201. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30202. /**
  30203. * Instantiates a particle system.
  30204. * 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.
  30205. * @param name The name of the particle system
  30206. */
  30207. constructor(name: string);
  30208. /**
  30209. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30210. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30211. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30212. * @returns the emitter
  30213. */
  30214. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30215. /**
  30216. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30217. * @param radius The radius of the hemisphere to emit from
  30218. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30219. * @returns the emitter
  30220. */
  30221. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30222. /**
  30223. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30224. * @param radius The radius of the sphere to emit from
  30225. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30226. * @returns the emitter
  30227. */
  30228. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30229. /**
  30230. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30231. * @param radius The radius of the sphere to emit from
  30232. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30233. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30234. * @returns the emitter
  30235. */
  30236. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30237. /**
  30238. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30239. * @param radius The radius of the emission cylinder
  30240. * @param height The height of the emission cylinder
  30241. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30242. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30243. * @returns the emitter
  30244. */
  30245. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30246. /**
  30247. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30248. * @param radius The radius of the cylinder to emit from
  30249. * @param height The height of the emission cylinder
  30250. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30251. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30252. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30253. * @returns the emitter
  30254. */
  30255. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30256. /**
  30257. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30258. * @param radius The radius of the cone to emit from
  30259. * @param angle The base angle of the cone
  30260. * @returns the emitter
  30261. */
  30262. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30263. /**
  30264. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30265. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30266. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30267. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30268. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30269. * @returns the emitter
  30270. */
  30271. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30272. }
  30273. }
  30274. declare module BABYLON {
  30275. /**
  30276. * This represents a GPU particle system in Babylon
  30277. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30278. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30279. */
  30280. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30281. /**
  30282. * The layer mask we are rendering the particles through.
  30283. */
  30284. layerMask: number;
  30285. private _capacity;
  30286. private _activeCount;
  30287. private _currentActiveCount;
  30288. private _accumulatedCount;
  30289. private _renderEffect;
  30290. private _updateEffect;
  30291. private _buffer0;
  30292. private _buffer1;
  30293. private _spriteBuffer;
  30294. private _updateVAO;
  30295. private _renderVAO;
  30296. private _targetIndex;
  30297. private _sourceBuffer;
  30298. private _targetBuffer;
  30299. private _engine;
  30300. private _currentRenderId;
  30301. private _started;
  30302. private _stopped;
  30303. private _timeDelta;
  30304. private _randomTexture;
  30305. private _randomTexture2;
  30306. private _attributesStrideSize;
  30307. private _updateEffectOptions;
  30308. private _randomTextureSize;
  30309. private _actualFrame;
  30310. private readonly _rawTextureWidth;
  30311. /**
  30312. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30313. */
  30314. static readonly IsSupported: boolean;
  30315. /**
  30316. * An event triggered when the system is disposed.
  30317. */
  30318. onDisposeObservable: Observable<GPUParticleSystem>;
  30319. /**
  30320. * Gets the maximum number of particles active at the same time.
  30321. * @returns The max number of active particles.
  30322. */
  30323. getCapacity(): number;
  30324. /**
  30325. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30326. * to override the particles.
  30327. */
  30328. forceDepthWrite: boolean;
  30329. /**
  30330. * Gets or set the number of active particles
  30331. */
  30332. activeParticleCount: number;
  30333. private _preWarmDone;
  30334. /**
  30335. * Is this system ready to be used/rendered
  30336. * @return true if the system is ready
  30337. */
  30338. isReady(): boolean;
  30339. /**
  30340. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30341. * @returns True if it has been started, otherwise false.
  30342. */
  30343. isStarted(): boolean;
  30344. /**
  30345. * Starts the particle system and begins to emit
  30346. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30347. */
  30348. start(delay?: number): void;
  30349. /**
  30350. * Stops the particle system.
  30351. */
  30352. stop(): void;
  30353. /**
  30354. * Remove all active particles
  30355. */
  30356. reset(): void;
  30357. /**
  30358. * Returns the string "GPUParticleSystem"
  30359. * @returns a string containing the class name
  30360. */
  30361. getClassName(): string;
  30362. private _colorGradientsTexture;
  30363. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30364. /**
  30365. * Adds a new color gradient
  30366. * @param gradient defines the gradient to use (between 0 and 1)
  30367. * @param color1 defines the color to affect to the specified gradient
  30368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30369. * @returns the current particle system
  30370. */
  30371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30372. /**
  30373. * Remove a specific color gradient
  30374. * @param gradient defines the gradient to remove
  30375. * @returns the current particle system
  30376. */
  30377. removeColorGradient(gradient: number): GPUParticleSystem;
  30378. private _angularSpeedGradientsTexture;
  30379. private _sizeGradientsTexture;
  30380. private _velocityGradientsTexture;
  30381. private _limitVelocityGradientsTexture;
  30382. private _dragGradientsTexture;
  30383. private _addFactorGradient;
  30384. /**
  30385. * Adds a new size gradient
  30386. * @param gradient defines the gradient to use (between 0 and 1)
  30387. * @param factor defines the size factor to affect to the specified gradient
  30388. * @returns the current particle system
  30389. */
  30390. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30391. /**
  30392. * Remove a specific size gradient
  30393. * @param gradient defines the gradient to remove
  30394. * @returns the current particle system
  30395. */
  30396. removeSizeGradient(gradient: number): GPUParticleSystem;
  30397. /**
  30398. * Adds a new angular speed gradient
  30399. * @param gradient defines the gradient to use (between 0 and 1)
  30400. * @param factor defines the angular speed to affect to the specified gradient
  30401. * @returns the current particle system
  30402. */
  30403. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30404. /**
  30405. * Remove a specific angular speed gradient
  30406. * @param gradient defines the gradient to remove
  30407. * @returns the current particle system
  30408. */
  30409. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30410. /**
  30411. * Adds a new velocity gradient
  30412. * @param gradient defines the gradient to use (between 0 and 1)
  30413. * @param factor defines the velocity to affect to the specified gradient
  30414. * @returns the current particle system
  30415. */
  30416. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30417. /**
  30418. * Remove a specific velocity gradient
  30419. * @param gradient defines the gradient to remove
  30420. * @returns the current particle system
  30421. */
  30422. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30423. /**
  30424. * Adds a new limit velocity gradient
  30425. * @param gradient defines the gradient to use (between 0 and 1)
  30426. * @param factor defines the limit velocity value to affect to the specified gradient
  30427. * @returns the current particle system
  30428. */
  30429. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30430. /**
  30431. * Remove a specific limit velocity gradient
  30432. * @param gradient defines the gradient to remove
  30433. * @returns the current particle system
  30434. */
  30435. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30436. /**
  30437. * Adds a new drag gradient
  30438. * @param gradient defines the gradient to use (between 0 and 1)
  30439. * @param factor defines the drag value to affect to the specified gradient
  30440. * @returns the current particle system
  30441. */
  30442. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30443. /**
  30444. * Remove a specific drag gradient
  30445. * @param gradient defines the gradient to remove
  30446. * @returns the current particle system
  30447. */
  30448. removeDragGradient(gradient: number): GPUParticleSystem;
  30449. /**
  30450. * Not supported by GPUParticleSystem
  30451. * @param gradient defines the gradient to use (between 0 and 1)
  30452. * @param factor defines the emit rate value to affect to the specified gradient
  30453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30454. * @returns the current particle system
  30455. */
  30456. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30457. /**
  30458. * Not supported by GPUParticleSystem
  30459. * @param gradient defines the gradient to remove
  30460. * @returns the current particle system
  30461. */
  30462. removeEmitRateGradient(gradient: number): IParticleSystem;
  30463. /**
  30464. * Not supported by GPUParticleSystem
  30465. * @param gradient defines the gradient to use (between 0 and 1)
  30466. * @param factor defines the start size value to affect to the specified gradient
  30467. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30468. * @returns the current particle system
  30469. */
  30470. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30471. /**
  30472. * Not supported by GPUParticleSystem
  30473. * @param gradient defines the gradient to remove
  30474. * @returns the current particle system
  30475. */
  30476. removeStartSizeGradient(gradient: number): IParticleSystem;
  30477. /**
  30478. * Not supported by GPUParticleSystem
  30479. * @param gradient defines the gradient to use (between 0 and 1)
  30480. * @param min defines the color remap minimal range
  30481. * @param max defines the color remap maximal range
  30482. * @returns the current particle system
  30483. */
  30484. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30485. /**
  30486. * Not supported by GPUParticleSystem
  30487. * @param gradient defines the gradient to remove
  30488. * @returns the current particle system
  30489. */
  30490. removeColorRemapGradient(gradient: number): IParticleSystem;
  30491. /**
  30492. * Not supported by GPUParticleSystem
  30493. * @param gradient defines the gradient to use (between 0 and 1)
  30494. * @param min defines the alpha remap minimal range
  30495. * @param max defines the alpha remap maximal range
  30496. * @returns the current particle system
  30497. */
  30498. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30499. /**
  30500. * Not supported by GPUParticleSystem
  30501. * @param gradient defines the gradient to remove
  30502. * @returns the current particle system
  30503. */
  30504. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30505. /**
  30506. * Not supported by GPUParticleSystem
  30507. * @param gradient defines the gradient to use (between 0 and 1)
  30508. * @param color defines the color to affect to the specified gradient
  30509. * @returns the current particle system
  30510. */
  30511. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30512. /**
  30513. * Not supported by GPUParticleSystem
  30514. * @param gradient defines the gradient to remove
  30515. * @returns the current particle system
  30516. */
  30517. removeRampGradient(gradient: number): IParticleSystem;
  30518. /**
  30519. * Not supported by GPUParticleSystem
  30520. * @returns the list of ramp gradients
  30521. */
  30522. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30523. /**
  30524. * Not supported by GPUParticleSystem
  30525. * Gets or sets a boolean indicating that ramp gradients must be used
  30526. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30527. */
  30528. useRampGradients: boolean;
  30529. /**
  30530. * Not supported by GPUParticleSystem
  30531. * @param gradient defines the gradient to use (between 0 and 1)
  30532. * @param factor defines the life time factor to affect to the specified gradient
  30533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30534. * @returns the current particle system
  30535. */
  30536. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30537. /**
  30538. * Not supported by GPUParticleSystem
  30539. * @param gradient defines the gradient to remove
  30540. * @returns the current particle system
  30541. */
  30542. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30543. /**
  30544. * Instantiates a GPU particle system.
  30545. * 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.
  30546. * @param name The name of the particle system
  30547. * @param options The options used to create the system
  30548. * @param scene The scene the particle system belongs to
  30549. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30550. */
  30551. constructor(name: string, options: Partial<{
  30552. capacity: number;
  30553. randomTextureSize: number;
  30554. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30555. protected _reset(): void;
  30556. private _createUpdateVAO;
  30557. private _createRenderVAO;
  30558. private _initialize;
  30559. /** @hidden */
  30560. _recreateUpdateEffect(): void;
  30561. /** @hidden */
  30562. _recreateRenderEffect(): void;
  30563. /**
  30564. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30565. * @param preWarm defines if we are in the pre-warmimg phase
  30566. */
  30567. animate(preWarm?: boolean): void;
  30568. private _createFactorGradientTexture;
  30569. private _createSizeGradientTexture;
  30570. private _createAngularSpeedGradientTexture;
  30571. private _createVelocityGradientTexture;
  30572. private _createLimitVelocityGradientTexture;
  30573. private _createDragGradientTexture;
  30574. private _createColorGradientTexture;
  30575. /**
  30576. * Renders the particle system in its current state
  30577. * @param preWarm defines if the system should only update the particles but not render them
  30578. * @returns the current number of particles
  30579. */
  30580. render(preWarm?: boolean): number;
  30581. /**
  30582. * Rebuilds the particle system
  30583. */
  30584. rebuild(): void;
  30585. private _releaseBuffers;
  30586. private _releaseVAOs;
  30587. /**
  30588. * Disposes the particle system and free the associated resources
  30589. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30590. */
  30591. dispose(disposeTexture?: boolean): void;
  30592. /**
  30593. * Clones the particle system.
  30594. * @param name The name of the cloned object
  30595. * @param newEmitter The new emitter to use
  30596. * @returns the cloned particle system
  30597. */
  30598. clone(name: string, newEmitter: any): GPUParticleSystem;
  30599. /**
  30600. * Serializes the particle system to a JSON object.
  30601. * @returns the JSON object
  30602. */
  30603. serialize(): any;
  30604. /**
  30605. * Parses a JSON object to create a GPU particle system.
  30606. * @param parsedParticleSystem The JSON object to parse
  30607. * @param scene The scene to create the particle system in
  30608. * @param rootUrl The root url to use to load external dependencies like texture
  30609. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30610. * @returns the parsed GPU particle system
  30611. */
  30612. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30613. }
  30614. }
  30615. declare module BABYLON {
  30616. /**
  30617. * Interface representing a particle system in Babylon.js.
  30618. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30619. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30620. */
  30621. interface IParticleSystem {
  30622. /**
  30623. * List of animations used by the particle system.
  30624. */
  30625. animations: Animation[];
  30626. /**
  30627. * The id of the Particle system.
  30628. */
  30629. id: string;
  30630. /**
  30631. * The name of the Particle system.
  30632. */
  30633. name: string;
  30634. /**
  30635. * The emitter represents the Mesh or position we are attaching the particle system to.
  30636. */
  30637. emitter: Nullable<AbstractMesh | Vector3>;
  30638. /**
  30639. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30640. */
  30641. isBillboardBased: boolean;
  30642. /**
  30643. * The rendering group used by the Particle system to chose when to render.
  30644. */
  30645. renderingGroupId: number;
  30646. /**
  30647. * The layer mask we are rendering the particles through.
  30648. */
  30649. layerMask: number;
  30650. /**
  30651. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30652. */
  30653. updateSpeed: number;
  30654. /**
  30655. * The amount of time the particle system is running (depends of the overall update speed).
  30656. */
  30657. targetStopDuration: number;
  30658. /**
  30659. * The texture used to render each particle. (this can be a spritesheet)
  30660. */
  30661. particleTexture: Nullable<Texture>;
  30662. /**
  30663. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  30664. */
  30665. blendMode: number;
  30666. /**
  30667. * Minimum life time of emitting particles.
  30668. */
  30669. minLifeTime: number;
  30670. /**
  30671. * Maximum life time of emitting particles.
  30672. */
  30673. maxLifeTime: number;
  30674. /**
  30675. * Minimum Size of emitting particles.
  30676. */
  30677. minSize: number;
  30678. /**
  30679. * Maximum Size of emitting particles.
  30680. */
  30681. maxSize: number;
  30682. /**
  30683. * Minimum scale of emitting particles on X axis.
  30684. */
  30685. minScaleX: number;
  30686. /**
  30687. * Maximum scale of emitting particles on X axis.
  30688. */
  30689. maxScaleX: number;
  30690. /**
  30691. * Minimum scale of emitting particles on Y axis.
  30692. */
  30693. minScaleY: number;
  30694. /**
  30695. * Maximum scale of emitting particles on Y axis.
  30696. */
  30697. maxScaleY: number;
  30698. /**
  30699. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30700. */
  30701. color1: Color4;
  30702. /**
  30703. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  30704. */
  30705. color2: Color4;
  30706. /**
  30707. * Color the particle will have at the end of its lifetime.
  30708. */
  30709. colorDead: Color4;
  30710. /**
  30711. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  30712. */
  30713. emitRate: number;
  30714. /**
  30715. * You can use gravity if you want to give an orientation to your particles.
  30716. */
  30717. gravity: Vector3;
  30718. /**
  30719. * Minimum power of emitting particles.
  30720. */
  30721. minEmitPower: number;
  30722. /**
  30723. * Maximum power of emitting particles.
  30724. */
  30725. maxEmitPower: number;
  30726. /**
  30727. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30728. */
  30729. minAngularSpeed: number;
  30730. /**
  30731. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30732. */
  30733. maxAngularSpeed: number;
  30734. /**
  30735. * Gets or sets the minimal initial rotation in radians.
  30736. */
  30737. minInitialRotation: number;
  30738. /**
  30739. * Gets or sets the maximal initial rotation in radians.
  30740. */
  30741. maxInitialRotation: number;
  30742. /**
  30743. * The particle emitter type defines the emitter used by the particle system.
  30744. * It can be for example box, sphere, or cone...
  30745. */
  30746. particleEmitterType: Nullable<IParticleEmitterType>;
  30747. /**
  30748. * Defines the delay in milliseconds before starting the system (0 by default)
  30749. */
  30750. startDelay: number;
  30751. /**
  30752. * 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
  30753. */
  30754. preWarmCycles: number;
  30755. /**
  30756. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  30757. */
  30758. preWarmStepOffset: number;
  30759. /**
  30760. * 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)
  30761. */
  30762. spriteCellChangeSpeed: number;
  30763. /**
  30764. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30765. */
  30766. startSpriteCellID: number;
  30767. /**
  30768. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30769. */
  30770. endSpriteCellID: number;
  30771. /**
  30772. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30773. */
  30774. spriteCellWidth: number;
  30775. /**
  30776. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30777. */
  30778. spriteCellHeight: number;
  30779. /**
  30780. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30781. */
  30782. spriteRandomStartCell: boolean;
  30783. /**
  30784. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  30785. */
  30786. isAnimationSheetEnabled: boolean;
  30787. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30788. translationPivot: Vector2;
  30789. /**
  30790. * Gets or sets a texture used to add random noise to particle positions
  30791. */
  30792. noiseTexture: Nullable<BaseTexture>;
  30793. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30794. noiseStrength: Vector3;
  30795. /**
  30796. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30797. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30798. */
  30799. billboardMode: number;
  30800. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30801. limitVelocityDamping: number;
  30802. /**
  30803. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30804. */
  30805. beginAnimationOnStart: boolean;
  30806. /**
  30807. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30808. */
  30809. beginAnimationFrom: number;
  30810. /**
  30811. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30812. */
  30813. beginAnimationTo: number;
  30814. /**
  30815. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30816. */
  30817. beginAnimationLoop: boolean;
  30818. /**
  30819. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30820. */
  30821. disposeOnStop: boolean;
  30822. /**
  30823. * Gets the maximum number of particles active at the same time.
  30824. * @returns The max number of active particles.
  30825. */
  30826. getCapacity(): number;
  30827. /**
  30828. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30829. * @returns True if it has been started, otherwise false.
  30830. */
  30831. isStarted(): boolean;
  30832. /**
  30833. * Animates the particle system for this frame.
  30834. */
  30835. animate(): void;
  30836. /**
  30837. * Renders the particle system in its current state.
  30838. * @returns the current number of particles
  30839. */
  30840. render(): number;
  30841. /**
  30842. * Dispose the particle system and frees its associated resources.
  30843. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30844. */
  30845. dispose(disposeTexture?: boolean): void;
  30846. /**
  30847. * Clones the particle system.
  30848. * @param name The name of the cloned object
  30849. * @param newEmitter The new emitter to use
  30850. * @returns the cloned particle system
  30851. */
  30852. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  30853. /**
  30854. * Serializes the particle system to a JSON object.
  30855. * @returns the JSON object
  30856. */
  30857. serialize(): any;
  30858. /**
  30859. * Rebuild the particle system
  30860. */
  30861. rebuild(): void;
  30862. /**
  30863. * Starts the particle system and begins to emit
  30864. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  30865. */
  30866. start(delay?: number): void;
  30867. /**
  30868. * Stops the particle system.
  30869. */
  30870. stop(): void;
  30871. /**
  30872. * Remove all active particles
  30873. */
  30874. reset(): void;
  30875. /**
  30876. * Is this system ready to be used/rendered
  30877. * @return true if the system is ready
  30878. */
  30879. isReady(): boolean;
  30880. /**
  30881. * Adds a new color gradient
  30882. * @param gradient defines the gradient to use (between 0 and 1)
  30883. * @param color1 defines the color to affect to the specified gradient
  30884. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30885. * @returns the current particle system
  30886. */
  30887. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  30888. /**
  30889. * Remove a specific color gradient
  30890. * @param gradient defines the gradient to remove
  30891. * @returns the current particle system
  30892. */
  30893. removeColorGradient(gradient: number): IParticleSystem;
  30894. /**
  30895. * Adds a new size gradient
  30896. * @param gradient defines the gradient to use (between 0 and 1)
  30897. * @param factor defines the size factor to affect to the specified gradient
  30898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30899. * @returns the current particle system
  30900. */
  30901. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30902. /**
  30903. * Remove a specific size gradient
  30904. * @param gradient defines the gradient to remove
  30905. * @returns the current particle system
  30906. */
  30907. removeSizeGradient(gradient: number): IParticleSystem;
  30908. /**
  30909. * Gets the current list of color gradients.
  30910. * You must use addColorGradient and removeColorGradient to udpate this list
  30911. * @returns the list of color gradients
  30912. */
  30913. getColorGradients(): Nullable<Array<ColorGradient>>;
  30914. /**
  30915. * Gets the current list of size gradients.
  30916. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30917. * @returns the list of size gradients
  30918. */
  30919. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30920. /**
  30921. * Gets the current list of angular speed gradients.
  30922. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30923. * @returns the list of angular speed gradients
  30924. */
  30925. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30926. /**
  30927. * Adds a new angular speed gradient
  30928. * @param gradient defines the gradient to use (between 0 and 1)
  30929. * @param factor defines the angular speed to affect to the specified gradient
  30930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30931. * @returns the current particle system
  30932. */
  30933. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30934. /**
  30935. * Remove a specific angular speed gradient
  30936. * @param gradient defines the gradient to remove
  30937. * @returns the current particle system
  30938. */
  30939. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  30940. /**
  30941. * Gets the current list of velocity gradients.
  30942. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30943. * @returns the list of velocity gradients
  30944. */
  30945. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30946. /**
  30947. * Adds a new velocity gradient
  30948. * @param gradient defines the gradient to use (between 0 and 1)
  30949. * @param factor defines the velocity to affect to the specified gradient
  30950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30951. * @returns the current particle system
  30952. */
  30953. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30954. /**
  30955. * Remove a specific velocity gradient
  30956. * @param gradient defines the gradient to remove
  30957. * @returns the current particle system
  30958. */
  30959. removeVelocityGradient(gradient: number): IParticleSystem;
  30960. /**
  30961. * Gets the current list of limit velocity gradients.
  30962. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30963. * @returns the list of limit velocity gradients
  30964. */
  30965. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30966. /**
  30967. * Adds a new limit velocity gradient
  30968. * @param gradient defines the gradient to use (between 0 and 1)
  30969. * @param factor defines the limit velocity to affect to the specified gradient
  30970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30971. * @returns the current particle system
  30972. */
  30973. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30974. /**
  30975. * Remove a specific limit velocity gradient
  30976. * @param gradient defines the gradient to remove
  30977. * @returns the current particle system
  30978. */
  30979. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  30980. /**
  30981. * Adds a new drag gradient
  30982. * @param gradient defines the gradient to use (between 0 and 1)
  30983. * @param factor defines the drag to affect to the specified gradient
  30984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30985. * @returns the current particle system
  30986. */
  30987. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30988. /**
  30989. * Remove a specific drag gradient
  30990. * @param gradient defines the gradient to remove
  30991. * @returns the current particle system
  30992. */
  30993. removeDragGradient(gradient: number): IParticleSystem;
  30994. /**
  30995. * Gets the current list of drag gradients.
  30996. * You must use addDragGradient and removeDragGradient to udpate this list
  30997. * @returns the list of drag gradients
  30998. */
  30999. getDragGradients(): Nullable<Array<FactorGradient>>;
  31000. /**
  31001. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31002. * @param gradient defines the gradient to use (between 0 and 1)
  31003. * @param factor defines the emit rate to affect to the specified gradient
  31004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31005. * @returns the current particle system
  31006. */
  31007. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31008. /**
  31009. * Remove a specific emit rate gradient
  31010. * @param gradient defines the gradient to remove
  31011. * @returns the current particle system
  31012. */
  31013. removeEmitRateGradient(gradient: number): IParticleSystem;
  31014. /**
  31015. * Gets the current list of emit rate gradients.
  31016. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31017. * @returns the list of emit rate gradients
  31018. */
  31019. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31020. /**
  31021. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31022. * @param gradient defines the gradient to use (between 0 and 1)
  31023. * @param factor defines the start size to affect to the specified gradient
  31024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31025. * @returns the current particle system
  31026. */
  31027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31028. /**
  31029. * Remove a specific start size gradient
  31030. * @param gradient defines the gradient to remove
  31031. * @returns the current particle system
  31032. */
  31033. removeStartSizeGradient(gradient: number): IParticleSystem;
  31034. /**
  31035. * Gets the current list of start size gradients.
  31036. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31037. * @returns the list of start size gradients
  31038. */
  31039. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31040. /**
  31041. * Adds a new life time gradient
  31042. * @param gradient defines the gradient to use (between 0 and 1)
  31043. * @param factor defines the life time factor to affect to the specified gradient
  31044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31045. * @returns the current particle system
  31046. */
  31047. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31048. /**
  31049. * Remove a specific life time gradient
  31050. * @param gradient defines the gradient to remove
  31051. * @returns the current particle system
  31052. */
  31053. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31054. /**
  31055. * Gets the current list of life time gradients.
  31056. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31057. * @returns the list of life time gradients
  31058. */
  31059. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31060. /**
  31061. * Gets the current list of color gradients.
  31062. * You must use addColorGradient and removeColorGradient to udpate this list
  31063. * @returns the list of color gradients
  31064. */
  31065. getColorGradients(): Nullable<Array<ColorGradient>>;
  31066. /**
  31067. * Adds a new ramp gradient used to remap particle colors
  31068. * @param gradient defines the gradient to use (between 0 and 1)
  31069. * @param color defines the color to affect to the specified gradient
  31070. * @returns the current particle system
  31071. */
  31072. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31073. /**
  31074. * Gets the current list of ramp gradients.
  31075. * You must use addRampGradient and removeRampGradient to udpate this list
  31076. * @returns the list of ramp gradients
  31077. */
  31078. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31079. /** Gets or sets a boolean indicating that ramp gradients must be used
  31080. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31081. */
  31082. useRampGradients: boolean;
  31083. /**
  31084. * Adds a new color remap gradient
  31085. * @param gradient defines the gradient to use (between 0 and 1)
  31086. * @param min defines the color remap minimal range
  31087. * @param max defines the color remap maximal range
  31088. * @returns the current particle system
  31089. */
  31090. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31091. /**
  31092. * Gets the current list of color remap gradients.
  31093. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31094. * @returns the list of color remap gradients
  31095. */
  31096. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31097. /**
  31098. * Adds a new alpha remap gradient
  31099. * @param gradient defines the gradient to use (between 0 and 1)
  31100. * @param min defines the alpha remap minimal range
  31101. * @param max defines the alpha remap maximal range
  31102. * @returns the current particle system
  31103. */
  31104. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31105. /**
  31106. * Gets the current list of alpha remap gradients.
  31107. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31108. * @returns the list of alpha remap gradients
  31109. */
  31110. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31111. /**
  31112. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31113. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31114. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31115. * @returns the emitter
  31116. */
  31117. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31118. /**
  31119. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31120. * @param radius The radius of the hemisphere to emit from
  31121. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31122. * @returns the emitter
  31123. */
  31124. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31125. /**
  31126. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31127. * @param radius The radius of the sphere to emit from
  31128. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31129. * @returns the emitter
  31130. */
  31131. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31132. /**
  31133. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31134. * @param radius The radius of the sphere to emit from
  31135. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31136. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31137. * @returns the emitter
  31138. */
  31139. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31140. /**
  31141. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31142. * @param radius The radius of the emission cylinder
  31143. * @param height The height of the emission cylinder
  31144. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31145. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31146. * @returns the emitter
  31147. */
  31148. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31149. /**
  31150. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31151. * @param radius The radius of the cylinder to emit from
  31152. * @param height The height of the emission cylinder
  31153. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31154. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31155. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31156. * @returns the emitter
  31157. */
  31158. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31159. /**
  31160. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31161. * @param radius The radius of the cone to emit from
  31162. * @param angle The base angle of the cone
  31163. * @returns the emitter
  31164. */
  31165. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31166. /**
  31167. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31170. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31171. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31172. * @returns the emitter
  31173. */
  31174. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31175. /**
  31176. * Get hosting scene
  31177. * @returns the scene
  31178. */
  31179. getScene(): Scene;
  31180. }
  31181. }
  31182. declare module BABYLON {
  31183. /**
  31184. * A particle represents one of the element emitted by a particle system.
  31185. * This is mainly define by its coordinates, direction, velocity and age.
  31186. */
  31187. class Particle {
  31188. /**
  31189. * The particle system the particle belongs to.
  31190. */
  31191. particleSystem: ParticleSystem;
  31192. private static _Count;
  31193. /**
  31194. * Unique ID of the particle
  31195. */
  31196. id: number;
  31197. /**
  31198. * The world position of the particle in the scene.
  31199. */
  31200. position: Vector3;
  31201. /**
  31202. * The world direction of the particle in the scene.
  31203. */
  31204. direction: Vector3;
  31205. /**
  31206. * The color of the particle.
  31207. */
  31208. color: Color4;
  31209. /**
  31210. * The color change of the particle per step.
  31211. */
  31212. colorStep: Color4;
  31213. /**
  31214. * Defines how long will the life of the particle be.
  31215. */
  31216. lifeTime: number;
  31217. /**
  31218. * The current age of the particle.
  31219. */
  31220. age: number;
  31221. /**
  31222. * The current size of the particle.
  31223. */
  31224. size: number;
  31225. /**
  31226. * The current scale of the particle.
  31227. */
  31228. scale: Vector2;
  31229. /**
  31230. * The current angle of the particle.
  31231. */
  31232. angle: number;
  31233. /**
  31234. * Defines how fast is the angle changing.
  31235. */
  31236. angularSpeed: number;
  31237. /**
  31238. * Defines the cell index used by the particle to be rendered from a sprite.
  31239. */
  31240. cellIndex: number;
  31241. /**
  31242. * The information required to support color remapping
  31243. */
  31244. remapData: Vector4;
  31245. /** @hidden */
  31246. _randomCellOffset?: number;
  31247. /** @hidden */
  31248. _initialDirection: Nullable<Vector3>;
  31249. /** @hidden */
  31250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31251. /** @hidden */
  31252. _initialStartSpriteCellID: number;
  31253. /** @hidden */
  31254. _initialEndSpriteCellID: number;
  31255. /** @hidden */
  31256. _currentColorGradient: Nullable<ColorGradient>;
  31257. /** @hidden */
  31258. _currentColor1: Color4;
  31259. /** @hidden */
  31260. _currentColor2: Color4;
  31261. /** @hidden */
  31262. _currentSizeGradient: Nullable<FactorGradient>;
  31263. /** @hidden */
  31264. _currentSize1: number;
  31265. /** @hidden */
  31266. _currentSize2: number;
  31267. /** @hidden */
  31268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31269. /** @hidden */
  31270. _currentAngularSpeed1: number;
  31271. /** @hidden */
  31272. _currentAngularSpeed2: number;
  31273. /** @hidden */
  31274. _currentVelocityGradient: Nullable<FactorGradient>;
  31275. /** @hidden */
  31276. _currentVelocity1: number;
  31277. /** @hidden */
  31278. _currentVelocity2: number;
  31279. /** @hidden */
  31280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31281. /** @hidden */
  31282. _currentLimitVelocity1: number;
  31283. /** @hidden */
  31284. _currentLimitVelocity2: number;
  31285. /** @hidden */
  31286. _currentDragGradient: Nullable<FactorGradient>;
  31287. /** @hidden */
  31288. _currentDrag1: number;
  31289. /** @hidden */
  31290. _currentDrag2: number;
  31291. /** @hidden */
  31292. _randomNoiseCoordinates1: Vector3;
  31293. /** @hidden */
  31294. _randomNoiseCoordinates2: Vector3;
  31295. /**
  31296. * Creates a new instance Particle
  31297. * @param particleSystem the particle system the particle belongs to
  31298. */
  31299. constructor(
  31300. /**
  31301. * The particle system the particle belongs to.
  31302. */
  31303. particleSystem: ParticleSystem);
  31304. private updateCellInfoFromSystem;
  31305. /**
  31306. * Defines how the sprite cell index is updated for the particle
  31307. */
  31308. updateCellIndex(): void;
  31309. /** @hidden */
  31310. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31311. /** @hidden */
  31312. _inheritParticleInfoToSubEmitters(): void;
  31313. /** @hidden */
  31314. _reset(): void;
  31315. /**
  31316. * Copy the properties of particle to another one.
  31317. * @param other the particle to copy the information to.
  31318. */
  31319. copyTo(other: Particle): void;
  31320. }
  31321. }
  31322. declare module BABYLON {
  31323. /**
  31324. * This class is made for on one-liner static method to help creating particle system set.
  31325. */
  31326. class ParticleHelper {
  31327. /**
  31328. * Gets or sets base Assets URL
  31329. */
  31330. static BaseAssetsUrl: string;
  31331. /**
  31332. * Create a default particle system that you can tweak
  31333. * @param emitter defines the emitter to use
  31334. * @param capacity defines the system capacity (default is 500 particles)
  31335. * @param scene defines the hosting scene
  31336. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31337. * @returns the new Particle system
  31338. */
  31339. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31340. /**
  31341. * This is the main static method (one-liner) of this helper to create different particle systems
  31342. * @param type This string represents the type to the particle system to create
  31343. * @param scene The scene where the particle system should live
  31344. * @param gpu If the system will use gpu
  31345. * @returns the ParticleSystemSet created
  31346. */
  31347. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31348. /**
  31349. * Static function used to export a particle system to a ParticleSystemSet variable.
  31350. * Please note that the emitter shape is not exported
  31351. * @param systems defines the particle systems to export
  31352. * @returns the created particle system set
  31353. */
  31354. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31355. }
  31356. }
  31357. declare module BABYLON {
  31358. /**
  31359. * This represents a particle system in Babylon.
  31360. * 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.
  31361. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31362. * @example https://doc.babylonjs.com/babylon101/particles
  31363. */
  31364. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31365. /**
  31366. * Billboard mode will only apply to Y axis
  31367. */
  31368. static readonly BILLBOARDMODE_Y: number;
  31369. /**
  31370. * Billboard mode will apply to all axes
  31371. */
  31372. static readonly BILLBOARDMODE_ALL: number;
  31373. /**
  31374. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31375. */
  31376. static readonly BILLBOARDMODE_STRETCHED: number;
  31377. /**
  31378. * This function can be defined to provide custom update for active particles.
  31379. * This function will be called instead of regular update (age, position, color, etc.).
  31380. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31381. */
  31382. updateFunction: (particles: Particle[]) => void;
  31383. private _emitterWorldMatrix;
  31384. /**
  31385. * This function can be defined to specify initial direction for every new particle.
  31386. * It by default use the emitterType defined function
  31387. */
  31388. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31389. /**
  31390. * This function can be defined to specify initial position for every new particle.
  31391. * It by default use the emitterType defined function
  31392. */
  31393. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31394. /**
  31395. * @hidden
  31396. */
  31397. _inheritedVelocityOffset: Vector3;
  31398. /**
  31399. * An event triggered when the system is disposed
  31400. */
  31401. onDisposeObservable: Observable<ParticleSystem>;
  31402. private _onDisposeObserver;
  31403. /**
  31404. * Sets a callback that will be triggered when the system is disposed
  31405. */
  31406. onDispose: () => void;
  31407. private _particles;
  31408. private _epsilon;
  31409. private _capacity;
  31410. private _stockParticles;
  31411. private _newPartsExcess;
  31412. private _vertexData;
  31413. private _vertexBuffer;
  31414. private _vertexBuffers;
  31415. private _spriteBuffer;
  31416. private _indexBuffer;
  31417. private _effect;
  31418. private _customEffect;
  31419. private _cachedDefines;
  31420. private _scaledColorStep;
  31421. private _colorDiff;
  31422. private _scaledDirection;
  31423. private _scaledGravity;
  31424. private _currentRenderId;
  31425. private _alive;
  31426. private _useInstancing;
  31427. private _started;
  31428. private _stopped;
  31429. private _actualFrame;
  31430. private _scaledUpdateSpeed;
  31431. private _vertexBufferSize;
  31432. /** @hidden */
  31433. _currentEmitRateGradient: Nullable<FactorGradient>;
  31434. /** @hidden */
  31435. _currentEmitRate1: number;
  31436. /** @hidden */
  31437. _currentEmitRate2: number;
  31438. /** @hidden */
  31439. _currentStartSizeGradient: Nullable<FactorGradient>;
  31440. /** @hidden */
  31441. _currentStartSize1: number;
  31442. /** @hidden */
  31443. _currentStartSize2: number;
  31444. private readonly _rawTextureWidth;
  31445. private _rampGradientsTexture;
  31446. private _useRampGradients;
  31447. /** Gets or sets a boolean indicating that ramp gradients must be used
  31448. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31449. */
  31450. useRampGradients: boolean;
  31451. /**
  31452. * 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.
  31453. * 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: [])
  31454. */
  31455. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31456. private _subEmitters;
  31457. /**
  31458. * @hidden
  31459. * If the particle systems emitter should be disposed when the particle system is disposed
  31460. */
  31461. _disposeEmitterOnDispose: boolean;
  31462. /**
  31463. * The current active Sub-systems, this property is used by the root particle system only.
  31464. */
  31465. activeSubSystems: Array<ParticleSystem>;
  31466. private _rootParticleSystem;
  31467. /**
  31468. * Gets the current list of active particles
  31469. */
  31470. readonly particles: Particle[];
  31471. /**
  31472. * Returns the string "ParticleSystem"
  31473. * @returns a string containing the class name
  31474. */
  31475. getClassName(): string;
  31476. /**
  31477. * Instantiates a particle system.
  31478. * 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.
  31479. * @param name The name of the particle system
  31480. * @param capacity The max number of particles alive at the same time
  31481. * @param scene The scene the particle system belongs to
  31482. * @param customEffect a custom effect used to change the way particles are rendered by default
  31483. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31484. * @param epsilon Offset used to render the particles
  31485. */
  31486. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31487. private _addFactorGradient;
  31488. private _removeFactorGradient;
  31489. /**
  31490. * Adds a new life time gradient
  31491. * @param gradient defines the gradient to use (between 0 and 1)
  31492. * @param factor defines the life time factor to affect to the specified gradient
  31493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31494. * @returns the current particle system
  31495. */
  31496. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31497. /**
  31498. * Remove a specific life time gradient
  31499. * @param gradient defines the gradient to remove
  31500. * @returns the current particle system
  31501. */
  31502. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31503. /**
  31504. * Adds a new size gradient
  31505. * @param gradient defines the gradient to use (between 0 and 1)
  31506. * @param factor defines the size factor to affect to the specified gradient
  31507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31508. * @returns the current particle system
  31509. */
  31510. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31511. /**
  31512. * Remove a specific size gradient
  31513. * @param gradient defines the gradient to remove
  31514. * @returns the current particle system
  31515. */
  31516. removeSizeGradient(gradient: number): IParticleSystem;
  31517. /**
  31518. * Adds a new color remap gradient
  31519. * @param gradient defines the gradient to use (between 0 and 1)
  31520. * @param min defines the color remap minimal range
  31521. * @param max defines the color remap maximal range
  31522. * @returns the current particle system
  31523. */
  31524. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31525. /**
  31526. * Remove a specific color remap gradient
  31527. * @param gradient defines the gradient to remove
  31528. * @returns the current particle system
  31529. */
  31530. removeColorRemapGradient(gradient: number): IParticleSystem;
  31531. /**
  31532. * Adds a new alpha remap gradient
  31533. * @param gradient defines the gradient to use (between 0 and 1)
  31534. * @param min defines the alpha remap minimal range
  31535. * @param max defines the alpha remap maximal range
  31536. * @returns the current particle system
  31537. */
  31538. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31539. /**
  31540. * Remove a specific alpha remap gradient
  31541. * @param gradient defines the gradient to remove
  31542. * @returns the current particle system
  31543. */
  31544. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31545. /**
  31546. * Adds a new angular speed gradient
  31547. * @param gradient defines the gradient to use (between 0 and 1)
  31548. * @param factor defines the angular speed to affect to the specified gradient
  31549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31550. * @returns the current particle system
  31551. */
  31552. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31553. /**
  31554. * Remove a specific angular speed gradient
  31555. * @param gradient defines the gradient to remove
  31556. * @returns the current particle system
  31557. */
  31558. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31559. /**
  31560. * Adds a new velocity gradient
  31561. * @param gradient defines the gradient to use (between 0 and 1)
  31562. * @param factor defines the velocity to affect to the specified gradient
  31563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31564. * @returns the current particle system
  31565. */
  31566. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31567. /**
  31568. * Remove a specific velocity gradient
  31569. * @param gradient defines the gradient to remove
  31570. * @returns the current particle system
  31571. */
  31572. removeVelocityGradient(gradient: number): IParticleSystem;
  31573. /**
  31574. * Adds a new limit velocity gradient
  31575. * @param gradient defines the gradient to use (between 0 and 1)
  31576. * @param factor defines the limit velocity value to affect to the specified gradient
  31577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31578. * @returns the current particle system
  31579. */
  31580. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31581. /**
  31582. * Remove a specific limit velocity gradient
  31583. * @param gradient defines the gradient to remove
  31584. * @returns the current particle system
  31585. */
  31586. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31587. /**
  31588. * Adds a new drag gradient
  31589. * @param gradient defines the gradient to use (between 0 and 1)
  31590. * @param factor defines the drag value to affect to the specified gradient
  31591. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31592. * @returns the current particle system
  31593. */
  31594. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31595. /**
  31596. * Remove a specific drag gradient
  31597. * @param gradient defines the gradient to remove
  31598. * @returns the current particle system
  31599. */
  31600. removeDragGradient(gradient: number): IParticleSystem;
  31601. /**
  31602. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31603. * @param gradient defines the gradient to use (between 0 and 1)
  31604. * @param factor defines the emit rate value to affect to the specified gradient
  31605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31606. * @returns the current particle system
  31607. */
  31608. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31609. /**
  31610. * Remove a specific emit rate gradient
  31611. * @param gradient defines the gradient to remove
  31612. * @returns the current particle system
  31613. */
  31614. removeEmitRateGradient(gradient: number): IParticleSystem;
  31615. /**
  31616. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31617. * @param gradient defines the gradient to use (between 0 and 1)
  31618. * @param factor defines the start size value to affect to the specified gradient
  31619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31620. * @returns the current particle system
  31621. */
  31622. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31623. /**
  31624. * Remove a specific start size gradient
  31625. * @param gradient defines the gradient to remove
  31626. * @returns the current particle system
  31627. */
  31628. removeStartSizeGradient(gradient: number): IParticleSystem;
  31629. private _createRampGradientTexture;
  31630. /**
  31631. * Gets the current list of ramp gradients.
  31632. * You must use addRampGradient and removeRampGradient to udpate this list
  31633. * @returns the list of ramp gradients
  31634. */
  31635. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31636. /**
  31637. * Adds a new ramp gradient used to remap particle colors
  31638. * @param gradient defines the gradient to use (between 0 and 1)
  31639. * @param color defines the color to affect to the specified gradient
  31640. * @returns the current particle system
  31641. */
  31642. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  31643. /**
  31644. * Remove a specific ramp gradient
  31645. * @param gradient defines the gradient to remove
  31646. * @returns the current particle system
  31647. */
  31648. removeRampGradient(gradient: number): ParticleSystem;
  31649. /**
  31650. * Adds a new color gradient
  31651. * @param gradient defines the gradient to use (between 0 and 1)
  31652. * @param color1 defines the color to affect to the specified gradient
  31653. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31654. * @returns this particle system
  31655. */
  31656. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31657. /**
  31658. * Remove a specific color gradient
  31659. * @param gradient defines the gradient to remove
  31660. * @returns this particle system
  31661. */
  31662. removeColorGradient(gradient: number): IParticleSystem;
  31663. private _fetchR;
  31664. protected _reset(): void;
  31665. private _resetEffect;
  31666. private _createVertexBuffers;
  31667. private _createIndexBuffer;
  31668. /**
  31669. * Gets the maximum number of particles active at the same time.
  31670. * @returns The max number of active particles.
  31671. */
  31672. getCapacity(): number;
  31673. /**
  31674. * Gets whether there are still active particles in the system.
  31675. * @returns True if it is alive, otherwise false.
  31676. */
  31677. isAlive(): boolean;
  31678. /**
  31679. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31680. * @returns True if it has been started, otherwise false.
  31681. */
  31682. isStarted(): boolean;
  31683. private _prepareSubEmitterInternalArray;
  31684. /**
  31685. * Starts the particle system and begins to emit
  31686. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  31687. */
  31688. start(delay?: number): void;
  31689. /**
  31690. * Stops the particle system.
  31691. * @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.
  31692. */
  31693. stop(stopSubEmitters?: boolean): void;
  31694. /**
  31695. * Remove all active particles
  31696. */
  31697. reset(): void;
  31698. /**
  31699. * @hidden (for internal use only)
  31700. */
  31701. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  31702. /**
  31703. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  31704. * Its lifetime will start back at 0.
  31705. */
  31706. recycleParticle: (particle: Particle) => void;
  31707. private _stopSubEmitters;
  31708. private _createParticle;
  31709. private _removeFromRoot;
  31710. private _emitFromParticle;
  31711. private _update;
  31712. /** @hidden */
  31713. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  31714. /** @hidden */
  31715. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  31716. /** @hidden */
  31717. private _getEffect;
  31718. /**
  31719. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31720. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  31721. */
  31722. animate(preWarmOnly?: boolean): void;
  31723. private _appendParticleVertices;
  31724. /**
  31725. * Rebuilds the particle system.
  31726. */
  31727. rebuild(): void;
  31728. /**
  31729. * Is this system ready to be used/rendered
  31730. * @return true if the system is ready
  31731. */
  31732. isReady(): boolean;
  31733. private _render;
  31734. /**
  31735. * Renders the particle system in its current state.
  31736. * @returns the current number of particles
  31737. */
  31738. render(): number;
  31739. /**
  31740. * Disposes the particle system and free the associated resources
  31741. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31742. */
  31743. dispose(disposeTexture?: boolean): void;
  31744. /**
  31745. * Clones the particle system.
  31746. * @param name The name of the cloned object
  31747. * @param newEmitter The new emitter to use
  31748. * @returns the cloned particle system
  31749. */
  31750. clone(name: string, newEmitter: any): ParticleSystem;
  31751. /**
  31752. * Serializes the particle system to a JSON object.
  31753. * @returns the JSON object
  31754. */
  31755. serialize(): any;
  31756. /** @hidden */
  31757. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  31758. /** @hidden */
  31759. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  31760. /**
  31761. * Parses a JSON object to create a particle system.
  31762. * @param parsedParticleSystem The JSON object to parse
  31763. * @param scene The scene to create the particle system in
  31764. * @param rootUrl The root url to use to load external dependencies like texture
  31765. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31766. * @returns the Parsed particle system
  31767. */
  31768. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  31769. }
  31770. }
  31771. declare module BABYLON {
  31772. interface Engine {
  31773. /**
  31774. * Create an effect to use with particle systems.
  31775. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  31776. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  31777. * @param uniformsNames defines a list of attribute names
  31778. * @param samplers defines an array of string used to represent textures
  31779. * @param defines defines the string containing the defines to use to compile the shaders
  31780. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31781. * @param onCompiled defines a function to call when the effect creation is successful
  31782. * @param onError defines a function to call when the effect creation has failed
  31783. * @returns the new Effect
  31784. */
  31785. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  31786. }
  31787. interface Mesh {
  31788. /**
  31789. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  31790. * @returns an array of IParticleSystem
  31791. */
  31792. getEmittedParticleSystems(): IParticleSystem[];
  31793. /**
  31794. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  31795. * @returns an array of IParticleSystem
  31796. */
  31797. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * Represents a set of particle systems working together to create a specific effect
  31803. */
  31804. class ParticleSystemSet implements IDisposable {
  31805. private _emitterCreationOptions;
  31806. private _emitterNode;
  31807. /**
  31808. * Gets the particle system list
  31809. */
  31810. systems: IParticleSystem[];
  31811. /**
  31812. * Gets the emitter node used with this set
  31813. */
  31814. readonly emitterNode: Nullable<TransformNode>;
  31815. /**
  31816. * Creates a new emitter mesh as a sphere
  31817. * @param options defines the options used to create the sphere
  31818. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  31819. * @param scene defines the hosting scene
  31820. */
  31821. setEmitterAsSphere(options: {
  31822. diameter: number;
  31823. segments: number;
  31824. color: Color3;
  31825. }, renderingGroupId: number, scene: Scene): void;
  31826. /**
  31827. * Starts all particle systems of the set
  31828. * @param emitter defines an optional mesh to use as emitter for the particle systems
  31829. */
  31830. start(emitter?: AbstractMesh): void;
  31831. /**
  31832. * Release all associated resources
  31833. */
  31834. dispose(): void;
  31835. /**
  31836. * Serialize the set into a JSON compatible object
  31837. * @returns a JSON compatible representation of the set
  31838. */
  31839. serialize(): any;
  31840. /**
  31841. * Parse a new ParticleSystemSet from a serialized source
  31842. * @param data defines a JSON compatible representation of the set
  31843. * @param scene defines the hosting scene
  31844. * @param gpu defines if we want GPU particles or CPU particles
  31845. * @returns a new ParticleSystemSet
  31846. */
  31847. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  31848. }
  31849. }
  31850. declare module BABYLON {
  31851. /**
  31852. * Represents one particle of a solid particle system.
  31853. */
  31854. class SolidParticle {
  31855. /**
  31856. * particle global index
  31857. */
  31858. idx: number;
  31859. /**
  31860. * The color of the particle
  31861. */
  31862. color: Nullable<Color4>;
  31863. /**
  31864. * The world space position of the particle.
  31865. */
  31866. position: Vector3;
  31867. /**
  31868. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31869. */
  31870. rotation: Vector3;
  31871. /**
  31872. * The world space rotation quaternion of the particle.
  31873. */
  31874. rotationQuaternion: Nullable<Quaternion>;
  31875. /**
  31876. * The scaling of the particle.
  31877. */
  31878. scaling: Vector3;
  31879. /**
  31880. * The uvs of the particle.
  31881. */
  31882. uvs: Vector4;
  31883. /**
  31884. * The current speed of the particle.
  31885. */
  31886. velocity: Vector3;
  31887. /**
  31888. * The pivot point in the particle local space.
  31889. */
  31890. pivot: Vector3;
  31891. /**
  31892. * Must the particle be translated from its pivot point in its local space ?
  31893. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31894. * Default : false
  31895. */
  31896. translateFromPivot: boolean;
  31897. /**
  31898. * Is the particle active or not ?
  31899. */
  31900. alive: boolean;
  31901. /**
  31902. * Is the particle visible or not ?
  31903. */
  31904. isVisible: boolean;
  31905. /**
  31906. * Index of this particle in the global "positions" array (Internal use)
  31907. * @hidden
  31908. */
  31909. _pos: number;
  31910. /**
  31911. * @hidden Index of this particle in the global "indices" array (Internal use)
  31912. */
  31913. _ind: number;
  31914. /**
  31915. * @hidden ModelShape of this particle (Internal use)
  31916. */
  31917. _model: ModelShape;
  31918. /**
  31919. * ModelShape id of this particle
  31920. */
  31921. shapeId: number;
  31922. /**
  31923. * Index of the particle in its shape id (Internal use)
  31924. */
  31925. idxInShape: number;
  31926. /**
  31927. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31928. */
  31929. _modelBoundingInfo: BoundingInfo;
  31930. /**
  31931. * @hidden Particle BoundingInfo object (Internal use)
  31932. */
  31933. _boundingInfo: BoundingInfo;
  31934. /**
  31935. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31936. */
  31937. _sps: SolidParticleSystem;
  31938. /**
  31939. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31940. */
  31941. _stillInvisible: boolean;
  31942. /**
  31943. * @hidden Last computed particle rotation matrix
  31944. */
  31945. _rotationMatrix: number[];
  31946. /**
  31947. * Parent particle Id, if any.
  31948. * Default null.
  31949. */
  31950. parentId: Nullable<number>;
  31951. /**
  31952. * @hidden Internal global position in the SPS.
  31953. */
  31954. _globalPosition: Vector3;
  31955. /**
  31956. * Creates a Solid Particle object.
  31957. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31958. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  31959. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31960. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31961. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31962. * @param shapeId (integer) is the model shape identifier in the SPS.
  31963. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31964. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31965. */
  31966. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  31967. /**
  31968. * Legacy support, changed scale to scaling
  31969. */
  31970. /**
  31971. * Legacy support, changed scale to scaling
  31972. */
  31973. scale: Vector3;
  31974. /**
  31975. * Legacy support, changed quaternion to rotationQuaternion
  31976. */
  31977. /**
  31978. * Legacy support, changed quaternion to rotationQuaternion
  31979. */
  31980. quaternion: Nullable<Quaternion>;
  31981. /**
  31982. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31983. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31984. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31985. * @returns true if it intersects
  31986. */
  31987. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31988. /**
  31989. * get the rotation matrix of the particle
  31990. * @hidden
  31991. */
  31992. getRotationMatrix(m: Matrix): void;
  31993. }
  31994. /**
  31995. * Represents the shape of the model used by one particle of a solid particle system.
  31996. * SPS internal tool, don't use it manually.
  31997. */
  31998. class ModelShape {
  31999. /**
  32000. * The shape id
  32001. * @hidden
  32002. */
  32003. shapeID: number;
  32004. /**
  32005. * flat array of model positions (internal use)
  32006. * @hidden
  32007. */
  32008. _shape: Vector3[];
  32009. /**
  32010. * flat array of model UVs (internal use)
  32011. * @hidden
  32012. */
  32013. _shapeUV: number[];
  32014. /**
  32015. * length of the shape in the model indices array (internal use)
  32016. * @hidden
  32017. */
  32018. _indicesLength: number;
  32019. /**
  32020. * Custom position function (internal use)
  32021. * @hidden
  32022. */
  32023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32024. /**
  32025. * Custom vertex function (internal use)
  32026. * @hidden
  32027. */
  32028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32029. /**
  32030. * 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.
  32031. * SPS internal tool, don't use it manually.
  32032. * @hidden
  32033. */
  32034. 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>);
  32035. }
  32036. /**
  32037. * Represents a Depth Sorted Particle in the solid particle system.
  32038. */
  32039. class DepthSortedParticle {
  32040. /**
  32041. * Index of the particle in the "indices" array
  32042. */
  32043. ind: number;
  32044. /**
  32045. * Length of the particle shape in the "indices" array
  32046. */
  32047. indicesLength: number;
  32048. /**
  32049. * Squared distance from the particle to the camera
  32050. */
  32051. sqDistance: number;
  32052. }
  32053. }
  32054. declare module BABYLON {
  32055. /**
  32056. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32057. *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.
  32058. * The SPS is also a particle system. It provides some methods to manage the particles.
  32059. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32060. *
  32061. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32062. */
  32063. class SolidParticleSystem implements IDisposable {
  32064. /**
  32065. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32066. * Example : var p = SPS.particles[i];
  32067. */
  32068. particles: SolidParticle[];
  32069. /**
  32070. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32071. */
  32072. nbParticles: number;
  32073. /**
  32074. * If the particles must ever face the camera (default false). Useful for planar particles.
  32075. */
  32076. billboard: boolean;
  32077. /**
  32078. * Recompute normals when adding a shape
  32079. */
  32080. recomputeNormals: boolean;
  32081. /**
  32082. * This a counter ofr your own usage. It's not set by any SPS functions.
  32083. */
  32084. counter: number;
  32085. /**
  32086. * The SPS name. This name is also given to the underlying mesh.
  32087. */
  32088. name: string;
  32089. /**
  32090. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32091. */
  32092. mesh: Mesh;
  32093. /**
  32094. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32095. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32096. */
  32097. vars: any;
  32098. /**
  32099. * This array is populated when the SPS is set as 'pickable'.
  32100. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32101. * Each element of this array is an object `{idx: int, faceId: int}`.
  32102. * `idx` is the picked particle index in the `SPS.particles` array
  32103. * `faceId` is the picked face index counted within this particle.
  32104. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32105. */
  32106. pickedParticles: {
  32107. idx: number;
  32108. faceId: number;
  32109. }[];
  32110. /**
  32111. * This array is populated when `enableDepthSort` is set to true.
  32112. * Each element of this array is an instance of the class DepthSortedParticle.
  32113. */
  32114. depthSortedParticles: DepthSortedParticle[];
  32115. /**
  32116. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32117. * @hidden
  32118. */
  32119. _bSphereOnly: boolean;
  32120. /**
  32121. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32122. * @hidden
  32123. */
  32124. _bSphereRadiusFactor: number;
  32125. private _scene;
  32126. private _positions;
  32127. private _indices;
  32128. private _normals;
  32129. private _colors;
  32130. private _uvs;
  32131. private _indices32;
  32132. private _positions32;
  32133. private _normals32;
  32134. private _fixedNormal32;
  32135. private _colors32;
  32136. private _uvs32;
  32137. private _index;
  32138. private _updatable;
  32139. private _pickable;
  32140. private _isVisibilityBoxLocked;
  32141. private _alwaysVisible;
  32142. private _depthSort;
  32143. private _shapeCounter;
  32144. private _copy;
  32145. private _color;
  32146. private _computeParticleColor;
  32147. private _computeParticleTexture;
  32148. private _computeParticleRotation;
  32149. private _computeParticleVertex;
  32150. private _computeBoundingBox;
  32151. private _depthSortParticles;
  32152. private _camera;
  32153. private _mustUnrotateFixedNormals;
  32154. private _particlesIntersect;
  32155. private _needs32Bits;
  32156. /**
  32157. * Creates a SPS (Solid Particle System) object.
  32158. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32159. * @param scene (Scene) is the scene in which the SPS is added.
  32160. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32161. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32162. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32163. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32164. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32165. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32166. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32167. */
  32168. constructor(name: string, scene: Scene, options?: {
  32169. updatable?: boolean;
  32170. isPickable?: boolean;
  32171. enableDepthSort?: boolean;
  32172. particleIntersection?: boolean;
  32173. boundingSphereOnly?: boolean;
  32174. bSphereRadiusFactor?: number;
  32175. });
  32176. /**
  32177. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32178. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32179. * @returns the created mesh
  32180. */
  32181. buildMesh(): Mesh;
  32182. /**
  32183. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32184. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32185. * Thus the particles generated from `digest()` have their property `position` set yet.
  32186. * @param mesh ( Mesh ) is the mesh to be digested
  32187. * @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
  32188. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32189. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32190. * @returns the current SPS
  32191. */
  32192. digest(mesh: Mesh, options?: {
  32193. facetNb?: number;
  32194. number?: number;
  32195. delta?: number;
  32196. }): SolidParticleSystem;
  32197. private _unrotateFixedNormals;
  32198. private _resetCopy;
  32199. private _meshBuilder;
  32200. private _posToShape;
  32201. private _uvsToShapeUV;
  32202. private _addParticle;
  32203. /**
  32204. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32205. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32206. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32207. * @param nb (positive integer) the number of particles to be created from this model
  32208. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32209. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32210. * @returns the number of shapes in the system
  32211. */
  32212. addShape(mesh: Mesh, nb: number, options?: {
  32213. positionFunction?: any;
  32214. vertexFunction?: any;
  32215. }): number;
  32216. private _rebuildParticle;
  32217. /**
  32218. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32219. * @returns the SPS.
  32220. */
  32221. rebuildMesh(): SolidParticleSystem;
  32222. /**
  32223. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32224. * This method calls `updateParticle()` for each particle of the SPS.
  32225. * For an animated SPS, it is usually called within the render loop.
  32226. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32227. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32228. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32229. * @returns the SPS.
  32230. */
  32231. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32232. /**
  32233. * Disposes the SPS.
  32234. */
  32235. dispose(): void;
  32236. /**
  32237. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32238. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32239. * @returns the SPS.
  32240. */
  32241. refreshVisibleSize(): SolidParticleSystem;
  32242. /**
  32243. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32244. * @param size the size (float) of the visibility box
  32245. * note : this doesn't lock the SPS mesh bounding box.
  32246. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32247. */
  32248. setVisibilityBox(size: number): void;
  32249. /**
  32250. * Gets whether the SPS as always visible or not
  32251. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32252. */
  32253. /**
  32254. * Sets the SPS as always visible or not
  32255. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32256. */
  32257. isAlwaysVisible: boolean;
  32258. /**
  32259. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32260. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32261. */
  32262. /**
  32263. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32264. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32265. */
  32266. isVisibilityBoxLocked: boolean;
  32267. /**
  32268. * Tells to `setParticles()` to compute the particle rotations or not.
  32269. * Default value : true. The SPS is faster when it's set to false.
  32270. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32271. */
  32272. /**
  32273. * Gets if `setParticles()` computes the particle rotations or not.
  32274. * Default value : true. The SPS is faster when it's set to false.
  32275. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32276. */
  32277. computeParticleRotation: boolean;
  32278. /**
  32279. * Tells to `setParticles()` to compute the particle colors or not.
  32280. * Default value : true. The SPS is faster when it's set to false.
  32281. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32282. */
  32283. /**
  32284. * Gets if `setParticles()` computes the particle colors or not.
  32285. * Default value : true. The SPS is faster when it's set to false.
  32286. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32287. */
  32288. computeParticleColor: boolean;
  32289. /**
  32290. * Gets if `setParticles()` computes the particle textures or not.
  32291. * Default value : true. The SPS is faster when it's set to false.
  32292. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32293. */
  32294. computeParticleTexture: boolean;
  32295. /**
  32296. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32297. * Default value : false. The SPS is faster when it's set to false.
  32298. * Note : the particle custom vertex positions aren't stored values.
  32299. */
  32300. /**
  32301. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32302. * Default value : false. The SPS is faster when it's set to false.
  32303. * Note : the particle custom vertex positions aren't stored values.
  32304. */
  32305. computeParticleVertex: boolean;
  32306. /**
  32307. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32308. */
  32309. /**
  32310. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32311. */
  32312. computeBoundingBox: boolean;
  32313. /**
  32314. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32315. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32316. * Default : `true`
  32317. */
  32318. /**
  32319. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32320. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32321. * Default : `true`
  32322. */
  32323. depthSortParticles: boolean;
  32324. /**
  32325. * This function does nothing. It may be overwritten to set all the particle first values.
  32326. * The SPS doesn't call this function, you may have to call it by your own.
  32327. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32328. */
  32329. initParticles(): void;
  32330. /**
  32331. * This function does nothing. It may be overwritten to recycle a particle.
  32332. * The SPS doesn't call this function, you may have to call it by your own.
  32333. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32334. * @param particle The particle to recycle
  32335. * @returns the recycled particle
  32336. */
  32337. recycleParticle(particle: SolidParticle): SolidParticle;
  32338. /**
  32339. * Updates a particle : this function should be overwritten by the user.
  32340. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32341. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32342. * @example : just set a particle position or velocity and recycle conditions
  32343. * @param particle The particle to update
  32344. * @returns the updated particle
  32345. */
  32346. updateParticle(particle: SolidParticle): SolidParticle;
  32347. /**
  32348. * Updates a vertex of a particle : it can be overwritten by the user.
  32349. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32350. * @param particle the current particle
  32351. * @param vertex the current index of the current particle
  32352. * @param pt the index of the current vertex in the particle shape
  32353. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32354. * @example : just set a vertex particle position
  32355. * @returns the updated vertex
  32356. */
  32357. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32358. /**
  32359. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32360. * This does nothing and may be overwritten by the user.
  32361. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32362. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32363. * @param update the boolean update value actually passed to setParticles()
  32364. */
  32365. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32366. /**
  32367. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32368. * This will be passed three parameters.
  32369. * This does nothing and may be overwritten by the user.
  32370. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32371. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32372. * @param update the boolean update value actually passed to setParticles()
  32373. */
  32374. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32375. }
  32376. }
  32377. declare module BABYLON {
  32378. /**
  32379. * Type of sub emitter
  32380. */
  32381. enum SubEmitterType {
  32382. /**
  32383. * Attached to the particle over it's lifetime
  32384. */
  32385. ATTACHED = 0,
  32386. /**
  32387. * Created when the particle dies
  32388. */
  32389. END = 1
  32390. }
  32391. /**
  32392. * Sub emitter class used to emit particles from an existing particle
  32393. */
  32394. class SubEmitter {
  32395. /**
  32396. * the particle system to be used by the sub emitter
  32397. */
  32398. particleSystem: ParticleSystem;
  32399. /**
  32400. * Type of the submitter (Default: END)
  32401. */
  32402. type: SubEmitterType;
  32403. /**
  32404. * 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)
  32405. * Note: This only is supported when using an emitter of type Mesh
  32406. */
  32407. inheritDirection: boolean;
  32408. /**
  32409. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32410. */
  32411. inheritedVelocityAmount: number;
  32412. /**
  32413. * Creates a sub emitter
  32414. * @param particleSystem the particle system to be used by the sub emitter
  32415. */
  32416. constructor(
  32417. /**
  32418. * the particle system to be used by the sub emitter
  32419. */
  32420. particleSystem: ParticleSystem);
  32421. /**
  32422. * Clones the sub emitter
  32423. * @returns the cloned sub emitter
  32424. */
  32425. clone(): SubEmitter;
  32426. /**
  32427. * Serialize current object to a JSON object
  32428. * @returns the serialized object
  32429. */
  32430. serialize(): any;
  32431. /**
  32432. * Creates a new SubEmitter from a serialized JSON version
  32433. * @param serializationObject defines the JSON object to read from
  32434. * @param scene defines the hosting scene
  32435. * @param rootUrl defines the rootUrl for data loading
  32436. * @returns a new SubEmitter
  32437. */
  32438. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32439. /** Release associated resources */
  32440. dispose(): void;
  32441. }
  32442. }
  32443. declare module BABYLON {
  32444. /**
  32445. * Interface used to describe a physics joint
  32446. */
  32447. interface PhysicsImpostorJoint {
  32448. /** Defines the main impostor to which the joint is linked */
  32449. mainImpostor: PhysicsImpostor;
  32450. /** Defines the impostor that is connected to the main impostor using this joint */
  32451. connectedImpostor: PhysicsImpostor;
  32452. /** Defines the joint itself */
  32453. joint: PhysicsJoint;
  32454. }
  32455. /** @hidden */
  32456. interface IPhysicsEnginePlugin {
  32457. world: any;
  32458. name: string;
  32459. setGravity(gravity: Vector3): void;
  32460. setTimeStep(timeStep: number): void;
  32461. getTimeStep(): number;
  32462. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32463. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32464. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32465. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32466. removePhysicsBody(impostor: PhysicsImpostor): void;
  32467. generateJoint(joint: PhysicsImpostorJoint): void;
  32468. removeJoint(joint: PhysicsImpostorJoint): void;
  32469. isSupported(): boolean;
  32470. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32471. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32472. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32473. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32474. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32475. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32476. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32477. getBodyMass(impostor: PhysicsImpostor): number;
  32478. getBodyFriction(impostor: PhysicsImpostor): number;
  32479. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32480. getBodyRestitution(impostor: PhysicsImpostor): number;
  32481. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32482. sleepBody(impostor: PhysicsImpostor): void;
  32483. wakeUpBody(impostor: PhysicsImpostor): void;
  32484. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32485. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32486. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32487. getRadius(impostor: PhysicsImpostor): number;
  32488. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32489. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32490. dispose(): void;
  32491. }
  32492. /**
  32493. * Interface used to define a physics engine
  32494. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32495. */
  32496. interface IPhysicsEngine {
  32497. /**
  32498. * Gets the gravity vector used by the simulation
  32499. */
  32500. gravity: Vector3;
  32501. /**
  32502. * Sets the gravity vector used by the simulation
  32503. * @param gravity defines the gravity vector to use
  32504. */
  32505. setGravity(gravity: Vector3): void;
  32506. /**
  32507. * Set the time step of the physics engine.
  32508. * Default is 1/60.
  32509. * To slow it down, enter 1/600 for example.
  32510. * To speed it up, 1/30
  32511. * @param newTimeStep the new timestep to apply to this world.
  32512. */
  32513. setTimeStep(newTimeStep: number): void;
  32514. /**
  32515. * Get the time step of the physics engine.
  32516. * @returns the current time step
  32517. */
  32518. getTimeStep(): number;
  32519. /**
  32520. * Release all resources
  32521. */
  32522. dispose(): void;
  32523. /**
  32524. * Gets the name of the current physics plugin
  32525. * @returns the name of the plugin
  32526. */
  32527. getPhysicsPluginName(): string;
  32528. /**
  32529. * Adding a new impostor for the impostor tracking.
  32530. * This will be done by the impostor itself.
  32531. * @param impostor the impostor to add
  32532. */
  32533. addImpostor(impostor: PhysicsImpostor): void;
  32534. /**
  32535. * Remove an impostor from the engine.
  32536. * This impostor and its mesh will not longer be updated by the physics engine.
  32537. * @param impostor the impostor to remove
  32538. */
  32539. removeImpostor(impostor: PhysicsImpostor): void;
  32540. /**
  32541. * Add a joint to the physics engine
  32542. * @param mainImpostor defines the main impostor to which the joint is added.
  32543. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32544. * @param joint defines the joint that will connect both impostors.
  32545. */
  32546. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32547. /**
  32548. * Removes a joint from the simulation
  32549. * @param mainImpostor defines the impostor used with the joint
  32550. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32551. * @param joint defines the joint to remove
  32552. */
  32553. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32554. /**
  32555. * Gets the current plugin used to run the simulation
  32556. * @returns current plugin
  32557. */
  32558. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32559. /**
  32560. * Gets the list of physic impostors
  32561. * @returns an array of PhysicsImpostor
  32562. */
  32563. getImpostors(): Array<PhysicsImpostor>;
  32564. /**
  32565. * Gets the impostor for a physics enabled object
  32566. * @param object defines the object impersonated by the impostor
  32567. * @returns the PhysicsImpostor or null if not found
  32568. */
  32569. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32570. /**
  32571. * Gets the impostor for a physics body object
  32572. * @param body defines physics body used by the impostor
  32573. * @returns the PhysicsImpostor or null if not found
  32574. */
  32575. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32576. /**
  32577. * Called by the scene. No need to call it.
  32578. * @param delta defines the timespam between frames
  32579. */
  32580. _step(delta: number): void;
  32581. }
  32582. }
  32583. declare module BABYLON {
  32584. /**
  32585. * Class used to control physics engine
  32586. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32587. */
  32588. class PhysicsEngine implements IPhysicsEngine {
  32589. private _physicsPlugin;
  32590. /**
  32591. * Global value used to control the smallest number supported by the simulation
  32592. */
  32593. static Epsilon: number;
  32594. private _impostors;
  32595. private _joints;
  32596. /**
  32597. * Gets the gravity vector used by the simulation
  32598. */
  32599. gravity: Vector3;
  32600. /**
  32601. * Creates a new Physics Engine
  32602. * @param gravity defines the gravity vector used by the simulation
  32603. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32604. */
  32605. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32606. /**
  32607. * Sets the gravity vector used by the simulation
  32608. * @param gravity defines the gravity vector to use
  32609. */
  32610. setGravity(gravity: Vector3): void;
  32611. /**
  32612. * Set the time step of the physics engine.
  32613. * Default is 1/60.
  32614. * To slow it down, enter 1/600 for example.
  32615. * To speed it up, 1/30
  32616. * @param newTimeStep defines the new timestep to apply to this world.
  32617. */
  32618. setTimeStep(newTimeStep?: number): void;
  32619. /**
  32620. * Get the time step of the physics engine.
  32621. * @returns the current time step
  32622. */
  32623. getTimeStep(): number;
  32624. /**
  32625. * Release all resources
  32626. */
  32627. dispose(): void;
  32628. /**
  32629. * Gets the name of the current physics plugin
  32630. * @returns the name of the plugin
  32631. */
  32632. getPhysicsPluginName(): string;
  32633. /**
  32634. * Adding a new impostor for the impostor tracking.
  32635. * This will be done by the impostor itself.
  32636. * @param impostor the impostor to add
  32637. */
  32638. addImpostor(impostor: PhysicsImpostor): void;
  32639. /**
  32640. * Remove an impostor from the engine.
  32641. * This impostor and its mesh will not longer be updated by the physics engine.
  32642. * @param impostor the impostor to remove
  32643. */
  32644. removeImpostor(impostor: PhysicsImpostor): void;
  32645. /**
  32646. * Add a joint to the physics engine
  32647. * @param mainImpostor defines the main impostor to which the joint is added.
  32648. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32649. * @param joint defines the joint that will connect both impostors.
  32650. */
  32651. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32652. /**
  32653. * Removes a joint from the simulation
  32654. * @param mainImpostor defines the impostor used with the joint
  32655. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32656. * @param joint defines the joint to remove
  32657. */
  32658. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32659. /**
  32660. * Called by the scene. No need to call it.
  32661. * @param delta defines the timespam between frames
  32662. */
  32663. _step(delta: number): void;
  32664. /**
  32665. * Gets the current plugin used to run the simulation
  32666. * @returns current plugin
  32667. */
  32668. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32669. /**
  32670. * Gets the list of physic impostors
  32671. * @returns an array of PhysicsImpostor
  32672. */
  32673. getImpostors(): Array<PhysicsImpostor>;
  32674. /**
  32675. * Gets the impostor for a physics enabled object
  32676. * @param object defines the object impersonated by the impostor
  32677. * @returns the PhysicsImpostor or null if not found
  32678. */
  32679. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32680. /**
  32681. * Gets the impostor for a physics body object
  32682. * @param body defines physics body used by the impostor
  32683. * @returns the PhysicsImpostor or null if not found
  32684. */
  32685. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32686. }
  32687. }
  32688. declare module BABYLON {
  32689. interface Scene {
  32690. /** @hidden (Backing field) */
  32691. _physicsEngine: Nullable<IPhysicsEngine>;
  32692. /**
  32693. * Gets the current physics engine
  32694. * @returns a IPhysicsEngine or null if none attached
  32695. */
  32696. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  32697. /**
  32698. * Enables physics to the current scene
  32699. * @param gravity defines the scene's gravity for the physics engine
  32700. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  32701. * @return a boolean indicating if the physics engine was initialized
  32702. */
  32703. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  32704. /**
  32705. * Disables and disposes the physics engine associated with the scene
  32706. */
  32707. disablePhysicsEngine(): void;
  32708. /**
  32709. * Gets a boolean indicating if there is an active physics engine
  32710. * @returns a boolean indicating if there is an active physics engine
  32711. */
  32712. isPhysicsEnabled(): boolean;
  32713. /**
  32714. * Deletes a physics compound impostor
  32715. * @param compound defines the compound to delete
  32716. */
  32717. deleteCompoundImpostor(compound: any): void;
  32718. /**
  32719. * An event triggered when physic simulation is about to be run
  32720. */
  32721. onBeforePhysicsObservable: Observable<Scene>;
  32722. /**
  32723. * An event triggered when physic simulation has been done
  32724. */
  32725. onAfterPhysicsObservable: Observable<Scene>;
  32726. }
  32727. interface AbstractMesh {
  32728. /** @hidden */
  32729. _physicsImpostor: Nullable<PhysicsImpostor>;
  32730. /**
  32731. * Gets or sets impostor used for physic simulation
  32732. * @see http://doc.babylonjs.com/features/physics_engine
  32733. */
  32734. physicsImpostor: Nullable<PhysicsImpostor>;
  32735. /**
  32736. * Gets the current physics impostor
  32737. * @see http://doc.babylonjs.com/features/physics_engine
  32738. * @returns a physics impostor or null
  32739. */
  32740. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  32741. /** Apply a physic impulse to the mesh
  32742. * @param force defines the force to apply
  32743. * @param contactPoint defines where to apply the force
  32744. * @returns the current mesh
  32745. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32746. */
  32747. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  32748. /**
  32749. * Creates a physic joint between two meshes
  32750. * @param otherMesh defines the other mesh to use
  32751. * @param pivot1 defines the pivot to use on this mesh
  32752. * @param pivot2 defines the pivot to use on the other mesh
  32753. * @param options defines additional options (can be plugin dependent)
  32754. * @returns the current mesh
  32755. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  32756. */
  32757. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  32758. /** @hidden */
  32759. _disposePhysicsObserver: Nullable<Observer<Node>>;
  32760. }
  32761. /**
  32762. * Defines the physics engine scene component responsible to manage a physics engine
  32763. */
  32764. class PhysicsEngineSceneComponent implements ISceneComponent {
  32765. /**
  32766. * The component name helpful to identify the component in the list of scene components.
  32767. */
  32768. readonly name: string;
  32769. /**
  32770. * The scene the component belongs to.
  32771. */
  32772. scene: Scene;
  32773. /**
  32774. * Creates a new instance of the component for the given scene
  32775. * @param scene Defines the scene to register the component in
  32776. */
  32777. constructor(scene: Scene);
  32778. /**
  32779. * Registers the component in a given scene
  32780. */
  32781. register(): void;
  32782. /**
  32783. * Rebuilds the elements related to this component in case of
  32784. * context lost for instance.
  32785. */
  32786. rebuild(): void;
  32787. /**
  32788. * Disposes the component and the associated ressources
  32789. */
  32790. dispose(): void;
  32791. }
  32792. }
  32793. declare module BABYLON {
  32794. /**
  32795. * A helper for physics simulations
  32796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32797. */
  32798. class PhysicsHelper {
  32799. private _scene;
  32800. private _physicsEngine;
  32801. /**
  32802. * Initializes the Physics helper
  32803. * @param scene Babylon.js scene
  32804. */
  32805. constructor(scene: Scene);
  32806. /**
  32807. * Applies a radial explosion impulse
  32808. * @param origin the origin of the explosion
  32809. * @param radius the explosion radius
  32810. * @param strength the explosion strength
  32811. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32812. * @returns A physics radial explosion event, or null
  32813. */
  32814. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32815. /**
  32816. * Applies a radial explosion force
  32817. * @param origin the origin of the explosion
  32818. * @param radius the explosion radius
  32819. * @param strength the explosion strength
  32820. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32821. * @returns A physics radial explosion event, or null
  32822. */
  32823. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  32824. /**
  32825. * Creates a gravitational field
  32826. * @param origin the origin of the explosion
  32827. * @param radius the explosion radius
  32828. * @param strength the explosion strength
  32829. * @param falloff possible options: Constant & Linear. Defaults to Constant
  32830. * @returns A physics gravitational field event, or null
  32831. */
  32832. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  32833. /**
  32834. * Creates a physics updraft event
  32835. * @param origin the origin of the updraft
  32836. * @param radius the radius of the updraft
  32837. * @param strength the strength of the updraft
  32838. * @param height the height of the updraft
  32839. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  32840. * @returns A physics updraft event, or null
  32841. */
  32842. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  32843. /**
  32844. * Creates a physics vortex event
  32845. * @param origin the of the vortex
  32846. * @param radius the radius of the vortex
  32847. * @param strength the strength of the vortex
  32848. * @param height the height of the vortex
  32849. * @returns a Physics vortex event, or null
  32850. * A physics vortex event or null
  32851. */
  32852. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  32853. }
  32854. /**
  32855. * Represents a physics radial explosion event
  32856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32857. */
  32858. class PhysicsRadialExplosionEvent {
  32859. private _scene;
  32860. private _sphere;
  32861. private _sphereOptions;
  32862. private _rays;
  32863. private _dataFetched;
  32864. /**
  32865. * Initializes a radial explosioin event
  32866. * @param scene BabylonJS scene
  32867. */
  32868. constructor(scene: Scene);
  32869. /**
  32870. * Returns the data related to the radial explosion event (sphere & rays).
  32871. * @returns The radial explosion event data
  32872. */
  32873. getData(): PhysicsRadialExplosionEventData;
  32874. /**
  32875. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  32876. * @param impostor A physics imposter
  32877. * @param origin the origin of the explosion
  32878. * @param radius the explosion radius
  32879. * @param strength the explosion strength
  32880. * @param falloff possible options: Constant & Linear
  32881. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  32882. */
  32883. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  32884. /**
  32885. * Disposes the sphere.
  32886. * @param force Specifies if the sphere should be disposed by force
  32887. */
  32888. dispose(force?: boolean): void;
  32889. /*** Helpers ***/
  32890. private _prepareSphere;
  32891. private _intersectsWithSphere;
  32892. }
  32893. /**
  32894. * Represents a gravitational field event
  32895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32896. */
  32897. class PhysicsGravitationalFieldEvent {
  32898. private _physicsHelper;
  32899. private _scene;
  32900. private _origin;
  32901. private _radius;
  32902. private _strength;
  32903. private _falloff;
  32904. private _tickCallback;
  32905. private _sphere;
  32906. private _dataFetched;
  32907. /**
  32908. * Initializes the physics gravitational field event
  32909. * @param physicsHelper A physics helper
  32910. * @param scene BabylonJS scene
  32911. * @param origin The origin position of the gravitational field event
  32912. * @param radius The radius of the gravitational field event
  32913. * @param strength The strength of the gravitational field event
  32914. * @param falloff The falloff for the gravitational field event
  32915. */
  32916. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  32917. /**
  32918. * Returns the data related to the gravitational field event (sphere).
  32919. * @returns A gravitational field event
  32920. */
  32921. getData(): PhysicsGravitationalFieldEventData;
  32922. /**
  32923. * Enables the gravitational field.
  32924. */
  32925. enable(): void;
  32926. /**
  32927. * Disables the gravitational field.
  32928. */
  32929. disable(): void;
  32930. /**
  32931. * Disposes the sphere.
  32932. * @param force The force to dispose from the gravitational field event
  32933. */
  32934. dispose(force?: boolean): void;
  32935. private _tick;
  32936. }
  32937. /**
  32938. * Represents a physics updraft event
  32939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32940. */
  32941. class PhysicsUpdraftEvent {
  32942. private _scene;
  32943. private _origin;
  32944. private _radius;
  32945. private _strength;
  32946. private _height;
  32947. private _updraftMode;
  32948. private _physicsEngine;
  32949. private _originTop;
  32950. private _originDirection;
  32951. private _tickCallback;
  32952. private _cylinder;
  32953. private _cylinderPosition;
  32954. private _dataFetched;
  32955. /**
  32956. * Initializes the physics updraft event
  32957. * @param _scene BabylonJS scene
  32958. * @param _origin The origin position of the updraft
  32959. * @param _radius The radius of the updraft
  32960. * @param _strength The strength of the updraft
  32961. * @param _height The height of the updraft
  32962. * @param _updraftMode The mode of the updraft
  32963. */
  32964. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  32965. /**
  32966. * Returns the data related to the updraft event (cylinder).
  32967. * @returns A physics updraft event
  32968. */
  32969. getData(): PhysicsUpdraftEventData;
  32970. /**
  32971. * Enables the updraft.
  32972. */
  32973. enable(): void;
  32974. /**
  32975. * Disables the cortex.
  32976. */
  32977. disable(): void;
  32978. /**
  32979. * Disposes the sphere.
  32980. * @param force Specifies if the updraft should be disposed by force
  32981. */
  32982. dispose(force?: boolean): void;
  32983. private getImpostorForceAndContactPoint;
  32984. private _tick;
  32985. /*** Helpers ***/
  32986. private _prepareCylinder;
  32987. private _intersectsWithCylinder;
  32988. }
  32989. /**
  32990. * Represents a physics vortex event
  32991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32992. */
  32993. class PhysicsVortexEvent {
  32994. private _scene;
  32995. private _origin;
  32996. private _radius;
  32997. private _strength;
  32998. private _height;
  32999. private _physicsEngine;
  33000. private _originTop;
  33001. private _centripetalForceThreshold;
  33002. private _updraftMultiplier;
  33003. private _tickCallback;
  33004. private _cylinder;
  33005. private _cylinderPosition;
  33006. private _dataFetched;
  33007. /**
  33008. * Initializes the physics vortex event
  33009. * @param _scene The BabylonJS scene
  33010. * @param _origin The origin position of the vortex
  33011. * @param _radius The radius of the vortex
  33012. * @param _strength The strength of the vortex
  33013. * @param _height The height of the vortex
  33014. */
  33015. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33016. /**
  33017. * Returns the data related to the vortex event (cylinder).
  33018. * @returns The physics vortex event data
  33019. */
  33020. getData(): PhysicsVortexEventData;
  33021. /**
  33022. * Enables the vortex.
  33023. */
  33024. enable(): void;
  33025. /**
  33026. * Disables the cortex.
  33027. */
  33028. disable(): void;
  33029. /**
  33030. * Disposes the sphere.
  33031. * @param force
  33032. */
  33033. dispose(force?: boolean): void;
  33034. private getImpostorForceAndContactPoint;
  33035. private _tick;
  33036. /*** Helpers ***/
  33037. private _prepareCylinder;
  33038. private _intersectsWithCylinder;
  33039. }
  33040. /**
  33041. * The strenght of the force in correspondence to the distance of the affected object
  33042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33043. */
  33044. enum PhysicsRadialImpulseFalloff {
  33045. /** Defines that impulse is constant in strength across it's whole radius */
  33046. Constant = 0,
  33047. /** DEfines that impulse gets weaker if it's further from the origin */
  33048. Linear = 1
  33049. }
  33050. /**
  33051. * The strength of the force in correspondence to the distance of the affected object
  33052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33053. */
  33054. enum PhysicsUpdraftMode {
  33055. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33056. Center = 0,
  33057. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33058. Perpendicular = 1
  33059. }
  33060. /**
  33061. * Interface for a physics force and contact point
  33062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33063. */
  33064. interface PhysicsForceAndContactPoint {
  33065. /**
  33066. * The force applied at the contact point
  33067. */
  33068. force: Vector3;
  33069. /**
  33070. * The contact point
  33071. */
  33072. contactPoint: Vector3;
  33073. }
  33074. /**
  33075. * Interface for radial explosion event data
  33076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33077. */
  33078. interface PhysicsRadialExplosionEventData {
  33079. /**
  33080. * A sphere used for the radial explosion event
  33081. */
  33082. sphere: Mesh;
  33083. /**
  33084. * An array of rays for the radial explosion event
  33085. */
  33086. rays: Array<Ray>;
  33087. }
  33088. /**
  33089. * Interface for gravitational field event data
  33090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33091. */
  33092. interface PhysicsGravitationalFieldEventData {
  33093. /**
  33094. * A sphere mesh used for the gravitational field event
  33095. */
  33096. sphere: Mesh;
  33097. }
  33098. /**
  33099. * Interface for updraft event data
  33100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33101. */
  33102. interface PhysicsUpdraftEventData {
  33103. /**
  33104. * A cylinder used for the updraft event
  33105. */
  33106. cylinder: Mesh;
  33107. }
  33108. /**
  33109. * Interface for vortex event data
  33110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33111. */
  33112. interface PhysicsVortexEventData {
  33113. /**
  33114. * A cylinder used for the vortex event
  33115. */
  33116. cylinder: Mesh;
  33117. }
  33118. }
  33119. declare module BABYLON {
  33120. /**
  33121. * The interface for the physics imposter parameters
  33122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33123. */
  33124. interface PhysicsImpostorParameters {
  33125. /**
  33126. * The mass of the physics imposter
  33127. */
  33128. mass: number;
  33129. /**
  33130. * The friction of the physics imposter
  33131. */
  33132. friction?: number;
  33133. /**
  33134. * The coefficient of restitution of the physics imposter
  33135. */
  33136. restitution?: number;
  33137. /**
  33138. * The native options of the physics imposter
  33139. */
  33140. nativeOptions?: any;
  33141. /**
  33142. * Specifies if the parent should be ignored
  33143. */
  33144. ignoreParent?: boolean;
  33145. /**
  33146. * Specifies if bi-directional transformations should be disabled
  33147. */
  33148. disableBidirectionalTransformation?: boolean;
  33149. }
  33150. /**
  33151. * Interface for a physics-enabled object
  33152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33153. */
  33154. interface IPhysicsEnabledObject {
  33155. /**
  33156. * The position of the physics-enabled object
  33157. */
  33158. position: Vector3;
  33159. /**
  33160. * The rotation of the physics-enabled object
  33161. */
  33162. rotationQuaternion: Nullable<Quaternion>;
  33163. /**
  33164. * The scale of the physics-enabled object
  33165. */
  33166. scaling: Vector3;
  33167. /**
  33168. * The rotation of the physics-enabled object
  33169. */
  33170. rotation?: Vector3;
  33171. /**
  33172. * The parent of the physics-enabled object
  33173. */
  33174. parent?: any;
  33175. /**
  33176. * The bounding info of the physics-enabled object
  33177. * @returns The bounding info of the physics-enabled object
  33178. */
  33179. getBoundingInfo(): BoundingInfo;
  33180. /**
  33181. * Computes the world matrix
  33182. * @param force Specifies if the world matrix should be computed by force
  33183. * @returns A world matrix
  33184. */
  33185. computeWorldMatrix(force: boolean): Matrix;
  33186. /**
  33187. * Gets the world matrix
  33188. * @returns A world matrix
  33189. */
  33190. getWorldMatrix?(): Matrix;
  33191. /**
  33192. * Gets the child meshes
  33193. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33194. * @returns An array of abstract meshes
  33195. */
  33196. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33197. /**
  33198. * Gets the vertex data
  33199. * @param kind The type of vertex data
  33200. * @returns A nullable array of numbers, or a float32 array
  33201. */
  33202. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33203. /**
  33204. * Gets the indices from the mesh
  33205. * @returns A nullable array of index arrays
  33206. */
  33207. getIndices?(): Nullable<IndicesArray>;
  33208. /**
  33209. * Gets the scene from the mesh
  33210. * @returns the indices array or null
  33211. */
  33212. getScene?(): Scene;
  33213. /**
  33214. * Gets the absolute position from the mesh
  33215. * @returns the absolute position
  33216. */
  33217. getAbsolutePosition(): Vector3;
  33218. /**
  33219. * Gets the absolute pivot point from the mesh
  33220. * @returns the absolute pivot point
  33221. */
  33222. getAbsolutePivotPoint(): Vector3;
  33223. /**
  33224. * Rotates the mesh
  33225. * @param axis The axis of rotation
  33226. * @param amount The amount of rotation
  33227. * @param space The space of the rotation
  33228. * @returns The rotation transform node
  33229. */
  33230. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33231. /**
  33232. * Translates the mesh
  33233. * @param axis The axis of translation
  33234. * @param distance The distance of translation
  33235. * @param space The space of the translation
  33236. * @returns The transform node
  33237. */
  33238. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33239. /**
  33240. * Sets the absolute position of the mesh
  33241. * @param absolutePosition The absolute position of the mesh
  33242. * @returns The transform node
  33243. */
  33244. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33245. /**
  33246. * Gets the class name of the mesh
  33247. * @returns The class name
  33248. */
  33249. getClassName(): string;
  33250. }
  33251. /**
  33252. * Represents a physics imposter
  33253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33254. */
  33255. class PhysicsImpostor {
  33256. /**
  33257. * The physics-enabled object used as the physics imposter
  33258. */
  33259. object: IPhysicsEnabledObject;
  33260. /**
  33261. * The type of the physics imposter
  33262. */
  33263. type: number;
  33264. private _options;
  33265. private _scene?;
  33266. /**
  33267. * The default object size of the imposter
  33268. */
  33269. static DEFAULT_OBJECT_SIZE: Vector3;
  33270. /**
  33271. * The identity quaternion of the imposter
  33272. */
  33273. static IDENTITY_QUATERNION: Quaternion;
  33274. private _physicsEngine;
  33275. private _physicsBody;
  33276. private _bodyUpdateRequired;
  33277. private _onBeforePhysicsStepCallbacks;
  33278. private _onAfterPhysicsStepCallbacks;
  33279. private _onPhysicsCollideCallbacks;
  33280. private _deltaPosition;
  33281. private _deltaRotation;
  33282. private _deltaRotationConjugated;
  33283. private _parent;
  33284. private _isDisposed;
  33285. private static _tmpVecs;
  33286. private static _tmpQuat;
  33287. /**
  33288. * Specifies if the physics imposter is disposed
  33289. */
  33290. readonly isDisposed: boolean;
  33291. /**
  33292. * Gets the mass of the physics imposter
  33293. */
  33294. mass: number;
  33295. /**
  33296. * Gets the coefficient of friction
  33297. */
  33298. /**
  33299. * Sets the coefficient of friction
  33300. */
  33301. friction: number;
  33302. /**
  33303. * Gets the coefficient of restitution
  33304. */
  33305. /**
  33306. * Sets the coefficient of restitution
  33307. */
  33308. restitution: number;
  33309. /**
  33310. * The unique id of the physics imposter
  33311. * set by the physics engine when adding this impostor to the array
  33312. */
  33313. uniqueId: number;
  33314. private _joints;
  33315. /**
  33316. * Initializes the physics imposter
  33317. * @param object The physics-enabled object used as the physics imposter
  33318. * @param type The type of the physics imposter
  33319. * @param _options The options for the physics imposter
  33320. * @param _scene The Babylon scene
  33321. */
  33322. constructor(
  33323. /**
  33324. * The physics-enabled object used as the physics imposter
  33325. */
  33326. object: IPhysicsEnabledObject,
  33327. /**
  33328. * The type of the physics imposter
  33329. */
  33330. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33331. /**
  33332. * This function will completly initialize this impostor.
  33333. * It will create a new body - but only if this mesh has no parent.
  33334. * If it has, this impostor will not be used other than to define the impostor
  33335. * of the child mesh.
  33336. * @hidden
  33337. */
  33338. _init(): void;
  33339. private _getPhysicsParent;
  33340. /**
  33341. * Should a new body be generated.
  33342. * @returns boolean specifying if body initialization is required
  33343. */
  33344. isBodyInitRequired(): boolean;
  33345. /**
  33346. * Sets the updated scaling
  33347. * @param updated Specifies if the scaling is updated
  33348. */
  33349. setScalingUpdated(updated: boolean): void;
  33350. /**
  33351. * Force a regeneration of this or the parent's impostor's body.
  33352. * Use under cautious - This will remove all joints already implemented.
  33353. */
  33354. forceUpdate(): void;
  33355. /**
  33356. * Gets the body that holds this impostor. Either its own, or its parent.
  33357. */
  33358. /**
  33359. * Set the physics body. Used mainly by the physics engine/plugin
  33360. */
  33361. physicsBody: any;
  33362. /**
  33363. * Get the parent of the physics imposter
  33364. * @returns Physics imposter or null
  33365. */
  33366. /**
  33367. * Sets the parent of the physics imposter
  33368. */
  33369. parent: Nullable<PhysicsImpostor>;
  33370. /**
  33371. * Resets the update flags
  33372. */
  33373. resetUpdateFlags(): void;
  33374. /**
  33375. * Gets the object extend size
  33376. * @returns the object extend size
  33377. */
  33378. getObjectExtendSize(): Vector3;
  33379. /**
  33380. * Gets the object center
  33381. * @returns The object center
  33382. */
  33383. getObjectCenter(): Vector3;
  33384. /**
  33385. * Get a specific parametes from the options parameter
  33386. * @param paramName The object parameter name
  33387. * @returns The object parameter
  33388. */
  33389. getParam(paramName: string): any;
  33390. /**
  33391. * Sets a specific parameter in the options given to the physics plugin
  33392. * @param paramName The parameter name
  33393. * @param value The value of the parameter
  33394. */
  33395. setParam(paramName: string, value: number): void;
  33396. /**
  33397. * Specifically change the body's mass option. Won't recreate the physics body object
  33398. * @param mass The mass of the physics imposter
  33399. */
  33400. setMass(mass: number): void;
  33401. /**
  33402. * Gets the linear velocity
  33403. * @returns linear velocity or null
  33404. */
  33405. getLinearVelocity(): Nullable<Vector3>;
  33406. /**
  33407. * Sets the linear velocity
  33408. * @param velocity linear velocity or null
  33409. */
  33410. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33411. /**
  33412. * Gets the angular velocity
  33413. * @returns angular velocity or null
  33414. */
  33415. getAngularVelocity(): Nullable<Vector3>;
  33416. /**
  33417. * Sets the angular velocity
  33418. * @param velocity The velocity or null
  33419. */
  33420. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33421. /**
  33422. * Execute a function with the physics plugin native code
  33423. * Provide a function the will have two variables - the world object and the physics body object
  33424. * @param func The function to execute with the physics plugin native code
  33425. */
  33426. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33427. /**
  33428. * Register a function that will be executed before the physics world is stepping forward
  33429. * @param func The function to execute before the physics world is stepped forward
  33430. */
  33431. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33432. /**
  33433. * Unregister a function that will be executed before the physics world is stepping forward
  33434. * @param func The function to execute before the physics world is stepped forward
  33435. */
  33436. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33437. /**
  33438. * Register a function that will be executed after the physics step
  33439. * @param func The function to execute after physics step
  33440. */
  33441. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33442. /**
  33443. * Unregisters a function that will be executed after the physics step
  33444. * @param func The function to execute after physics step
  33445. */
  33446. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33447. /**
  33448. * register a function that will be executed when this impostor collides against a different body
  33449. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33450. * @param func Callback that is executed on collision
  33451. */
  33452. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33453. /**
  33454. * Unregisters the physics imposter on contact
  33455. * @param collideAgainst The physics object to collide against
  33456. * @param func Callback to execute on collision
  33457. */
  33458. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33459. private _tmpQuat;
  33460. private _tmpQuat2;
  33461. /**
  33462. * Get the parent rotation
  33463. * @returns The parent rotation
  33464. */
  33465. getParentsRotation(): Quaternion;
  33466. /**
  33467. * this function is executed by the physics engine.
  33468. */
  33469. beforeStep: () => void;
  33470. /**
  33471. * this function is executed by the physics engine
  33472. */
  33473. afterStep: () => void;
  33474. /**
  33475. * Legacy collision detection event support
  33476. */
  33477. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33478. /**
  33479. * event and body object due to cannon's event-based architecture.
  33480. */
  33481. onCollide: (e: {
  33482. body: any;
  33483. }) => void;
  33484. /**
  33485. * Apply a force
  33486. * @param force The force to apply
  33487. * @param contactPoint The contact point for the force
  33488. * @returns The physics imposter
  33489. */
  33490. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33491. /**
  33492. * Apply an impulse
  33493. * @param force The impulse force
  33494. * @param contactPoint The contact point for the impulse force
  33495. * @returns The physics imposter
  33496. */
  33497. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33498. /**
  33499. * A help function to create a joint
  33500. * @param otherImpostor A physics imposter used to create a joint
  33501. * @param jointType The type of joint
  33502. * @param jointData The data for the joint
  33503. * @returns The physics imposter
  33504. */
  33505. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33506. /**
  33507. * Add a joint to this impostor with a different impostor
  33508. * @param otherImpostor A physics imposter used to add a joint
  33509. * @param joint The joint to add
  33510. * @returns The physics imposter
  33511. */
  33512. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33513. /**
  33514. * Will keep this body still, in a sleep mode.
  33515. * @returns the physics imposter
  33516. */
  33517. sleep(): PhysicsImpostor;
  33518. /**
  33519. * Wake the body up.
  33520. * @returns The physics imposter
  33521. */
  33522. wakeUp(): PhysicsImpostor;
  33523. /**
  33524. * Clones the physics imposter
  33525. * @param newObject The physics imposter clones to this physics-enabled object
  33526. * @returns A nullable physics imposter
  33527. */
  33528. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33529. /**
  33530. * Disposes the physics imposter
  33531. */
  33532. dispose(): void;
  33533. /**
  33534. * Sets the delta position
  33535. * @param position The delta position amount
  33536. */
  33537. setDeltaPosition(position: Vector3): void;
  33538. /**
  33539. * Sets the delta rotation
  33540. * @param rotation The delta rotation amount
  33541. */
  33542. setDeltaRotation(rotation: Quaternion): void;
  33543. /**
  33544. * Gets the box size of the physics imposter and stores the result in the input parameter
  33545. * @param result Stores the box size
  33546. * @returns The physics imposter
  33547. */
  33548. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33549. /**
  33550. * Gets the radius of the physics imposter
  33551. * @returns Radius of the physics imposter
  33552. */
  33553. getRadius(): number;
  33554. /**
  33555. * Sync a bone with this impostor
  33556. * @param bone The bone to sync to the impostor.
  33557. * @param boneMesh The mesh that the bone is influencing.
  33558. * @param jointPivot The pivot of the joint / bone in local space.
  33559. * @param distToJoint Optional distance from the impostor to the joint.
  33560. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33561. */
  33562. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33563. /**
  33564. * Sync impostor to a bone
  33565. * @param bone The bone that the impostor will be synced to.
  33566. * @param boneMesh The mesh that the bone is influencing.
  33567. * @param jointPivot The pivot of the joint / bone in local space.
  33568. * @param distToJoint Optional distance from the impostor to the joint.
  33569. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33570. * @param boneAxis Optional vector3 axis the bone is aligned with
  33571. */
  33572. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33573. /**
  33574. * No-Imposter type
  33575. */
  33576. static NoImpostor: number;
  33577. /**
  33578. * Sphere-Imposter type
  33579. */
  33580. static SphereImpostor: number;
  33581. /**
  33582. * Box-Imposter type
  33583. */
  33584. static BoxImpostor: number;
  33585. /**
  33586. * Plane-Imposter type
  33587. */
  33588. static PlaneImpostor: number;
  33589. /**
  33590. * Mesh-imposter type
  33591. */
  33592. static MeshImpostor: number;
  33593. /**
  33594. * Cylinder-Imposter type
  33595. */
  33596. static CylinderImpostor: number;
  33597. /**
  33598. * Particle-Imposter type
  33599. */
  33600. static ParticleImpostor: number;
  33601. /**
  33602. * Heightmap-Imposter type
  33603. */
  33604. static HeightmapImpostor: number;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * Interface for Physics-Joint data
  33610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33611. */
  33612. interface PhysicsJointData {
  33613. /**
  33614. * The main pivot of the joint
  33615. */
  33616. mainPivot?: Vector3;
  33617. /**
  33618. * The connected pivot of the joint
  33619. */
  33620. connectedPivot?: Vector3;
  33621. /**
  33622. * The main axis of the joint
  33623. */
  33624. mainAxis?: Vector3;
  33625. /**
  33626. * The connected axis of the joint
  33627. */
  33628. connectedAxis?: Vector3;
  33629. /**
  33630. * The collision of the joint
  33631. */
  33632. collision?: boolean;
  33633. /**
  33634. * Native Oimo/Cannon/Energy data
  33635. */
  33636. nativeParams?: any;
  33637. }
  33638. /**
  33639. * This is a holder class for the physics joint created by the physics plugin
  33640. * It holds a set of functions to control the underlying joint
  33641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33642. */
  33643. class PhysicsJoint {
  33644. /**
  33645. * The type of the physics joint
  33646. */
  33647. type: number;
  33648. /**
  33649. * The data for the physics joint
  33650. */
  33651. jointData: PhysicsJointData;
  33652. private _physicsJoint;
  33653. protected _physicsPlugin: IPhysicsEnginePlugin;
  33654. /**
  33655. * Initializes the physics joint
  33656. * @param type The type of the physics joint
  33657. * @param jointData The data for the physics joint
  33658. */
  33659. constructor(
  33660. /**
  33661. * The type of the physics joint
  33662. */
  33663. type: number,
  33664. /**
  33665. * The data for the physics joint
  33666. */
  33667. jointData: PhysicsJointData);
  33668. /**
  33669. * Gets the physics joint
  33670. */
  33671. /**
  33672. * Sets the physics joint
  33673. */
  33674. physicsJoint: any;
  33675. /**
  33676. * Sets the physics plugin
  33677. */
  33678. physicsPlugin: IPhysicsEnginePlugin;
  33679. /**
  33680. * Execute a function that is physics-plugin specific.
  33681. * @param {Function} func the function that will be executed.
  33682. * It accepts two parameters: the physics world and the physics joint
  33683. */
  33684. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  33685. /**
  33686. * Distance-Joint type
  33687. */
  33688. static DistanceJoint: number;
  33689. /**
  33690. * Hinge-Joint type
  33691. */
  33692. static HingeJoint: number;
  33693. /**
  33694. * Ball-and-Socket joint type
  33695. */
  33696. static BallAndSocketJoint: number;
  33697. /**
  33698. * Wheel-Joint type
  33699. */
  33700. static WheelJoint: number;
  33701. /**
  33702. * Slider-Joint type
  33703. */
  33704. static SliderJoint: number;
  33705. /**
  33706. * Prismatic-Joint type
  33707. */
  33708. static PrismaticJoint: number;
  33709. /**
  33710. * Universal-Joint type
  33711. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  33712. */
  33713. static UniversalJoint: number;
  33714. /**
  33715. * Hinge-Joint 2 type
  33716. */
  33717. static Hinge2Joint: number;
  33718. /**
  33719. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  33720. */
  33721. static PointToPointJoint: number;
  33722. /**
  33723. * Spring-Joint type
  33724. */
  33725. static SpringJoint: number;
  33726. /**
  33727. * Lock-Joint type
  33728. */
  33729. static LockJoint: number;
  33730. }
  33731. /**
  33732. * A class representing a physics distance joint
  33733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33734. */
  33735. class DistanceJoint extends PhysicsJoint {
  33736. /**
  33737. *
  33738. * @param jointData The data for the Distance-Joint
  33739. */
  33740. constructor(jointData: DistanceJointData);
  33741. /**
  33742. * Update the predefined distance.
  33743. * @param maxDistance The maximum preferred distance
  33744. * @param minDistance The minimum preferred distance
  33745. */
  33746. updateDistance(maxDistance: number, minDistance?: number): void;
  33747. }
  33748. /**
  33749. * Represents a Motor-Enabled Joint
  33750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33751. */
  33752. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  33753. /**
  33754. * Initializes the Motor-Enabled Joint
  33755. * @param type The type of the joint
  33756. * @param jointData The physica joint data for the joint
  33757. */
  33758. constructor(type: number, jointData: PhysicsJointData);
  33759. /**
  33760. * Set the motor values.
  33761. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33762. * @param force the force to apply
  33763. * @param maxForce max force for this motor.
  33764. */
  33765. setMotor(force?: number, maxForce?: number): void;
  33766. /**
  33767. * Set the motor's limits.
  33768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33769. * @param upperLimit The upper limit of the motor
  33770. * @param lowerLimit The lower limit of the motor
  33771. */
  33772. setLimit(upperLimit: number, lowerLimit?: number): void;
  33773. }
  33774. /**
  33775. * This class represents a single physics Hinge-Joint
  33776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33777. */
  33778. class HingeJoint extends MotorEnabledJoint {
  33779. /**
  33780. * Initializes the Hinge-Joint
  33781. * @param jointData The joint data for the Hinge-Joint
  33782. */
  33783. constructor(jointData: PhysicsJointData);
  33784. /**
  33785. * Set the motor values.
  33786. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33787. * @param {number} force the force to apply
  33788. * @param {number} maxForce max force for this motor.
  33789. */
  33790. setMotor(force?: number, maxForce?: number): void;
  33791. /**
  33792. * Set the motor's limits.
  33793. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33794. * @param upperLimit The upper limit of the motor
  33795. * @param lowerLimit The lower limit of the motor
  33796. */
  33797. setLimit(upperLimit: number, lowerLimit?: number): void;
  33798. }
  33799. /**
  33800. * This class represents a dual hinge physics joint (same as wheel joint)
  33801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33802. */
  33803. class Hinge2Joint extends MotorEnabledJoint {
  33804. /**
  33805. * Initializes the Hinge2-Joint
  33806. * @param jointData The joint data for the Hinge2-Joint
  33807. */
  33808. constructor(jointData: PhysicsJointData);
  33809. /**
  33810. * Set the motor values.
  33811. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33812. * @param {number} force the force to apply
  33813. * @param {number} maxForce max force for this motor.
  33814. * @param {motorIndex} the motor's index, 0 or 1.
  33815. */
  33816. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33817. /**
  33818. * Set the motor limits.
  33819. * Attention, this function is plugin specific. Engines won't react 100% the same.
  33820. * @param {number} upperLimit the upper limit
  33821. * @param {number} lowerLimit lower limit
  33822. * @param {motorIndex} the motor's index, 0 or 1.
  33823. */
  33824. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33825. }
  33826. /**
  33827. * Interface for a motor enabled joint
  33828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33829. */
  33830. interface IMotorEnabledJoint {
  33831. /**
  33832. * Physics joint
  33833. */
  33834. physicsJoint: any;
  33835. /**
  33836. * Sets the motor of the motor-enabled joint
  33837. * @param force The force of the motor
  33838. * @param maxForce The maximum force of the motor
  33839. * @param motorIndex The index of the motor
  33840. */
  33841. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33842. /**
  33843. * Sets the limit of the motor
  33844. * @param upperLimit The upper limit of the motor
  33845. * @param lowerLimit The lower limit of the motor
  33846. * @param motorIndex The index of the motor
  33847. */
  33848. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33849. }
  33850. /**
  33851. * Joint data for a Distance-Joint
  33852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33853. */
  33854. interface DistanceJointData extends PhysicsJointData {
  33855. /**
  33856. * Max distance the 2 joint objects can be apart
  33857. */
  33858. maxDistance: number;
  33859. }
  33860. /**
  33861. * Joint data from a spring joint
  33862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33863. */
  33864. interface SpringJointData extends PhysicsJointData {
  33865. /**
  33866. * Length of the spring
  33867. */
  33868. length: number;
  33869. /**
  33870. * Stiffness of the spring
  33871. */
  33872. stiffness: number;
  33873. /**
  33874. * Damping of the spring
  33875. */
  33876. damping: number;
  33877. /** this callback will be called when applying the force to the impostors. */
  33878. forceApplicationCallback: () => void;
  33879. }
  33880. }
  33881. declare module BABYLON {
  33882. /**
  33883. * Postprocess used to generate anaglyphic rendering
  33884. */
  33885. class AnaglyphPostProcess extends PostProcess {
  33886. private _passedProcess;
  33887. /**
  33888. * Creates a new AnaglyphPostProcess
  33889. * @param name defines postprocess name
  33890. * @param options defines creation options or target ratio scale
  33891. * @param rigCameras defines cameras using this postprocess
  33892. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  33893. * @param engine defines hosting engine
  33894. * @param reusable defines if the postprocess will be reused multiple times per frame
  33895. */
  33896. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  33897. }
  33898. }
  33899. declare module BABYLON {
  33900. /**
  33901. * Post process used to render in black and white
  33902. */
  33903. class BlackAndWhitePostProcess extends PostProcess {
  33904. /**
  33905. * Linear about to convert he result to black and white (default: 1)
  33906. */
  33907. degree: number;
  33908. /**
  33909. * Creates a black and white post process
  33910. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  33911. * @param name The name of the effect.
  33912. * @param options The required width/height ratio to downsize to before computing the render pass.
  33913. * @param camera The camera to apply the render pass to.
  33914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33915. * @param engine The engine which the post process will be applied. (default: current engine)
  33916. * @param reusable If the post process can be reused on the same frame. (default: false)
  33917. */
  33918. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  33924. */
  33925. class BloomEffect extends PostProcessRenderEffect {
  33926. private bloomScale;
  33927. /**
  33928. * @hidden Internal
  33929. */
  33930. _effects: Array<PostProcess>;
  33931. /**
  33932. * @hidden Internal
  33933. */
  33934. _downscale: ExtractHighlightsPostProcess;
  33935. private _blurX;
  33936. private _blurY;
  33937. private _merge;
  33938. /**
  33939. * The luminance threshold to find bright areas of the image to bloom.
  33940. */
  33941. threshold: number;
  33942. /**
  33943. * The strength of the bloom.
  33944. */
  33945. weight: number;
  33946. /**
  33947. * Specifies the size of the bloom blur kernel, relative to the final output size
  33948. */
  33949. kernel: number;
  33950. /**
  33951. * Creates a new instance of @see BloomEffect
  33952. * @param scene The scene the effect belongs to.
  33953. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  33954. * @param bloomKernel The size of the kernel to be used when applying the blur.
  33955. * @param bloomWeight The the strength of bloom.
  33956. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  33957. * @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)
  33958. */
  33959. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  33960. /**
  33961. * Disposes each of the internal effects for a given camera.
  33962. * @param camera The camera to dispose the effect on.
  33963. */
  33964. disposeEffects(camera: Camera): void;
  33965. /**
  33966. * @hidden Internal
  33967. */
  33968. _updateEffects(): void;
  33969. /**
  33970. * Internal
  33971. * @returns if all the contained post processes are ready.
  33972. * @hidden
  33973. */
  33974. _isReady(): boolean;
  33975. }
  33976. }
  33977. declare module BABYLON {
  33978. /**
  33979. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  33980. */
  33981. class BloomMergePostProcess extends PostProcess {
  33982. /** Weight of the bloom to be added to the original input. */
  33983. weight: number;
  33984. /**
  33985. * Creates a new instance of @see BloomMergePostProcess
  33986. * @param name The name of the effect.
  33987. * @param originalFromInput Post process which's input will be used for the merge.
  33988. * @param blurred Blurred highlights post process which's output will be used.
  33989. * @param weight Weight of the bloom to be added to the original input.
  33990. * @param options The required width/height ratio to downsize to before computing the render pass.
  33991. * @param camera The camera to apply the render pass to.
  33992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  33993. * @param engine The engine which the post process will be applied. (default: current engine)
  33994. * @param reusable If the post process can be reused on the same frame. (default: false)
  33995. * @param textureType Type of textures used when performing the post process. (default: 0)
  33996. * @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)
  33997. */
  33998. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  33999. /** Weight of the bloom to be added to the original input. */
  34000. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34001. }
  34002. }
  34003. declare module BABYLON {
  34004. /**
  34005. * The Blur Post Process which blurs an image based on a kernel and direction.
  34006. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34007. */
  34008. class BlurPostProcess extends PostProcess {
  34009. /** The direction in which to blur the image. */
  34010. direction: Vector2;
  34011. private blockCompilation;
  34012. protected _kernel: number;
  34013. protected _idealKernel: number;
  34014. protected _packedFloat: boolean;
  34015. private _staticDefines;
  34016. /**
  34017. * Sets the length in pixels of the blur sample region
  34018. */
  34019. /**
  34020. * Gets the length in pixels of the blur sample region
  34021. */
  34022. kernel: number;
  34023. /**
  34024. * Sets wether or not the blur needs to unpack/repack floats
  34025. */
  34026. /**
  34027. * Gets wether or not the blur is unpacking/repacking floats
  34028. */
  34029. packedFloat: boolean;
  34030. /**
  34031. * Creates a new instance BlurPostProcess
  34032. * @param name The name of the effect.
  34033. * @param direction The direction in which to blur the image.
  34034. * @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.
  34035. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34036. * @param camera The camera to apply the render pass to.
  34037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34038. * @param engine The engine which the post process will be applied. (default: current engine)
  34039. * @param reusable If the post process can be reused on the same frame. (default: false)
  34040. * @param textureType Type of textures used when performing the post process. (default: 0)
  34041. * @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)
  34042. */
  34043. constructor(name: string,
  34044. /** The direction in which to blur the image. */
  34045. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34046. /**
  34047. * Updates the effect with the current post process compile time values and recompiles the shader.
  34048. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34049. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34050. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34051. * @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
  34052. * @param onCompiled Called when the shader has been compiled.
  34053. * @param onError Called if there is an error when compiling a shader.
  34054. */
  34055. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34056. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34057. /**
  34058. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34059. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34060. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34061. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34062. * The gaps between physical kernels are compensated for in the weighting of the samples
  34063. * @param idealKernel Ideal blur kernel.
  34064. * @return Nearest best kernel.
  34065. */
  34066. protected _nearestBestKernel(idealKernel: number): number;
  34067. /**
  34068. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34069. * @param x The point on the Gaussian distribution to sample.
  34070. * @return the value of the Gaussian function at x.
  34071. */
  34072. protected _gaussianWeight(x: number): number;
  34073. /**
  34074. * Generates a string that can be used as a floating point number in GLSL.
  34075. * @param x Value to print.
  34076. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34077. * @return GLSL float string.
  34078. */
  34079. protected _glslFloat(x: number, decimalFigures?: number): string;
  34080. }
  34081. }
  34082. declare module BABYLON {
  34083. /**
  34084. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34085. */
  34086. class ChromaticAberrationPostProcess extends PostProcess {
  34087. /**
  34088. * The amount of seperation of rgb channels (default: 30)
  34089. */
  34090. aberrationAmount: number;
  34091. /**
  34092. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34093. */
  34094. radialIntensity: number;
  34095. /**
  34096. * 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))
  34097. */
  34098. direction: Vector2;
  34099. /**
  34100. * 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))
  34101. */
  34102. centerPosition: Vector2;
  34103. /**
  34104. * Creates a new instance ChromaticAberrationPostProcess
  34105. * @param name The name of the effect.
  34106. * @param screenWidth The width of the screen to apply the effect on.
  34107. * @param screenHeight The height of the screen to apply the effect on.
  34108. * @param options The required width/height ratio to downsize to before computing the render pass.
  34109. * @param camera The camera to apply the render pass to.
  34110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34111. * @param engine The engine which the post process will be applied. (default: current engine)
  34112. * @param reusable If the post process can be reused on the same frame. (default: false)
  34113. * @param textureType Type of textures used when performing the post process. (default: 0)
  34114. * @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)
  34115. */
  34116. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34117. }
  34118. }
  34119. declare module BABYLON {
  34120. /**
  34121. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34122. */
  34123. class CircleOfConfusionPostProcess extends PostProcess {
  34124. /**
  34125. * 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.
  34126. */
  34127. lensSize: number;
  34128. /**
  34129. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34130. */
  34131. fStop: number;
  34132. /**
  34133. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34134. */
  34135. focusDistance: number;
  34136. /**
  34137. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34138. */
  34139. focalLength: number;
  34140. private _depthTexture;
  34141. /**
  34142. * Creates a new instance CircleOfConfusionPostProcess
  34143. * @param name The name of the effect.
  34144. * @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.
  34145. * @param options The required width/height ratio to downsize to before computing the render pass.
  34146. * @param camera The camera to apply the render pass to.
  34147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34148. * @param engine The engine which the post process will be applied. (default: current engine)
  34149. * @param reusable If the post process can be reused on the same frame. (default: false)
  34150. * @param textureType Type of textures used when performing the post process. (default: 0)
  34151. * @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)
  34152. */
  34153. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34154. /**
  34155. * 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.
  34156. */
  34157. depthTexture: RenderTargetTexture;
  34158. }
  34159. }
  34160. declare module BABYLON {
  34161. /**
  34162. *
  34163. * This post-process allows the modification of rendered colors by using
  34164. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34165. *
  34166. * The object needs to be provided an url to a texture containing the color
  34167. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34168. * Use an image editing software to tweak the LUT to match your needs.
  34169. *
  34170. * For an example of a color LUT, see here:
  34171. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34172. * For explanations on color grading, see here:
  34173. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34174. *
  34175. */
  34176. class ColorCorrectionPostProcess extends PostProcess {
  34177. private _colorTableTexture;
  34178. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34179. }
  34180. }
  34181. declare module BABYLON {
  34182. /**
  34183. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34184. * input texture to perform effects such as edge detection or sharpening
  34185. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34186. */
  34187. class ConvolutionPostProcess extends PostProcess {
  34188. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34189. kernel: number[];
  34190. /**
  34191. * Creates a new instance ConvolutionPostProcess
  34192. * @param name The name of the effect.
  34193. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34194. * @param options The required width/height ratio to downsize to before computing the render pass.
  34195. * @param camera The camera to apply the render pass to.
  34196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34197. * @param engine The engine which the post process will be applied. (default: current engine)
  34198. * @param reusable If the post process can be reused on the same frame. (default: false)
  34199. * @param textureType Type of textures used when performing the post process. (default: 0)
  34200. */
  34201. constructor(name: string,
  34202. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34203. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34204. /**
  34205. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34206. */
  34207. static EdgeDetect0Kernel: number[];
  34208. /**
  34209. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34210. */
  34211. static EdgeDetect1Kernel: number[];
  34212. /**
  34213. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34214. */
  34215. static EdgeDetect2Kernel: number[];
  34216. /**
  34217. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34218. */
  34219. static SharpenKernel: number[];
  34220. /**
  34221. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34222. */
  34223. static EmbossKernel: number[];
  34224. /**
  34225. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34226. */
  34227. static GaussianKernel: number[];
  34228. }
  34229. }
  34230. declare module BABYLON {
  34231. /**
  34232. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34233. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34234. * based on samples that have a large difference in distance than the center pixel.
  34235. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34236. */
  34237. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34238. direction: Vector2;
  34239. /**
  34240. * Creates a new instance CircleOfConfusionPostProcess
  34241. * @param name The name of the effect.
  34242. * @param scene The scene the effect belongs to.
  34243. * @param direction The direction the blur should be applied.
  34244. * @param kernel The size of the kernel used to blur.
  34245. * @param options The required width/height ratio to downsize to before computing the render pass.
  34246. * @param camera The camera to apply the render pass to.
  34247. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34248. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34250. * @param engine The engine which the post process will be applied. (default: current engine)
  34251. * @param reusable If the post process can be reused on the same frame. (default: false)
  34252. * @param textureType Type of textures used when performing the post process. (default: 0)
  34253. * @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)
  34254. */
  34255. 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);
  34256. }
  34257. }
  34258. declare module BABYLON {
  34259. /**
  34260. * Specifies the level of max blur that should be applied when using the depth of field effect
  34261. */
  34262. enum DepthOfFieldEffectBlurLevel {
  34263. /**
  34264. * Subtle blur
  34265. */
  34266. Low = 0,
  34267. /**
  34268. * Medium blur
  34269. */
  34270. Medium = 1,
  34271. /**
  34272. * Large blur
  34273. */
  34274. High = 2
  34275. }
  34276. /**
  34277. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34278. */
  34279. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34280. private _circleOfConfusion;
  34281. /**
  34282. * @hidden Internal, blurs from high to low
  34283. */
  34284. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34285. private _depthOfFieldBlurY;
  34286. private _dofMerge;
  34287. /**
  34288. * @hidden Internal post processes in depth of field effect
  34289. */
  34290. _effects: Array<PostProcess>;
  34291. /**
  34292. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34293. */
  34294. focalLength: number;
  34295. /**
  34296. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34297. */
  34298. fStop: number;
  34299. /**
  34300. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34301. */
  34302. focusDistance: number;
  34303. /**
  34304. * 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.
  34305. */
  34306. lensSize: number;
  34307. /**
  34308. * Creates a new instance DepthOfFieldEffect
  34309. * @param scene The scene the effect belongs to.
  34310. * @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.
  34311. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34312. * @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)
  34313. */
  34314. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34315. /**
  34316. * 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.
  34317. */
  34318. depthTexture: RenderTargetTexture;
  34319. /**
  34320. * Disposes each of the internal effects for a given camera.
  34321. * @param camera The camera to dispose the effect on.
  34322. */
  34323. disposeEffects(camera: Camera): void;
  34324. /**
  34325. * @hidden Internal
  34326. */
  34327. _updateEffects(): void;
  34328. /**
  34329. * Internal
  34330. * @returns if all the contained post processes are ready.
  34331. * @hidden
  34332. */
  34333. _isReady(): boolean;
  34334. }
  34335. }
  34336. declare module BABYLON {
  34337. /**
  34338. * Options to be set when merging outputs from the default pipeline.
  34339. */
  34340. class DepthOfFieldMergePostProcessOptions {
  34341. /**
  34342. * The original image to merge on top of
  34343. */
  34344. originalFromInput: PostProcess;
  34345. /**
  34346. * Parameters to perform the merge of the depth of field effect
  34347. */
  34348. depthOfField?: {
  34349. circleOfConfusion: PostProcess;
  34350. blurSteps: Array<PostProcess>;
  34351. };
  34352. /**
  34353. * Parameters to perform the merge of bloom effect
  34354. */
  34355. bloom?: {
  34356. blurred: PostProcess;
  34357. weight: number;
  34358. };
  34359. }
  34360. /**
  34361. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34362. */
  34363. class DepthOfFieldMergePostProcess extends PostProcess {
  34364. private blurSteps;
  34365. /**
  34366. * Creates a new instance of DepthOfFieldMergePostProcess
  34367. * @param name The name of the effect.
  34368. * @param originalFromInput Post process which's input will be used for the merge.
  34369. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34370. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  34371. * @param options The required width/height ratio to downsize to before computing the render pass.
  34372. * @param camera The camera to apply the render pass to.
  34373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34374. * @param engine The engine which the post process will be applied. (default: current engine)
  34375. * @param reusable If the post process can be reused on the same frame. (default: false)
  34376. * @param textureType Type of textures used when performing the post process. (default: 0)
  34377. * @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)
  34378. */
  34379. 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);
  34380. /**
  34381. * Updates the effect with the current post process compile time values and recompiles the shader.
  34382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34385. * @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
  34386. * @param onCompiled Called when the shader has been compiled.
  34387. * @param onError Called if there is an error when compiling a shader.
  34388. */
  34389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34390. }
  34391. }
  34392. declare module BABYLON {
  34393. /**
  34394. * DisplayPassPostProcess which produces an output the same as it's input
  34395. */
  34396. class DisplayPassPostProcess extends PostProcess {
  34397. /**
  34398. * Creates the DisplayPassPostProcess
  34399. * @param name The name of the effect.
  34400. * @param options The required width/height ratio to downsize to before computing the render pass.
  34401. * @param camera The camera to apply the render pass to.
  34402. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34403. * @param engine The engine which the post process will be applied. (default: current engine)
  34404. * @param reusable If the post process can be reused on the same frame. (default: false)
  34405. */
  34406. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34407. }
  34408. }
  34409. declare module BABYLON {
  34410. /**
  34411. * 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.
  34412. */
  34413. class ExtractHighlightsPostProcess extends PostProcess {
  34414. /**
  34415. * The luminance threshold, pixels below this value will be set to black.
  34416. */
  34417. threshold: number;
  34418. /** @hidden */
  34419. _exposure: number;
  34420. /**
  34421. * Post process which has the input texture to be used when performing highlight extraction
  34422. * @hidden
  34423. */
  34424. _inputPostProcess: Nullable<PostProcess>;
  34425. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34426. }
  34427. }
  34428. declare module BABYLON {
  34429. /**
  34430. * Applies a kernel filter to the image
  34431. */
  34432. class FilterPostProcess extends PostProcess {
  34433. /** The matrix to be applied to the image */
  34434. kernelMatrix: Matrix;
  34435. /**
  34436. *
  34437. * @param name The name of the effect.
  34438. * @param kernelMatrix The matrix to be applied to the image
  34439. * @param options The required width/height ratio to downsize to before computing the render pass.
  34440. * @param camera The camera to apply the render pass to.
  34441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34442. * @param engine The engine which the post process will be applied. (default: current engine)
  34443. * @param reusable If the post process can be reused on the same frame. (default: false)
  34444. */
  34445. constructor(name: string,
  34446. /** The matrix to be applied to the image */
  34447. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34448. }
  34449. }
  34450. declare module BABYLON {
  34451. /**
  34452. * Fxaa post process
  34453. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  34454. */
  34455. class FxaaPostProcess extends PostProcess {
  34456. /** @hidden */
  34457. texelWidth: number;
  34458. /** @hidden */
  34459. texelHeight: number;
  34460. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34461. private _getDefines;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. /**
  34466. * The GrainPostProcess adds noise to the image at mid luminance levels
  34467. */
  34468. class GrainPostProcess extends PostProcess {
  34469. /**
  34470. * The intensity of the grain added (default: 30)
  34471. */
  34472. intensity: number;
  34473. /**
  34474. * If the grain should be randomized on every frame
  34475. */
  34476. animated: boolean;
  34477. /**
  34478. * Creates a new instance of @see GrainPostProcess
  34479. * @param name The name of the effect.
  34480. * @param options The required width/height ratio to downsize to before computing the render pass.
  34481. * @param camera The camera to apply the render pass to.
  34482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34483. * @param engine The engine which the post process will be applied. (default: current engine)
  34484. * @param reusable If the post process can be reused on the same frame. (default: false)
  34485. * @param textureType Type of textures used when performing the post process. (default: 0)
  34486. * @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)
  34487. */
  34488. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34489. }
  34490. }
  34491. declare module BABYLON {
  34492. /**
  34493. * Extracts highlights from the image
  34494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34495. */
  34496. class HighlightsPostProcess extends PostProcess {
  34497. /**
  34498. * Extracts highlights from the image
  34499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34500. * @param name The name of the effect.
  34501. * @param options The required width/height ratio to downsize to before computing the render pass.
  34502. * @param camera The camera to apply the render pass to.
  34503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34504. * @param engine The engine which the post process will be applied. (default: current engine)
  34505. * @param reusable If the post process can be reused on the same frame. (default: false)
  34506. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  34507. */
  34508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34509. }
  34510. }
  34511. declare module BABYLON {
  34512. /**
  34513. * ImageProcessingPostProcess
  34514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  34515. */
  34516. class ImageProcessingPostProcess extends PostProcess {
  34517. /**
  34518. * Default configuration related to image processing available in the PBR Material.
  34519. */
  34520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34521. /**
  34522. * Gets the image processing configuration used either in this material.
  34523. */
  34524. /**
  34525. * Sets the Default image processing configuration used either in the this material.
  34526. *
  34527. * If sets to null, the scene one is in use.
  34528. */
  34529. imageProcessingConfiguration: ImageProcessingConfiguration;
  34530. /**
  34531. * Keep track of the image processing observer to allow dispose and replace.
  34532. */
  34533. private _imageProcessingObserver;
  34534. /**
  34535. * Attaches a new image processing configuration to the PBR Material.
  34536. * @param configuration
  34537. */
  34538. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  34539. /**
  34540. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34541. */
  34542. /**
  34543. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  34544. */
  34545. colorCurves: Nullable<ColorCurves>;
  34546. /**
  34547. * Gets wether the color curves effect is enabled.
  34548. */
  34549. /**
  34550. * Sets wether the color curves effect is enabled.
  34551. */
  34552. colorCurvesEnabled: boolean;
  34553. /**
  34554. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34555. */
  34556. /**
  34557. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  34558. */
  34559. colorGradingTexture: Nullable<BaseTexture>;
  34560. /**
  34561. * Gets wether the color grading effect is enabled.
  34562. */
  34563. /**
  34564. * Gets wether the color grading effect is enabled.
  34565. */
  34566. colorGradingEnabled: boolean;
  34567. /**
  34568. * Gets exposure used in the effect.
  34569. */
  34570. /**
  34571. * Sets exposure used in the effect.
  34572. */
  34573. exposure: number;
  34574. /**
  34575. * Gets wether tonemapping is enabled or not.
  34576. */
  34577. /**
  34578. * Sets wether tonemapping is enabled or not
  34579. */
  34580. toneMappingEnabled: boolean;
  34581. /**
  34582. * Gets contrast used in the effect.
  34583. */
  34584. /**
  34585. * Sets contrast used in the effect.
  34586. */
  34587. contrast: number;
  34588. /**
  34589. * Gets Vignette stretch size.
  34590. */
  34591. /**
  34592. * Sets Vignette stretch size.
  34593. */
  34594. vignetteStretch: number;
  34595. /**
  34596. * Gets Vignette centre X Offset.
  34597. */
  34598. /**
  34599. * Sets Vignette centre X Offset.
  34600. */
  34601. vignetteCentreX: number;
  34602. /**
  34603. * Gets Vignette centre Y Offset.
  34604. */
  34605. /**
  34606. * Sets Vignette centre Y Offset.
  34607. */
  34608. vignetteCentreY: number;
  34609. /**
  34610. * Gets Vignette weight or intensity of the vignette effect.
  34611. */
  34612. /**
  34613. * Sets Vignette weight or intensity of the vignette effect.
  34614. */
  34615. vignetteWeight: number;
  34616. /**
  34617. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34618. * if vignetteEnabled is set to true.
  34619. */
  34620. /**
  34621. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  34622. * if vignetteEnabled is set to true.
  34623. */
  34624. vignetteColor: Color4;
  34625. /**
  34626. * Gets Camera field of view used by the Vignette effect.
  34627. */
  34628. /**
  34629. * Sets Camera field of view used by the Vignette effect.
  34630. */
  34631. vignetteCameraFov: number;
  34632. /**
  34633. * Gets the vignette blend mode allowing different kind of effect.
  34634. */
  34635. /**
  34636. * Sets the vignette blend mode allowing different kind of effect.
  34637. */
  34638. vignetteBlendMode: number;
  34639. /**
  34640. * Gets wether the vignette effect is enabled.
  34641. */
  34642. /**
  34643. * Sets wether the vignette effect is enabled.
  34644. */
  34645. vignetteEnabled: boolean;
  34646. private _fromLinearSpace;
  34647. /**
  34648. * Gets wether the input of the processing is in Gamma or Linear Space.
  34649. */
  34650. /**
  34651. * Sets wether the input of the processing is in Gamma or Linear Space.
  34652. */
  34653. fromLinearSpace: boolean;
  34654. /**
  34655. * Defines cache preventing GC.
  34656. */
  34657. private _defines;
  34658. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  34659. /**
  34660. * "ImageProcessingPostProcess"
  34661. * @returns "ImageProcessingPostProcess"
  34662. */
  34663. getClassName(): string;
  34664. protected _updateParameters(): void;
  34665. dispose(camera?: Camera): void;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  34671. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  34672. * As an example, all you have to do is to create the post-process:
  34673. * var mb = new BABYLON.MotionBlurPostProcess(
  34674. * 'mb', // The name of the effect.
  34675. * scene, // The scene containing the objects to blur according to their velocity.
  34676. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  34677. * camera // The camera to apply the render pass to.
  34678. * );
  34679. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  34680. */
  34681. class MotionBlurPostProcess extends PostProcess {
  34682. /**
  34683. * Defines how much the image is blurred by the movement. Default value is equal to 1
  34684. */
  34685. motionStrength: number;
  34686. /**
  34687. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  34688. */
  34689. /**
  34690. * Sets the number of iterations to be used for motion blur quality
  34691. */
  34692. motionBlurSamples: number;
  34693. private _motionBlurSamples;
  34694. private _geometryBufferRenderer;
  34695. /**
  34696. * Creates a new instance MotionBlurPostProcess
  34697. * @param name The name of the effect.
  34698. * @param scene The scene containing the objects to blur according to their velocity.
  34699. * @param options The required width/height ratio to downsize to before computing the render pass.
  34700. * @param camera The camera to apply the render pass to.
  34701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34702. * @param engine The engine which the post process will be applied. (default: current engine)
  34703. * @param reusable If the post process can be reused on the same frame. (default: false)
  34704. * @param textureType Type of textures used when performing the post process. (default: 0)
  34705. * @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)
  34706. */
  34707. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34708. /**
  34709. * Disposes the post process.
  34710. * @param camera The camera to dispose the post process on.
  34711. */
  34712. dispose(camera?: Camera): void;
  34713. }
  34714. }
  34715. declare module BABYLON {
  34716. /**
  34717. * PassPostProcess which produces an output the same as it's input
  34718. */
  34719. class PassPostProcess extends PostProcess {
  34720. /**
  34721. * Creates the PassPostProcess
  34722. * @param name The name of the effect.
  34723. * @param options The required width/height ratio to downsize to before computing the render pass.
  34724. * @param camera The camera to apply the render pass to.
  34725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34726. * @param engine The engine which the post process will be applied. (default: current engine)
  34727. * @param reusable If the post process can be reused on the same frame. (default: false)
  34728. * @param textureType The type of texture to be used when performing the post processing.
  34729. * @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)
  34730. */
  34731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34732. }
  34733. }
  34734. declare module BABYLON {
  34735. /**
  34736. * Size options for a post process
  34737. */
  34738. type PostProcessOptions = {
  34739. width: number;
  34740. height: number;
  34741. };
  34742. /**
  34743. * PostProcess can be used to apply a shader to a texture after it has been rendered
  34744. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  34745. */
  34746. class PostProcess {
  34747. /** Name of the PostProcess. */
  34748. name: string;
  34749. /**
  34750. * Width of the texture to apply the post process on
  34751. */
  34752. width: number;
  34753. /**
  34754. * Height of the texture to apply the post process on
  34755. */
  34756. height: number;
  34757. /**
  34758. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  34759. * @hidden
  34760. */
  34761. _outputTexture: Nullable<InternalTexture>;
  34762. /**
  34763. * Sampling mode used by the shader
  34764. * See https://doc.babylonjs.com/classes/3.1/texture
  34765. */
  34766. renderTargetSamplingMode: number;
  34767. /**
  34768. * Clear color to use when screen clearing
  34769. */
  34770. clearColor: Color4;
  34771. /**
  34772. * If the buffer needs to be cleared before applying the post process. (default: true)
  34773. * Should be set to false if shader will overwrite all previous pixels.
  34774. */
  34775. autoClear: boolean;
  34776. /**
  34777. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  34778. */
  34779. alphaMode: number;
  34780. /**
  34781. * Sets the setAlphaBlendConstants of the babylon engine
  34782. */
  34783. alphaConstants: Color4;
  34784. /**
  34785. * Animations to be used for the post processing
  34786. */
  34787. animations: Animation[];
  34788. /**
  34789. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  34790. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  34791. */
  34792. enablePixelPerfectMode: boolean;
  34793. /**
  34794. * Force the postprocess to be applied without taking in account viewport
  34795. */
  34796. forceFullscreenViewport: boolean;
  34797. /**
  34798. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  34799. *
  34800. * | Value | Type | Description |
  34801. * | ----- | ----------------------------------- | ----------- |
  34802. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  34803. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  34804. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  34805. *
  34806. */
  34807. scaleMode: number;
  34808. /**
  34809. * Force textures to be a power of two (default: false)
  34810. */
  34811. alwaysForcePOT: boolean;
  34812. private _samples;
  34813. /**
  34814. * Number of sample textures (default: 1)
  34815. */
  34816. samples: number;
  34817. /**
  34818. * Modify the scale of the post process to be the same as the viewport (default: false)
  34819. */
  34820. adaptScaleToCurrentViewport: boolean;
  34821. private _camera;
  34822. private _scene;
  34823. private _engine;
  34824. private _options;
  34825. private _reusable;
  34826. private _textureType;
  34827. /**
  34828. * Smart array of input and output textures for the post process.
  34829. * @hidden
  34830. */
  34831. _textures: SmartArray<InternalTexture>;
  34832. /**
  34833. * The index in _textures that corresponds to the output texture.
  34834. * @hidden
  34835. */
  34836. _currentRenderTextureInd: number;
  34837. private _effect;
  34838. private _samplers;
  34839. private _fragmentUrl;
  34840. private _vertexUrl;
  34841. private _parameters;
  34842. private _scaleRatio;
  34843. protected _indexParameters: any;
  34844. private _shareOutputWithPostProcess;
  34845. private _texelSize;
  34846. private _forcedOutputTexture;
  34847. /**
  34848. * An event triggered when the postprocess is activated.
  34849. */
  34850. onActivateObservable: Observable<Camera>;
  34851. private _onActivateObserver;
  34852. /**
  34853. * A function that is added to the onActivateObservable
  34854. */
  34855. onActivate: Nullable<(camera: Camera) => void>;
  34856. /**
  34857. * An event triggered when the postprocess changes its size.
  34858. */
  34859. onSizeChangedObservable: Observable<PostProcess>;
  34860. private _onSizeChangedObserver;
  34861. /**
  34862. * A function that is added to the onSizeChangedObservable
  34863. */
  34864. onSizeChanged: (postProcess: PostProcess) => void;
  34865. /**
  34866. * An event triggered when the postprocess applies its effect.
  34867. */
  34868. onApplyObservable: Observable<Effect>;
  34869. private _onApplyObserver;
  34870. /**
  34871. * A function that is added to the onApplyObservable
  34872. */
  34873. onApply: (effect: Effect) => void;
  34874. /**
  34875. * An event triggered before rendering the postprocess
  34876. */
  34877. onBeforeRenderObservable: Observable<Effect>;
  34878. private _onBeforeRenderObserver;
  34879. /**
  34880. * A function that is added to the onBeforeRenderObservable
  34881. */
  34882. onBeforeRender: (effect: Effect) => void;
  34883. /**
  34884. * An event triggered after rendering the postprocess
  34885. */
  34886. onAfterRenderObservable: Observable<Effect>;
  34887. private _onAfterRenderObserver;
  34888. /**
  34889. * A function that is added to the onAfterRenderObservable
  34890. */
  34891. onAfterRender: (efect: Effect) => void;
  34892. /**
  34893. * 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
  34894. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  34895. */
  34896. inputTexture: InternalTexture;
  34897. /**
  34898. * Gets the camera which post process is applied to.
  34899. * @returns The camera the post process is applied to.
  34900. */
  34901. getCamera(): Camera;
  34902. /**
  34903. * Gets the texel size of the postprocess.
  34904. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  34905. */
  34906. readonly texelSize: Vector2;
  34907. /**
  34908. * Creates a new instance PostProcess
  34909. * @param name The name of the PostProcess.
  34910. * @param fragmentUrl The url of the fragment shader to be used.
  34911. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  34912. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  34913. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34914. * @param camera The camera to apply the render pass to.
  34915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34916. * @param engine The engine which the post process will be applied. (default: current engine)
  34917. * @param reusable If the post process can be reused on the same frame. (default: false)
  34918. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  34919. * @param textureType Type of textures used when performing the post process. (default: 0)
  34920. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  34921. * @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
  34922. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  34923. */
  34924. constructor(
  34925. /** Name of the PostProcess. */
  34926. 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);
  34927. /**
  34928. * Gets the engine which this post process belongs to.
  34929. * @returns The engine the post process was enabled with.
  34930. */
  34931. getEngine(): Engine;
  34932. /**
  34933. * The effect that is created when initializing the post process.
  34934. * @returns The created effect corrisponding the the postprocess.
  34935. */
  34936. getEffect(): Effect;
  34937. /**
  34938. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  34939. * @param postProcess The post process to share the output with.
  34940. * @returns This post process.
  34941. */
  34942. shareOutputWith(postProcess: PostProcess): PostProcess;
  34943. /**
  34944. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  34945. * This should be called if the post process that shares output with this post process is disabled/disposed.
  34946. */
  34947. useOwnOutput(): void;
  34948. /**
  34949. * Updates the effect with the current post process compile time values and recompiles the shader.
  34950. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34951. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34952. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34953. * @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
  34954. * @param onCompiled Called when the shader has been compiled.
  34955. * @param onError Called if there is an error when compiling a shader.
  34956. */
  34957. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34958. /**
  34959. * The post process is reusable if it can be used multiple times within one frame.
  34960. * @returns If the post process is reusable
  34961. */
  34962. isReusable(): boolean;
  34963. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  34964. markTextureDirty(): void;
  34965. /**
  34966. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  34967. * 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.
  34968. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  34969. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  34970. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  34971. * @returns The target texture that was bound to be written to.
  34972. */
  34973. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  34974. /**
  34975. * If the post process is supported.
  34976. */
  34977. readonly isSupported: boolean;
  34978. /**
  34979. * The aspect ratio of the output texture.
  34980. */
  34981. readonly aspectRatio: number;
  34982. /**
  34983. * Get a value indicating if the post-process is ready to be used
  34984. * @returns true if the post-process is ready (shader is compiled)
  34985. */
  34986. isReady(): boolean;
  34987. /**
  34988. * Binds all textures and uniforms to the shader, this will be run on every pass.
  34989. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  34990. */
  34991. apply(): Nullable<Effect>;
  34992. private _disposeTextures;
  34993. /**
  34994. * Disposes the post process.
  34995. * @param camera The camera to dispose the post process on.
  34996. */
  34997. dispose(camera?: Camera): void;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35003. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35004. */
  35005. class PostProcessManager {
  35006. private _scene;
  35007. private _indexBuffer;
  35008. private _vertexBuffers;
  35009. /**
  35010. * Creates a new instance PostProcess
  35011. * @param scene The scene that the post process is associated with.
  35012. */
  35013. constructor(scene: Scene);
  35014. private _prepareBuffers;
  35015. private _buildIndexBuffer;
  35016. /**
  35017. * Rebuilds the vertex buffers of the manager.
  35018. * @hidden
  35019. */
  35020. _rebuild(): void;
  35021. /**
  35022. * Prepares a frame to be run through a post process.
  35023. * @param sourceTexture The input texture to the post procesess. (default: null)
  35024. * @param postProcesses An array of post processes to be run. (default: null)
  35025. * @returns True if the post processes were able to be run.
  35026. * @hidden
  35027. */
  35028. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35029. /**
  35030. * Manually render a set of post processes to a texture.
  35031. * @param postProcesses An array of post processes to be run.
  35032. * @param targetTexture The target texture to render to.
  35033. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35034. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35035. * @param lodLevel defines which lod of the texture to render to
  35036. */
  35037. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35038. /**
  35039. * Finalize the result of the output of the postprocesses.
  35040. * @param doNotPresent If true the result will not be displayed to the screen.
  35041. * @param targetTexture The target texture to render to.
  35042. * @param faceIndex The index of the face to bind the target texture to.
  35043. * @param postProcesses The array of post processes to render.
  35044. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35045. * @hidden
  35046. */
  35047. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35048. /**
  35049. * Disposes of the post process manager.
  35050. */
  35051. dispose(): void;
  35052. }
  35053. }
  35054. declare module BABYLON {
  35055. /**
  35056. * Post process which applies a refractin texture
  35057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35058. */
  35059. class RefractionPostProcess extends PostProcess {
  35060. /** the base color of the refraction (used to taint the rendering) */
  35061. color: Color3;
  35062. /** simulated refraction depth */
  35063. depth: number;
  35064. /** the coefficient of the base color (0 to remove base color tainting) */
  35065. colorLevel: number;
  35066. private _refTexture;
  35067. private _ownRefractionTexture;
  35068. /**
  35069. * Gets or sets the refraction texture
  35070. * Please note that you are responsible for disposing the texture if you set it manually
  35071. */
  35072. refractionTexture: Texture;
  35073. /**
  35074. * Initializes the RefractionPostProcess
  35075. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35076. * @param name The name of the effect.
  35077. * @param refractionTextureUrl Url of the refraction texture to use
  35078. * @param color the base color of the refraction (used to taint the rendering)
  35079. * @param depth simulated refraction depth
  35080. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35081. * @param camera The camera to apply the render pass to.
  35082. * @param options The required width/height ratio to downsize to before computing the render pass.
  35083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35084. * @param engine The engine which the post process will be applied. (default: current engine)
  35085. * @param reusable If the post process can be reused on the same frame. (default: false)
  35086. */
  35087. constructor(name: string, refractionTextureUrl: string,
  35088. /** the base color of the refraction (used to taint the rendering) */
  35089. color: Color3,
  35090. /** simulated refraction depth */
  35091. depth: number,
  35092. /** the coefficient of the base color (0 to remove base color tainting) */
  35093. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35094. /**
  35095. * Disposes of the post process
  35096. * @param camera Camera to dispose post process on
  35097. */
  35098. dispose(camera: Camera): void;
  35099. }
  35100. }
  35101. declare module BABYLON {
  35102. /**
  35103. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35104. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35105. */
  35106. class SharpenPostProcess extends PostProcess {
  35107. /**
  35108. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35109. */
  35110. colorAmount: number;
  35111. /**
  35112. * How much sharpness should be applied (default: 0.3)
  35113. */
  35114. edgeAmount: number;
  35115. /**
  35116. * Creates a new instance ConvolutionPostProcess
  35117. * @param name The name of the effect.
  35118. * @param options The required width/height ratio to downsize to before computing the render pass.
  35119. * @param camera The camera to apply the render pass to.
  35120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35121. * @param engine The engine which the post process will be applied. (default: current engine)
  35122. * @param reusable If the post process can be reused on the same frame. (default: false)
  35123. * @param textureType Type of textures used when performing the post process. (default: 0)
  35124. * @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)
  35125. */
  35126. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35127. }
  35128. }
  35129. declare module BABYLON {
  35130. /**
  35131. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35132. */
  35133. class StereoscopicInterlacePostProcess extends PostProcess {
  35134. private _stepSize;
  35135. private _passedProcess;
  35136. /**
  35137. * Initializes a StereoscopicInterlacePostProcess
  35138. * @param name The name of the effect.
  35139. * @param rigCameras The rig cameras to be appled to the post process
  35140. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35142. * @param engine The engine which the post process will be applied. (default: current engine)
  35143. * @param reusable If the post process can be reused on the same frame. (default: false)
  35144. */
  35145. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35146. }
  35147. }
  35148. declare module BABYLON {
  35149. /** Defines operator used for tonemapping */
  35150. enum TonemappingOperator {
  35151. /** Hable */
  35152. Hable = 0,
  35153. /** Reinhard */
  35154. Reinhard = 1,
  35155. /** HejiDawson */
  35156. HejiDawson = 2,
  35157. /** Photographic */
  35158. Photographic = 3
  35159. }
  35160. /**
  35161. * Defines a post process to apply tone mapping
  35162. */
  35163. class TonemapPostProcess extends PostProcess {
  35164. private _operator;
  35165. /** Defines the required exposure adjustement */
  35166. exposureAdjustment: number;
  35167. /**
  35168. * Creates a new TonemapPostProcess
  35169. * @param name defines the name of the postprocess
  35170. * @param _operator defines the operator to use
  35171. * @param exposureAdjustment defines the required exposure adjustement
  35172. * @param camera defines the camera to use (can be null)
  35173. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35174. * @param engine defines the hosting engine (can be ignore if camera is set)
  35175. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35176. */
  35177. constructor(name: string, _operator: TonemappingOperator,
  35178. /** Defines the required exposure adjustement */
  35179. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35180. }
  35181. }
  35182. declare module BABYLON {
  35183. /**
  35184. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35185. */
  35186. class VolumetricLightScatteringPostProcess extends PostProcess {
  35187. private _volumetricLightScatteringPass;
  35188. private _volumetricLightScatteringRTT;
  35189. private _viewPort;
  35190. private _screenCoordinates;
  35191. private _cachedDefines;
  35192. /**
  35193. * If not undefined, the mesh position is computed from the attached node position
  35194. */
  35195. attachedNode: {
  35196. position: Vector3;
  35197. };
  35198. /**
  35199. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35200. */
  35201. customMeshPosition: Vector3;
  35202. /**
  35203. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35204. */
  35205. useCustomMeshPosition: boolean;
  35206. /**
  35207. * If the post-process should inverse the light scattering direction
  35208. */
  35209. invert: boolean;
  35210. /**
  35211. * The internal mesh used by the post-process
  35212. */
  35213. mesh: Mesh;
  35214. /**
  35215. * @hidden
  35216. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35217. */
  35218. useDiffuseColor: boolean;
  35219. /**
  35220. * Array containing the excluded meshes not rendered in the internal pass
  35221. */
  35222. excludedMeshes: AbstractMesh[];
  35223. /**
  35224. * Controls the overall intensity of the post-process
  35225. */
  35226. exposure: number;
  35227. /**
  35228. * Dissipates each sample's contribution in range [0, 1]
  35229. */
  35230. decay: number;
  35231. /**
  35232. * Controls the overall intensity of each sample
  35233. */
  35234. weight: number;
  35235. /**
  35236. * Controls the density of each sample
  35237. */
  35238. density: number;
  35239. /**
  35240. * @constructor
  35241. * @param name The post-process name
  35242. * @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)
  35243. * @param camera The camera that the post-process will be attached to
  35244. * @param mesh The mesh used to create the light scattering
  35245. * @param samples The post-process quality, default 100
  35246. * @param samplingModeThe post-process filtering mode
  35247. * @param engine The babylon engine
  35248. * @param reusable If the post-process is reusable
  35249. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35250. */
  35251. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35252. /**
  35253. * Returns the string "VolumetricLightScatteringPostProcess"
  35254. * @returns "VolumetricLightScatteringPostProcess"
  35255. */
  35256. getClassName(): string;
  35257. private _isReady;
  35258. /**
  35259. * Sets the new light position for light scattering effect
  35260. * @param position The new custom light position
  35261. */
  35262. setCustomMeshPosition(position: Vector3): void;
  35263. /**
  35264. * Returns the light position for light scattering effect
  35265. * @return Vector3 The custom light position
  35266. */
  35267. getCustomMeshPosition(): Vector3;
  35268. /**
  35269. * Disposes the internal assets and detaches the post-process from the camera
  35270. */
  35271. dispose(camera: Camera): void;
  35272. /**
  35273. * Returns the render target texture used by the post-process
  35274. * @return the render target texture used by the post-process
  35275. */
  35276. getPass(): RenderTargetTexture;
  35277. private _meshExcluded;
  35278. private _createPass;
  35279. private _updateMeshScreenCoordinates;
  35280. /**
  35281. * Creates a default mesh for the Volumeric Light Scattering post-process
  35282. * @param name The mesh name
  35283. * @param scene The scene where to create the mesh
  35284. * @return the default mesh
  35285. */
  35286. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35287. }
  35288. }
  35289. declare module BABYLON {
  35290. /**
  35291. * VRDistortionCorrectionPostProcess used for mobile VR
  35292. */
  35293. class VRDistortionCorrectionPostProcess extends PostProcess {
  35294. private _isRightEye;
  35295. private _distortionFactors;
  35296. private _postProcessScaleFactor;
  35297. private _lensCenterOffset;
  35298. private _scaleIn;
  35299. private _scaleFactor;
  35300. private _lensCenter;
  35301. /**
  35302. * Initializes the VRDistortionCorrectionPostProcess
  35303. * @param name The name of the effect.
  35304. * @param camera The camera to apply the render pass to.
  35305. * @param isRightEye If this is for the right eye distortion
  35306. * @param vrMetrics All the required metrics for the VR camera
  35307. */
  35308. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35309. }
  35310. }
  35311. declare module BABYLON {
  35312. interface Scene {
  35313. /**
  35314. * The list of reflection probes added to the scene
  35315. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  35316. */
  35317. reflectionProbes: Array<ReflectionProbe>;
  35318. }
  35319. /**
  35320. * Class used to generate realtime reflection / refraction cube textures
  35321. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  35322. */
  35323. class ReflectionProbe {
  35324. /** defines the name of the probe */
  35325. name: string;
  35326. private _scene;
  35327. private _renderTargetTexture;
  35328. private _projectionMatrix;
  35329. private _viewMatrix;
  35330. private _target;
  35331. private _add;
  35332. private _attachedMesh;
  35333. private _invertYAxis;
  35334. /** Gets or sets probe position (center of the cube map) */
  35335. position: Vector3;
  35336. /**
  35337. * Creates a new reflection probe
  35338. * @param name defines the name of the probe
  35339. * @param size defines the texture resolution (for each face)
  35340. * @param scene defines the hosting scene
  35341. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  35342. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  35343. */
  35344. constructor(
  35345. /** defines the name of the probe */
  35346. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  35347. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  35348. samples: number;
  35349. /** Gets or sets the refresh rate to use (on every frame by default) */
  35350. refreshRate: number;
  35351. /**
  35352. * Gets the hosting scene
  35353. * @returns a Scene
  35354. */
  35355. getScene(): Scene;
  35356. /** Gets the internal CubeTexture used to render to */
  35357. readonly cubeTexture: RenderTargetTexture;
  35358. /** Gets the list of meshes to render */
  35359. readonly renderList: Nullable<AbstractMesh[]>;
  35360. /**
  35361. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  35362. * @param mesh defines the mesh to attach to
  35363. */
  35364. attachToMesh(mesh: AbstractMesh): void;
  35365. /**
  35366. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  35367. * @param renderingGroupId The rendering group id corresponding to its index
  35368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35369. */
  35370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  35371. /**
  35372. * Clean all associated resources
  35373. */
  35374. dispose(): void;
  35375. }
  35376. }
  35377. declare module BABYLON {
  35378. interface Scene {
  35379. /** @hidden (Backing field) */
  35380. _boundingBoxRenderer: BoundingBoxRenderer;
  35381. /** @hidden (Backing field) */
  35382. _forceShowBoundingBoxes: boolean;
  35383. /**
  35384. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35385. */
  35386. forceShowBoundingBoxes: boolean;
  35387. /**
  35388. * Gets the bounding box renderer associated with the scene
  35389. * @returns a BoundingBoxRenderer
  35390. */
  35391. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35392. }
  35393. interface AbstractMesh {
  35394. /** @hidden (Backing field) */
  35395. _showBoundingBox: boolean;
  35396. /**
  35397. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35398. */
  35399. showBoundingBox: boolean;
  35400. }
  35401. /**
  35402. * Component responsible of rendering the bounding box of the meshes in a scene.
  35403. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35404. */
  35405. class BoundingBoxRenderer implements ISceneComponent {
  35406. /**
  35407. * The component name helpfull to identify the component in the list of scene components.
  35408. */
  35409. readonly name: string;
  35410. /**
  35411. * The scene the component belongs to.
  35412. */
  35413. scene: Scene;
  35414. /**
  35415. * Color of the bounding box lines placed in front of an object
  35416. */
  35417. frontColor: Color3;
  35418. /**
  35419. * Color of the bounding box lines placed behind an object
  35420. */
  35421. backColor: Color3;
  35422. /**
  35423. * Defines if the renderer should show the back lines or not
  35424. */
  35425. showBackLines: boolean;
  35426. /**
  35427. * @hidden
  35428. */
  35429. renderList: SmartArray<BoundingBox>;
  35430. private _colorShader;
  35431. private _vertexBuffers;
  35432. private _indexBuffer;
  35433. /**
  35434. * Instantiates a new bounding box renderer in a scene.
  35435. * @param scene the scene the renderer renders in
  35436. */
  35437. constructor(scene: Scene);
  35438. /**
  35439. * Registers the component in a given scene
  35440. */
  35441. register(): void;
  35442. private _evaluateSubMesh;
  35443. private _activeMesh;
  35444. private _prepareRessources;
  35445. private _createIndexBuffer;
  35446. /**
  35447. * Rebuilds the elements related to this component in case of
  35448. * context lost for instance.
  35449. */
  35450. rebuild(): void;
  35451. /**
  35452. * @hidden
  35453. */
  35454. reset(): void;
  35455. /**
  35456. * Render the bounding boxes of a specific rendering group
  35457. * @param renderingGroupId defines the rendering group to render
  35458. */
  35459. render(renderingGroupId: number): void;
  35460. /**
  35461. * In case of occlusion queries, we can render the occlusion bounding box through this method
  35462. * @param mesh Define the mesh to render the occlusion bounding box for
  35463. */
  35464. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  35465. /**
  35466. * Dispose and release the resources attached to this renderer.
  35467. */
  35468. dispose(): void;
  35469. }
  35470. }
  35471. declare module BABYLON {
  35472. /**
  35473. * This represents a depth renderer in Babylon.
  35474. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  35475. */
  35476. class DepthRenderer {
  35477. private _scene;
  35478. private _depthMap;
  35479. private _effect;
  35480. private _cachedDefines;
  35481. private _camera;
  35482. /**
  35483. * Specifiess that the depth renderer will only be used within
  35484. * the camera it is created for.
  35485. * This can help forcing its rendering during the camera processing.
  35486. */
  35487. useOnlyInActiveCamera: boolean;
  35488. /**
  35489. * Instantiates a depth renderer
  35490. * @param scene The scene the renderer belongs to
  35491. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  35492. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  35493. */
  35494. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  35495. /**
  35496. * Creates the depth rendering effect and checks if the effect is ready.
  35497. * @param subMesh The submesh to be used to render the depth map of
  35498. * @param useInstances If multiple world instances should be used
  35499. * @returns if the depth renderer is ready to render the depth map
  35500. */
  35501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35502. /**
  35503. * Gets the texture which the depth map will be written to.
  35504. * @returns The depth map texture
  35505. */
  35506. getDepthMap(): RenderTargetTexture;
  35507. /**
  35508. * Disposes of the depth renderer.
  35509. */
  35510. dispose(): void;
  35511. }
  35512. }
  35513. declare module BABYLON {
  35514. interface Scene {
  35515. /** @hidden (Backing field) */
  35516. _depthRenderer: {
  35517. [id: string]: DepthRenderer;
  35518. };
  35519. /**
  35520. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  35521. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  35522. * @returns the created depth renderer
  35523. */
  35524. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  35525. /**
  35526. * Disables a depth renderer for a given camera
  35527. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  35528. */
  35529. disableDepthRenderer(camera?: Nullable<Camera>): void;
  35530. }
  35531. /**
  35532. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  35533. * in several rendering techniques.
  35534. */
  35535. class DepthRendererSceneComponent implements ISceneComponent {
  35536. /**
  35537. * The component name helpfull to identify the component in the list of scene components.
  35538. */
  35539. readonly name: string;
  35540. /**
  35541. * The scene the component belongs to.
  35542. */
  35543. scene: Scene;
  35544. /**
  35545. * Creates a new instance of the component for the given scene
  35546. * @param scene Defines the scene to register the component in
  35547. */
  35548. constructor(scene: Scene);
  35549. /**
  35550. * Registers the component in a given scene
  35551. */
  35552. register(): void;
  35553. /**
  35554. * Rebuilds the elements related to this component in case of
  35555. * context lost for instance.
  35556. */
  35557. rebuild(): void;
  35558. /**
  35559. * Disposes the component and the associated ressources
  35560. */
  35561. dispose(): void;
  35562. private _gatherRenderTargets;
  35563. private _gatherActiveCameraRenderTargets;
  35564. }
  35565. }
  35566. declare module BABYLON {
  35567. interface AbstractMesh {
  35568. /**
  35569. * Disables the mesh edge rendering mode
  35570. * @returns the currentAbstractMesh
  35571. */
  35572. disableEdgesRendering(): AbstractMesh;
  35573. /**
  35574. * Enables the edge rendering mode on the mesh.
  35575. * This mode makes the mesh edges visible
  35576. * @param epsilon defines the maximal distance between two angles to detect a face
  35577. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35578. * @returns the currentAbstractMesh
  35579. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35580. */
  35581. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35582. /**
  35583. * Gets the edgesRenderer associated with the mesh
  35584. */
  35585. edgesRenderer: Nullable<EdgesRenderer>;
  35586. }
  35587. interface LinesMesh {
  35588. /**
  35589. * Enables the edge rendering mode on the mesh.
  35590. * This mode makes the mesh edges visible
  35591. * @param epsilon defines the maximal distance between two angles to detect a face
  35592. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35593. * @returns the currentAbstractMesh
  35594. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35595. */
  35596. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35597. }
  35598. /**
  35599. * Defines the minimum contract an Edges renderer should follow.
  35600. */
  35601. interface IEdgesRenderer extends IDisposable {
  35602. /**
  35603. * Gets or sets a boolean indicating if the edgesRenderer is active
  35604. */
  35605. isEnabled: boolean;
  35606. /**
  35607. * Renders the edges of the attached mesh,
  35608. */
  35609. render(): void;
  35610. /**
  35611. * Checks wether or not the edges renderer is ready to render.
  35612. * @return true if ready, otherwise false.
  35613. */
  35614. isReady(): boolean;
  35615. }
  35616. /**
  35617. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  35618. */
  35619. class EdgesRenderer implements IEdgesRenderer {
  35620. /**
  35621. * Define the size of the edges with an orthographic camera
  35622. */
  35623. edgesWidthScalerForOrthographic: number;
  35624. /**
  35625. * Define the size of the edges with a perspective camera
  35626. */
  35627. edgesWidthScalerForPerspective: number;
  35628. protected _source: AbstractMesh;
  35629. protected _linesPositions: number[];
  35630. protected _linesNormals: number[];
  35631. protected _linesIndices: number[];
  35632. protected _epsilon: number;
  35633. protected _indicesCount: number;
  35634. protected _lineShader: ShaderMaterial;
  35635. protected _ib: WebGLBuffer;
  35636. protected _buffers: {
  35637. [key: string]: Nullable<VertexBuffer>;
  35638. };
  35639. protected _checkVerticesInsteadOfIndices: boolean;
  35640. private _meshRebuildObserver;
  35641. private _meshDisposeObserver;
  35642. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  35643. isEnabled: boolean;
  35644. /**
  35645. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  35646. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  35647. * @param source Mesh used to create edges
  35648. * @param epsilon sum of angles in adjacency to check for edge
  35649. * @param checkVerticesInsteadOfIndices
  35650. * @param generateEdgesLines - should generate Lines or only prepare resources.
  35651. */
  35652. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  35653. protected _prepareRessources(): void;
  35654. /** @hidden */
  35655. _rebuild(): void;
  35656. /**
  35657. * Releases the required resources for the edges renderer
  35658. */
  35659. dispose(): void;
  35660. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  35661. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  35662. /**
  35663. * Checks if the pair of p0 and p1 is en edge
  35664. * @param faceIndex
  35665. * @param edge
  35666. * @param faceNormals
  35667. * @param p0
  35668. * @param p1
  35669. * @private
  35670. */
  35671. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35672. /**
  35673. * Generates lines edges from adjacencjes
  35674. * @private
  35675. */
  35676. _generateEdgesLines(): void;
  35677. /**
  35678. * Checks wether or not the edges renderer is ready to render.
  35679. * @return true if ready, otherwise false.
  35680. */
  35681. isReady(): boolean;
  35682. /**
  35683. * Renders the edges of the attached mesh,
  35684. */
  35685. render(): void;
  35686. }
  35687. }
  35688. declare module BABYLON {
  35689. /**
  35690. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  35691. */
  35692. class GeometryBufferRenderer {
  35693. /**
  35694. * Constant used to retrieve the position texture index in the G-Buffer textures array
  35695. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  35696. */
  35697. static readonly POSITION_TEXTURE_TYPE: number;
  35698. /**
  35699. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  35700. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  35701. */
  35702. static readonly VELOCITY_TEXTURE_TYPE: number;
  35703. /**
  35704. * Dictionary used to store the previous transformation matrices of each rendered mesh
  35705. * in order to compute objects velocities when enableVelocity is set to "true"
  35706. * @hidden
  35707. */
  35708. _previousTransformationMatrices: {
  35709. [index: number]: Matrix;
  35710. };
  35711. private _scene;
  35712. private _multiRenderTarget;
  35713. private _ratio;
  35714. private _enablePosition;
  35715. private _enableVelocity;
  35716. private _positionIndex;
  35717. private _velocityIndex;
  35718. protected _effect: Effect;
  35719. protected _cachedDefines: string;
  35720. /**
  35721. * Set the render list (meshes to be rendered) used in the G buffer.
  35722. */
  35723. renderList: Mesh[];
  35724. /**
  35725. * Gets wether or not G buffer are supported by the running hardware.
  35726. * This requires draw buffer supports
  35727. */
  35728. readonly isSupported: boolean;
  35729. /**
  35730. * Returns the index of the given texture type in the G-Buffer textures array
  35731. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  35732. * @returns the index of the given texture type in the G-Buffer textures array
  35733. */
  35734. getTextureIndex(textureType: number): number;
  35735. /**
  35736. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  35737. */
  35738. /**
  35739. * Sets whether or not objects positions are enabled for the G buffer.
  35740. */
  35741. enablePosition: boolean;
  35742. /**
  35743. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  35744. */
  35745. /**
  35746. * Sets wether or not objects velocities are enabled for the G buffer.
  35747. */
  35748. enableVelocity: boolean;
  35749. /**
  35750. * Gets the scene associated with the buffer.
  35751. */
  35752. readonly scene: Scene;
  35753. /**
  35754. * Gets the ratio used by the buffer during its creation.
  35755. * How big is the buffer related to the main canvas.
  35756. */
  35757. readonly ratio: number;
  35758. /**
  35759. * Creates a new G Buffer for the scene
  35760. * @param scene The scene the buffer belongs to
  35761. * @param ratio How big is the buffer related to the main canvas.
  35762. */
  35763. constructor(scene: Scene, ratio?: number);
  35764. /**
  35765. * Checks wether everything is ready to render a submesh to the G buffer.
  35766. * @param subMesh the submesh to check readiness for
  35767. * @param useInstances is the mesh drawn using instance or not
  35768. * @returns true if ready otherwise false
  35769. */
  35770. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35771. /**
  35772. * Gets the current underlying G Buffer.
  35773. * @returns the buffer
  35774. */
  35775. getGBuffer(): MultiRenderTarget;
  35776. /**
  35777. * Gets the number of samples used to render the buffer (anti aliasing).
  35778. */
  35779. /**
  35780. * Sets the number of samples used to render the buffer (anti aliasing).
  35781. */
  35782. samples: number;
  35783. /**
  35784. * Disposes the renderer and frees up associated resources.
  35785. */
  35786. dispose(): void;
  35787. protected _createRenderTargets(): void;
  35788. }
  35789. }
  35790. declare module BABYLON {
  35791. interface Scene {
  35792. /** @hidden (Backing field) */
  35793. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35794. /**
  35795. * Gets or Sets the current geometry buffer associated to the scene.
  35796. */
  35797. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  35798. /**
  35799. * Enables a GeometryBufferRender and associates it with the scene
  35800. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  35801. * @returns the GeometryBufferRenderer
  35802. */
  35803. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  35804. /**
  35805. * Disables the GeometryBufferRender associated with the scene
  35806. */
  35807. disableGeometryBufferRenderer(): void;
  35808. }
  35809. /**
  35810. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  35811. * in several rendering techniques.
  35812. */
  35813. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  35814. /**
  35815. * The component name helpful to identify the component in the list of scene components.
  35816. */
  35817. readonly name: string;
  35818. /**
  35819. * The scene the component belongs to.
  35820. */
  35821. scene: Scene;
  35822. /**
  35823. * Creates a new instance of the component for the given scene
  35824. * @param scene Defines the scene to register the component in
  35825. */
  35826. constructor(scene: Scene);
  35827. /**
  35828. * Registers the component in a given scene
  35829. */
  35830. register(): void;
  35831. /**
  35832. * Rebuilds the elements related to this component in case of
  35833. * context lost for instance.
  35834. */
  35835. rebuild(): void;
  35836. /**
  35837. * Disposes the component and the associated ressources
  35838. */
  35839. dispose(): void;
  35840. private _gatherRenderTargets;
  35841. }
  35842. }
  35843. declare module BABYLON {
  35844. /**
  35845. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  35846. */
  35847. class LineEdgesRenderer extends EdgesRenderer {
  35848. /**
  35849. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  35850. * @param source LineMesh used to generate edges
  35851. * @param epsilon not important (specified angle for edge detection)
  35852. * @param checkVerticesInsteadOfIndices not important for LineMesh
  35853. */
  35854. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  35855. /**
  35856. * Always create the edge since its a line so only important things are p0 and p1
  35857. * @param faceIndex not important for LineMesh
  35858. * @param edge not important for LineMesh
  35859. * @param faceNormals not important for LineMesh
  35860. * @param p0 beginnig of line
  35861. * @param p1 end of line
  35862. */
  35863. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  35864. /**
  35865. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  35866. */
  35867. _generateEdgesLines(): void;
  35868. }
  35869. }
  35870. declare module BABYLON {
  35871. interface Scene {
  35872. /** @hidden */
  35873. _outlineRenderer: OutlineRenderer;
  35874. /**
  35875. * Gets the outline renderer associated with the scene
  35876. * @returns a OutlineRenderer
  35877. */
  35878. getOutlineRenderer(): OutlineRenderer;
  35879. }
  35880. interface AbstractMesh {
  35881. /** @hidden (Backing field) */
  35882. _renderOutline: boolean;
  35883. /**
  35884. * Gets or sets a boolean indicating if the outline must be rendered as well
  35885. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  35886. */
  35887. renderOutline: boolean;
  35888. /** @hidden (Backing field) */
  35889. _renderOverlay: boolean;
  35890. /**
  35891. * Gets or sets a boolean indicating if the overlay must be rendered as well
  35892. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  35893. */
  35894. renderOverlay: boolean;
  35895. }
  35896. /**
  35897. * This class is responsible to draw bothe outline/overlay of meshes.
  35898. * It should not be used directly but through the available method on mesh.
  35899. */
  35900. class OutlineRenderer implements ISceneComponent {
  35901. /**
  35902. * The name of the component. Each component must have a unique name.
  35903. */
  35904. name: string;
  35905. /**
  35906. * The scene the component belongs to.
  35907. */
  35908. scene: Scene;
  35909. /**
  35910. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  35911. */
  35912. zOffset: number;
  35913. private _engine;
  35914. private _effect;
  35915. private _cachedDefines;
  35916. private _savedDepthWrite;
  35917. /**
  35918. * Instantiates a new outline renderer. (There could be only one per scene).
  35919. * @param scene Defines the scene it belongs to
  35920. */
  35921. constructor(scene: Scene);
  35922. /**
  35923. * Register the component to one instance of a scene.
  35924. */
  35925. register(): void;
  35926. /**
  35927. * Rebuilds the elements related to this component in case of
  35928. * context lost for instance.
  35929. */
  35930. rebuild(): void;
  35931. /**
  35932. * Disposes the component and the associated ressources.
  35933. */
  35934. dispose(): void;
  35935. /**
  35936. * Renders the outline in the canvas.
  35937. * @param subMesh Defines the sumesh to render
  35938. * @param batch Defines the batch of meshes in case of instances
  35939. * @param useOverlay Defines if the rendering is for the overlay or the outline
  35940. */
  35941. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  35942. /**
  35943. * Returns whether or not the outline renderer is ready for a given submesh.
  35944. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  35945. * @param subMesh Defines the submesh to check readyness for
  35946. * @param useInstances Defines wheter wee are trying to render instances or not
  35947. * @returns true if ready otherwise false
  35948. */
  35949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  35950. private _beforeRenderingMesh;
  35951. private _afterRenderingMesh;
  35952. }
  35953. }
  35954. declare module BABYLON {
  35955. /**
  35956. * This represents the object necessary to create a rendering group.
  35957. * This is exclusively used and created by the rendering manager.
  35958. * To modify the behavior, you use the available helpers in your scene or meshes.
  35959. * @hidden
  35960. */
  35961. class RenderingGroup {
  35962. index: number;
  35963. private _scene;
  35964. private _opaqueSubMeshes;
  35965. private _transparentSubMeshes;
  35966. private _alphaTestSubMeshes;
  35967. private _depthOnlySubMeshes;
  35968. private _particleSystems;
  35969. private _spriteManagers;
  35970. private _opaqueSortCompareFn;
  35971. private _alphaTestSortCompareFn;
  35972. private _transparentSortCompareFn;
  35973. private _renderOpaque;
  35974. private _renderAlphaTest;
  35975. private _renderTransparent;
  35976. private _edgesRenderers;
  35977. onBeforeTransparentRendering: () => void;
  35978. /**
  35979. * Set the opaque sort comparison function.
  35980. * If null the sub meshes will be render in the order they were created
  35981. */
  35982. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35983. /**
  35984. * Set the alpha test sort comparison function.
  35985. * If null the sub meshes will be render in the order they were created
  35986. */
  35987. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35988. /**
  35989. * Set the transparent sort comparison function.
  35990. * If null the sub meshes will be render in the order they were created
  35991. */
  35992. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  35993. /**
  35994. * Creates a new rendering group.
  35995. * @param index The rendering group index
  35996. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  35997. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  35998. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  35999. */
  36000. 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>);
  36001. /**
  36002. * Render all the sub meshes contained in the group.
  36003. * @param customRenderFunction Used to override the default render behaviour of the group.
  36004. * @returns true if rendered some submeshes.
  36005. */
  36006. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36007. /**
  36008. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36009. * @param subMeshes The submeshes to render
  36010. */
  36011. private renderOpaqueSorted;
  36012. /**
  36013. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36014. * @param subMeshes The submeshes to render
  36015. */
  36016. private renderAlphaTestSorted;
  36017. /**
  36018. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36019. * @param subMeshes The submeshes to render
  36020. */
  36021. private renderTransparentSorted;
  36022. /**
  36023. * Renders the submeshes in a specified order.
  36024. * @param subMeshes The submeshes to sort before render
  36025. * @param sortCompareFn The comparison function use to sort
  36026. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36027. * @param transparent Specifies to activate blending if true
  36028. */
  36029. private static renderSorted;
  36030. /**
  36031. * Renders the submeshes in the order they were dispatched (no sort applied).
  36032. * @param subMeshes The submeshes to render
  36033. */
  36034. private static renderUnsorted;
  36035. /**
  36036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36037. * are rendered back to front if in the same alpha index.
  36038. *
  36039. * @param a The first submesh
  36040. * @param b The second submesh
  36041. * @returns The result of the comparison
  36042. */
  36043. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36044. /**
  36045. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36046. * are rendered back to front.
  36047. *
  36048. * @param a The first submesh
  36049. * @param b The second submesh
  36050. * @returns The result of the comparison
  36051. */
  36052. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36053. /**
  36054. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36055. * are rendered front to back (prevent overdraw).
  36056. *
  36057. * @param a The first submesh
  36058. * @param b The second submesh
  36059. * @returns The result of the comparison
  36060. */
  36061. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36062. /**
  36063. * Resets the different lists of submeshes to prepare a new frame.
  36064. */
  36065. prepare(): void;
  36066. dispose(): void;
  36067. /**
  36068. * Inserts the submesh in its correct queue depending on its material.
  36069. * @param subMesh The submesh to dispatch
  36070. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36071. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36072. */
  36073. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36074. dispatchSprites(spriteManager: ISpriteManager): void;
  36075. dispatchParticles(particleSystem: IParticleSystem): void;
  36076. private _renderParticles;
  36077. private _renderSprites;
  36078. }
  36079. }
  36080. declare module BABYLON {
  36081. /**
  36082. * Interface describing the different options available in the rendering manager
  36083. * regarding Auto Clear between groups.
  36084. */
  36085. interface IRenderingManagerAutoClearSetup {
  36086. /**
  36087. * Defines whether or not autoclear is enable.
  36088. */
  36089. autoClear: boolean;
  36090. /**
  36091. * Defines whether or not to autoclear the depth buffer.
  36092. */
  36093. depth: boolean;
  36094. /**
  36095. * Defines whether or not to autoclear the stencil buffer.
  36096. */
  36097. stencil: boolean;
  36098. }
  36099. /**
  36100. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36101. * It is enable to manage the different groups as well as the different necessary sort functions.
  36102. * This should not be used directly aside of the few static configurations
  36103. */
  36104. class RenderingManager {
  36105. /**
  36106. * The max id used for rendering groups (not included)
  36107. */
  36108. static MAX_RENDERINGGROUPS: number;
  36109. /**
  36110. * The min id used for rendering groups (included)
  36111. */
  36112. static MIN_RENDERINGGROUPS: number;
  36113. /**
  36114. * Used to globally prevent autoclearing scenes.
  36115. */
  36116. static AUTOCLEAR: boolean;
  36117. /**
  36118. * @hidden
  36119. */
  36120. _useSceneAutoClearSetup: boolean;
  36121. private _scene;
  36122. private _renderingGroups;
  36123. private _depthStencilBufferAlreadyCleaned;
  36124. private _autoClearDepthStencil;
  36125. private _customOpaqueSortCompareFn;
  36126. private _customAlphaTestSortCompareFn;
  36127. private _customTransparentSortCompareFn;
  36128. private _renderingGroupInfo;
  36129. /**
  36130. * Instantiates a new rendering group for a particular scene
  36131. * @param scene Defines the scene the groups belongs to
  36132. */
  36133. constructor(scene: Scene);
  36134. private _clearDepthStencilBuffer;
  36135. /**
  36136. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36137. * @hidden
  36138. */
  36139. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36140. /**
  36141. * Resets the different information of the group to prepare a new frame
  36142. * @hidden
  36143. */
  36144. reset(): void;
  36145. /**
  36146. * Dispose and release the group and its associated resources.
  36147. * @hidden
  36148. */
  36149. dispose(): void;
  36150. /**
  36151. * Clear the info related to rendering groups preventing retention points during dispose.
  36152. */
  36153. freeRenderingGroups(): void;
  36154. private _prepareRenderingGroup;
  36155. /**
  36156. * Add a sprite manager to the rendering manager in order to render it this frame.
  36157. * @param spriteManager Define the sprite manager to render
  36158. */
  36159. dispatchSprites(spriteManager: ISpriteManager): void;
  36160. /**
  36161. * Add a particle system to the rendering manager in order to render it this frame.
  36162. * @param particleSystem Define the particle system to render
  36163. */
  36164. dispatchParticles(particleSystem: IParticleSystem): void;
  36165. /**
  36166. * Add a submesh to the manager in order to render it this frame
  36167. * @param subMesh The submesh to dispatch
  36168. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36169. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36170. */
  36171. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36172. /**
  36173. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36174. * This allowed control for front to back rendering or reversly depending of the special needs.
  36175. *
  36176. * @param renderingGroupId The rendering group id corresponding to its index
  36177. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36178. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36179. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36180. */
  36181. 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;
  36182. /**
  36183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36184. *
  36185. * @param renderingGroupId The rendering group id corresponding to its index
  36186. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36187. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36188. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36189. */
  36190. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36191. /**
  36192. * Gets the current auto clear configuration for one rendering group of the rendering
  36193. * manager.
  36194. * @param index the rendering group index to get the information for
  36195. * @returns The auto clear setup for the requested rendering group
  36196. */
  36197. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36198. }
  36199. }
  36200. declare module BABYLON {
  36201. /**
  36202. * Renders a layer on top of an existing scene
  36203. */
  36204. class UtilityLayerRenderer implements IDisposable {
  36205. /** the original scene that will be rendered on top of */
  36206. originalScene: Scene;
  36207. private _pointerCaptures;
  36208. private _lastPointerEvents;
  36209. private static _DefaultUtilityLayer;
  36210. private static _DefaultKeepDepthUtilityLayer;
  36211. /**
  36212. * 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)
  36213. */
  36214. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36215. /**
  36216. * 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)
  36217. */
  36218. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36219. /**
  36220. * The scene that is rendered on top of the original scene
  36221. */
  36222. utilityLayerScene: Scene;
  36223. /**
  36224. * If the utility layer should automatically be rendered on top of existing scene
  36225. */
  36226. shouldRender: boolean;
  36227. /**
  36228. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36229. */
  36230. onlyCheckPointerDownEvents: boolean;
  36231. /**
  36232. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36233. */
  36234. processAllEvents: boolean;
  36235. /**
  36236. * Observable raised when the pointer move from the utility layer scene to the main scene
  36237. */
  36238. onPointerOutObservable: Observable<number>;
  36239. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36240. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36241. private _afterRenderObserver;
  36242. private _sceneDisposeObserver;
  36243. private _originalPointerObserver;
  36244. /**
  36245. * Instantiates a UtilityLayerRenderer
  36246. * @param originalScene the original scene that will be rendered on top of
  36247. */
  36248. constructor(
  36249. /** the original scene that will be rendered on top of */
  36250. originalScene: Scene);
  36251. private _notifyObservers;
  36252. /**
  36253. * Renders the utility layers scene on top of the original scene
  36254. */
  36255. render(): void;
  36256. /**
  36257. * Disposes of the renderer
  36258. */
  36259. dispose(): void;
  36260. private _updateCamera;
  36261. }
  36262. }
  36263. declare module BABYLON {
  36264. /**
  36265. * Class used to represent a sprite
  36266. * @see http://doc.babylonjs.com/babylon101/sprites
  36267. */
  36268. class Sprite {
  36269. /** defines the name */
  36270. name: string;
  36271. /** Gets or sets the current world position */
  36272. position: Vector3;
  36273. /** Gets or sets the main color */
  36274. color: Color4;
  36275. /** Gets or sets the width */
  36276. width: number;
  36277. /** Gets or sets the height */
  36278. height: number;
  36279. /** Gets or sets rotation angle */
  36280. angle: number;
  36281. /** Gets or sets the cell index in the sprite sheet */
  36282. cellIndex: number;
  36283. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36284. invertU: number;
  36285. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36286. invertV: number;
  36287. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36288. disposeWhenFinishedAnimating: boolean;
  36289. /** Gets the list of attached animations */
  36290. animations: Animation[];
  36291. /** Gets or sets a boolean indicating if the sprite can be picked */
  36292. isPickable: boolean;
  36293. /**
  36294. * Gets or sets the associated action manager
  36295. */
  36296. actionManager: Nullable<ActionManager>;
  36297. private _animationStarted;
  36298. private _loopAnimation;
  36299. private _fromIndex;
  36300. private _toIndex;
  36301. private _delay;
  36302. private _direction;
  36303. private _manager;
  36304. private _time;
  36305. private _onAnimationEnd;
  36306. /**
  36307. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36308. */
  36309. isVisible: boolean;
  36310. /**
  36311. * Gets or sets the sprite size
  36312. */
  36313. size: number;
  36314. /**
  36315. * Creates a new Sprite
  36316. * @param name defines the name
  36317. * @param manager defines the manager
  36318. */
  36319. constructor(
  36320. /** defines the name */
  36321. name: string, manager: ISpriteManager);
  36322. /**
  36323. * Starts an animation
  36324. * @param from defines the initial key
  36325. * @param to defines the end key
  36326. * @param loop defines if the animation must loop
  36327. * @param delay defines the start delay (in ms)
  36328. * @param onAnimationEnd defines a callback to call when animation ends
  36329. */
  36330. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36331. /** Stops current animation (if any) */
  36332. stopAnimation(): void;
  36333. /** @hidden */
  36334. _animate(deltaTime: number): void;
  36335. /** Release associated resources */
  36336. dispose(): void;
  36337. }
  36338. }
  36339. declare module BABYLON {
  36340. /**
  36341. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36342. */
  36343. interface ISpriteManager extends IDisposable {
  36344. /**
  36345. * Restricts the camera to viewing objects with the same layerMask.
  36346. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36347. */
  36348. layerMask: number;
  36349. /**
  36350. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36351. */
  36352. isPickable: boolean;
  36353. /**
  36354. * Specifies the rendering group id for this mesh (0 by default)
  36355. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36356. */
  36357. renderingGroupId: number;
  36358. /**
  36359. * Defines the list of sprites managed by the manager.
  36360. */
  36361. sprites: Array<Sprite>;
  36362. /**
  36363. * Tests the intersection of a sprite with a specific ray.
  36364. * @param ray The ray we are sending to test the collision
  36365. * @param camera The camera space we are sending rays in
  36366. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36367. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36368. * @returns picking info or null.
  36369. */
  36370. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36371. /**
  36372. * Renders the list of sprites on screen.
  36373. */
  36374. render(): void;
  36375. }
  36376. /**
  36377. * Class used to manage multiple sprites on the same spritesheet
  36378. * @see http://doc.babylonjs.com/babylon101/sprites
  36379. */
  36380. class SpriteManager implements ISpriteManager {
  36381. /** defines the manager's name */
  36382. name: string;
  36383. /** Gets the list of sprites */
  36384. sprites: Sprite[];
  36385. /** Gets or sets the rendering group id (0 by default) */
  36386. renderingGroupId: number;
  36387. /** Gets or sets camera layer mask */
  36388. layerMask: number;
  36389. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36390. fogEnabled: boolean;
  36391. /** Gets or sets a boolean indicating if the sprites are pickable */
  36392. isPickable: boolean;
  36393. /** Defines the default width of a cell in the spritesheet */
  36394. cellWidth: number;
  36395. /** Defines the default height of a cell in the spritesheet */
  36396. cellHeight: number;
  36397. /**
  36398. * An event triggered when the manager is disposed.
  36399. */
  36400. onDisposeObservable: Observable<SpriteManager>;
  36401. private _onDisposeObserver;
  36402. /**
  36403. * Callback called when the manager is disposed
  36404. */
  36405. onDispose: () => void;
  36406. private _capacity;
  36407. private _spriteTexture;
  36408. private _epsilon;
  36409. private _scene;
  36410. private _vertexData;
  36411. private _buffer;
  36412. private _vertexBuffers;
  36413. private _indexBuffer;
  36414. private _effectBase;
  36415. private _effectFog;
  36416. /**
  36417. * Gets or sets the spritesheet texture
  36418. */
  36419. texture: Texture;
  36420. /**
  36421. * Creates a new sprite manager
  36422. * @param name defines the manager's name
  36423. * @param imgUrl defines the sprite sheet url
  36424. * @param capacity defines the maximum allowed number of sprites
  36425. * @param cellSize defines the size of a sprite cell
  36426. * @param scene defines the hosting scene
  36427. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36428. * @param samplingMode defines the smapling mode to use with spritesheet
  36429. */
  36430. constructor(
  36431. /** defines the manager's name */
  36432. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36433. private _appendSpriteVertex;
  36434. /**
  36435. * Intersects the sprites with a ray
  36436. * @param ray defines the ray to intersect with
  36437. * @param camera defines the current active camera
  36438. * @param predicate defines a predicate used to select candidate sprites
  36439. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36440. * @returns null if no hit or a PickingInfo
  36441. */
  36442. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36443. /**
  36444. * Render all child sprites
  36445. */
  36446. render(): void;
  36447. /**
  36448. * Release associated resources
  36449. */
  36450. dispose(): void;
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. interface Scene {
  36455. /** @hidden */
  36456. _pointerOverSprite: Nullable<Sprite>;
  36457. /** @hidden */
  36458. _pickedDownSprite: Nullable<Sprite>;
  36459. /** @hidden */
  36460. _tempSpritePickingRay: Nullable<Ray>;
  36461. /**
  36462. * All of the sprite managers added to this scene
  36463. * @see http://doc.babylonjs.com/babylon101/sprites
  36464. */
  36465. spriteManagers: Array<ISpriteManager>;
  36466. /**
  36467. * An event triggered when sprites rendering is about to start
  36468. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36469. */
  36470. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36471. /**
  36472. * An event triggered when sprites rendering is done
  36473. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36474. */
  36475. onAfterSpritesRenderingObservable: Observable<Scene>;
  36476. /** @hidden */
  36477. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36478. /** Launch a ray to try to pick a sprite in the scene
  36479. * @param x position on screen
  36480. * @param y position on screen
  36481. * @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
  36482. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36483. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36484. * @returns a PickingInfo
  36485. */
  36486. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36487. /** Use the given ray to pick a sprite in the scene
  36488. * @param ray The ray (in world space) to use to pick meshes
  36489. * @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
  36490. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36491. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36492. * @returns a PickingInfo
  36493. */
  36494. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36495. /**
  36496. * Force the sprite under the pointer
  36497. * @param sprite defines the sprite to use
  36498. */
  36499. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36500. /**
  36501. * Gets the sprite under the pointer
  36502. * @returns a Sprite or null if no sprite is under the pointer
  36503. */
  36504. getPointerOverSprite(): Nullable<Sprite>;
  36505. }
  36506. /**
  36507. * Defines the sprite scene component responsible to manage sprites
  36508. * in a given scene.
  36509. */
  36510. class SpriteSceneComponent implements ISceneComponent {
  36511. /**
  36512. * The component name helpfull to identify the component in the list of scene components.
  36513. */
  36514. readonly name: string;
  36515. /**
  36516. * The scene the component belongs to.
  36517. */
  36518. scene: Scene;
  36519. /** @hidden */
  36520. private _spritePredicate;
  36521. /**
  36522. * Creates a new instance of the component for the given scene
  36523. * @param scene Defines the scene to register the component in
  36524. */
  36525. constructor(scene: Scene);
  36526. /**
  36527. * Registers the component in a given scene
  36528. */
  36529. register(): void;
  36530. /**
  36531. * Rebuilds the elements related to this component in case of
  36532. * context lost for instance.
  36533. */
  36534. rebuild(): void;
  36535. /**
  36536. * Disposes the component and the associated ressources.
  36537. */
  36538. dispose(): void;
  36539. private _pickSpriteButKeepRay;
  36540. private _pointerMove;
  36541. private _pointerDown;
  36542. private _pointerUp;
  36543. }
  36544. }
  36545. declare module BABYLON {
  36546. /**
  36547. * @hidden
  36548. **/
  36549. class _AlphaState {
  36550. private _isAlphaBlendDirty;
  36551. private _isBlendFunctionParametersDirty;
  36552. private _isBlendEquationParametersDirty;
  36553. private _isBlendConstantsDirty;
  36554. private _alphaBlend;
  36555. private _blendFunctionParameters;
  36556. private _blendEquationParameters;
  36557. private _blendConstants;
  36558. /**
  36559. * Initializes the state.
  36560. */
  36561. constructor();
  36562. readonly isDirty: boolean;
  36563. alphaBlend: boolean;
  36564. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36565. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36566. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36567. reset(): void;
  36568. apply(gl: WebGLRenderingContext): void;
  36569. }
  36570. }
  36571. declare module BABYLON {
  36572. /**
  36573. * @hidden
  36574. **/
  36575. class _DepthCullingState {
  36576. private _isDepthTestDirty;
  36577. private _isDepthMaskDirty;
  36578. private _isDepthFuncDirty;
  36579. private _isCullFaceDirty;
  36580. private _isCullDirty;
  36581. private _isZOffsetDirty;
  36582. private _isFrontFaceDirty;
  36583. private _depthTest;
  36584. private _depthMask;
  36585. private _depthFunc;
  36586. private _cull;
  36587. private _cullFace;
  36588. private _zOffset;
  36589. private _frontFace;
  36590. /**
  36591. * Initializes the state.
  36592. */
  36593. constructor();
  36594. readonly isDirty: boolean;
  36595. zOffset: number;
  36596. cullFace: Nullable<number>;
  36597. cull: Nullable<boolean>;
  36598. depthFunc: Nullable<number>;
  36599. depthMask: boolean;
  36600. depthTest: boolean;
  36601. frontFace: Nullable<number>;
  36602. reset(): void;
  36603. apply(gl: WebGLRenderingContext): void;
  36604. }
  36605. }
  36606. declare module BABYLON {
  36607. /**
  36608. * @hidden
  36609. **/
  36610. class _StencilState {
  36611. private _isStencilTestDirty;
  36612. private _isStencilMaskDirty;
  36613. private _isStencilFuncDirty;
  36614. private _isStencilOpDirty;
  36615. private _stencilTest;
  36616. private _stencilMask;
  36617. private _stencilFunc;
  36618. private _stencilFuncRef;
  36619. private _stencilFuncMask;
  36620. private _stencilOpStencilFail;
  36621. private _stencilOpDepthFail;
  36622. private _stencilOpStencilDepthPass;
  36623. readonly isDirty: boolean;
  36624. stencilFunc: number;
  36625. stencilFuncRef: number;
  36626. stencilFuncMask: number;
  36627. stencilOpStencilFail: number;
  36628. stencilOpDepthFail: number;
  36629. stencilOpStencilDepthPass: number;
  36630. stencilMask: number;
  36631. stencilTest: boolean;
  36632. constructor();
  36633. reset(): void;
  36634. apply(gl: WebGLRenderingContext): void;
  36635. }
  36636. }
  36637. declare module BABYLON {
  36638. /**
  36639. * Class used to evalaute queries containing `and` and `or` operators
  36640. */
  36641. class AndOrNotEvaluator {
  36642. /**
  36643. * Evaluate a query
  36644. * @param query defines the query to evaluate
  36645. * @param evaluateCallback defines the callback used to filter result
  36646. * @returns true if the query matches
  36647. */
  36648. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  36649. private static _HandleParenthesisContent;
  36650. private static _SimplifyNegation;
  36651. }
  36652. }
  36653. declare module BABYLON {
  36654. /**
  36655. * Defines the list of states available for a task inside a AssetsManager
  36656. */
  36657. enum AssetTaskState {
  36658. /**
  36659. * Initialization
  36660. */
  36661. INIT = 0,
  36662. /**
  36663. * Running
  36664. */
  36665. RUNNING = 1,
  36666. /**
  36667. * Done
  36668. */
  36669. DONE = 2,
  36670. /**
  36671. * Error
  36672. */
  36673. ERROR = 3
  36674. }
  36675. /**
  36676. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  36677. */
  36678. abstract class AbstractAssetTask {
  36679. /**
  36680. * Task name
  36681. */ name: string;
  36682. /**
  36683. * Callback called when the task is successful
  36684. */
  36685. onSuccess: (task: any) => void;
  36686. /**
  36687. * Callback called when the task is not successful
  36688. */
  36689. onError: (task: any, message?: string, exception?: any) => void;
  36690. /**
  36691. * Creates a new AssetsManager
  36692. * @param name defines the name of the task
  36693. */
  36694. constructor(
  36695. /**
  36696. * Task name
  36697. */ name: string);
  36698. private _isCompleted;
  36699. private _taskState;
  36700. private _errorObject;
  36701. /**
  36702. * Get if the task is completed
  36703. */
  36704. readonly isCompleted: boolean;
  36705. /**
  36706. * Gets the current state of the task
  36707. */
  36708. readonly taskState: AssetTaskState;
  36709. /**
  36710. * Gets the current error object (if task is in error)
  36711. */
  36712. readonly errorObject: {
  36713. message?: string;
  36714. exception?: any;
  36715. };
  36716. /**
  36717. * Internal only
  36718. * @hidden
  36719. */
  36720. _setErrorObject(message?: string, exception?: any): void;
  36721. /**
  36722. * Execute the current task
  36723. * @param scene defines the scene where you want your assets to be loaded
  36724. * @param onSuccess is a callback called when the task is successfully executed
  36725. * @param onError is a callback called if an error occurs
  36726. */
  36727. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36728. /**
  36729. * Execute the current task
  36730. * @param scene defines the scene where you want your assets to be loaded
  36731. * @param onSuccess is a callback called when the task is successfully executed
  36732. * @param onError is a callback called if an error occurs
  36733. */
  36734. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36735. /**
  36736. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  36737. * This can be used with failed tasks that have the reason for failure fixed.
  36738. */
  36739. reset(): void;
  36740. private onErrorCallback;
  36741. private onDoneCallback;
  36742. }
  36743. /**
  36744. * Define the interface used by progress events raised during assets loading
  36745. */
  36746. interface IAssetsProgressEvent {
  36747. /**
  36748. * Defines the number of remaining tasks to process
  36749. */
  36750. remainingCount: number;
  36751. /**
  36752. * Defines the total number of tasks
  36753. */
  36754. totalCount: number;
  36755. /**
  36756. * Defines the task that was just processed
  36757. */
  36758. task: AbstractAssetTask;
  36759. }
  36760. /**
  36761. * Class used to share progress information about assets loading
  36762. */
  36763. class AssetsProgressEvent implements IAssetsProgressEvent {
  36764. /**
  36765. * Defines the number of remaining tasks to process
  36766. */
  36767. remainingCount: number;
  36768. /**
  36769. * Defines the total number of tasks
  36770. */
  36771. totalCount: number;
  36772. /**
  36773. * Defines the task that was just processed
  36774. */
  36775. task: AbstractAssetTask;
  36776. /**
  36777. * Creates a AssetsProgressEvent
  36778. * @param remainingCount defines the number of remaining tasks to process
  36779. * @param totalCount defines the total number of tasks
  36780. * @param task defines the task that was just processed
  36781. */
  36782. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  36783. }
  36784. /**
  36785. * Define a task used by AssetsManager to load meshes
  36786. */
  36787. class MeshAssetTask extends AbstractAssetTask {
  36788. /**
  36789. * Defines the name of the task
  36790. */
  36791. name: string;
  36792. /**
  36793. * Defines the list of mesh's names you want to load
  36794. */
  36795. meshesNames: any;
  36796. /**
  36797. * Defines the root url to use as a base to load your meshes and associated resources
  36798. */
  36799. rootUrl: string;
  36800. /**
  36801. * Defines the filename of the scene to load from
  36802. */
  36803. sceneFilename: string;
  36804. /**
  36805. * Gets the list of loaded meshes
  36806. */
  36807. loadedMeshes: Array<AbstractMesh>;
  36808. /**
  36809. * Gets the list of loaded particle systems
  36810. */
  36811. loadedParticleSystems: Array<IParticleSystem>;
  36812. /**
  36813. * Gets the list of loaded skeletons
  36814. */
  36815. loadedSkeletons: Array<Skeleton>;
  36816. /**
  36817. * Callback called when the task is successful
  36818. */
  36819. onSuccess: (task: MeshAssetTask) => void;
  36820. /**
  36821. * Callback called when the task is successful
  36822. */
  36823. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  36824. /**
  36825. * Creates a new MeshAssetTask
  36826. * @param name defines the name of the task
  36827. * @param meshesNames defines the list of mesh's names you want to load
  36828. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  36829. * @param sceneFilename defines the filename of the scene to load from
  36830. */
  36831. constructor(
  36832. /**
  36833. * Defines the name of the task
  36834. */
  36835. name: string,
  36836. /**
  36837. * Defines the list of mesh's names you want to load
  36838. */
  36839. meshesNames: any,
  36840. /**
  36841. * Defines the root url to use as a base to load your meshes and associated resources
  36842. */
  36843. rootUrl: string,
  36844. /**
  36845. * Defines the filename of the scene to load from
  36846. */
  36847. sceneFilename: string);
  36848. /**
  36849. * Execute the current task
  36850. * @param scene defines the scene where you want your assets to be loaded
  36851. * @param onSuccess is a callback called when the task is successfully executed
  36852. * @param onError is a callback called if an error occurs
  36853. */
  36854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36855. }
  36856. /**
  36857. * Define a task used by AssetsManager to load text content
  36858. */
  36859. class TextFileAssetTask extends AbstractAssetTask {
  36860. /**
  36861. * Defines the name of the task
  36862. */
  36863. name: string;
  36864. /**
  36865. * Defines the location of the file to load
  36866. */
  36867. url: string;
  36868. /**
  36869. * Gets the loaded text string
  36870. */
  36871. text: string;
  36872. /**
  36873. * Callback called when the task is successful
  36874. */
  36875. onSuccess: (task: TextFileAssetTask) => void;
  36876. /**
  36877. * Callback called when the task is successful
  36878. */
  36879. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  36880. /**
  36881. * Creates a new TextFileAssetTask object
  36882. * @param name defines the name of the task
  36883. * @param url defines the location of the file to load
  36884. */
  36885. constructor(
  36886. /**
  36887. * Defines the name of the task
  36888. */
  36889. name: string,
  36890. /**
  36891. * Defines the location of the file to load
  36892. */
  36893. url: string);
  36894. /**
  36895. * Execute the current task
  36896. * @param scene defines the scene where you want your assets to be loaded
  36897. * @param onSuccess is a callback called when the task is successfully executed
  36898. * @param onError is a callback called if an error occurs
  36899. */
  36900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36901. }
  36902. /**
  36903. * Define a task used by AssetsManager to load binary data
  36904. */
  36905. class BinaryFileAssetTask extends AbstractAssetTask {
  36906. /**
  36907. * Defines the name of the task
  36908. */
  36909. name: string;
  36910. /**
  36911. * Defines the location of the file to load
  36912. */
  36913. url: string;
  36914. /**
  36915. * Gets the lodaded data (as an array buffer)
  36916. */
  36917. data: ArrayBuffer;
  36918. /**
  36919. * Callback called when the task is successful
  36920. */
  36921. onSuccess: (task: BinaryFileAssetTask) => void;
  36922. /**
  36923. * Callback called when the task is successful
  36924. */
  36925. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  36926. /**
  36927. * Creates a new BinaryFileAssetTask object
  36928. * @param name defines the name of the new task
  36929. * @param url defines the location of the file to load
  36930. */
  36931. constructor(
  36932. /**
  36933. * Defines the name of the task
  36934. */
  36935. name: string,
  36936. /**
  36937. * Defines the location of the file to load
  36938. */
  36939. url: string);
  36940. /**
  36941. * Execute the current task
  36942. * @param scene defines the scene where you want your assets to be loaded
  36943. * @param onSuccess is a callback called when the task is successfully executed
  36944. * @param onError is a callback called if an error occurs
  36945. */
  36946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36947. }
  36948. /**
  36949. * Define a task used by AssetsManager to load images
  36950. */
  36951. class ImageAssetTask extends AbstractAssetTask {
  36952. /**
  36953. * Defines the name of the task
  36954. */
  36955. name: string;
  36956. /**
  36957. * Defines the location of the image to load
  36958. */
  36959. url: string;
  36960. /**
  36961. * Gets the loaded images
  36962. */
  36963. image: HTMLImageElement;
  36964. /**
  36965. * Callback called when the task is successful
  36966. */
  36967. onSuccess: (task: ImageAssetTask) => void;
  36968. /**
  36969. * Callback called when the task is successful
  36970. */
  36971. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  36972. /**
  36973. * Creates a new ImageAssetTask
  36974. * @param name defines the name of the task
  36975. * @param url defines the location of the image to load
  36976. */
  36977. constructor(
  36978. /**
  36979. * Defines the name of the task
  36980. */
  36981. name: string,
  36982. /**
  36983. * Defines the location of the image to load
  36984. */
  36985. url: string);
  36986. /**
  36987. * Execute the current task
  36988. * @param scene defines the scene where you want your assets to be loaded
  36989. * @param onSuccess is a callback called when the task is successfully executed
  36990. * @param onError is a callback called if an error occurs
  36991. */
  36992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  36993. }
  36994. /**
  36995. * Defines the interface used by texture loading tasks
  36996. */
  36997. interface ITextureAssetTask<TEX extends BaseTexture> {
  36998. /**
  36999. * Gets the loaded texture
  37000. */
  37001. texture: TEX;
  37002. }
  37003. /**
  37004. * Define a task used by AssetsManager to load 2D textures
  37005. */
  37006. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37007. /**
  37008. * Defines the name of the task
  37009. */
  37010. name: string;
  37011. /**
  37012. * Defines the location of the file to load
  37013. */
  37014. url: string;
  37015. /**
  37016. * Defines if mipmap should not be generated (default is false)
  37017. */
  37018. noMipmap?: boolean | undefined;
  37019. /**
  37020. * Defines if texture must be inverted on Y axis (default is false)
  37021. */
  37022. invertY?: boolean | undefined;
  37023. /**
  37024. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37025. */
  37026. samplingMode: number;
  37027. /**
  37028. * Gets the loaded texture
  37029. */
  37030. texture: Texture;
  37031. /**
  37032. * Callback called when the task is successful
  37033. */
  37034. onSuccess: (task: TextureAssetTask) => void;
  37035. /**
  37036. * Callback called when the task is successful
  37037. */
  37038. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37039. /**
  37040. * Creates a new TextureAssetTask object
  37041. * @param name defines the name of the task
  37042. * @param url defines the location of the file to load
  37043. * @param noMipmap defines if mipmap should not be generated (default is false)
  37044. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37045. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37046. */
  37047. constructor(
  37048. /**
  37049. * Defines the name of the task
  37050. */
  37051. name: string,
  37052. /**
  37053. * Defines the location of the file to load
  37054. */
  37055. url: string,
  37056. /**
  37057. * Defines if mipmap should not be generated (default is false)
  37058. */
  37059. noMipmap?: boolean | undefined,
  37060. /**
  37061. * Defines if texture must be inverted on Y axis (default is false)
  37062. */
  37063. invertY?: boolean | undefined,
  37064. /**
  37065. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37066. */
  37067. samplingMode?: number);
  37068. /**
  37069. * Execute the current task
  37070. * @param scene defines the scene where you want your assets to be loaded
  37071. * @param onSuccess is a callback called when the task is successfully executed
  37072. * @param onError is a callback called if an error occurs
  37073. */
  37074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37075. }
  37076. /**
  37077. * Define a task used by AssetsManager to load cube textures
  37078. */
  37079. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37080. /**
  37081. * Defines the name of the task
  37082. */
  37083. name: string;
  37084. /**
  37085. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37086. */
  37087. url: string;
  37088. /**
  37089. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37090. */
  37091. extensions?: string[] | undefined;
  37092. /**
  37093. * Defines if mipmaps should not be generated (default is false)
  37094. */
  37095. noMipmap?: boolean | undefined;
  37096. /**
  37097. * Defines the explicit list of files (undefined by default)
  37098. */
  37099. files?: string[] | undefined;
  37100. /**
  37101. * Gets the loaded texture
  37102. */
  37103. texture: CubeTexture;
  37104. /**
  37105. * Callback called when the task is successful
  37106. */
  37107. onSuccess: (task: CubeTextureAssetTask) => void;
  37108. /**
  37109. * Callback called when the task is successful
  37110. */
  37111. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37112. /**
  37113. * Creates a new CubeTextureAssetTask
  37114. * @param name defines the name of the task
  37115. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37116. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37117. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37118. * @param files defines the explicit list of files (undefined by default)
  37119. */
  37120. constructor(
  37121. /**
  37122. * Defines the name of the task
  37123. */
  37124. name: string,
  37125. /**
  37126. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37127. */
  37128. url: string,
  37129. /**
  37130. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37131. */
  37132. extensions?: string[] | undefined,
  37133. /**
  37134. * Defines if mipmaps should not be generated (default is false)
  37135. */
  37136. noMipmap?: boolean | undefined,
  37137. /**
  37138. * Defines the explicit list of files (undefined by default)
  37139. */
  37140. files?: string[] | undefined);
  37141. /**
  37142. * Execute the current task
  37143. * @param scene defines the scene where you want your assets to be loaded
  37144. * @param onSuccess is a callback called when the task is successfully executed
  37145. * @param onError is a callback called if an error occurs
  37146. */
  37147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37148. }
  37149. /**
  37150. * Define a task used by AssetsManager to load HDR cube textures
  37151. */
  37152. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37153. /**
  37154. * Defines the name of the task
  37155. */
  37156. name: string;
  37157. /**
  37158. * Defines the location of the file to load
  37159. */
  37160. url: string;
  37161. /**
  37162. * Defines the desired size (the more it increases the longer the generation will be)
  37163. */
  37164. size: number;
  37165. /**
  37166. * Defines if mipmaps should not be generated (default is false)
  37167. */
  37168. noMipmap: boolean;
  37169. /**
  37170. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37171. */
  37172. generateHarmonics: boolean;
  37173. /**
  37174. * 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)
  37175. */
  37176. gammaSpace: boolean;
  37177. /**
  37178. * Internal Use Only
  37179. */
  37180. reserved: boolean;
  37181. /**
  37182. * Gets the loaded texture
  37183. */
  37184. texture: HDRCubeTexture;
  37185. /**
  37186. * Callback called when the task is successful
  37187. */
  37188. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37189. /**
  37190. * Callback called when the task is successful
  37191. */
  37192. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37193. /**
  37194. * Creates a new HDRCubeTextureAssetTask object
  37195. * @param name defines the name of the task
  37196. * @param url defines the location of the file to load
  37197. * @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.
  37198. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37199. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37200. * @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)
  37201. * @param reserved Internal use only
  37202. */
  37203. constructor(
  37204. /**
  37205. * Defines the name of the task
  37206. */
  37207. name: string,
  37208. /**
  37209. * Defines the location of the file to load
  37210. */
  37211. url: string,
  37212. /**
  37213. * Defines the desired size (the more it increases the longer the generation will be)
  37214. */
  37215. size: number,
  37216. /**
  37217. * Defines if mipmaps should not be generated (default is false)
  37218. */
  37219. noMipmap?: boolean,
  37220. /**
  37221. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37222. */
  37223. generateHarmonics?: boolean,
  37224. /**
  37225. * 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)
  37226. */
  37227. gammaSpace?: boolean,
  37228. /**
  37229. * Internal Use Only
  37230. */
  37231. reserved?: boolean);
  37232. /**
  37233. * Execute the current task
  37234. * @param scene defines the scene where you want your assets to be loaded
  37235. * @param onSuccess is a callback called when the task is successfully executed
  37236. * @param onError is a callback called if an error occurs
  37237. */
  37238. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37239. }
  37240. /**
  37241. * This class can be used to easily import assets into a scene
  37242. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37243. */
  37244. class AssetsManager {
  37245. private _scene;
  37246. private _isLoading;
  37247. protected _tasks: AbstractAssetTask[];
  37248. protected _waitingTasksCount: number;
  37249. protected _totalTasksCount: number;
  37250. /**
  37251. * Callback called when all tasks are processed
  37252. */
  37253. onFinish: (tasks: AbstractAssetTask[]) => void;
  37254. /**
  37255. * Callback called when a task is successful
  37256. */
  37257. onTaskSuccess: (task: AbstractAssetTask) => void;
  37258. /**
  37259. * Callback called when a task had an error
  37260. */
  37261. onTaskError: (task: AbstractAssetTask) => void;
  37262. /**
  37263. * Callback called when a task is done (whatever the result is)
  37264. */
  37265. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37266. /**
  37267. * Observable called when all tasks are processed
  37268. */
  37269. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37270. /**
  37271. * Observable called when a task had an error
  37272. */
  37273. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37274. /**
  37275. * Observable called when a task is successful
  37276. */
  37277. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37278. /**
  37279. * Observable called when a task is done (whatever the result is)
  37280. */
  37281. onProgressObservable: Observable<IAssetsProgressEvent>;
  37282. /**
  37283. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37285. */
  37286. useDefaultLoadingScreen: boolean;
  37287. /**
  37288. * Creates a new AssetsManager
  37289. * @param scene defines the scene to work on
  37290. */
  37291. constructor(scene: Scene);
  37292. /**
  37293. * Add a MeshAssetTask to the list of active tasks
  37294. * @param taskName defines the name of the new task
  37295. * @param meshesNames defines the name of meshes to load
  37296. * @param rootUrl defines the root url to use to locate files
  37297. * @param sceneFilename defines the filename of the scene file
  37298. * @returns a new MeshAssetTask object
  37299. */
  37300. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37301. /**
  37302. * Add a TextFileAssetTask to the list of active tasks
  37303. * @param taskName defines the name of the new task
  37304. * @param url defines the url of the file to load
  37305. * @returns a new TextFileAssetTask object
  37306. */
  37307. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37308. /**
  37309. * Add a BinaryFileAssetTask to the list of active tasks
  37310. * @param taskName defines the name of the new task
  37311. * @param url defines the url of the file to load
  37312. * @returns a new BinaryFileAssetTask object
  37313. */
  37314. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37315. /**
  37316. * Add a ImageAssetTask to the list of active tasks
  37317. * @param taskName defines the name of the new task
  37318. * @param url defines the url of the file to load
  37319. * @returns a new ImageAssetTask object
  37320. */
  37321. addImageTask(taskName: string, url: string): ImageAssetTask;
  37322. /**
  37323. * Add a TextureAssetTask to the list of active tasks
  37324. * @param taskName defines the name of the new task
  37325. * @param url defines the url of the file to load
  37326. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37327. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37328. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37329. * @returns a new TextureAssetTask object
  37330. */
  37331. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37332. /**
  37333. * Add a CubeTextureAssetTask to the list of active tasks
  37334. * @param taskName defines the name of the new task
  37335. * @param url defines the url of the file to load
  37336. * @param extensions defines the extension to use to load the cube map (can be null)
  37337. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37338. * @param files defines the list of files to load (can be null)
  37339. * @returns a new CubeTextureAssetTask object
  37340. */
  37341. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37342. /**
  37343. *
  37344. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37345. * @param taskName defines the name of the new task
  37346. * @param url defines the url of the file to load
  37347. * @param size defines the size you want for the cubemap (can be null)
  37348. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37349. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37350. * @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)
  37351. * @param reserved Internal use only
  37352. * @returns a new HDRCubeTextureAssetTask object
  37353. */
  37354. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37355. /**
  37356. * Remove a task from the assets manager.
  37357. * @param task the task to remove
  37358. */
  37359. removeTask(task: AbstractAssetTask): void;
  37360. private _decreaseWaitingTasksCount;
  37361. private _runTask;
  37362. /**
  37363. * Reset the AssetsManager and remove all tasks
  37364. * @return the current instance of the AssetsManager
  37365. */
  37366. reset(): AssetsManager;
  37367. /**
  37368. * Start the loading process
  37369. * @return the current instance of the AssetsManager
  37370. */
  37371. load(): AssetsManager;
  37372. }
  37373. }
  37374. declare module BABYLON {
  37375. /**
  37376. * Direct draw surface info
  37377. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37378. */
  37379. interface DDSInfo {
  37380. /**
  37381. * Width of the texture
  37382. */
  37383. width: number;
  37384. /**
  37385. * Width of the texture
  37386. */
  37387. height: number;
  37388. /**
  37389. * Number of Mipmaps for the texture
  37390. * @see https://en.wikipedia.org/wiki/Mipmap
  37391. */
  37392. mipmapCount: number;
  37393. /**
  37394. * If the textures format is a known fourCC format
  37395. * @see https://www.fourcc.org/
  37396. */
  37397. isFourCC: boolean;
  37398. /**
  37399. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37400. */
  37401. isRGB: boolean;
  37402. /**
  37403. * If the texture is a lumincance format
  37404. */
  37405. isLuminance: boolean;
  37406. /**
  37407. * If this is a cube texture
  37408. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37409. */
  37410. isCube: boolean;
  37411. /**
  37412. * If the texture is a compressed format eg. FOURCC_DXT1
  37413. */
  37414. isCompressed: boolean;
  37415. /**
  37416. * The dxgiFormat of the texture
  37417. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37418. */
  37419. dxgiFormat: number;
  37420. /**
  37421. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37422. */
  37423. textureType: number;
  37424. /**
  37425. * Sphericle polynomial created for the dds texture
  37426. */
  37427. sphericalPolynomial?: SphericalPolynomial;
  37428. }
  37429. /**
  37430. * Class used to provide DDS decompression tools
  37431. */
  37432. class DDSTools {
  37433. /**
  37434. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37435. */
  37436. static StoreLODInAlphaChannel: boolean;
  37437. /**
  37438. * Gets DDS information from an array buffer
  37439. * @param arrayBuffer defines the array buffer to read data from
  37440. * @returns the DDS information
  37441. */
  37442. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37443. private static _FloatView;
  37444. private static _Int32View;
  37445. private static _ToHalfFloat;
  37446. private static _FromHalfFloat;
  37447. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37448. private static _GetHalfFloatRGBAArrayBuffer;
  37449. private static _GetFloatRGBAArrayBuffer;
  37450. private static _GetFloatAsUIntRGBAArrayBuffer;
  37451. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37452. private static _GetRGBAArrayBuffer;
  37453. private static _ExtractLongWordOrder;
  37454. private static _GetRGBArrayBuffer;
  37455. private static _GetLuminanceArrayBuffer;
  37456. /**
  37457. * Uploads DDS Levels to a Babylon Texture
  37458. * @hidden
  37459. */
  37460. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37461. }
  37462. }
  37463. declare module BABYLON {
  37464. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37465. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37466. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37467. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37468. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37469. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37470. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37471. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37472. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37473. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37474. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37475. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37476. /**
  37477. * Decorator used to define property that can be serialized as reference to a camera
  37478. * @param sourceName defines the name of the property to decorate
  37479. */
  37480. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37481. /**
  37482. * Class used to help serialization objects
  37483. */
  37484. class SerializationHelper {
  37485. /**
  37486. * Static function used to serialized a specific entity
  37487. * @param entity defines the entity to serialize
  37488. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37489. * @returns a JSON compatible object representing the serialization of the entity
  37490. */
  37491. static Serialize<T>(entity: T, serializationObject?: any): any;
  37492. /**
  37493. * Creates a new entity from a serialization data object
  37494. * @param creationFunction defines a function used to instanciated the new entity
  37495. * @param source defines the source serialization data
  37496. * @param scene defines the hosting scene
  37497. * @param rootUrl defines the root url for resources
  37498. * @returns a new entity
  37499. */
  37500. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37501. /**
  37502. * Clones an object
  37503. * @param creationFunction defines the function used to instanciate the new object
  37504. * @param source defines the source object
  37505. * @returns the cloned object
  37506. */
  37507. static Clone<T>(creationFunction: () => T, source: T): T;
  37508. /**
  37509. * Instanciates a new object based on a source one (some data will be shared between both object)
  37510. * @param creationFunction defines the function used to instanciate the new object
  37511. * @param source defines the source object
  37512. * @returns the new object
  37513. */
  37514. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37515. }
  37516. }
  37517. declare module BABYLON {
  37518. /**
  37519. * Wrapper class for promise with external resolve and reject.
  37520. */
  37521. class Deferred<T> {
  37522. /**
  37523. * The promise associated with this deferred object.
  37524. */
  37525. readonly promise: Promise<T>;
  37526. private _resolve;
  37527. private _reject;
  37528. /**
  37529. * The resolve method of the promise associated with this deferred object.
  37530. */
  37531. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37532. /**
  37533. * The reject method of the promise associated with this deferred object.
  37534. */
  37535. readonly reject: (reason?: any) => void;
  37536. /**
  37537. * Constructor for this deferred object.
  37538. */
  37539. constructor();
  37540. }
  37541. }
  37542. declare module BABYLON {
  37543. /**
  37544. * Raw texture data and descriptor sufficient for WebGL texture upload
  37545. */
  37546. interface EnvironmentTextureInfo {
  37547. /**
  37548. * Version of the environment map
  37549. */
  37550. version: number;
  37551. /**
  37552. * Width of image
  37553. */
  37554. width: number;
  37555. /**
  37556. * Irradiance information stored in the file.
  37557. */
  37558. irradiance: any;
  37559. /**
  37560. * Specular information stored in the file.
  37561. */
  37562. specular: any;
  37563. }
  37564. /**
  37565. * Sets of helpers addressing the serialization and deserialization of environment texture
  37566. * stored in a BabylonJS env file.
  37567. * Those files are usually stored as .env files.
  37568. */
  37569. class EnvironmentTextureTools {
  37570. /**
  37571. * Magic number identifying the env file.
  37572. */
  37573. private static _MagicBytes;
  37574. /**
  37575. * Gets the environment info from an env file.
  37576. * @param data The array buffer containing the .env bytes.
  37577. * @returns the environment file info (the json header) if successfully parsed.
  37578. */
  37579. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37580. /**
  37581. * Creates an environment texture from a loaded cube texture.
  37582. * @param texture defines the cube texture to convert in env file
  37583. * @return a promise containing the environment data if succesfull.
  37584. */
  37585. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37586. /**
  37587. * Creates a JSON representation of the spherical data.
  37588. * @param texture defines the texture containing the polynomials
  37589. * @return the JSON representation of the spherical info
  37590. */
  37591. private static _CreateEnvTextureIrradiance;
  37592. /**
  37593. * Uploads the texture info contained in the env file to the GPU.
  37594. * @param texture defines the internal texture to upload to
  37595. * @param arrayBuffer defines the buffer cotaining the data to load
  37596. * @param info defines the texture info retrieved through the GetEnvInfo method
  37597. * @returns a promise
  37598. */
  37599. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  37600. /**
  37601. * Uploads the levels of image data to the GPU.
  37602. * @param texture defines the internal texture to upload to
  37603. * @param imageData defines the array buffer views of image data [mipmap][face]
  37604. * @returns a promise
  37605. */
  37606. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  37607. /**
  37608. * Uploads spherical polynomials information to the texture.
  37609. * @param texture defines the texture we are trying to upload the information to
  37610. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  37611. */
  37612. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  37613. }
  37614. }
  37615. declare module BABYLON {
  37616. /**
  37617. * Class used to help managing file picking and drag'n'drop
  37618. */
  37619. class FilesInput {
  37620. /**
  37621. * List of files ready to be loaded
  37622. */
  37623. static FilesToLoad: {
  37624. [key: string]: File;
  37625. };
  37626. /**
  37627. * Callback called when a file is processed
  37628. */
  37629. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  37630. private _engine;
  37631. private _currentScene;
  37632. private _sceneLoadedCallback;
  37633. private _progressCallback;
  37634. private _additionalRenderLoopLogicCallback;
  37635. private _textureLoadingCallback;
  37636. private _startingProcessingFilesCallback;
  37637. private _onReloadCallback;
  37638. private _errorCallback;
  37639. private _elementToMonitor;
  37640. private _sceneFileToLoad;
  37641. private _filesToLoad;
  37642. /**
  37643. * Creates a new FilesInput
  37644. * @param engine defines the rendering engine
  37645. * @param scene defines the hosting scene
  37646. * @param sceneLoadedCallback callback called when scene is loaded
  37647. * @param progressCallback callback called to track progress
  37648. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  37649. * @param textureLoadingCallback callback called when a texture is loading
  37650. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  37651. * @param onReloadCallback callback called when a reload is requested
  37652. * @param errorCallback callback call if an error occurs
  37653. */
  37654. 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);
  37655. private _dragEnterHandler;
  37656. private _dragOverHandler;
  37657. private _dropHandler;
  37658. /**
  37659. * Calls this function to listen to drag'n'drop events on a specific DOM element
  37660. * @param elementToMonitor defines the DOM element to track
  37661. */
  37662. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  37663. /**
  37664. * Release all associated resources
  37665. */
  37666. dispose(): void;
  37667. private renderFunction;
  37668. private drag;
  37669. private drop;
  37670. private _traverseFolder;
  37671. private _processFiles;
  37672. /**
  37673. * Load files from a drop event
  37674. * @param event defines the drop event to use as source
  37675. */
  37676. loadFiles(event: any): void;
  37677. private _processReload;
  37678. /**
  37679. * Reload the current scene from the loaded files
  37680. */
  37681. reload(): void;
  37682. }
  37683. }
  37684. declare module BABYLON {
  37685. /**
  37686. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  37687. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  37688. */
  37689. class KhronosTextureContainer {
  37690. /** contents of the KTX container file */
  37691. arrayBuffer: any;
  37692. private static HEADER_LEN;
  37693. private static COMPRESSED_2D;
  37694. private static COMPRESSED_3D;
  37695. private static TEX_2D;
  37696. private static TEX_3D;
  37697. /**
  37698. * Gets the openGL type
  37699. */
  37700. glType: number;
  37701. /**
  37702. * Gets the openGL type size
  37703. */
  37704. glTypeSize: number;
  37705. /**
  37706. * Gets the openGL format
  37707. */
  37708. glFormat: number;
  37709. /**
  37710. * Gets the openGL internal format
  37711. */
  37712. glInternalFormat: number;
  37713. /**
  37714. * Gets the base internal format
  37715. */
  37716. glBaseInternalFormat: number;
  37717. /**
  37718. * Gets image width in pixel
  37719. */
  37720. pixelWidth: number;
  37721. /**
  37722. * Gets image height in pixel
  37723. */
  37724. pixelHeight: number;
  37725. /**
  37726. * Gets image depth in pixels
  37727. */
  37728. pixelDepth: number;
  37729. /**
  37730. * Gets the number of array elements
  37731. */
  37732. numberOfArrayElements: number;
  37733. /**
  37734. * Gets the number of faces
  37735. */
  37736. numberOfFaces: number;
  37737. /**
  37738. * Gets the number of mipmap levels
  37739. */
  37740. numberOfMipmapLevels: number;
  37741. /**
  37742. * Gets the bytes of key value data
  37743. */
  37744. bytesOfKeyValueData: number;
  37745. /**
  37746. * Gets the load type
  37747. */
  37748. loadType: number;
  37749. /**
  37750. * Creates a new KhronosTextureContainer
  37751. * @param arrayBuffer contents of the KTX container file
  37752. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  37753. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  37754. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  37755. */
  37756. constructor(
  37757. /** contents of the KTX container file */
  37758. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  37759. /**
  37760. * Revert the endianness of a value.
  37761. * Not as fast hardware based, but will probably never need to use
  37762. * @param val defines the value to convert
  37763. * @returns the new value
  37764. */
  37765. switchEndianness(val: number): number;
  37766. /**
  37767. * Uploads KTX content to a Babylon Texture.
  37768. * It is assumed that the texture has already been created & is currently bound
  37769. * @hidden
  37770. */
  37771. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  37772. private _upload2DCompressedLevels;
  37773. }
  37774. }
  37775. declare module BABYLON {
  37776. /**
  37777. * A class serves as a medium between the observable and its observers
  37778. */
  37779. class EventState {
  37780. /**
  37781. * Create a new EventState
  37782. * @param mask defines the mask associated with this state
  37783. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37784. * @param target defines the original target of the state
  37785. * @param currentTarget defines the current target of the state
  37786. */
  37787. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  37788. /**
  37789. * Initialize the current event state
  37790. * @param mask defines the mask associated with this state
  37791. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  37792. * @param target defines the original target of the state
  37793. * @param currentTarget defines the current target of the state
  37794. * @returns the current event state
  37795. */
  37796. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  37797. /**
  37798. * An Observer can set this property to true to prevent subsequent observers of being notified
  37799. */
  37800. skipNextObservers: boolean;
  37801. /**
  37802. * Get the mask value that were used to trigger the event corresponding to this EventState object
  37803. */
  37804. mask: number;
  37805. /**
  37806. * The object that originally notified the event
  37807. */
  37808. target?: any;
  37809. /**
  37810. * The current object in the bubbling phase
  37811. */
  37812. currentTarget?: any;
  37813. /**
  37814. * This will be populated with the return value of the last function that was executed.
  37815. * If it is the first function in the callback chain it will be the event data.
  37816. */
  37817. lastReturnValue?: any;
  37818. }
  37819. /**
  37820. * Represent an Observer registered to a given Observable object.
  37821. */
  37822. class Observer<T> {
  37823. /**
  37824. * Defines the callback to call when the observer is notified
  37825. */
  37826. callback: (eventData: T, eventState: EventState) => void;
  37827. /**
  37828. * Defines the mask of the observer (used to filter notifications)
  37829. */
  37830. mask: number;
  37831. /**
  37832. * Defines the current scope used to restore the JS context
  37833. */
  37834. scope: any;
  37835. /** @hidden */
  37836. _willBeUnregistered: boolean;
  37837. /**
  37838. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  37839. */
  37840. unregisterOnNextCall: boolean;
  37841. /**
  37842. * Creates a new observer
  37843. * @param callback defines the callback to call when the observer is notified
  37844. * @param mask defines the mask of the observer (used to filter notifications)
  37845. * @param scope defines the current scope used to restore the JS context
  37846. */
  37847. constructor(
  37848. /**
  37849. * Defines the callback to call when the observer is notified
  37850. */
  37851. callback: (eventData: T, eventState: EventState) => void,
  37852. /**
  37853. * Defines the mask of the observer (used to filter notifications)
  37854. */
  37855. mask: number,
  37856. /**
  37857. * Defines the current scope used to restore the JS context
  37858. */
  37859. scope?: any);
  37860. }
  37861. /**
  37862. * Represent a list of observers registered to multiple Observables object.
  37863. */
  37864. class MultiObserver<T> {
  37865. private _observers;
  37866. private _observables;
  37867. /**
  37868. * Release associated resources
  37869. */
  37870. dispose(): void;
  37871. /**
  37872. * Raise a callback when one of the observable will notify
  37873. * @param observables defines a list of observables to watch
  37874. * @param callback defines the callback to call on notification
  37875. * @param mask defines the mask used to filter notifications
  37876. * @param scope defines the current scope used to restore the JS context
  37877. * @returns the new MultiObserver
  37878. */
  37879. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  37880. }
  37881. /**
  37882. * The Observable class is a simple implementation of the Observable pattern.
  37883. *
  37884. * 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.
  37885. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  37886. * 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).
  37887. * 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.
  37888. */
  37889. class Observable<T> {
  37890. private _observers;
  37891. private _eventState;
  37892. private _onObserverAdded;
  37893. /**
  37894. * Creates a new observable
  37895. * @param onObserverAdded defines a callback to call when a new observer is added
  37896. */
  37897. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  37898. /**
  37899. * Create a new Observer with the specified callback
  37900. * @param callback the callback that will be executed for that Observer
  37901. * @param mask the mask used to filter observers
  37902. * @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.
  37903. * @param scope optional scope for the callback to be called from
  37904. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  37905. * @returns the new observer created for the callback
  37906. */
  37907. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  37908. /**
  37909. * Create a new Observer with the specified callback and unregisters after the next notification
  37910. * @param callback the callback that will be executed for that Observer
  37911. * @returns the new observer created for the callback
  37912. */
  37913. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  37914. /**
  37915. * Remove an Observer from the Observable object
  37916. * @param observer the instance of the Observer to remove
  37917. * @returns false if it doesn't belong to this Observable
  37918. */
  37919. remove(observer: Nullable<Observer<T>>): boolean;
  37920. /**
  37921. * Remove a callback from the Observable object
  37922. * @param callback the callback to remove
  37923. * @param scope optional scope. If used only the callbacks with this scope will be removed
  37924. * @returns false if it doesn't belong to this Observable
  37925. */
  37926. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  37927. private _deferUnregister;
  37928. private _remove;
  37929. /**
  37930. * Notify all Observers by calling their respective callback with the given data
  37931. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  37932. * @param eventData defines the data to send to all observers
  37933. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  37934. * @param target defines the original target of the state
  37935. * @param currentTarget defines the current target of the state
  37936. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  37937. */
  37938. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  37939. /**
  37940. * Calling this will execute each callback, expecting it to be a promise or return a value.
  37941. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  37942. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  37943. * and it is crucial that all callbacks will be executed.
  37944. * The order of the callbacks is kept, callbacks are not executed parallel.
  37945. *
  37946. * @param eventData The data to be sent to each callback
  37947. * @param mask is used to filter observers defaults to -1
  37948. * @param target defines the callback target (see EventState)
  37949. * @param currentTarget defines he current object in the bubbling phase
  37950. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  37951. */
  37952. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  37953. /**
  37954. * Notify a specific observer
  37955. * @param observer defines the observer to notify
  37956. * @param eventData defines the data to be sent to each callback
  37957. * @param mask is used to filter observers defaults to -1
  37958. */
  37959. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  37960. /**
  37961. * Gets a boolean indicating if the observable has at least one observer
  37962. * @returns true is the Observable has at least one Observer registered
  37963. */
  37964. hasObservers(): boolean;
  37965. /**
  37966. * Clear the list of observers
  37967. */
  37968. clear(): void;
  37969. /**
  37970. * Clone the current observable
  37971. * @returns a new observable
  37972. */
  37973. clone(): Observable<T>;
  37974. /**
  37975. * Does this observable handles observer registered with a given mask
  37976. * @param mask defines the mask to be tested
  37977. * @return whether or not one observer registered with the given mask is handeled
  37978. **/
  37979. hasSpecificMask(mask?: number): boolean;
  37980. }
  37981. }
  37982. declare module BABYLON {
  37983. /**
  37984. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37985. */
  37986. class PerformanceMonitor {
  37987. private _enabled;
  37988. private _rollingFrameTime;
  37989. private _lastFrameTimeMs;
  37990. /**
  37991. * constructor
  37992. * @param frameSampleSize The number of samples required to saturate the sliding window
  37993. */
  37994. constructor(frameSampleSize?: number);
  37995. /**
  37996. * Samples current frame
  37997. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37998. */
  37999. sampleFrame(timeMs?: number): void;
  38000. /**
  38001. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38002. */
  38003. readonly averageFrameTime: number;
  38004. /**
  38005. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38006. */
  38007. readonly averageFrameTimeVariance: number;
  38008. /**
  38009. * Returns the frame time of the most recent frame
  38010. */
  38011. readonly instantaneousFrameTime: number;
  38012. /**
  38013. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38014. */
  38015. readonly averageFPS: number;
  38016. /**
  38017. * Returns the average framerate in frames per second using the most recent frame time
  38018. */
  38019. readonly instantaneousFPS: number;
  38020. /**
  38021. * Returns true if enough samples have been taken to completely fill the sliding window
  38022. */
  38023. readonly isSaturated: boolean;
  38024. /**
  38025. * Enables contributions to the sliding window sample set
  38026. */
  38027. enable(): void;
  38028. /**
  38029. * Disables contributions to the sliding window sample set
  38030. * Samples will not be interpolated over the disabled period
  38031. */
  38032. disable(): void;
  38033. /**
  38034. * Returns true if sampling is enabled
  38035. */
  38036. readonly isEnabled: boolean;
  38037. /**
  38038. * Resets performance monitor
  38039. */
  38040. reset(): void;
  38041. }
  38042. /**
  38043. * RollingAverage
  38044. *
  38045. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38046. */
  38047. class RollingAverage {
  38048. /**
  38049. * Current average
  38050. */
  38051. average: number;
  38052. /**
  38053. * Current variance
  38054. */
  38055. variance: number;
  38056. protected _samples: Array<number>;
  38057. protected _sampleCount: number;
  38058. protected _pos: number;
  38059. protected _m2: number;
  38060. /**
  38061. * constructor
  38062. * @param length The number of samples required to saturate the sliding window
  38063. */
  38064. constructor(length: number);
  38065. /**
  38066. * Adds a sample to the sample set
  38067. * @param v The sample value
  38068. */
  38069. add(v: number): void;
  38070. /**
  38071. * Returns previously added values or null if outside of history or outside the sliding window domain
  38072. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38073. * @return Value previously recorded with add() or null if outside of range
  38074. */
  38075. history(i: number): number;
  38076. /**
  38077. * Returns true if enough samples have been taken to completely fill the sliding window
  38078. * @return true if sample-set saturated
  38079. */
  38080. isSaturated(): boolean;
  38081. /**
  38082. * Resets the rolling average (equivalent to 0 samples taken so far)
  38083. */
  38084. reset(): void;
  38085. /**
  38086. * Wraps a value around the sample range boundaries
  38087. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38088. * @return Wrapped position in sample range
  38089. */
  38090. protected _wrapPosition(i: number): number;
  38091. }
  38092. }
  38093. declare module BABYLON {
  38094. /**
  38095. * Helper class that provides a small promise polyfill
  38096. */
  38097. class PromisePolyfill {
  38098. /**
  38099. * Static function used to check if the polyfill is required
  38100. * If this is the case then the function will inject the polyfill to window.Promise
  38101. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38102. */
  38103. static Apply(force?: boolean): void;
  38104. }
  38105. }
  38106. declare module BABYLON {
  38107. /**
  38108. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38110. */
  38111. class SceneOptimization {
  38112. /**
  38113. * Defines the priority of this optimization (0 by default which means first in the list)
  38114. */
  38115. priority: number;
  38116. /**
  38117. * Gets a string describing the action executed by the current optimization
  38118. * @returns description string
  38119. */
  38120. getDescription(): string;
  38121. /**
  38122. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38123. * @param scene defines the current scene where to apply this optimization
  38124. * @param optimizer defines the current optimizer
  38125. * @returns true if everything that can be done was applied
  38126. */
  38127. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38128. /**
  38129. * Creates the SceneOptimization object
  38130. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38131. * @param desc defines the description associated with the optimization
  38132. */
  38133. constructor(
  38134. /**
  38135. * Defines the priority of this optimization (0 by default which means first in the list)
  38136. */
  38137. priority?: number);
  38138. }
  38139. /**
  38140. * Defines an optimization used to reduce the size of render target textures
  38141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38142. */
  38143. class TextureOptimization extends SceneOptimization {
  38144. /**
  38145. * Defines the priority of this optimization (0 by default which means first in the list)
  38146. */
  38147. priority: number;
  38148. /**
  38149. * 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
  38150. */
  38151. maximumSize: number;
  38152. /**
  38153. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38154. */
  38155. step: number;
  38156. /**
  38157. * Gets a string describing the action executed by the current optimization
  38158. * @returns description string
  38159. */
  38160. getDescription(): string;
  38161. /**
  38162. * Creates the TextureOptimization object
  38163. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38164. * @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
  38165. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38166. */
  38167. constructor(
  38168. /**
  38169. * Defines the priority of this optimization (0 by default which means first in the list)
  38170. */
  38171. priority?: number,
  38172. /**
  38173. * 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
  38174. */
  38175. maximumSize?: number,
  38176. /**
  38177. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38178. */
  38179. step?: number);
  38180. /**
  38181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38182. * @param scene defines the current scene where to apply this optimization
  38183. * @param optimizer defines the current optimizer
  38184. * @returns true if everything that can be done was applied
  38185. */
  38186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38187. }
  38188. /**
  38189. * Defines an optimization used to increase or decrease the rendering resolution
  38190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38191. */
  38192. class HardwareScalingOptimization extends SceneOptimization {
  38193. /**
  38194. * Defines the priority of this optimization (0 by default which means first in the list)
  38195. */
  38196. priority: number;
  38197. /**
  38198. * Defines the maximum scale to use (2 by default)
  38199. */
  38200. maximumScale: number;
  38201. /**
  38202. * Defines the step to use between two passes (0.5 by default)
  38203. */
  38204. step: number;
  38205. private _currentScale;
  38206. private _directionOffset;
  38207. /**
  38208. * Gets a string describing the action executed by the current optimization
  38209. * @return description string
  38210. */
  38211. getDescription(): string;
  38212. /**
  38213. * Creates the HardwareScalingOptimization object
  38214. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38215. * @param maximumScale defines the maximum scale to use (2 by default)
  38216. * @param step defines the step to use between two passes (0.5 by default)
  38217. */
  38218. constructor(
  38219. /**
  38220. * Defines the priority of this optimization (0 by default which means first in the list)
  38221. */
  38222. priority?: number,
  38223. /**
  38224. * Defines the maximum scale to use (2 by default)
  38225. */
  38226. maximumScale?: number,
  38227. /**
  38228. * Defines the step to use between two passes (0.5 by default)
  38229. */
  38230. step?: number);
  38231. /**
  38232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38233. * @param scene defines the current scene where to apply this optimization
  38234. * @param optimizer defines the current optimizer
  38235. * @returns true if everything that can be done was applied
  38236. */
  38237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38238. }
  38239. /**
  38240. * Defines an optimization used to remove shadows
  38241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38242. */
  38243. class ShadowsOptimization extends SceneOptimization {
  38244. /**
  38245. * Gets a string describing the action executed by the current optimization
  38246. * @return description string
  38247. */
  38248. getDescription(): string;
  38249. /**
  38250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38251. * @param scene defines the current scene where to apply this optimization
  38252. * @param optimizer defines the current optimizer
  38253. * @returns true if everything that can be done was applied
  38254. */
  38255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38256. }
  38257. /**
  38258. * Defines an optimization used to turn post-processes off
  38259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38260. */
  38261. class PostProcessesOptimization extends SceneOptimization {
  38262. /**
  38263. * Gets a string describing the action executed by the current optimization
  38264. * @return description string
  38265. */
  38266. getDescription(): string;
  38267. /**
  38268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38269. * @param scene defines the current scene where to apply this optimization
  38270. * @param optimizer defines the current optimizer
  38271. * @returns true if everything that can be done was applied
  38272. */
  38273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38274. }
  38275. /**
  38276. * Defines an optimization used to turn lens flares off
  38277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38278. */
  38279. class LensFlaresOptimization extends SceneOptimization {
  38280. /**
  38281. * Gets a string describing the action executed by the current optimization
  38282. * @return description string
  38283. */
  38284. getDescription(): string;
  38285. /**
  38286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38287. * @param scene defines the current scene where to apply this optimization
  38288. * @param optimizer defines the current optimizer
  38289. * @returns true if everything that can be done was applied
  38290. */
  38291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38292. }
  38293. /**
  38294. * Defines an optimization based on user defined callback.
  38295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38296. */
  38297. class CustomOptimization extends SceneOptimization {
  38298. /**
  38299. * Callback called to apply the custom optimization.
  38300. */
  38301. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38302. /**
  38303. * Callback called to get custom description
  38304. */
  38305. onGetDescription: () => string;
  38306. /**
  38307. * Gets a string describing the action executed by the current optimization
  38308. * @returns description string
  38309. */
  38310. getDescription(): string;
  38311. /**
  38312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38313. * @param scene defines the current scene where to apply this optimization
  38314. * @param optimizer defines the current optimizer
  38315. * @returns true if everything that can be done was applied
  38316. */
  38317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38318. }
  38319. /**
  38320. * Defines an optimization used to turn particles off
  38321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38322. */
  38323. class ParticlesOptimization extends SceneOptimization {
  38324. /**
  38325. * Gets a string describing the action executed by the current optimization
  38326. * @return description string
  38327. */
  38328. getDescription(): string;
  38329. /**
  38330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38331. * @param scene defines the current scene where to apply this optimization
  38332. * @param optimizer defines the current optimizer
  38333. * @returns true if everything that can be done was applied
  38334. */
  38335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38336. }
  38337. /**
  38338. * Defines an optimization used to turn render targets off
  38339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38340. */
  38341. class RenderTargetsOptimization extends SceneOptimization {
  38342. /**
  38343. * Gets a string describing the action executed by the current optimization
  38344. * @return description string
  38345. */
  38346. getDescription(): string;
  38347. /**
  38348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38349. * @param scene defines the current scene where to apply this optimization
  38350. * @param optimizer defines the current optimizer
  38351. * @returns true if everything that can be done was applied
  38352. */
  38353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38354. }
  38355. /**
  38356. * Defines an optimization used to merge meshes with compatible materials
  38357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38358. */
  38359. class MergeMeshesOptimization extends SceneOptimization {
  38360. private static _UpdateSelectionTree;
  38361. /**
  38362. * Gets or sets a boolean which defines if optimization octree has to be updated
  38363. */
  38364. /**
  38365. * Gets or sets a boolean which defines if optimization octree has to be updated
  38366. */
  38367. static UpdateSelectionTree: boolean;
  38368. /**
  38369. * Gets a string describing the action executed by the current optimization
  38370. * @return description string
  38371. */
  38372. getDescription(): string;
  38373. private _canBeMerged;
  38374. /**
  38375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38376. * @param scene defines the current scene where to apply this optimization
  38377. * @param optimizer defines the current optimizer
  38378. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38379. * @returns true if everything that can be done was applied
  38380. */
  38381. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38382. }
  38383. /**
  38384. * Defines a list of options used by SceneOptimizer
  38385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38386. */
  38387. class SceneOptimizerOptions {
  38388. /**
  38389. * Defines the target frame rate to reach (60 by default)
  38390. */
  38391. targetFrameRate: number;
  38392. /**
  38393. * Defines the interval between two checkes (2000ms by default)
  38394. */
  38395. trackerDuration: number;
  38396. /**
  38397. * Gets the list of optimizations to apply
  38398. */
  38399. optimizations: SceneOptimization[];
  38400. /**
  38401. * Creates a new list of options used by SceneOptimizer
  38402. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38403. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38404. */
  38405. constructor(
  38406. /**
  38407. * Defines the target frame rate to reach (60 by default)
  38408. */
  38409. targetFrameRate?: number,
  38410. /**
  38411. * Defines the interval between two checkes (2000ms by default)
  38412. */
  38413. trackerDuration?: number);
  38414. /**
  38415. * Add a new optimization
  38416. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38417. * @returns the current SceneOptimizerOptions
  38418. */
  38419. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38420. /**
  38421. * Add a new custom optimization
  38422. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38423. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38424. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38425. * @returns the current SceneOptimizerOptions
  38426. */
  38427. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38428. /**
  38429. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38430. * @param targetFrameRate defines the target frame rate (60 by default)
  38431. * @returns a SceneOptimizerOptions object
  38432. */
  38433. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38434. /**
  38435. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38436. * @param targetFrameRate defines the target frame rate (60 by default)
  38437. * @returns a SceneOptimizerOptions object
  38438. */
  38439. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38440. /**
  38441. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38442. * @param targetFrameRate defines the target frame rate (60 by default)
  38443. * @returns a SceneOptimizerOptions object
  38444. */
  38445. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38446. }
  38447. /**
  38448. * Class used to run optimizations in order to reach a target frame rate
  38449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38450. */
  38451. class SceneOptimizer implements IDisposable {
  38452. private _isRunning;
  38453. private _options;
  38454. private _scene;
  38455. private _currentPriorityLevel;
  38456. private _targetFrameRate;
  38457. private _trackerDuration;
  38458. private _currentFrameRate;
  38459. private _sceneDisposeObserver;
  38460. private _improvementMode;
  38461. /**
  38462. * Defines an observable called when the optimizer reaches the target frame rate
  38463. */
  38464. onSuccessObservable: Observable<SceneOptimizer>;
  38465. /**
  38466. * Defines an observable called when the optimizer enables an optimization
  38467. */
  38468. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38469. /**
  38470. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38471. */
  38472. onFailureObservable: Observable<SceneOptimizer>;
  38473. /**
  38474. * Gets a boolean indicating if the optimizer is in improvement mode
  38475. */
  38476. readonly isInImprovementMode: boolean;
  38477. /**
  38478. * Gets the current priority level (0 at start)
  38479. */
  38480. readonly currentPriorityLevel: number;
  38481. /**
  38482. * Gets the current frame rate checked by the SceneOptimizer
  38483. */
  38484. readonly currentFrameRate: number;
  38485. /**
  38486. * Gets or sets the current target frame rate (60 by default)
  38487. */
  38488. /**
  38489. * Gets or sets the current target frame rate (60 by default)
  38490. */
  38491. targetFrameRate: number;
  38492. /**
  38493. * Gets or sets the current interval between two checks (every 2000ms by default)
  38494. */
  38495. /**
  38496. * Gets or sets the current interval between two checks (every 2000ms by default)
  38497. */
  38498. trackerDuration: number;
  38499. /**
  38500. * Gets the list of active optimizations
  38501. */
  38502. readonly optimizations: SceneOptimization[];
  38503. /**
  38504. * Creates a new SceneOptimizer
  38505. * @param scene defines the scene to work on
  38506. * @param options defines the options to use with the SceneOptimizer
  38507. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38508. * @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)
  38509. */
  38510. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38511. /**
  38512. * Stops the current optimizer
  38513. */
  38514. stop(): void;
  38515. /**
  38516. * Reset the optimizer to initial step (current priority level = 0)
  38517. */
  38518. reset(): void;
  38519. /**
  38520. * Start the optimizer. By default it will try to reach a specific framerate
  38521. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38522. */
  38523. start(): void;
  38524. private _checkCurrentState;
  38525. /**
  38526. * Release all resources
  38527. */
  38528. dispose(): void;
  38529. /**
  38530. * Helper function to create a SceneOptimizer with one single line of code
  38531. * @param scene defines the scene to work on
  38532. * @param options defines the options to use with the SceneOptimizer
  38533. * @param onSuccess defines a callback to call on success
  38534. * @param onFailure defines a callback to call on failure
  38535. * @returns the new SceneOptimizer object
  38536. */
  38537. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38538. }
  38539. }
  38540. declare module BABYLON {
  38541. /**
  38542. * Class used to serialize a scene into a string
  38543. */
  38544. class SceneSerializer {
  38545. /**
  38546. * Clear cache used by a previous serialization
  38547. */
  38548. static ClearCache(): void;
  38549. /**
  38550. * Serialize a scene into a JSON compatible object
  38551. * @param scene defines the scene to serialize
  38552. * @returns a JSON compatible object
  38553. */
  38554. static Serialize(scene: Scene): any;
  38555. /**
  38556. * Serialize a mesh into a JSON compatible object
  38557. * @param toSerialize defines the mesh to serialize
  38558. * @param withParents defines if parents must be serialized as well
  38559. * @param withChildren defines if children must be serialized as well
  38560. * @returns a JSON compatible object
  38561. */
  38562. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. /**
  38567. * Defines an array and its length.
  38568. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38569. */
  38570. interface ISmartArrayLike<T> {
  38571. /**
  38572. * The data of the array.
  38573. */
  38574. data: Array<T>;
  38575. /**
  38576. * The active length of the array.
  38577. */
  38578. length: number;
  38579. }
  38580. /**
  38581. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38582. */
  38583. class SmartArray<T> implements ISmartArrayLike<T> {
  38584. /**
  38585. * The full set of data from the array.
  38586. */
  38587. data: Array<T>;
  38588. /**
  38589. * The active length of the array.
  38590. */
  38591. length: number;
  38592. protected _id: number;
  38593. /**
  38594. * Instantiates a Smart Array.
  38595. * @param capacity defines the default capacity of the array.
  38596. */
  38597. constructor(capacity: number);
  38598. /**
  38599. * Pushes a value at the end of the active data.
  38600. * @param value defines the object to push in the array.
  38601. */
  38602. push(value: T): void;
  38603. /**
  38604. * Iterates over the active data and apply the lambda to them.
  38605. * @param func defines the action to apply on each value.
  38606. */
  38607. forEach(func: (content: T) => void): void;
  38608. /**
  38609. * Sorts the full sets of data.
  38610. * @param compareFn defines the comparison function to apply.
  38611. */
  38612. sort(compareFn: (a: T, b: T) => number): void;
  38613. /**
  38614. * Resets the active data to an empty array.
  38615. */
  38616. reset(): void;
  38617. /**
  38618. * Releases all the data from the array as well as the array.
  38619. */
  38620. dispose(): void;
  38621. /**
  38622. * Concats the active data with a given array.
  38623. * @param array defines the data to concatenate with.
  38624. */
  38625. concat(array: any): void;
  38626. /**
  38627. * Returns the position of a value in the active data.
  38628. * @param value defines the value to find the index for
  38629. * @returns the index if found in the active data otherwise -1
  38630. */
  38631. indexOf(value: T): number;
  38632. /**
  38633. * Returns whether an element is part of the active data.
  38634. * @param value defines the value to look for
  38635. * @returns true if found in the active data otherwise false
  38636. */
  38637. contains(value: T): boolean;
  38638. private static _GlobalId;
  38639. }
  38640. /**
  38641. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38642. * The data in this array can only be present once
  38643. */
  38644. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  38645. private _duplicateId;
  38646. /**
  38647. * Pushes a value at the end of the active data.
  38648. * THIS DOES NOT PREVENT DUPPLICATE DATA
  38649. * @param value defines the object to push in the array.
  38650. */
  38651. push(value: T): void;
  38652. /**
  38653. * Pushes a value at the end of the active data.
  38654. * If the data is already present, it won t be added again
  38655. * @param value defines the object to push in the array.
  38656. * @returns true if added false if it was already present
  38657. */
  38658. pushNoDuplicate(value: T): boolean;
  38659. /**
  38660. * Resets the active data to an empty array.
  38661. */
  38662. reset(): void;
  38663. /**
  38664. * Concats the active data with a given array.
  38665. * This ensures no dupplicate will be present in the result.
  38666. * @param array defines the data to concatenate with.
  38667. */
  38668. concatWithNoDuplicate(array: any): void;
  38669. }
  38670. }
  38671. declare module BABYLON {
  38672. /**
  38673. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38674. * The underlying implementation relies on an associative array to ensure the best performances.
  38675. * The value can be anything including 'null' but except 'undefined'
  38676. */
  38677. class StringDictionary<T> {
  38678. /**
  38679. * This will clear this dictionary and copy the content from the 'source' one.
  38680. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38681. * @param source the dictionary to take the content from and copy to this dictionary
  38682. */
  38683. copyFrom(source: StringDictionary<T>): void;
  38684. /**
  38685. * Get a value based from its key
  38686. * @param key the given key to get the matching value from
  38687. * @return the value if found, otherwise undefined is returned
  38688. */
  38689. get(key: string): T | undefined;
  38690. /**
  38691. * Get a value from its key or add it if it doesn't exist.
  38692. * This method will ensure you that a given key/data will be present in the dictionary.
  38693. * @param key the given key to get the matching value from
  38694. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38695. * The factory will only be invoked if there's no data for the given key.
  38696. * @return the value corresponding to the key.
  38697. */
  38698. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38699. /**
  38700. * Get a value from its key if present in the dictionary otherwise add it
  38701. * @param key the key to get the value from
  38702. * @param val if there's no such key/value pair in the dictionary add it with this value
  38703. * @return the value corresponding to the key
  38704. */
  38705. getOrAdd(key: string, val: T): T;
  38706. /**
  38707. * Check if there's a given key in the dictionary
  38708. * @param key the key to check for
  38709. * @return true if the key is present, false otherwise
  38710. */
  38711. contains(key: string): boolean;
  38712. /**
  38713. * Add a new key and its corresponding value
  38714. * @param key the key to add
  38715. * @param value the value corresponding to the key
  38716. * @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
  38717. */
  38718. add(key: string, value: T): boolean;
  38719. /**
  38720. * Update a specific value associated to a key
  38721. * @param key defines the key to use
  38722. * @param value defines the value to store
  38723. * @returns true if the value was updated (or false if the key was not found)
  38724. */
  38725. set(key: string, value: T): boolean;
  38726. /**
  38727. * Get the element of the given key and remove it from the dictionary
  38728. * @param key defines the key to search
  38729. * @returns the value associated with the key or null if not found
  38730. */
  38731. getAndRemove(key: string): Nullable<T>;
  38732. /**
  38733. * Remove a key/value from the dictionary.
  38734. * @param key the key to remove
  38735. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38736. */
  38737. remove(key: string): boolean;
  38738. /**
  38739. * Clear the whole content of the dictionary
  38740. */
  38741. clear(): void;
  38742. /**
  38743. * Gets the current count
  38744. */
  38745. readonly count: number;
  38746. /**
  38747. * Execute a callback on each key/val of the dictionary.
  38748. * Note that you can remove any element in this dictionary in the callback implementation
  38749. * @param callback the callback to execute on a given key/value pair
  38750. */
  38751. forEach(callback: (key: string, val: T) => void): void;
  38752. /**
  38753. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38754. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38755. * Note that you can remove any element in this dictionary in the callback implementation
  38756. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38757. * @returns the first item
  38758. */
  38759. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38760. private _count;
  38761. private _data;
  38762. }
  38763. }
  38764. declare module BABYLON {
  38765. /**
  38766. * Class used to store custom tags
  38767. */
  38768. class Tags {
  38769. /**
  38770. * Adds support for tags on the given object
  38771. * @param obj defines the object to use
  38772. */
  38773. static EnableFor(obj: any): void;
  38774. /**
  38775. * Removes tags support
  38776. * @param obj defines the object to use
  38777. */
  38778. static DisableFor(obj: any): void;
  38779. /**
  38780. * Gets a boolean indicating if the given object has tags
  38781. * @param obj defines the object to use
  38782. * @returns a boolean
  38783. */
  38784. static HasTags(obj: any): boolean;
  38785. /**
  38786. * Gets the tags available on a given object
  38787. * @param obj defines the object to use
  38788. * @param asString defines if the tags must be returned as a string instead of an array of strings
  38789. * @returns the tags
  38790. */
  38791. static GetTags(obj: any, asString?: boolean): any;
  38792. /**
  38793. * Adds tags to an object
  38794. * @param obj defines the object to use
  38795. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  38796. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  38797. */
  38798. static AddTagsTo(obj: any, tagsString: string): void;
  38799. /**
  38800. * @hidden
  38801. */
  38802. static _AddTagTo(obj: any, tag: string): void;
  38803. /**
  38804. * Removes specific tags from a specific object
  38805. * @param obj defines the object to use
  38806. * @param tagsString defines the tags to remove
  38807. */
  38808. static RemoveTagsFrom(obj: any, tagsString: string): void;
  38809. /**
  38810. * @hidden
  38811. */
  38812. static _RemoveTagFrom(obj: any, tag: string): void;
  38813. /**
  38814. * Defines if tags hosted on an object match a given query
  38815. * @param obj defines the object to use
  38816. * @param tagsQuery defines the tag query
  38817. * @returns a boolean
  38818. */
  38819. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  38820. }
  38821. }
  38822. declare module BABYLON {
  38823. /**
  38824. * Class used to host texture specific utilities
  38825. */
  38826. class TextureTools {
  38827. /**
  38828. * Uses the GPU to create a copy texture rescaled at a given size
  38829. * @param texture Texture to copy from
  38830. * @param width defines the desired width
  38831. * @param height defines the desired height
  38832. * @param useBilinearMode defines if bilinear mode has to be used
  38833. * @return the generated texture
  38834. */
  38835. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  38836. /**
  38837. * Gets an environment BRDF texture for a given scene
  38838. * @param scene defines the hosting scene
  38839. * @returns the environment BRDF texture
  38840. */
  38841. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  38842. private static _environmentBRDFBase64Texture;
  38843. }
  38844. }
  38845. declare module BABYLON {
  38846. /**
  38847. * Based on jsTGALoader - Javascript loader for TGA file
  38848. * By Vincent Thibault
  38849. * @see http://blog.robrowser.com/javascript-tga-loader.html
  38850. */
  38851. class TGATools {
  38852. private static _TYPE_INDEXED;
  38853. private static _TYPE_RGB;
  38854. private static _TYPE_GREY;
  38855. private static _TYPE_RLE_INDEXED;
  38856. private static _TYPE_RLE_RGB;
  38857. private static _TYPE_RLE_GREY;
  38858. private static _ORIGIN_MASK;
  38859. private static _ORIGIN_SHIFT;
  38860. private static _ORIGIN_BL;
  38861. private static _ORIGIN_BR;
  38862. private static _ORIGIN_UL;
  38863. private static _ORIGIN_UR;
  38864. /**
  38865. * Gets the header of a TGA file
  38866. * @param data defines the TGA data
  38867. * @returns the header
  38868. */
  38869. static GetTGAHeader(data: Uint8Array): any;
  38870. /**
  38871. * Uploads TGA content to a Babylon Texture
  38872. * @hidden
  38873. */
  38874. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  38875. /** @hidden */
  38876. 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;
  38877. /** @hidden */
  38878. 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;
  38879. /** @hidden */
  38880. 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;
  38881. /** @hidden */
  38882. 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;
  38883. /** @hidden */
  38884. 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;
  38885. /** @hidden */
  38886. 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;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. /**
  38891. * Interface for any object that can request an animation frame
  38892. */
  38893. interface ICustomAnimationFrameRequester {
  38894. /**
  38895. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38896. */
  38897. renderFunction?: Function;
  38898. /**
  38899. * Called to request the next frame to render to
  38900. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38901. */
  38902. requestAnimationFrame: Function;
  38903. /**
  38904. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38905. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38906. */
  38907. requestID?: number;
  38908. }
  38909. /**
  38910. * Interface containing an array of animations
  38911. */
  38912. interface IAnimatable {
  38913. /**
  38914. * Array of animations
  38915. */
  38916. animations: Array<Animation>;
  38917. }
  38918. /** Interface used by value gradients (color, factor, ...) */
  38919. interface IValueGradient {
  38920. /**
  38921. * Gets or sets the gradient value (between 0 and 1)
  38922. */
  38923. gradient: number;
  38924. }
  38925. /** Class used to store color4 gradient */
  38926. class ColorGradient implements IValueGradient {
  38927. /**
  38928. * Gets or sets the gradient value (between 0 and 1)
  38929. */
  38930. gradient: number;
  38931. /**
  38932. * Gets or sets first associated color
  38933. */
  38934. color1: Color4;
  38935. /**
  38936. * Gets or sets second associated color
  38937. */
  38938. color2?: Color4;
  38939. /**
  38940. * Will get a color picked randomly between color1 and color2.
  38941. * If color2 is undefined then color1 will be used
  38942. * @param result defines the target Color4 to store the result in
  38943. */
  38944. getColorToRef(result: Color4): void;
  38945. }
  38946. /** Class used to store color 3 gradient */
  38947. class Color3Gradient implements IValueGradient {
  38948. /**
  38949. * Gets or sets the gradient value (between 0 and 1)
  38950. */
  38951. gradient: number;
  38952. /**
  38953. * Gets or sets the associated color
  38954. */
  38955. color: Color3;
  38956. }
  38957. /** Class used to store factor gradient */
  38958. class FactorGradient implements IValueGradient {
  38959. /**
  38960. * Gets or sets the gradient value (between 0 and 1)
  38961. */
  38962. gradient: number;
  38963. /**
  38964. * Gets or sets first associated factor
  38965. */
  38966. factor1: number;
  38967. /**
  38968. * Gets or sets second associated factor
  38969. */
  38970. factor2?: number;
  38971. /**
  38972. * Will get a number picked randomly between factor1 and factor2.
  38973. * If factor2 is undefined then factor1 will be used
  38974. * @returns the picked number
  38975. */
  38976. getFactor(): number;
  38977. }
  38978. /**
  38979. * @ignore
  38980. * Application error to support additional information when loading a file
  38981. */
  38982. class LoadFileError extends Error {
  38983. /** defines the optional XHR request */
  38984. request?: XMLHttpRequest | undefined;
  38985. private static _setPrototypeOf;
  38986. /**
  38987. * Creates a new LoadFileError
  38988. * @param message defines the message of the error
  38989. * @param request defines the optional XHR request
  38990. */
  38991. constructor(message: string,
  38992. /** defines the optional XHR request */
  38993. request?: XMLHttpRequest | undefined);
  38994. }
  38995. /**
  38996. * Class used to define a retry strategy when error happens while loading assets
  38997. */
  38998. class RetryStrategy {
  38999. /**
  39000. * Function used to defines an exponential back off strategy
  39001. * @param maxRetries defines the maximum number of retries (3 by default)
  39002. * @param baseInterval defines the interval between retries
  39003. * @returns the strategy function to use
  39004. */
  39005. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39006. }
  39007. /**
  39008. * File request interface
  39009. */
  39010. interface IFileRequest {
  39011. /**
  39012. * Raised when the request is complete (success or error).
  39013. */
  39014. onCompleteObservable: Observable<IFileRequest>;
  39015. /**
  39016. * Aborts the request for a file.
  39017. */
  39018. abort: () => void;
  39019. }
  39020. /**
  39021. * Class containing a set of static utilities functions
  39022. */
  39023. class Tools {
  39024. /**
  39025. * Gets or sets the base URL to use to load assets
  39026. */
  39027. static BaseUrl: string;
  39028. /**
  39029. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39030. */
  39031. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39032. /**
  39033. * Default behaviour for cors in the application.
  39034. * It can be a string if the expected behavior is identical in the entire app.
  39035. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39036. */
  39037. static CorsBehavior: string | ((url: string | string[]) => string);
  39038. /**
  39039. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39040. * @ignorenaming
  39041. */
  39042. static UseFallbackTexture: boolean;
  39043. /**
  39044. * Use this object to register external classes like custom textures or material
  39045. * to allow the laoders to instantiate them
  39046. */
  39047. static RegisteredExternalClasses: {
  39048. [key: string]: Object;
  39049. };
  39050. /**
  39051. * Texture content used if a texture cannot loaded
  39052. * @ignorenaming
  39053. */
  39054. static fallbackTexture: string;
  39055. /**
  39056. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39057. * @param u defines the coordinate on X axis
  39058. * @param v defines the coordinate on Y axis
  39059. * @param width defines the width of the source data
  39060. * @param height defines the height of the source data
  39061. * @param pixels defines the source byte array
  39062. * @param color defines the output color
  39063. */
  39064. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39065. /**
  39066. * Interpolates between a and b via alpha
  39067. * @param a The lower value (returned when alpha = 0)
  39068. * @param b The upper value (returned when alpha = 1)
  39069. * @param alpha The interpolation-factor
  39070. * @return The mixed value
  39071. */
  39072. static Mix(a: number, b: number, alpha: number): number;
  39073. /**
  39074. * Tries to instantiate a new object from a given class name
  39075. * @param className defines the class name to instantiate
  39076. * @returns the new object or null if the system was not able to do the instantiation
  39077. */
  39078. static Instantiate(className: string): any;
  39079. /**
  39080. * Provides a slice function that will work even on IE
  39081. * @param data defines the array to slice
  39082. * @param start defines the start of the data (optional)
  39083. * @param end defines the end of the data (optional)
  39084. * @returns the new sliced array
  39085. */
  39086. static Slice<T>(data: T, start?: number, end?: number): T;
  39087. /**
  39088. * Polyfill for setImmediate
  39089. * @param action defines the action to execute after the current execution block
  39090. */
  39091. static SetImmediate(action: () => void): void;
  39092. /**
  39093. * Function indicating if a number is an exponent of 2
  39094. * @param value defines the value to test
  39095. * @returns true if the value is an exponent of 2
  39096. */
  39097. static IsExponentOfTwo(value: number): boolean;
  39098. private static _tmpFloatArray;
  39099. /**
  39100. * Returns the nearest 32-bit single precision float representation of a Number
  39101. * @param value A Number. If the parameter is of a different type, it will get converted
  39102. * to a number or to NaN if it cannot be converted
  39103. * @returns number
  39104. */
  39105. static FloatRound(value: number): number;
  39106. /**
  39107. * Find the next highest power of two.
  39108. * @param x Number to start search from.
  39109. * @return Next highest power of two.
  39110. */
  39111. static CeilingPOT(x: number): number;
  39112. /**
  39113. * Find the next lowest power of two.
  39114. * @param x Number to start search from.
  39115. * @return Next lowest power of two.
  39116. */
  39117. static FloorPOT(x: number): number;
  39118. /**
  39119. * Find the nearest power of two.
  39120. * @param x Number to start search from.
  39121. * @return Next nearest power of two.
  39122. */
  39123. static NearestPOT(x: number): number;
  39124. /**
  39125. * Get the closest exponent of two
  39126. * @param value defines the value to approximate
  39127. * @param max defines the maximum value to return
  39128. * @param mode defines how to define the closest value
  39129. * @returns closest exponent of two of the given value
  39130. */
  39131. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39132. /**
  39133. * Extracts the filename from a path
  39134. * @param path defines the path to use
  39135. * @returns the filename
  39136. */
  39137. static GetFilename(path: string): string;
  39138. /**
  39139. * Extracts the "folder" part of a path (everything before the filename).
  39140. * @param uri The URI to extract the info from
  39141. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39142. * @returns The "folder" part of the path
  39143. */
  39144. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39145. /**
  39146. * Extracts text content from a DOM element hierarchy
  39147. * @param element defines the root element
  39148. * @returns a string
  39149. */
  39150. static GetDOMTextContent(element: HTMLElement): string;
  39151. /**
  39152. * Convert an angle in radians to degrees
  39153. * @param angle defines the angle to convert
  39154. * @returns the angle in degrees
  39155. */
  39156. static ToDegrees(angle: number): number;
  39157. /**
  39158. * Convert an angle in degrees to radians
  39159. * @param angle defines the angle to convert
  39160. * @returns the angle in radians
  39161. */
  39162. static ToRadians(angle: number): number;
  39163. /**
  39164. * Encode a buffer to a base64 string
  39165. * @param buffer defines the buffer to encode
  39166. * @returns the encoded string
  39167. */
  39168. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39169. /**
  39170. * Extracts minimum and maximum values from a list of indexed positions
  39171. * @param positions defines the positions to use
  39172. * @param indices defines the indices to the positions
  39173. * @param indexStart defines the start index
  39174. * @param indexCount defines the end index
  39175. * @param bias defines bias value to add to the result
  39176. * @return minimum and maximum values
  39177. */
  39178. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39179. minimum: Vector3;
  39180. maximum: Vector3;
  39181. };
  39182. /**
  39183. * Extracts minimum and maximum values from a list of positions
  39184. * @param positions defines the positions to use
  39185. * @param start defines the start index in the positions array
  39186. * @param count defines the number of positions to handle
  39187. * @param bias defines bias value to add to the result
  39188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39189. * @return minimum and maximum values
  39190. */
  39191. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39192. minimum: Vector3;
  39193. maximum: Vector3;
  39194. };
  39195. /**
  39196. * Returns an array if obj is not an array
  39197. * @param obj defines the object to evaluate as an array
  39198. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39199. * @returns either obj directly if obj is an array or a new array containing obj
  39200. */
  39201. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39202. /**
  39203. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39204. * @param size the number of element to construct and put in the array
  39205. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39206. * @returns a new array filled with new objects
  39207. */
  39208. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39209. /**
  39210. * Gets the pointer prefix to use
  39211. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39212. */
  39213. static GetPointerPrefix(): string;
  39214. /**
  39215. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39216. * @param func - the function to be called
  39217. * @param requester - the object that will request the next frame. Falls back to window.
  39218. * @returns frame number
  39219. */
  39220. static QueueNewFrame(func: () => void, requester?: any): number;
  39221. /**
  39222. * Ask the browser to promote the current element to fullscreen rendering mode
  39223. * @param element defines the DOM element to promote
  39224. */
  39225. static RequestFullscreen(element: HTMLElement): void;
  39226. /**
  39227. * Asks the browser to exit fullscreen mode
  39228. */
  39229. static ExitFullscreen(): void;
  39230. /**
  39231. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39232. * @param url define the url we are trying
  39233. * @param element define the dom element where to configure the cors policy
  39234. */
  39235. static SetCorsBehavior(url: string | string[], element: {
  39236. crossOrigin: string | null;
  39237. }): void;
  39238. /**
  39239. * Removes unwanted characters from an url
  39240. * @param url defines the url to clean
  39241. * @returns the cleaned url
  39242. */
  39243. static CleanUrl(url: string): string;
  39244. /**
  39245. * Gets or sets a function used to pre-process url before using them to load assets
  39246. */
  39247. static PreprocessUrl: (url: string) => string;
  39248. /**
  39249. * Loads an image as an HTMLImageElement.
  39250. * @param input url string, ArrayBuffer, or Blob to load
  39251. * @param onLoad callback called when the image successfully loads
  39252. * @param onError callback called when the image fails to load
  39253. * @param offlineProvider offline provider for caching
  39254. * @returns the HTMLImageElement of the loaded image
  39255. */
  39256. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39257. /**
  39258. * Loads a file
  39259. * @param url url string, ArrayBuffer, or Blob to load
  39260. * @param onSuccess callback called when the file successfully loads
  39261. * @param onProgress callback called while file is loading (if the server supports this mode)
  39262. * @param offlineProvider defines the offline provider for caching
  39263. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39264. * @param onError callback called when the file fails to load
  39265. * @returns a file request object
  39266. */
  39267. 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;
  39268. /**
  39269. * Load a script (identified by an url). When the url returns, the
  39270. * content of this file is added into a new script element, attached to the DOM (body element)
  39271. * @param scriptUrl defines the url of the script to laod
  39272. * @param onSuccess defines the callback called when the script is loaded
  39273. * @param onError defines the callback to call if an error occurs
  39274. */
  39275. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39276. /**
  39277. * Loads a file from a blob
  39278. * @param fileToLoad defines the blob to use
  39279. * @param callback defines the callback to call when data is loaded
  39280. * @param progressCallback defines the callback to call during loading process
  39281. * @returns a file request object
  39282. */
  39283. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39284. /**
  39285. * Loads a file
  39286. * @param fileToLoad defines the file to load
  39287. * @param callback defines the callback to call when data is loaded
  39288. * @param progressCallBack defines the callback to call during loading process
  39289. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39290. * @returns a file request object
  39291. */
  39292. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39293. /**
  39294. * Creates a data url from a given string content
  39295. * @param content defines the content to convert
  39296. * @returns the new data url link
  39297. */
  39298. static FileAsURL(content: string): string;
  39299. /**
  39300. * Format the given number to a specific decimal format
  39301. * @param value defines the number to format
  39302. * @param decimals defines the number of decimals to use
  39303. * @returns the formatted string
  39304. */
  39305. static Format(value: number, decimals?: number): string;
  39306. /**
  39307. * Checks if a given vector is inside a specific range
  39308. * @param v defines the vector to test
  39309. * @param min defines the minimum range
  39310. * @param max defines the maximum range
  39311. */
  39312. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39313. /**
  39314. * Tries to copy an object by duplicating every property
  39315. * @param source defines the source object
  39316. * @param destination defines the target object
  39317. * @param doNotCopyList defines a list of properties to avoid
  39318. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39319. */
  39320. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39321. /**
  39322. * Gets a boolean indicating if the given object has no own property
  39323. * @param obj defines the object to test
  39324. * @returns true if object has no own property
  39325. */
  39326. static IsEmpty(obj: any): boolean;
  39327. /**
  39328. * Function used to register events at window level
  39329. * @param events defines the events to register
  39330. */
  39331. static RegisterTopRootEvents(events: {
  39332. name: string;
  39333. handler: Nullable<(e: FocusEvent) => any>;
  39334. }[]): void;
  39335. /**
  39336. * Function used to unregister events from window level
  39337. * @param events defines the events to unregister
  39338. */
  39339. static UnregisterTopRootEvents(events: {
  39340. name: string;
  39341. handler: Nullable<(e: FocusEvent) => any>;
  39342. }[]): void;
  39343. /**
  39344. * Dumps the current bound framebuffer
  39345. * @param width defines the rendering width
  39346. * @param height defines the rendering height
  39347. * @param engine defines the hosting engine
  39348. * @param successCallback defines the callback triggered once the data are available
  39349. * @param mimeType defines the mime type of the result
  39350. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39351. */
  39352. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39353. /**
  39354. * Converts the canvas data to blob.
  39355. * This acts as a polyfill for browsers not supporting the to blob function.
  39356. * @param canvas Defines the canvas to extract the data from
  39357. * @param successCallback Defines the callback triggered once the data are available
  39358. * @param mimeType Defines the mime type of the result
  39359. */
  39360. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39361. /**
  39362. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39363. * @param successCallback defines the callback triggered once the data are available
  39364. * @param mimeType defines the mime type of the result
  39365. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39366. */
  39367. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39368. /**
  39369. * Downloads a blob in the browser
  39370. * @param blob defines the blob to download
  39371. * @param fileName defines the name of the downloaded file
  39372. */
  39373. static Download(blob: Blob, fileName: string): void;
  39374. /**
  39375. * Captures a screenshot of the current rendering
  39376. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39377. * @param engine defines the rendering engine
  39378. * @param camera defines the source camera
  39379. * @param size This parameter can be set to a single number or to an object with the
  39380. * following (optional) properties: precision, width, height. If a single number is passed,
  39381. * it will be used for both width and height. If an object is passed, the screenshot size
  39382. * will be derived from the parameters. The precision property is a multiplier allowing
  39383. * rendering at a higher or lower resolution
  39384. * @param successCallback defines the callback receives a single parameter which contains the
  39385. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39386. * src parameter of an <img> to display it
  39387. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39388. * Check your browser for supported MIME types
  39389. */
  39390. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39391. /**
  39392. * Generates an image screenshot from the specified camera.
  39393. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39394. * @param engine The engine to use for rendering
  39395. * @param camera The camera to use for rendering
  39396. * @param size This parameter can be set to a single number or to an object with the
  39397. * following (optional) properties: precision, width, height. If a single number is passed,
  39398. * it will be used for both width and height. If an object is passed, the screenshot size
  39399. * will be derived from the parameters. The precision property is a multiplier allowing
  39400. * rendering at a higher or lower resolution
  39401. * @param successCallback The callback receives a single parameter which contains the
  39402. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39403. * src parameter of an <img> to display it
  39404. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39405. * Check your browser for supported MIME types
  39406. * @param samples Texture samples (default: 1)
  39407. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39408. * @param fileName A name for for the downloaded file.
  39409. */
  39410. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39411. /**
  39412. * Validates if xhr data is correct
  39413. * @param xhr defines the request to validate
  39414. * @param dataType defines the expected data type
  39415. * @returns true if data is correct
  39416. */
  39417. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39418. /**
  39419. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39420. * Be aware Math.random() could cause collisions, but:
  39421. * "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"
  39422. * @returns a pseudo random id
  39423. */
  39424. static RandomId(): string;
  39425. /**
  39426. * Test if the given uri is a base64 string
  39427. * @param uri The uri to test
  39428. * @return True if the uri is a base64 string or false otherwise
  39429. */
  39430. static IsBase64(uri: string): boolean;
  39431. /**
  39432. * Decode the given base64 uri.
  39433. * @param uri The uri to decode
  39434. * @return The decoded base64 data.
  39435. */
  39436. static DecodeBase64(uri: string): ArrayBuffer;
  39437. /**
  39438. * No log
  39439. */
  39440. static readonly NoneLogLevel: number;
  39441. /**
  39442. * Only message logs
  39443. */
  39444. static readonly MessageLogLevel: number;
  39445. /**
  39446. * Only warning logs
  39447. */
  39448. static readonly WarningLogLevel: number;
  39449. /**
  39450. * Only error logs
  39451. */
  39452. static readonly ErrorLogLevel: number;
  39453. /**
  39454. * All logs
  39455. */
  39456. static readonly AllLogLevel: number;
  39457. private static _LogCache;
  39458. /**
  39459. * Gets a value indicating the number of loading errors
  39460. * @ignorenaming
  39461. */
  39462. static errorsCount: number;
  39463. /**
  39464. * Callback called when a new log is added
  39465. */
  39466. static OnNewCacheEntry: (entry: string) => void;
  39467. private static _AddLogEntry;
  39468. private static _FormatMessage;
  39469. private static _LogDisabled;
  39470. private static _LogEnabled;
  39471. private static _WarnDisabled;
  39472. private static _WarnEnabled;
  39473. private static _ErrorDisabled;
  39474. private static _ErrorEnabled;
  39475. /**
  39476. * Log a message to the console
  39477. */
  39478. static Log: (message: string) => void;
  39479. /**
  39480. * Write a warning message to the console
  39481. */
  39482. static Warn: (message: string) => void;
  39483. /**
  39484. * Write an error message to the console
  39485. */
  39486. static Error: (message: string) => void;
  39487. /**
  39488. * Gets current log cache (list of logs)
  39489. */
  39490. static readonly LogCache: string;
  39491. /**
  39492. * Clears the log cache
  39493. */
  39494. static ClearLogCache(): void;
  39495. /**
  39496. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39497. */
  39498. static LogLevels: number;
  39499. /**
  39500. * Checks if the loaded document was accessed via `file:`-Protocol.
  39501. * @returns boolean
  39502. */
  39503. static IsFileURL(): boolean;
  39504. /**
  39505. * Checks if the window object exists
  39506. * @returns true if the window object exists
  39507. */
  39508. static IsWindowObjectExist(): boolean;
  39509. /**
  39510. * No performance log
  39511. */
  39512. static readonly PerformanceNoneLogLevel: number;
  39513. /**
  39514. * Use user marks to log performance
  39515. */
  39516. static readonly PerformanceUserMarkLogLevel: number;
  39517. /**
  39518. * Log performance to the console
  39519. */
  39520. static readonly PerformanceConsoleLogLevel: number;
  39521. private static _performance;
  39522. /**
  39523. * Sets the current performance log level
  39524. */
  39525. static PerformanceLogLevel: number;
  39526. private static _StartPerformanceCounterDisabled;
  39527. private static _EndPerformanceCounterDisabled;
  39528. private static _StartUserMark;
  39529. private static _EndUserMark;
  39530. private static _StartPerformanceConsole;
  39531. private static _EndPerformanceConsole;
  39532. /**
  39533. * Starts a performance counter
  39534. */
  39535. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39536. /**
  39537. * Ends a specific performance coutner
  39538. */
  39539. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39540. /**
  39541. * Gets either window.performance.now() if supported or Date.now() else
  39542. */
  39543. static readonly Now: number;
  39544. /**
  39545. * This method will return the name of the class used to create the instance of the given object.
  39546. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39547. * @param object the object to get the class name from
  39548. * @param isType defines if the object is actually a type
  39549. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39550. */
  39551. static GetClassName(object: any, isType?: boolean): string;
  39552. /**
  39553. * Gets the first element of an array satisfying a given predicate
  39554. * @param array defines the array to browse
  39555. * @param predicate defines the predicate to use
  39556. * @returns null if not found or the element
  39557. */
  39558. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39559. /**
  39560. * This method will return the name of the full name of the class, including its owning module (if any).
  39561. * 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).
  39562. * @param object the object to get the class name from
  39563. * @param isType defines if the object is actually a type
  39564. * @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.
  39565. * @ignorenaming
  39566. */
  39567. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39568. /**
  39569. * Returns a promise that resolves after the given amount of time.
  39570. * @param delay Number of milliseconds to delay
  39571. * @returns Promise that resolves after the given amount of time
  39572. */
  39573. static DelayAsync(delay: number): Promise<void>;
  39574. /**
  39575. * Gets the current gradient from an array of IValueGradient
  39576. * @param ratio defines the current ratio to get
  39577. * @param gradients defines the array of IValueGradient
  39578. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39579. */
  39580. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39581. }
  39582. /**
  39583. * This class is used to track a performance counter which is number based.
  39584. * The user has access to many properties which give statistics of different nature.
  39585. *
  39586. * The implementer can track two kinds of Performance Counter: time and count.
  39587. * 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.
  39588. * 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.
  39589. */
  39590. class PerfCounter {
  39591. /**
  39592. * Gets or sets a global boolean to turn on and off all the counters
  39593. */
  39594. static Enabled: boolean;
  39595. /**
  39596. * Returns the smallest value ever
  39597. */
  39598. readonly min: number;
  39599. /**
  39600. * Returns the biggest value ever
  39601. */
  39602. readonly max: number;
  39603. /**
  39604. * Returns the average value since the performance counter is running
  39605. */
  39606. readonly average: number;
  39607. /**
  39608. * Returns the average value of the last second the counter was monitored
  39609. */
  39610. readonly lastSecAverage: number;
  39611. /**
  39612. * Returns the current value
  39613. */
  39614. readonly current: number;
  39615. /**
  39616. * Gets the accumulated total
  39617. */
  39618. readonly total: number;
  39619. /**
  39620. * Gets the total value count
  39621. */
  39622. readonly count: number;
  39623. /**
  39624. * Creates a new counter
  39625. */
  39626. constructor();
  39627. /**
  39628. * Call this method to start monitoring a new frame.
  39629. * 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.
  39630. */
  39631. fetchNewFrame(): void;
  39632. /**
  39633. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  39634. * @param newCount the count value to add to the monitored count
  39635. * @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.
  39636. */
  39637. addCount(newCount: number, fetchResult: boolean): void;
  39638. /**
  39639. * Start monitoring this performance counter
  39640. */
  39641. beginMonitoring(): void;
  39642. /**
  39643. * Compute the time lapsed since the previous beginMonitoring() call.
  39644. * @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
  39645. */
  39646. endMonitoring(newFrame?: boolean): void;
  39647. private _fetchResult;
  39648. private _startMonitoringTime;
  39649. private _min;
  39650. private _max;
  39651. private _average;
  39652. private _current;
  39653. private _totalValueCount;
  39654. private _totalAccumulated;
  39655. private _lastSecAverage;
  39656. private _lastSecAccumulated;
  39657. private _lastSecTime;
  39658. private _lastSecValueCount;
  39659. }
  39660. /**
  39661. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39662. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39663. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39664. * @param name The name of the class, case should be preserved
  39665. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39666. */
  39667. function className(name: string, module?: string): (target: Object) => void;
  39668. /**
  39669. * An implementation of a loop for asynchronous functions.
  39670. */
  39671. class AsyncLoop {
  39672. /**
  39673. * Defines the number of iterations for the loop
  39674. */
  39675. iterations: number;
  39676. /**
  39677. * Defines the current index of the loop.
  39678. */
  39679. index: number;
  39680. private _done;
  39681. private _fn;
  39682. private _successCallback;
  39683. /**
  39684. * Constructor.
  39685. * @param iterations the number of iterations.
  39686. * @param func the function to run each iteration
  39687. * @param successCallback the callback that will be called upon succesful execution
  39688. * @param offset starting offset.
  39689. */
  39690. constructor(
  39691. /**
  39692. * Defines the number of iterations for the loop
  39693. */
  39694. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39695. /**
  39696. * Execute the next iteration. Must be called after the last iteration was finished.
  39697. */
  39698. executeNext(): void;
  39699. /**
  39700. * Break the loop and run the success callback.
  39701. */
  39702. breakLoop(): void;
  39703. /**
  39704. * Create and run an async loop.
  39705. * @param iterations the number of iterations.
  39706. * @param fn the function to run each iteration
  39707. * @param successCallback the callback that will be called upon succesful execution
  39708. * @param offset starting offset.
  39709. * @returns the created async loop object
  39710. */
  39711. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39712. /**
  39713. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39714. * @param iterations total number of iterations
  39715. * @param syncedIterations number of synchronous iterations in each async iteration.
  39716. * @param fn the function to call each iteration.
  39717. * @param callback a success call back that will be called when iterating stops.
  39718. * @param breakFunction a break condition (optional)
  39719. * @param timeout timeout settings for the setTimeout function. default - 0.
  39720. * @returns the created async loop object
  39721. */
  39722. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39723. }
  39724. }
  39725. interface HTMLCanvasElement {
  39726. /** Track wether a record is in progress */
  39727. isRecording: boolean;
  39728. /** Capture Stream method defined by some browsers */
  39729. captureStream(fps?: number): MediaStream;
  39730. }
  39731. interface MediaRecorder {
  39732. /** Starts recording */
  39733. start(timeSlice: number): void;
  39734. /** Stops recording */
  39735. stop(): void;
  39736. /** Event raised when an error arised. */
  39737. onerror: (event: ErrorEvent) => void;
  39738. /** Event raised when the recording stops. */
  39739. onstop: (event: Event) => void;
  39740. /** Event raised when a new chunk of data is available and should be tracked. */
  39741. ondataavailable: (event: Event) => void;
  39742. }
  39743. interface MediaRecorderOptions {
  39744. /** The mime type you want to use as the recording container for the new MediaRecorder */
  39745. mimeType?: string;
  39746. /** The chosen bitrate for the audio component of the media. */
  39747. audioBitsPerSecond?: number;
  39748. /** The chosen bitrate for the video component of the media. */
  39749. videoBitsPerSecond?: number;
  39750. /** 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. */
  39751. bitsPerSecond?: number;
  39752. }
  39753. interface MediaRecorderConstructor {
  39754. /**
  39755. * A reference to the prototype.
  39756. */
  39757. readonly prototype: MediaRecorder;
  39758. /**
  39759. * Creates a new MediaRecorder.
  39760. * @param stream Defines the stream to record.
  39761. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  39762. */
  39763. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  39764. }
  39765. /**
  39766. * MediaRecoreder object available in some browsers.
  39767. */
  39768. declare var MediaRecorder: MediaRecorderConstructor;
  39769. declare module BABYLON {
  39770. /**
  39771. * This represents the different options avilable for the video capture.
  39772. */
  39773. interface VideoRecorderOptions {
  39774. /** Defines the mime type of the video */
  39775. mimeType: string;
  39776. /** Defines the video the video should be recorded at */
  39777. fps: number;
  39778. /** Defines the chunk size for the recording data */
  39779. recordChunckSize: number;
  39780. }
  39781. /**
  39782. * This can helps recording videos from BabylonJS.
  39783. * This is based on the available WebRTC functionalities of the browser.
  39784. *
  39785. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  39786. */
  39787. class VideoRecorder {
  39788. private static readonly _defaultOptions;
  39789. /**
  39790. * Returns wehther or not the VideoRecorder is available in your browser.
  39791. * @param engine Defines the Babylon Engine to check the support for
  39792. * @returns true if supported otherwise false
  39793. */
  39794. static IsSupported(engine: Engine): boolean;
  39795. private readonly _options;
  39796. private _canvas;
  39797. private _mediaRecorder;
  39798. private _recordedChunks;
  39799. private _fileName;
  39800. private _resolve;
  39801. private _reject;
  39802. /**
  39803. * True wether a recording is already in progress.
  39804. */
  39805. readonly isRecording: boolean;
  39806. /**
  39807. * Create a new VideoCapture object which can help converting what you see in Babylon to
  39808. * a video file.
  39809. * @param engine Defines the BabylonJS Engine you wish to record
  39810. * @param options Defines options that can be used to customized the capture
  39811. */
  39812. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  39813. /**
  39814. * Stops the current recording before the default capture timeout passed in the startRecording
  39815. * functions.
  39816. */
  39817. stopRecording(): void;
  39818. /**
  39819. * Starts recording the canvas for a max duration specified in parameters.
  39820. * @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.
  39821. * @param maxDuration Defines the maximum recording time in seconds.
  39822. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  39823. * @return a promise callback at the end of the recording with the video data in Blob.
  39824. */
  39825. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  39826. /**
  39827. * Releases internal resources used during the recording.
  39828. */
  39829. dispose(): void;
  39830. private _handleDataAvailable;
  39831. private _handleError;
  39832. private _handleStop;
  39833. }
  39834. }
  39835. declare module BABYLON {
  39836. /**
  39837. * Defines the potential axis of a Joystick
  39838. */
  39839. enum JoystickAxis {
  39840. /** X axis */
  39841. X = 0,
  39842. /** Y axis */
  39843. Y = 1,
  39844. /** Z axis */
  39845. Z = 2
  39846. }
  39847. /**
  39848. * Class used to define virtual joystick (used in touch mode)
  39849. */
  39850. class VirtualJoystick {
  39851. /**
  39852. * Gets or sets a boolean indicating that left and right values must be inverted
  39853. */
  39854. reverseLeftRight: boolean;
  39855. /**
  39856. * Gets or sets a boolean indicating that up and down values must be inverted
  39857. */
  39858. reverseUpDown: boolean;
  39859. /**
  39860. * Gets the offset value for the position (ie. the change of the position value)
  39861. */
  39862. deltaPosition: Vector3;
  39863. /**
  39864. * Gets a boolean indicating if the virtual joystick was pressed
  39865. */
  39866. pressed: boolean;
  39867. private static _globalJoystickIndex;
  39868. private static vjCanvas;
  39869. private static vjCanvasContext;
  39870. private static vjCanvasWidth;
  39871. private static vjCanvasHeight;
  39872. private static halfWidth;
  39873. private _action;
  39874. private _axisTargetedByLeftAndRight;
  39875. private _axisTargetedByUpAndDown;
  39876. private _joystickSensibility;
  39877. private _inversedSensibility;
  39878. private _joystickPointerID;
  39879. private _joystickColor;
  39880. private _joystickPointerPos;
  39881. private _joystickPreviousPointerPos;
  39882. private _joystickPointerStartPos;
  39883. private _deltaJoystickVector;
  39884. private _leftJoystick;
  39885. private _touches;
  39886. private _onPointerDownHandlerRef;
  39887. private _onPointerMoveHandlerRef;
  39888. private _onPointerUpHandlerRef;
  39889. private _onResize;
  39890. /**
  39891. * Creates a new virtual joystick
  39892. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39893. */
  39894. constructor(leftJoystick?: boolean);
  39895. /**
  39896. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39897. * @param newJoystickSensibility defines the new sensibility
  39898. */
  39899. setJoystickSensibility(newJoystickSensibility: number): void;
  39900. private _onPointerDown;
  39901. private _onPointerMove;
  39902. private _onPointerUp;
  39903. /**
  39904. * Change the color of the virtual joystick
  39905. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39906. */
  39907. setJoystickColor(newColor: string): void;
  39908. /**
  39909. * Defines a callback to call when the joystick is touched
  39910. * @param action defines the callback
  39911. */
  39912. setActionOnTouch(action: () => any): void;
  39913. /**
  39914. * Defines which axis you'd like to control for left & right
  39915. * @param axis defines the axis to use
  39916. */
  39917. setAxisForLeftRight(axis: JoystickAxis): void;
  39918. /**
  39919. * Defines which axis you'd like to control for up & down
  39920. * @param axis defines the axis to use
  39921. */
  39922. setAxisForUpDown(axis: JoystickAxis): void;
  39923. private _drawVirtualJoystick;
  39924. /**
  39925. * Release internal HTML canvas
  39926. */
  39927. releaseCanvas(): void;
  39928. }
  39929. }
  39930. declare module BABYLON {
  39931. /**
  39932. * Helper class to push actions to a pool of workers.
  39933. */
  39934. class WorkerPool implements IDisposable {
  39935. private _workerInfos;
  39936. private _pendingActions;
  39937. /**
  39938. * Constructor
  39939. * @param workers Array of workers to use for actions
  39940. */
  39941. constructor(workers: Array<Worker>);
  39942. /**
  39943. * Terminates all workers and clears any pending actions.
  39944. */
  39945. dispose(): void;
  39946. /**
  39947. * Pushes an action to the worker pool. If all the workers are active, the action will be
  39948. * pended until a worker has completed its action.
  39949. * @param action The action to perform. Call onComplete when the action is complete.
  39950. */
  39951. push(action: (worker: Worker, onComplete: () => void) => void): void;
  39952. private _execute;
  39953. }
  39954. }
  39955. declare module BABYLON {
  39956. /**
  39957. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39958. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39959. */
  39960. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39961. /**
  39962. * Gets the name of the behavior.
  39963. */
  39964. readonly name: string;
  39965. private _zoomStopsAnimation;
  39966. private _idleRotationSpeed;
  39967. private _idleRotationWaitTime;
  39968. private _idleRotationSpinupTime;
  39969. /**
  39970. * Sets the flag that indicates if user zooming should stop animation.
  39971. */
  39972. /**
  39973. * Gets the flag that indicates if user zooming should stop animation.
  39974. */
  39975. zoomStopsAnimation: boolean;
  39976. /**
  39977. * Sets the default speed at which the camera rotates around the model.
  39978. */
  39979. /**
  39980. * Gets the default speed at which the camera rotates around the model.
  39981. */
  39982. idleRotationSpeed: number;
  39983. /**
  39984. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39985. */
  39986. /**
  39987. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39988. */
  39989. idleRotationWaitTime: number;
  39990. /**
  39991. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39992. */
  39993. /**
  39994. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39995. */
  39996. idleRotationSpinupTime: number;
  39997. /**
  39998. * Gets a value indicating if the camera is currently rotating because of this behavior
  39999. */
  40000. readonly rotationInProgress: boolean;
  40001. private _onPrePointerObservableObserver;
  40002. private _onAfterCheckInputsObserver;
  40003. private _attachedCamera;
  40004. private _isPointerDown;
  40005. private _lastFrameTime;
  40006. private _lastInteractionTime;
  40007. private _cameraRotationSpeed;
  40008. /**
  40009. * Initializes the behavior.
  40010. */
  40011. init(): void;
  40012. /**
  40013. * Attaches the behavior to its arc rotate camera.
  40014. * @param camera Defines the camera to attach the behavior to
  40015. */
  40016. attach(camera: ArcRotateCamera): void;
  40017. /**
  40018. * Detaches the behavior from its current arc rotate camera.
  40019. */
  40020. detach(): void;
  40021. /**
  40022. * Returns true if user is scrolling.
  40023. * @return true if user is scrolling.
  40024. */
  40025. private _userIsZooming;
  40026. private _lastFrameRadius;
  40027. private _shouldAnimationStopForInteraction;
  40028. /**
  40029. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40030. */
  40031. private _applyUserInteraction;
  40032. private _userIsMoving;
  40033. }
  40034. }
  40035. declare module BABYLON {
  40036. /**
  40037. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40038. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40039. */
  40040. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40041. /**
  40042. * Gets the name of the behavior.
  40043. */
  40044. readonly name: string;
  40045. /**
  40046. * The easing function used by animations
  40047. */
  40048. static EasingFunction: BackEase;
  40049. /**
  40050. * The easing mode used by animations
  40051. */
  40052. static EasingMode: number;
  40053. /**
  40054. * The duration of the animation, in milliseconds
  40055. */
  40056. transitionDuration: number;
  40057. /**
  40058. * Length of the distance animated by the transition when lower radius is reached
  40059. */
  40060. lowerRadiusTransitionRange: number;
  40061. /**
  40062. * Length of the distance animated by the transition when upper radius is reached
  40063. */
  40064. upperRadiusTransitionRange: number;
  40065. private _autoTransitionRange;
  40066. /**
  40067. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40068. */
  40069. /**
  40070. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40071. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40072. */
  40073. autoTransitionRange: boolean;
  40074. private _attachedCamera;
  40075. private _onAfterCheckInputsObserver;
  40076. private _onMeshTargetChangedObserver;
  40077. /**
  40078. * Initializes the behavior.
  40079. */
  40080. init(): void;
  40081. /**
  40082. * Attaches the behavior to its arc rotate camera.
  40083. * @param camera Defines the camera to attach the behavior to
  40084. */
  40085. attach(camera: ArcRotateCamera): void;
  40086. /**
  40087. * Detaches the behavior from its current arc rotate camera.
  40088. */
  40089. detach(): void;
  40090. private _radiusIsAnimating;
  40091. private _radiusBounceTransition;
  40092. private _animatables;
  40093. private _cachedWheelPrecision;
  40094. /**
  40095. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40096. * @param radiusLimit The limit to check against.
  40097. * @return Bool to indicate if at limit.
  40098. */
  40099. private _isRadiusAtLimit;
  40100. /**
  40101. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40102. * @param radiusDelta The delta by which to animate to. Can be negative.
  40103. */
  40104. private _applyBoundRadiusAnimation;
  40105. /**
  40106. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40107. */
  40108. protected _clearAnimationLocks(): void;
  40109. /**
  40110. * Stops and removes all animations that have been applied to the camera
  40111. */
  40112. stopAllAnimations(): void;
  40113. }
  40114. }
  40115. declare module BABYLON {
  40116. /**
  40117. * 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.
  40118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40119. */
  40120. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40121. /**
  40122. * Gets the name of the behavior.
  40123. */
  40124. readonly name: string;
  40125. private _mode;
  40126. private _radiusScale;
  40127. private _positionScale;
  40128. private _defaultElevation;
  40129. private _elevationReturnTime;
  40130. private _elevationReturnWaitTime;
  40131. private _zoomStopsAnimation;
  40132. private _framingTime;
  40133. /**
  40134. * The easing function used by animations
  40135. */
  40136. static EasingFunction: ExponentialEase;
  40137. /**
  40138. * The easing mode used by animations
  40139. */
  40140. static EasingMode: number;
  40141. /**
  40142. * Sets the current mode used by the behavior
  40143. */
  40144. /**
  40145. * Gets current mode used by the behavior.
  40146. */
  40147. mode: number;
  40148. /**
  40149. * Sets the scale applied to the radius (1 by default)
  40150. */
  40151. /**
  40152. * Gets the scale applied to the radius
  40153. */
  40154. radiusScale: number;
  40155. /**
  40156. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40157. */
  40158. /**
  40159. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40160. */
  40161. positionScale: number;
  40162. /**
  40163. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40164. * behaviour is triggered, in radians.
  40165. */
  40166. /**
  40167. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40168. * behaviour is triggered, in radians.
  40169. */
  40170. defaultElevation: number;
  40171. /**
  40172. * Sets the time (in milliseconds) taken to return to the default beta position.
  40173. * Negative value indicates camera should not return to default.
  40174. */
  40175. /**
  40176. * Gets the time (in milliseconds) taken to return to the default beta position.
  40177. * Negative value indicates camera should not return to default.
  40178. */
  40179. elevationReturnTime: number;
  40180. /**
  40181. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40182. */
  40183. /**
  40184. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40185. */
  40186. elevationReturnWaitTime: number;
  40187. /**
  40188. * Sets the flag that indicates if user zooming should stop animation.
  40189. */
  40190. /**
  40191. * Gets the flag that indicates if user zooming should stop animation.
  40192. */
  40193. zoomStopsAnimation: boolean;
  40194. /**
  40195. * Sets the transition time when framing the mesh, in milliseconds
  40196. */
  40197. /**
  40198. * Gets the transition time when framing the mesh, in milliseconds
  40199. */
  40200. framingTime: number;
  40201. /**
  40202. * Define if the behavior should automatically change the configured
  40203. * camera limits and sensibilities.
  40204. */
  40205. autoCorrectCameraLimitsAndSensibility: boolean;
  40206. private _onPrePointerObservableObserver;
  40207. private _onAfterCheckInputsObserver;
  40208. private _onMeshTargetChangedObserver;
  40209. private _attachedCamera;
  40210. private _isPointerDown;
  40211. private _lastInteractionTime;
  40212. /**
  40213. * Initializes the behavior.
  40214. */
  40215. init(): void;
  40216. /**
  40217. * Attaches the behavior to its arc rotate camera.
  40218. * @param camera Defines the camera to attach the behavior to
  40219. */
  40220. attach(camera: ArcRotateCamera): void;
  40221. /**
  40222. * Detaches the behavior from its current arc rotate camera.
  40223. */
  40224. detach(): void;
  40225. private _animatables;
  40226. private _betaIsAnimating;
  40227. private _betaTransition;
  40228. private _radiusTransition;
  40229. private _vectorTransition;
  40230. /**
  40231. * Targets the given mesh and updates zoom level accordingly.
  40232. * @param mesh The mesh to target.
  40233. * @param radius Optional. If a cached radius position already exists, overrides default.
  40234. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40235. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40236. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40237. */
  40238. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40239. /**
  40240. * Targets the given mesh with its children and updates zoom level accordingly.
  40241. * @param mesh The mesh to target.
  40242. * @param radius Optional. If a cached radius position already exists, overrides default.
  40243. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40244. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40245. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40246. */
  40247. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40248. /**
  40249. * Targets the given meshes with their children and updates zoom level accordingly.
  40250. * @param meshes The mesh to target.
  40251. * @param radius Optional. If a cached radius position already exists, overrides default.
  40252. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40255. */
  40256. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40257. /**
  40258. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40259. * @param minimumWorld Determines the smaller position of the bounding box extend
  40260. * @param maximumWorld Determines the bigger position of the bounding box extend
  40261. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40262. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40263. */
  40264. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40265. /**
  40266. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40267. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40268. * frustum width.
  40269. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40270. * to fully enclose the mesh in the viewing frustum.
  40271. */
  40272. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40273. /**
  40274. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40275. * is automatically returned to its default position (expected to be above ground plane).
  40276. */
  40277. private _maintainCameraAboveGround;
  40278. /**
  40279. * Returns the frustum slope based on the canvas ratio and camera FOV
  40280. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40281. */
  40282. private _getFrustumSlope;
  40283. /**
  40284. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40285. */
  40286. private _clearAnimationLocks;
  40287. /**
  40288. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40289. */
  40290. private _applyUserInteraction;
  40291. /**
  40292. * Stops and removes all animations that have been applied to the camera
  40293. */
  40294. stopAllAnimations(): void;
  40295. /**
  40296. * Gets a value indicating if the user is moving the camera
  40297. */
  40298. readonly isUserIsMoving: boolean;
  40299. /**
  40300. * The camera can move all the way towards the mesh.
  40301. */
  40302. static IgnoreBoundsSizeMode: number;
  40303. /**
  40304. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40305. */
  40306. static FitFrustumSidesMode: number;
  40307. }
  40308. }
  40309. declare module BABYLON {
  40310. /**
  40311. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40312. */
  40313. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40314. private ui;
  40315. /**
  40316. * The name of the behavior
  40317. */
  40318. name: string;
  40319. /**
  40320. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40321. */
  40322. distanceAwayFromFace: number;
  40323. /**
  40324. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40325. */
  40326. distanceAwayFromBottomOfFace: number;
  40327. private _faceVectors;
  40328. private _target;
  40329. private _scene;
  40330. private _onRenderObserver;
  40331. private _tmpMatrix;
  40332. private _tmpVector;
  40333. /**
  40334. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40335. * @param ui The transform node that should be attched to the mesh
  40336. */
  40337. constructor(ui: BABYLON.TransformNode);
  40338. /**
  40339. * Initializes the behavior
  40340. */
  40341. init(): void;
  40342. private _closestFace;
  40343. private _zeroVector;
  40344. private _lookAtTmpMatrix;
  40345. private _lookAtToRef;
  40346. /**
  40347. * Attaches the AttachToBoxBehavior to the passed in mesh
  40348. * @param target The mesh that the specified node will be attached to
  40349. */
  40350. attach(target: BABYLON.Mesh): void;
  40351. /**
  40352. * Detaches the behavior from the mesh
  40353. */
  40354. detach(): void;
  40355. }
  40356. }
  40357. declare module BABYLON {
  40358. /**
  40359. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40360. */
  40361. class FadeInOutBehavior implements Behavior<Mesh> {
  40362. /**
  40363. * Time in milliseconds to delay before fading in (Default: 0)
  40364. */
  40365. delay: number;
  40366. /**
  40367. * Time in milliseconds for the mesh to fade in (Default: 300)
  40368. */
  40369. fadeInTime: number;
  40370. private _millisecondsPerFrame;
  40371. private _hovered;
  40372. private _hoverValue;
  40373. private _ownerNode;
  40374. /**
  40375. * Instatiates the FadeInOutBehavior
  40376. */
  40377. constructor();
  40378. /**
  40379. * The name of the behavior
  40380. */
  40381. readonly name: string;
  40382. /**
  40383. * Initializes the behavior
  40384. */
  40385. init(): void;
  40386. /**
  40387. * Attaches the fade behavior on the passed in mesh
  40388. * @param ownerNode The mesh that will be faded in/out once attached
  40389. */
  40390. attach(ownerNode: Mesh): void;
  40391. /**
  40392. * Detaches the behavior from the mesh
  40393. */
  40394. detach(): void;
  40395. /**
  40396. * Triggers the mesh to begin fading in or out
  40397. * @param value if the object should fade in or out (true to fade in)
  40398. */
  40399. fadeIn(value: boolean): void;
  40400. private _update;
  40401. private _setAllVisibility;
  40402. }
  40403. }
  40404. declare module BABYLON {
  40405. /**
  40406. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40407. */
  40408. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40409. private _dragBehaviorA;
  40410. private _dragBehaviorB;
  40411. private _startDistance;
  40412. private _initialScale;
  40413. private _targetScale;
  40414. private _ownerNode;
  40415. private _sceneRenderObserver;
  40416. /**
  40417. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40418. */
  40419. constructor();
  40420. /**
  40421. * The name of the behavior
  40422. */
  40423. readonly name: string;
  40424. /**
  40425. * Initializes the behavior
  40426. */
  40427. init(): void;
  40428. private _getCurrentDistance;
  40429. /**
  40430. * Attaches the scale behavior the passed in mesh
  40431. * @param ownerNode The mesh that will be scaled around once attached
  40432. */
  40433. attach(ownerNode: Mesh): void;
  40434. /**
  40435. * Detaches the behavior from the mesh
  40436. */
  40437. detach(): void;
  40438. }
  40439. }
  40440. declare module BABYLON {
  40441. /**
  40442. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40443. */
  40444. class PointerDragBehavior implements Behavior<Mesh> {
  40445. private static _AnyMouseID;
  40446. private _attachedNode;
  40447. private _dragPlane;
  40448. private _scene;
  40449. private _pointerObserver;
  40450. private _beforeRenderObserver;
  40451. private static _planeScene;
  40452. /**
  40453. * 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)
  40454. */
  40455. maxDragAngle: number;
  40456. /**
  40457. * @hidden
  40458. */
  40459. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40460. /**
  40461. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40462. */
  40463. currentDraggingPointerID: number;
  40464. /**
  40465. * The last position where the pointer hit the drag plane in world space
  40466. */
  40467. lastDragPosition: Vector3;
  40468. /**
  40469. * If the behavior is currently in a dragging state
  40470. */
  40471. dragging: boolean;
  40472. /**
  40473. * 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)
  40474. */
  40475. dragDeltaRatio: number;
  40476. /**
  40477. * If the drag plane orientation should be updated during the dragging (Default: true)
  40478. */
  40479. updateDragPlane: boolean;
  40480. private _debugMode;
  40481. private _moving;
  40482. /**
  40483. * Fires each time the attached mesh is dragged with the pointer
  40484. * * delta between last drag position and current drag position in world space
  40485. * * dragDistance along the drag axis
  40486. * * dragPlaneNormal normal of the current drag plane used during the drag
  40487. * * dragPlanePoint in world space where the drag intersects the drag plane
  40488. */
  40489. onDragObservable: Observable<{
  40490. delta: Vector3;
  40491. dragPlanePoint: Vector3;
  40492. dragPlaneNormal: Vector3;
  40493. dragDistance: number;
  40494. pointerId: number;
  40495. }>;
  40496. /**
  40497. * Fires each time a drag begins (eg. mouse down on mesh)
  40498. */
  40499. onDragStartObservable: Observable<{
  40500. dragPlanePoint: Vector3;
  40501. pointerId: number;
  40502. }>;
  40503. /**
  40504. * Fires each time a drag ends (eg. mouse release after drag)
  40505. */
  40506. onDragEndObservable: Observable<{
  40507. dragPlanePoint: Vector3;
  40508. pointerId: number;
  40509. }>;
  40510. /**
  40511. * If the attached mesh should be moved when dragged
  40512. */
  40513. moveAttached: boolean;
  40514. /**
  40515. * If the drag behavior will react to drag events (Default: true)
  40516. */
  40517. enabled: boolean;
  40518. /**
  40519. * If camera controls should be detached during the drag
  40520. */
  40521. detachCameraControls: boolean;
  40522. /**
  40523. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40524. */
  40525. useObjectOrienationForDragging: boolean;
  40526. private _options;
  40527. /**
  40528. * Creates a pointer drag behavior that can be attached to a mesh
  40529. * @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)
  40530. */
  40531. constructor(options?: {
  40532. dragAxis?: Vector3;
  40533. dragPlaneNormal?: Vector3;
  40534. });
  40535. /**
  40536. * The name of the behavior
  40537. */
  40538. readonly name: string;
  40539. /**
  40540. * Initializes the behavior
  40541. */
  40542. init(): void;
  40543. private _tmpVector;
  40544. private _alternatePickedPoint;
  40545. private _worldDragAxis;
  40546. private _targetPosition;
  40547. private _attachedElement;
  40548. /**
  40549. * Attaches the drag behavior the passed in mesh
  40550. * @param ownerNode The mesh that will be dragged around once attached
  40551. */
  40552. attach(ownerNode: Mesh): void;
  40553. /**
  40554. * Force relase the drag action by code.
  40555. */
  40556. releaseDrag(): void;
  40557. private _startDragRay;
  40558. private _lastPointerRay;
  40559. /**
  40560. * Simulates the start of a pointer drag event on the behavior
  40561. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40562. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40563. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40564. */
  40565. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40566. private _startDrag;
  40567. private _dragDelta;
  40568. private _moveDrag;
  40569. private _pickWithRayOnDragPlane;
  40570. private _pointA;
  40571. private _pointB;
  40572. private _pointC;
  40573. private _lineA;
  40574. private _lineB;
  40575. private _localAxis;
  40576. private _lookAt;
  40577. private _updateDragPlanePosition;
  40578. /**
  40579. * Detaches the behavior from the mesh
  40580. */
  40581. detach(): void;
  40582. }
  40583. }
  40584. declare module BABYLON {
  40585. /**
  40586. * 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
  40587. */
  40588. class SixDofDragBehavior implements Behavior<Mesh> {
  40589. private static _virtualScene;
  40590. private _ownerNode;
  40591. private _sceneRenderObserver;
  40592. private _scene;
  40593. private _targetPosition;
  40594. private _virtualOriginMesh;
  40595. private _virtualDragMesh;
  40596. private _pointerObserver;
  40597. private _moving;
  40598. private _startingOrientation;
  40599. /**
  40600. * 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)
  40601. */
  40602. private zDragFactor;
  40603. /**
  40604. * If the behavior is currently in a dragging state
  40605. */
  40606. dragging: boolean;
  40607. /**
  40608. * 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)
  40609. */
  40610. dragDeltaRatio: number;
  40611. /**
  40612. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40613. */
  40614. currentDraggingPointerID: number;
  40615. /**
  40616. * If camera controls should be detached during the drag
  40617. */
  40618. detachCameraControls: boolean;
  40619. /**
  40620. * Fires each time a drag starts
  40621. */
  40622. onDragStartObservable: Observable<{}>;
  40623. /**
  40624. * Fires each time a drag ends (eg. mouse release after drag)
  40625. */
  40626. onDragEndObservable: Observable<{}>;
  40627. /**
  40628. * 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
  40629. */
  40630. constructor();
  40631. /**
  40632. * The name of the behavior
  40633. */
  40634. readonly name: string;
  40635. /**
  40636. * Initializes the behavior
  40637. */
  40638. init(): void;
  40639. /**
  40640. * Attaches the scale behavior the passed in mesh
  40641. * @param ownerNode The mesh that will be scaled around once attached
  40642. */
  40643. attach(ownerNode: Mesh): void;
  40644. /**
  40645. * Detaches the behavior from the mesh
  40646. */
  40647. detach(): void;
  40648. }
  40649. }
  40650. declare module BABYLON {
  40651. /**
  40652. * Manage the gamepad inputs to control an arc rotate camera.
  40653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40654. */
  40655. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40656. /**
  40657. * Defines the camera the input is attached to.
  40658. */
  40659. camera: ArcRotateCamera;
  40660. /**
  40661. * Defines the gamepad the input is gathering event from.
  40662. */
  40663. gamepad: Nullable<Gamepad>;
  40664. /**
  40665. * Defines the gamepad rotation sensiblity.
  40666. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40667. */
  40668. gamepadRotationSensibility: number;
  40669. /**
  40670. * Defines the gamepad move sensiblity.
  40671. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40672. */
  40673. gamepadMoveSensibility: number;
  40674. private _onGamepadConnectedObserver;
  40675. private _onGamepadDisconnectedObserver;
  40676. /**
  40677. * Attach the input controls to a specific dom element to get the input from.
  40678. * @param element Defines the element the controls should be listened from
  40679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40680. */
  40681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40682. /**
  40683. * Detach the current controls from the specified dom element.
  40684. * @param element Defines the element to stop listening the inputs from
  40685. */
  40686. detachControl(element: Nullable<HTMLElement>): void;
  40687. /**
  40688. * Update the current camera state depending on the inputs that have been used this frame.
  40689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40690. */
  40691. checkInputs(): void;
  40692. /**
  40693. * Gets the class name of the current intput.
  40694. * @returns the class name
  40695. */
  40696. getClassName(): string;
  40697. /**
  40698. * Get the friendly name associated with the input class.
  40699. * @returns the input friendly name
  40700. */
  40701. getSimpleName(): string;
  40702. }
  40703. }
  40704. declare module BABYLON {
  40705. /**
  40706. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  40707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40708. */
  40709. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  40710. /**
  40711. * Defines the camera the input is attached to.
  40712. */
  40713. camera: ArcRotateCamera;
  40714. /**
  40715. * Defines the list of key codes associated with the up action (increase alpha)
  40716. */
  40717. keysUp: number[];
  40718. /**
  40719. * Defines the list of key codes associated with the down action (decrease alpha)
  40720. */
  40721. keysDown: number[];
  40722. /**
  40723. * Defines the list of key codes associated with the left action (increase beta)
  40724. */
  40725. keysLeft: number[];
  40726. /**
  40727. * Defines the list of key codes associated with the right action (decrease beta)
  40728. */
  40729. keysRight: number[];
  40730. /**
  40731. * Defines the list of key codes associated with the reset action.
  40732. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  40733. */
  40734. keysReset: number[];
  40735. /**
  40736. * Defines the panning sensibility of the inputs.
  40737. * (How fast is the camera paning)
  40738. */
  40739. panningSensibility: number;
  40740. /**
  40741. * Defines the zooming sensibility of the inputs.
  40742. * (How fast is the camera zooming)
  40743. */
  40744. zoomingSensibility: number;
  40745. /**
  40746. * Defines wether maintaining the alt key down switch the movement mode from
  40747. * orientation to zoom.
  40748. */
  40749. useAltToZoom: boolean;
  40750. /**
  40751. * Rotation speed of the camera
  40752. */
  40753. angularSpeed: number;
  40754. private _keys;
  40755. private _ctrlPressed;
  40756. private _altPressed;
  40757. private _onCanvasBlurObserver;
  40758. private _onKeyboardObserver;
  40759. private _engine;
  40760. private _scene;
  40761. /**
  40762. * Attach the input controls to a specific dom element to get the input from.
  40763. * @param element Defines the element the controls should be listened from
  40764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40765. */
  40766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40767. /**
  40768. * Detach the current controls from the specified dom element.
  40769. * @param element Defines the element to stop listening the inputs from
  40770. */
  40771. detachControl(element: Nullable<HTMLElement>): void;
  40772. /**
  40773. * Update the current camera state depending on the inputs that have been used this frame.
  40774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40775. */
  40776. checkInputs(): void;
  40777. /**
  40778. * Gets the class name of the current intput.
  40779. * @returns the class name
  40780. */
  40781. getClassName(): string;
  40782. /**
  40783. * Get the friendly name associated with the input class.
  40784. * @returns the input friendly name
  40785. */
  40786. getSimpleName(): string;
  40787. }
  40788. }
  40789. declare module BABYLON {
  40790. /**
  40791. * Manage the mouse wheel inputs to control an arc rotate camera.
  40792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40793. */
  40794. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40795. /**
  40796. * Defines the camera the input is attached to.
  40797. */
  40798. camera: ArcRotateCamera;
  40799. /**
  40800. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40801. */
  40802. wheelPrecision: number;
  40803. /**
  40804. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40805. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40806. */
  40807. wheelDeltaPercentage: number;
  40808. private _wheel;
  40809. private _observer;
  40810. /**
  40811. * Attach the input controls to a specific dom element to get the input from.
  40812. * @param element Defines the element the controls should be listened from
  40813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40814. */
  40815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40816. /**
  40817. * Detach the current controls from the specified dom element.
  40818. * @param element Defines the element to stop listening the inputs from
  40819. */
  40820. detachControl(element: Nullable<HTMLElement>): void;
  40821. /**
  40822. * Gets the class name of the current intput.
  40823. * @returns the class name
  40824. */
  40825. getClassName(): string;
  40826. /**
  40827. * Get the friendly name associated with the input class.
  40828. * @returns the input friendly name
  40829. */
  40830. getSimpleName(): string;
  40831. }
  40832. }
  40833. declare module BABYLON {
  40834. /**
  40835. * Manage the pointers inputs to control an arc rotate camera.
  40836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40837. */
  40838. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  40839. /**
  40840. * Defines the camera the input is attached to.
  40841. */
  40842. camera: ArcRotateCamera;
  40843. /**
  40844. * Defines the buttons associated with the input to handle camera move.
  40845. */
  40846. buttons: number[];
  40847. /**
  40848. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40849. */
  40850. angularSensibilityX: number;
  40851. /**
  40852. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40853. */
  40854. angularSensibilityY: number;
  40855. /**
  40856. * Defines the pointer pinch precision or how fast is the camera zooming.
  40857. */
  40858. pinchPrecision: number;
  40859. /**
  40860. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  40861. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40862. */
  40863. pinchDeltaPercentage: number;
  40864. /**
  40865. * Defines the pointer panning sensibility or how fast is the camera moving.
  40866. */
  40867. panningSensibility: number;
  40868. /**
  40869. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  40870. */
  40871. multiTouchPanning: boolean;
  40872. /**
  40873. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  40874. */
  40875. multiTouchPanAndZoom: boolean;
  40876. /**
  40877. * Revers pinch action direction.
  40878. */
  40879. pinchInwards: boolean;
  40880. private _isPanClick;
  40881. private _pointerInput;
  40882. private _observer;
  40883. private _onMouseMove;
  40884. private _onGestureStart;
  40885. private _onGesture;
  40886. private _MSGestureHandler;
  40887. private _onLostFocus;
  40888. private _onContextMenu;
  40889. /**
  40890. * Attach the input controls to a specific dom element to get the input from.
  40891. * @param element Defines the element the controls should be listened from
  40892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40893. */
  40894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40895. /**
  40896. * Detach the current controls from the specified dom element.
  40897. * @param element Defines the element to stop listening the inputs from
  40898. */
  40899. detachControl(element: Nullable<HTMLElement>): void;
  40900. /**
  40901. * Gets the class name of the current intput.
  40902. * @returns the class name
  40903. */
  40904. getClassName(): string;
  40905. /**
  40906. * Get the friendly name associated with the input class.
  40907. * @returns the input friendly name
  40908. */
  40909. getSimpleName(): string;
  40910. }
  40911. }
  40912. declare module BABYLON {
  40913. /**
  40914. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40916. */
  40917. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40918. /**
  40919. * Defines the camera the input is attached to.
  40920. */
  40921. camera: ArcRotateCamera;
  40922. /**
  40923. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40924. */
  40925. alphaCorrection: number;
  40926. /**
  40927. * Defines a correction factor applied on the beta value retrieved from the orientation events.
  40928. */
  40929. betaCorrection: number;
  40930. /**
  40931. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40932. */
  40933. gammaCorrection: number;
  40934. private _alpha;
  40935. private _gamma;
  40936. private _dirty;
  40937. private _deviceOrientationHandler;
  40938. /**
  40939. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40940. */
  40941. constructor();
  40942. /**
  40943. * Attach the input controls to a specific dom element to get the input from.
  40944. * @param element Defines the element the controls should be listened from
  40945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40946. */
  40947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40948. /** @hidden */
  40949. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40950. /**
  40951. * Update the current camera state depending on the inputs that have been used this frame.
  40952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40953. */
  40954. checkInputs(): void;
  40955. /**
  40956. * Detach the current controls from the specified dom element.
  40957. * @param element Defines the element to stop listening the inputs from
  40958. */
  40959. detachControl(element: Nullable<HTMLElement>): void;
  40960. /**
  40961. * Gets the class name of the current intput.
  40962. * @returns the class name
  40963. */
  40964. getClassName(): string;
  40965. /**
  40966. * Get the friendly name associated with the input class.
  40967. * @returns the input friendly name
  40968. */
  40969. getSimpleName(): string;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * Listen to keyboard events to control the camera.
  40975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40976. */
  40977. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40978. /**
  40979. * Defines the camera the input is attached to.
  40980. */
  40981. camera: FlyCamera;
  40982. /**
  40983. * The list of keyboard keys used to control the forward move of the camera.
  40984. */
  40985. keysForward: number[];
  40986. /**
  40987. * The list of keyboard keys used to control the backward move of the camera.
  40988. */
  40989. keysBackward: number[];
  40990. /**
  40991. * The list of keyboard keys used to control the forward move of the camera.
  40992. */
  40993. keysUp: number[];
  40994. /**
  40995. * The list of keyboard keys used to control the backward move of the camera.
  40996. */
  40997. keysDown: number[];
  40998. /**
  40999. * The list of keyboard keys used to control the right strafe move of the camera.
  41000. */
  41001. keysRight: number[];
  41002. /**
  41003. * The list of keyboard keys used to control the left strafe move of the camera.
  41004. */
  41005. keysLeft: number[];
  41006. private _keys;
  41007. private _onCanvasBlurObserver;
  41008. private _onKeyboardObserver;
  41009. private _engine;
  41010. private _scene;
  41011. /**
  41012. * Attach the input controls to a specific dom element to get the input from.
  41013. * @param element Defines the element the controls should be listened from
  41014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41015. */
  41016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41017. /**
  41018. * Detach the current controls from the specified dom element.
  41019. * @param element Defines the element to stop listening the inputs from
  41020. */
  41021. detachControl(element: Nullable<HTMLElement>): void;
  41022. /**
  41023. * Gets the class name of the current intput.
  41024. * @returns the class name
  41025. */
  41026. getClassName(): string;
  41027. /** @hidden */
  41028. _onLostFocus(e: FocusEvent): void;
  41029. /**
  41030. * Get the friendly name associated with the input class.
  41031. * @returns the input friendly name
  41032. */
  41033. getSimpleName(): string;
  41034. /**
  41035. * Update the current camera state depending on the inputs that have been used this frame.
  41036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41037. */
  41038. checkInputs(): void;
  41039. }
  41040. }
  41041. declare module BABYLON {
  41042. /**
  41043. * Listen to mouse events to control the camera.
  41044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41045. */
  41046. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41047. /**
  41048. * Defines the camera the input is attached to.
  41049. */
  41050. camera: FlyCamera;
  41051. /**
  41052. * Defines if touch is enabled. (Default is true.)
  41053. */
  41054. touchEnabled: boolean;
  41055. /**
  41056. * Defines the buttons associated with the input to handle camera rotation.
  41057. */
  41058. buttons: number[];
  41059. /**
  41060. * Assign buttons for Yaw control.
  41061. */
  41062. buttonsYaw: number[];
  41063. /**
  41064. * Assign buttons for Pitch control.
  41065. */
  41066. buttonsPitch: number[];
  41067. /**
  41068. * Assign buttons for Roll control.
  41069. */
  41070. buttonsRoll: number[];
  41071. /**
  41072. * Detect if any button is being pressed while mouse is moved.
  41073. * -1 = Mouse locked.
  41074. * 0 = Left button.
  41075. * 1 = Middle Button.
  41076. * 2 = Right Button.
  41077. */
  41078. activeButton: number;
  41079. /**
  41080. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41081. * Higher values reduce its sensitivity.
  41082. */
  41083. angularSensibility: number;
  41084. private _mousemoveCallback;
  41085. private _observer;
  41086. private _rollObserver;
  41087. private previousPosition;
  41088. private noPreventDefault;
  41089. private element;
  41090. /**
  41091. * Listen to mouse events to control the camera.
  41092. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41094. */
  41095. constructor(touchEnabled?: boolean);
  41096. /**
  41097. * Attach the mouse control to the HTML DOM element.
  41098. * @param element Defines the element that listens to the input events.
  41099. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41100. */
  41101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41102. /**
  41103. * Detach the current controls from the specified dom element.
  41104. * @param element Defines the element to stop listening the inputs from
  41105. */
  41106. detachControl(element: Nullable<HTMLElement>): void;
  41107. /**
  41108. * Gets the class name of the current input.
  41109. * @returns the class name.
  41110. */
  41111. getClassName(): string;
  41112. /**
  41113. * Get the friendly name associated with the input class.
  41114. * @returns the input's friendly name.
  41115. */
  41116. getSimpleName(): string;
  41117. private _pointerInput;
  41118. private _onMouseMove;
  41119. /**
  41120. * Rotate camera by mouse offset.
  41121. */
  41122. private rotateCamera;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41128. * Screen rotation is taken into account.
  41129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41130. */
  41131. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41132. private _camera;
  41133. private _screenOrientationAngle;
  41134. private _constantTranform;
  41135. private _screenQuaternion;
  41136. private _alpha;
  41137. private _beta;
  41138. private _gamma;
  41139. /**
  41140. * Instantiates a new input
  41141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41142. */
  41143. constructor();
  41144. /**
  41145. * Define the camera controlled by the input.
  41146. */
  41147. camera: FreeCamera;
  41148. /**
  41149. * Attach the input controls to a specific dom element to get the input from.
  41150. * @param element Defines the element the controls should be listened from
  41151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41152. */
  41153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41154. private _orientationChanged;
  41155. private _deviceOrientation;
  41156. /**
  41157. * Detach the current controls from the specified dom element.
  41158. * @param element Defines the element to stop listening the inputs from
  41159. */
  41160. detachControl(element: Nullable<HTMLElement>): void;
  41161. /**
  41162. * Update the current camera state depending on the inputs that have been used this frame.
  41163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41164. */
  41165. checkInputs(): void;
  41166. /**
  41167. * Gets the class name of the current intput.
  41168. * @returns the class name
  41169. */
  41170. getClassName(): string;
  41171. /**
  41172. * Get the friendly name associated with the input class.
  41173. * @returns the input friendly name
  41174. */
  41175. getSimpleName(): string;
  41176. }
  41177. }
  41178. declare module BABYLON {
  41179. /**
  41180. * Manage the gamepad inputs to control a free camera.
  41181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41182. */
  41183. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41184. /**
  41185. * Define the camera the input is attached to.
  41186. */
  41187. camera: FreeCamera;
  41188. /**
  41189. * Define the Gamepad controlling the input
  41190. */
  41191. gamepad: Nullable<Gamepad>;
  41192. /**
  41193. * Defines the gamepad rotation sensiblity.
  41194. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41195. */
  41196. gamepadAngularSensibility: number;
  41197. /**
  41198. * Defines the gamepad move sensiblity.
  41199. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41200. */
  41201. gamepadMoveSensibility: number;
  41202. private _onGamepadConnectedObserver;
  41203. private _onGamepadDisconnectedObserver;
  41204. private _cameraTransform;
  41205. private _deltaTransform;
  41206. private _vector3;
  41207. private _vector2;
  41208. /**
  41209. * Attach the input controls to a specific dom element to get the input from.
  41210. * @param element Defines the element the controls should be listened from
  41211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41212. */
  41213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41214. /**
  41215. * Detach the current controls from the specified dom element.
  41216. * @param element Defines the element to stop listening the inputs from
  41217. */
  41218. detachControl(element: Nullable<HTMLElement>): void;
  41219. /**
  41220. * Update the current camera state depending on the inputs that have been used this frame.
  41221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41222. */
  41223. checkInputs(): void;
  41224. /**
  41225. * Gets the class name of the current intput.
  41226. * @returns the class name
  41227. */
  41228. getClassName(): string;
  41229. /**
  41230. * Get the friendly name associated with the input class.
  41231. * @returns the input friendly name
  41232. */
  41233. getSimpleName(): string;
  41234. }
  41235. }
  41236. declare module BABYLON {
  41237. /**
  41238. * Manage the keyboard inputs to control the movement of a free camera.
  41239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41240. */
  41241. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41242. /**
  41243. * Defines the camera the input is attached to.
  41244. */
  41245. camera: FreeCamera;
  41246. /**
  41247. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41248. */
  41249. keysUp: number[];
  41250. /**
  41251. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41252. */
  41253. keysDown: number[];
  41254. /**
  41255. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41256. */
  41257. keysLeft: number[];
  41258. /**
  41259. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41260. */
  41261. keysRight: number[];
  41262. private _keys;
  41263. private _onCanvasBlurObserver;
  41264. private _onKeyboardObserver;
  41265. private _engine;
  41266. private _scene;
  41267. /**
  41268. * Attach the input controls to a specific dom element to get the input from.
  41269. * @param element Defines the element the controls should be listened from
  41270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41271. */
  41272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41273. /**
  41274. * Detach the current controls from the specified dom element.
  41275. * @param element Defines the element to stop listening the inputs from
  41276. */
  41277. detachControl(element: Nullable<HTMLElement>): void;
  41278. /**
  41279. * Update the current camera state depending on the inputs that have been used this frame.
  41280. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41281. */
  41282. checkInputs(): void;
  41283. /**
  41284. * Gets the class name of the current intput.
  41285. * @returns the class name
  41286. */
  41287. getClassName(): string;
  41288. /** @hidden */
  41289. _onLostFocus(e: FocusEvent): void;
  41290. /**
  41291. * Get the friendly name associated with the input class.
  41292. * @returns the input friendly name
  41293. */
  41294. getSimpleName(): string;
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Manage the mouse inputs to control the movement of a free camera.
  41300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41301. */
  41302. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41303. /**
  41304. * Define if touch is enabled in the mouse input
  41305. */
  41306. touchEnabled: boolean;
  41307. /**
  41308. * Defines the camera the input is attached to.
  41309. */
  41310. camera: FreeCamera;
  41311. /**
  41312. * Defines the buttons associated with the input to handle camera move.
  41313. */
  41314. buttons: number[];
  41315. /**
  41316. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41317. */
  41318. angularSensibility: number;
  41319. private _pointerInput;
  41320. private _onMouseMove;
  41321. private _observer;
  41322. private previousPosition;
  41323. /**
  41324. * Manage the mouse inputs to control the movement of a free camera.
  41325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41326. * @param touchEnabled Defines if touch is enabled or not
  41327. */
  41328. constructor(
  41329. /**
  41330. * Define if touch is enabled in the mouse input
  41331. */
  41332. touchEnabled?: boolean);
  41333. /**
  41334. * Attach the input controls to a specific dom element to get the input from.
  41335. * @param element Defines the element the controls should be listened from
  41336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41337. */
  41338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41339. /**
  41340. * Detach the current controls from the specified dom element.
  41341. * @param element Defines the element to stop listening the inputs from
  41342. */
  41343. detachControl(element: Nullable<HTMLElement>): void;
  41344. /**
  41345. * Gets the class name of the current intput.
  41346. * @returns the class name
  41347. */
  41348. getClassName(): string;
  41349. /**
  41350. * Get the friendly name associated with the input class.
  41351. * @returns the input friendly name
  41352. */
  41353. getSimpleName(): string;
  41354. }
  41355. }
  41356. declare module BABYLON {
  41357. /**
  41358. * Manage the touch inputs to control the movement of a free camera.
  41359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41360. */
  41361. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41362. /**
  41363. * Defines the camera the input is attached to.
  41364. */
  41365. camera: FreeCamera;
  41366. /**
  41367. * Defines the touch sensibility for rotation.
  41368. * The higher the faster.
  41369. */
  41370. touchAngularSensibility: number;
  41371. /**
  41372. * Defines the touch sensibility for move.
  41373. * The higher the faster.
  41374. */
  41375. touchMoveSensibility: number;
  41376. private _offsetX;
  41377. private _offsetY;
  41378. private _pointerPressed;
  41379. private _pointerInput;
  41380. private _observer;
  41381. private _onLostFocus;
  41382. /**
  41383. * Attach the input controls to a specific dom element to get the input from.
  41384. * @param element Defines the element the controls should be listened from
  41385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41386. */
  41387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41388. /**
  41389. * Detach the current controls from the specified dom element.
  41390. * @param element Defines the element to stop listening the inputs from
  41391. */
  41392. detachControl(element: Nullable<HTMLElement>): void;
  41393. /**
  41394. * Update the current camera state depending on the inputs that have been used this frame.
  41395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41396. */
  41397. checkInputs(): void;
  41398. /**
  41399. * Gets the class name of the current intput.
  41400. * @returns the class name
  41401. */
  41402. getClassName(): string;
  41403. /**
  41404. * Get the friendly name associated with the input class.
  41405. * @returns the input friendly name
  41406. */
  41407. getSimpleName(): string;
  41408. }
  41409. }
  41410. declare module BABYLON {
  41411. /**
  41412. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41414. */
  41415. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41416. /**
  41417. * Defines the camera the input is attached to.
  41418. */
  41419. camera: FreeCamera;
  41420. private _leftjoystick;
  41421. private _rightjoystick;
  41422. /**
  41423. * Gets the left stick of the virtual joystick.
  41424. * @returns The virtual Joystick
  41425. */
  41426. getLeftJoystick(): VirtualJoystick;
  41427. /**
  41428. * Gets the right stick of the virtual joystick.
  41429. * @returns The virtual Joystick
  41430. */
  41431. getRightJoystick(): VirtualJoystick;
  41432. /**
  41433. * Update the current camera state depending on the inputs that have been used this frame.
  41434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41435. */
  41436. checkInputs(): void;
  41437. /**
  41438. * Attach the input controls to a specific dom element to get the input from.
  41439. * @param element Defines the element the controls should be listened from
  41440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41441. */
  41442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41443. /**
  41444. * Detach the current controls from the specified dom element.
  41445. * @param element Defines the element to stop listening the inputs from
  41446. */
  41447. detachControl(element: Nullable<HTMLElement>): void;
  41448. /**
  41449. * Gets the class name of the current intput.
  41450. * @returns the class name
  41451. */
  41452. getClassName(): string;
  41453. /**
  41454. * Get the friendly name associated with the input class.
  41455. * @returns the input friendly name
  41456. */
  41457. getSimpleName(): string;
  41458. }
  41459. }
  41460. declare module BABYLON {
  41461. /**
  41462. * This represents all the required metrics to create a VR camera.
  41463. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41464. */
  41465. class VRCameraMetrics {
  41466. /**
  41467. * Define the horizontal resolution off the screen.
  41468. */
  41469. hResolution: number;
  41470. /**
  41471. * Define the vertical resolution off the screen.
  41472. */
  41473. vResolution: number;
  41474. /**
  41475. * Define the horizontal screen size.
  41476. */
  41477. hScreenSize: number;
  41478. /**
  41479. * Define the vertical screen size.
  41480. */
  41481. vScreenSize: number;
  41482. /**
  41483. * Define the vertical screen center position.
  41484. */
  41485. vScreenCenter: number;
  41486. /**
  41487. * Define the distance of the eyes to the screen.
  41488. */
  41489. eyeToScreenDistance: number;
  41490. /**
  41491. * Define the distance between both lenses
  41492. */
  41493. lensSeparationDistance: number;
  41494. /**
  41495. * Define the distance between both viewer's eyes.
  41496. */
  41497. interpupillaryDistance: number;
  41498. /**
  41499. * Define the distortion factor of the VR postprocess.
  41500. * Please, touch with care.
  41501. */
  41502. distortionK: number[];
  41503. /**
  41504. * Define the chromatic aberration correction factors for the VR post process.
  41505. */
  41506. chromaAbCorrection: number[];
  41507. /**
  41508. * Define the scale factor of the post process.
  41509. * The smaller the better but the slower.
  41510. */
  41511. postProcessScaleFactor: number;
  41512. /**
  41513. * Define an offset for the lens center.
  41514. */
  41515. lensCenterOffset: number;
  41516. /**
  41517. * Define if the current vr camera should compensate the distortion of the lense or not.
  41518. */
  41519. compensateDistortion: boolean;
  41520. /**
  41521. * Gets the rendering aspect ratio based on the provided resolutions.
  41522. */
  41523. readonly aspectRatio: number;
  41524. /**
  41525. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41526. */
  41527. readonly aspectRatioFov: number;
  41528. /**
  41529. * @hidden
  41530. */
  41531. readonly leftHMatrix: Matrix;
  41532. /**
  41533. * @hidden
  41534. */
  41535. readonly rightHMatrix: Matrix;
  41536. /**
  41537. * @hidden
  41538. */
  41539. readonly leftPreViewMatrix: Matrix;
  41540. /**
  41541. * @hidden
  41542. */
  41543. readonly rightPreViewMatrix: Matrix;
  41544. /**
  41545. * Get the default VRMetrics based on the most generic setup.
  41546. * @returns the default vr metrics
  41547. */
  41548. static GetDefault(): VRCameraMetrics;
  41549. }
  41550. }
  41551. declare module BABYLON {
  41552. /**
  41553. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41554. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41555. */
  41556. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41557. /**
  41558. * Creates a new VRDeviceOrientationArcRotateCamera
  41559. * @param name defines camera name
  41560. * @param alpha defines the camera rotation along the logitudinal axis
  41561. * @param beta defines the camera rotation along the latitudinal axis
  41562. * @param radius defines the camera distance from its target
  41563. * @param target defines the camera target
  41564. * @param scene defines the scene the camera belongs to
  41565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41567. */
  41568. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41569. /**
  41570. * Gets camera class name
  41571. * @returns VRDeviceOrientationArcRotateCamera
  41572. */
  41573. getClassName(): string;
  41574. }
  41575. }
  41576. declare module BABYLON {
  41577. /**
  41578. * Camera used to simulate VR rendering (based on FreeCamera)
  41579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41580. */
  41581. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41582. /**
  41583. * Creates a new VRDeviceOrientationFreeCamera
  41584. * @param name defines camera name
  41585. * @param position defines the start position of the camera
  41586. * @param scene defines the scene the camera belongs to
  41587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41589. */
  41590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41591. /**
  41592. * Gets camera class name
  41593. * @returns VRDeviceOrientationFreeCamera
  41594. */
  41595. getClassName(): string;
  41596. }
  41597. }
  41598. declare module BABYLON {
  41599. /**
  41600. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41601. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41602. */
  41603. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41604. /**
  41605. * Creates a new VRDeviceOrientationGamepadCamera
  41606. * @param name defines camera name
  41607. * @param position defines the start position of the camera
  41608. * @param scene defines the scene the camera belongs to
  41609. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41610. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41611. */
  41612. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41613. /**
  41614. * Gets camera class name
  41615. * @returns VRDeviceOrientationGamepadCamera
  41616. */
  41617. getClassName(): string;
  41618. }
  41619. }
  41620. declare module BABYLON {
  41621. /**
  41622. * Options to modify the vr teleportation behavior.
  41623. */
  41624. interface VRTeleportationOptions {
  41625. /**
  41626. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41627. */
  41628. floorMeshName?: string;
  41629. /**
  41630. * A list of meshes to be used as the teleportation floor. (default: empty)
  41631. */
  41632. floorMeshes?: Mesh[];
  41633. }
  41634. /**
  41635. * Options to modify the vr experience helper's behavior.
  41636. */
  41637. interface VRExperienceHelperOptions extends WebVROptions {
  41638. /**
  41639. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41640. */
  41641. createDeviceOrientationCamera?: boolean;
  41642. /**
  41643. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41644. */
  41645. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41646. /**
  41647. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41648. */
  41649. laserToggle?: boolean;
  41650. /**
  41651. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41652. */
  41653. floorMeshes?: Mesh[];
  41654. }
  41655. /**
  41656. * Helps to quickly add VR support to an existing scene.
  41657. * See http://doc.babylonjs.com/how_to/webvr_helper
  41658. */
  41659. class VRExperienceHelper {
  41660. /** Options to modify the vr experience helper's behavior. */
  41661. webVROptions: VRExperienceHelperOptions;
  41662. private _scene;
  41663. private _position;
  41664. private _btnVR;
  41665. private _btnVRDisplayed;
  41666. private _webVRsupported;
  41667. private _webVRready;
  41668. private _webVRrequesting;
  41669. private _webVRpresenting;
  41670. private _hasEnteredVR;
  41671. private _fullscreenVRpresenting;
  41672. private _canvas;
  41673. private _webVRCamera;
  41674. private _vrDeviceOrientationCamera;
  41675. private _deviceOrientationCamera;
  41676. private _existingCamera;
  41677. private _onKeyDown;
  41678. private _onVrDisplayPresentChange;
  41679. private _onVRDisplayChanged;
  41680. private _onVRRequestPresentStart;
  41681. private _onVRRequestPresentComplete;
  41682. /**
  41683. * Observable raised when entering VR.
  41684. */
  41685. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41686. /**
  41687. * Observable raised when exiting VR.
  41688. */
  41689. onExitingVRObservable: Observable<VRExperienceHelper>;
  41690. /**
  41691. * Observable raised when controller mesh is loaded.
  41692. */
  41693. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41694. /** Return this.onEnteringVRObservable
  41695. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41696. */
  41697. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41698. /** Return this.onExitingVRObservable
  41699. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41700. */
  41701. readonly onExitingVR: Observable<VRExperienceHelper>;
  41702. /** Return this.onControllerMeshLoadedObservable
  41703. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41704. */
  41705. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41706. private _rayLength;
  41707. private _useCustomVRButton;
  41708. private _teleportationRequested;
  41709. private _teleportActive;
  41710. private _floorMeshName;
  41711. private _floorMeshesCollection;
  41712. private _rotationAllowed;
  41713. private _teleportBackwardsVector;
  41714. private _teleportationTarget;
  41715. private _isDefaultTeleportationTarget;
  41716. private _postProcessMove;
  41717. private _teleportationFillColor;
  41718. private _teleportationBorderColor;
  41719. private _rotationAngle;
  41720. private _haloCenter;
  41721. private _cameraGazer;
  41722. private _padSensibilityUp;
  41723. private _padSensibilityDown;
  41724. private _leftController;
  41725. private _rightController;
  41726. /**
  41727. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41728. */
  41729. onNewMeshSelected: Observable<AbstractMesh>;
  41730. /**
  41731. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41732. */
  41733. onNewMeshPicked: Observable<PickingInfo>;
  41734. private _circleEase;
  41735. /**
  41736. * Observable raised before camera teleportation
  41737. */
  41738. onBeforeCameraTeleport: Observable<Vector3>;
  41739. /**
  41740. * Observable raised after camera teleportation
  41741. */
  41742. onAfterCameraTeleport: Observable<Vector3>;
  41743. /**
  41744. * Observable raised when current selected mesh gets unselected
  41745. */
  41746. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41747. private _raySelectionPredicate;
  41748. /**
  41749. * To be optionaly changed by user to define custom ray selection
  41750. */
  41751. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41752. /**
  41753. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41754. */
  41755. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41756. /**
  41757. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41758. */
  41759. teleportationEnabled: boolean;
  41760. private _defaultHeight;
  41761. private _teleportationInitialized;
  41762. private _interactionsEnabled;
  41763. private _interactionsRequested;
  41764. private _displayGaze;
  41765. private _displayLaserPointer;
  41766. /**
  41767. * The mesh used to display where the user is going to teleport.
  41768. */
  41769. /**
  41770. * Sets the mesh to be used to display where the user is going to teleport.
  41771. */
  41772. teleportationTarget: Mesh;
  41773. /**
  41774. * 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
  41775. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41776. * See http://doc.babylonjs.com/resources/baking_transformations
  41777. */
  41778. gazeTrackerMesh: Mesh;
  41779. /**
  41780. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41781. */
  41782. updateGazeTrackerScale: boolean;
  41783. /**
  41784. * The gaze tracking mesh corresponding to the left controller
  41785. */
  41786. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41787. /**
  41788. * The gaze tracking mesh corresponding to the right controller
  41789. */
  41790. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41791. /**
  41792. * If the ray of the gaze should be displayed.
  41793. */
  41794. /**
  41795. * Sets if the ray of the gaze should be displayed.
  41796. */
  41797. displayGaze: boolean;
  41798. /**
  41799. * If the ray of the LaserPointer should be displayed.
  41800. */
  41801. /**
  41802. * Sets if the ray of the LaserPointer should be displayed.
  41803. */
  41804. displayLaserPointer: boolean;
  41805. /**
  41806. * The deviceOrientationCamera used as the camera when not in VR.
  41807. */
  41808. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41809. /**
  41810. * Based on the current WebVR support, returns the current VR camera used.
  41811. */
  41812. readonly currentVRCamera: Nullable<Camera>;
  41813. /**
  41814. * The webVRCamera which is used when in VR.
  41815. */
  41816. readonly webVRCamera: WebVRFreeCamera;
  41817. /**
  41818. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41819. */
  41820. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41821. private readonly _teleportationRequestInitiated;
  41822. /**
  41823. * Instantiates a VRExperienceHelper.
  41824. * Helps to quickly add VR support to an existing scene.
  41825. * @param scene The scene the VRExperienceHelper belongs to.
  41826. * @param webVROptions Options to modify the vr experience helper's behavior.
  41827. */
  41828. constructor(scene: Scene,
  41829. /** Options to modify the vr experience helper's behavior. */
  41830. webVROptions?: VRExperienceHelperOptions);
  41831. private _onDefaultMeshLoaded;
  41832. private _onResize;
  41833. private _onFullscreenChange;
  41834. /**
  41835. * Gets a value indicating if we are currently in VR mode.
  41836. */
  41837. readonly isInVRMode: boolean;
  41838. private onVrDisplayPresentChange;
  41839. private onVRDisplayChanged;
  41840. private moveButtonToBottomRight;
  41841. private displayVRButton;
  41842. private updateButtonVisibility;
  41843. /**
  41844. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41845. * Otherwise, will use the fullscreen API.
  41846. */
  41847. enterVR(): void;
  41848. /**
  41849. * Attempt to exit VR, or fullscreen.
  41850. */
  41851. exitVR(): void;
  41852. /**
  41853. * The position of the vr experience helper.
  41854. */
  41855. /**
  41856. * Sets the position of the vr experience helper.
  41857. */
  41858. position: Vector3;
  41859. /**
  41860. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41861. */
  41862. enableInteractions(): void;
  41863. private readonly _noControllerIsActive;
  41864. private beforeRender;
  41865. private _isTeleportationFloor;
  41866. /**
  41867. * Adds a floor mesh to be used for teleportation.
  41868. * @param floorMesh the mesh to be used for teleportation.
  41869. */
  41870. addFloorMesh(floorMesh: Mesh): void;
  41871. /**
  41872. * Removes a floor mesh from being used for teleportation.
  41873. * @param floorMesh the mesh to be removed.
  41874. */
  41875. removeFloorMesh(floorMesh: Mesh): void;
  41876. /**
  41877. * Enables interactions and teleportation using the VR controllers and gaze.
  41878. * @param vrTeleportationOptions options to modify teleportation behavior.
  41879. */
  41880. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41881. private _onNewGamepadConnected;
  41882. private _tryEnableInteractionOnController;
  41883. private _onNewGamepadDisconnected;
  41884. private _enableInteractionOnController;
  41885. private _checkTeleportWithRay;
  41886. private _checkRotate;
  41887. private _checkTeleportBackwards;
  41888. private _enableTeleportationOnController;
  41889. private _createTeleportationCircles;
  41890. private _displayTeleportationTarget;
  41891. private _hideTeleportationTarget;
  41892. private _rotateCamera;
  41893. private _moveTeleportationSelectorTo;
  41894. private _workingVector;
  41895. private _workingQuaternion;
  41896. private _workingMatrix;
  41897. /**
  41898. * Teleports the users feet to the desired location
  41899. * @param location The location where the user's feet should be placed
  41900. */
  41901. teleportCamera(location: Vector3): void;
  41902. private _convertNormalToDirectionOfRay;
  41903. private _castRayAndSelectObject;
  41904. private _notifySelectedMeshUnselected;
  41905. /**
  41906. * Sets the color of the laser ray from the vr controllers.
  41907. * @param color new color for the ray.
  41908. */
  41909. changeLaserColor(color: Color3): void;
  41910. /**
  41911. * Sets the color of the ray from the vr headsets gaze.
  41912. * @param color new color for the ray.
  41913. */
  41914. changeGazeColor(color: Color3): void;
  41915. /**
  41916. * Exits VR and disposes of the vr experience helper
  41917. */
  41918. dispose(): void;
  41919. /**
  41920. * Gets the name of the VRExperienceHelper class
  41921. * @returns "VRExperienceHelper"
  41922. */
  41923. getClassName(): string;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  41929. * IMPORTANT!! The data is right-hand data.
  41930. * @export
  41931. * @interface DevicePose
  41932. */
  41933. interface DevicePose {
  41934. /**
  41935. * The position of the device, values in array are [x,y,z].
  41936. */
  41937. readonly position: Nullable<Float32Array>;
  41938. /**
  41939. * The linearVelocity of the device, values in array are [x,y,z].
  41940. */
  41941. readonly linearVelocity: Nullable<Float32Array>;
  41942. /**
  41943. * The linearAcceleration of the device, values in array are [x,y,z].
  41944. */
  41945. readonly linearAcceleration: Nullable<Float32Array>;
  41946. /**
  41947. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  41948. */
  41949. readonly orientation: Nullable<Float32Array>;
  41950. /**
  41951. * The angularVelocity of the device, values in array are [x,y,z].
  41952. */
  41953. readonly angularVelocity: Nullable<Float32Array>;
  41954. /**
  41955. * The angularAcceleration of the device, values in array are [x,y,z].
  41956. */
  41957. readonly angularAcceleration: Nullable<Float32Array>;
  41958. }
  41959. /**
  41960. * Interface representing a pose controlled object in Babylon.
  41961. * A pose controlled object has both regular pose values as well as pose values
  41962. * from an external device such as a VR head mounted display
  41963. */
  41964. interface PoseControlled {
  41965. /**
  41966. * The position of the object in babylon space.
  41967. */
  41968. position: Vector3;
  41969. /**
  41970. * The rotation quaternion of the object in babylon space.
  41971. */
  41972. rotationQuaternion: Quaternion;
  41973. /**
  41974. * The position of the device in babylon space.
  41975. */
  41976. devicePosition?: Vector3;
  41977. /**
  41978. * The rotation quaternion of the device in babylon space.
  41979. */
  41980. deviceRotationQuaternion: Quaternion;
  41981. /**
  41982. * The raw pose coming from the device.
  41983. */
  41984. rawPose: Nullable<DevicePose>;
  41985. /**
  41986. * The scale of the device to be used when translating from device space to babylon space.
  41987. */
  41988. deviceScaleFactor: number;
  41989. /**
  41990. * Updates the poseControlled values based on the input device pose.
  41991. * @param poseData the pose data to update the object with
  41992. */
  41993. updateFromDevice(poseData: DevicePose): void;
  41994. }
  41995. /**
  41996. * Set of options to customize the webVRCamera
  41997. */
  41998. interface WebVROptions {
  41999. /**
  42000. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42001. */
  42002. trackPosition?: boolean;
  42003. /**
  42004. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42005. */
  42006. positionScale?: number;
  42007. /**
  42008. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42009. */
  42010. displayName?: string;
  42011. /**
  42012. * Should the native controller meshes be initialized. (default: true)
  42013. */
  42014. controllerMeshes?: boolean;
  42015. /**
  42016. * Creating a default HemiLight only on controllers. (default: true)
  42017. */
  42018. defaultLightingOnControllers?: boolean;
  42019. /**
  42020. * If you don't want to use the default VR button of the helper. (default: false)
  42021. */
  42022. useCustomVRButton?: boolean;
  42023. /**
  42024. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42025. */
  42026. customVRButton?: HTMLButtonElement;
  42027. /**
  42028. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42029. */
  42030. rayLength?: number;
  42031. /**
  42032. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42033. */
  42034. defaultHeight?: number;
  42035. }
  42036. /**
  42037. * This represents a WebVR camera.
  42038. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42039. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42040. */
  42041. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42042. private webVROptions;
  42043. /**
  42044. * @hidden
  42045. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42046. */
  42047. _vrDevice: any;
  42048. /**
  42049. * The rawPose of the vrDevice.
  42050. */
  42051. rawPose: Nullable<DevicePose>;
  42052. private _onVREnabled;
  42053. private _specsVersion;
  42054. private _attached;
  42055. private _frameData;
  42056. protected _descendants: Array<Node>;
  42057. private _deviceRoomPosition;
  42058. /** @hidden */
  42059. _deviceRoomRotationQuaternion: Quaternion;
  42060. private _standingMatrix;
  42061. /**
  42062. * Represents device position in babylon space.
  42063. */
  42064. devicePosition: Vector3;
  42065. /**
  42066. * Represents device rotation in babylon space.
  42067. */
  42068. deviceRotationQuaternion: Quaternion;
  42069. /**
  42070. * The scale of the device to be used when translating from device space to babylon space.
  42071. */
  42072. deviceScaleFactor: number;
  42073. private _deviceToWorld;
  42074. private _worldToDevice;
  42075. /**
  42076. * References to the webVR controllers for the vrDevice.
  42077. */
  42078. controllers: Array<WebVRController>;
  42079. /**
  42080. * Emits an event when a controller is attached.
  42081. */
  42082. onControllersAttachedObservable: Observable<WebVRController[]>;
  42083. /**
  42084. * Emits an event when a controller's mesh has been loaded;
  42085. */
  42086. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42087. /**
  42088. * Emits an event when the HMD's pose has been updated.
  42089. */
  42090. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42091. private _poseSet;
  42092. /**
  42093. * If the rig cameras be used as parent instead of this camera.
  42094. */
  42095. rigParenting: boolean;
  42096. private _lightOnControllers;
  42097. private _defaultHeight?;
  42098. /**
  42099. * Instantiates a WebVRFreeCamera.
  42100. * @param name The name of the WebVRFreeCamera
  42101. * @param position The starting anchor position for the camera
  42102. * @param scene The scene the camera belongs to
  42103. * @param webVROptions a set of customizable options for the webVRCamera
  42104. */
  42105. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42106. /**
  42107. * Gets the device distance from the ground in meters.
  42108. * @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.
  42109. */
  42110. deviceDistanceToRoomGround(): number;
  42111. /**
  42112. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42113. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42114. */
  42115. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42116. /**
  42117. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42118. * @returns A promise with a boolean set to if the standing matrix is supported.
  42119. */
  42120. useStandingMatrixAsync(): Promise<boolean>;
  42121. /**
  42122. * Disposes the camera
  42123. */
  42124. dispose(): void;
  42125. /**
  42126. * Gets a vrController by name.
  42127. * @param name The name of the controller to retreive
  42128. * @returns the controller matching the name specified or null if not found
  42129. */
  42130. getControllerByName(name: string): Nullable<WebVRController>;
  42131. private _leftController;
  42132. /**
  42133. * The controller corrisponding to the users left hand.
  42134. */
  42135. readonly leftController: Nullable<WebVRController>;
  42136. private _rightController;
  42137. /**
  42138. * The controller corrisponding to the users right hand.
  42139. */
  42140. readonly rightController: Nullable<WebVRController>;
  42141. /**
  42142. * Casts a ray forward from the vrCamera's gaze.
  42143. * @param length Length of the ray (default: 100)
  42144. * @returns the ray corrisponding to the gaze
  42145. */
  42146. getForwardRay(length?: number): Ray;
  42147. /**
  42148. * @hidden
  42149. * Updates the camera based on device's frame data
  42150. */
  42151. _checkInputs(): void;
  42152. /**
  42153. * Updates the poseControlled values based on the input device pose.
  42154. * @param poseData Pose coming from the device
  42155. */
  42156. updateFromDevice(poseData: DevicePose): void;
  42157. private _htmlElementAttached;
  42158. private _detachIfAttached;
  42159. /**
  42160. * WebVR's attach control will start broadcasting frames to the device.
  42161. * Note that in certain browsers (chrome for example) this function must be called
  42162. * within a user-interaction callback. Example:
  42163. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42164. *
  42165. * @param element html element to attach the vrDevice to
  42166. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42167. */
  42168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42169. /**
  42170. * Detaches the camera from the html element and disables VR
  42171. *
  42172. * @param element html element to detach from
  42173. */
  42174. detachControl(element: HTMLElement): void;
  42175. /**
  42176. * @returns the name of this class
  42177. */
  42178. getClassName(): string;
  42179. /**
  42180. * Calls resetPose on the vrDisplay
  42181. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42182. */
  42183. resetToCurrentRotation(): void;
  42184. /**
  42185. * @hidden
  42186. * Updates the rig cameras (left and right eye)
  42187. */
  42188. _updateRigCameras(): void;
  42189. private _workingVector;
  42190. private _oneVector;
  42191. private _workingMatrix;
  42192. private updateCacheCalled;
  42193. private _correctPositionIfNotTrackPosition;
  42194. /**
  42195. * @hidden
  42196. * Updates the cached values of the camera
  42197. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  42198. */
  42199. _updateCache(ignoreParentClass?: boolean): void;
  42200. /**
  42201. * @hidden
  42202. * Get current device position in babylon world
  42203. */
  42204. _computeDevicePosition(): void;
  42205. /**
  42206. * Updates the current device position and rotation in the babylon world
  42207. */
  42208. update(): void;
  42209. /**
  42210. * @hidden
  42211. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  42212. * @returns an identity matrix
  42213. */
  42214. _getViewMatrix(): Matrix;
  42215. private _tmpMatrix;
  42216. /**
  42217. * This function is called by the two RIG cameras.
  42218. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  42219. */
  42220. protected _getWebVRViewMatrix(): Matrix;
  42221. protected _getWebVRProjectionMatrix(): Matrix;
  42222. private _onGamepadConnectedObserver;
  42223. private _onGamepadDisconnectedObserver;
  42224. private _updateCacheWhenTrackingDisabledObserver;
  42225. /**
  42226. * Initializes the controllers and their meshes
  42227. */
  42228. initControllers(): void;
  42229. }
  42230. }
  42231. declare module BABYLON {
  42232. /**
  42233. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42234. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42235. */
  42236. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42237. /**
  42238. * Creates a new AnaglyphArcRotateCamera
  42239. * @param name defines camera name
  42240. * @param alpha defines alpha angle (in radians)
  42241. * @param beta defines beta angle (in radians)
  42242. * @param radius defines radius
  42243. * @param target defines camera target
  42244. * @param interaxialDistance defines distance between each color axis
  42245. * @param scene defines the hosting scene
  42246. */
  42247. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42248. /**
  42249. * Gets camera class name
  42250. * @returns AnaglyphArcRotateCamera
  42251. */
  42252. getClassName(): string;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42258. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42259. */
  42260. class AnaglyphFreeCamera extends FreeCamera {
  42261. /**
  42262. * Creates a new AnaglyphFreeCamera
  42263. * @param name defines camera name
  42264. * @param position defines initial position
  42265. * @param interaxialDistance defines distance between each color axis
  42266. * @param scene defines the hosting scene
  42267. */
  42268. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42269. /**
  42270. * Gets camera class name
  42271. * @returns AnaglyphFreeCamera
  42272. */
  42273. getClassName(): string;
  42274. }
  42275. }
  42276. declare module BABYLON {
  42277. /**
  42278. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42279. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42280. */
  42281. class AnaglyphGamepadCamera extends GamepadCamera {
  42282. /**
  42283. * Creates a new AnaglyphGamepadCamera
  42284. * @param name defines camera name
  42285. * @param position defines initial position
  42286. * @param interaxialDistance defines distance between each color axis
  42287. * @param scene defines the hosting scene
  42288. */
  42289. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42290. /**
  42291. * Gets camera class name
  42292. * @returns AnaglyphGamepadCamera
  42293. */
  42294. getClassName(): string;
  42295. }
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42300. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42301. */
  42302. class AnaglyphUniversalCamera extends UniversalCamera {
  42303. /**
  42304. * Creates a new AnaglyphUniversalCamera
  42305. * @param name defines camera name
  42306. * @param position defines initial position
  42307. * @param interaxialDistance defines distance between each color axis
  42308. * @param scene defines the hosting scene
  42309. */
  42310. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42311. /**
  42312. * Gets camera class name
  42313. * @returns AnaglyphUniversalCamera
  42314. */
  42315. getClassName(): string;
  42316. }
  42317. }
  42318. declare module BABYLON {
  42319. /**
  42320. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42321. * @see http://doc.babylonjs.com/features/cameras
  42322. */
  42323. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42324. /**
  42325. * Creates a new StereoscopicArcRotateCamera
  42326. * @param name defines camera name
  42327. * @param alpha defines alpha angle (in radians)
  42328. * @param beta defines beta angle (in radians)
  42329. * @param radius defines radius
  42330. * @param target defines camera target
  42331. * @param interaxialDistance defines distance between each color axis
  42332. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42333. * @param scene defines the hosting scene
  42334. */
  42335. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42336. /**
  42337. * Gets camera class name
  42338. * @returns StereoscopicArcRotateCamera
  42339. */
  42340. getClassName(): string;
  42341. }
  42342. }
  42343. declare module BABYLON {
  42344. /**
  42345. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42346. * @see http://doc.babylonjs.com/features/cameras
  42347. */
  42348. class StereoscopicFreeCamera extends FreeCamera {
  42349. /**
  42350. * Creates a new StereoscopicFreeCamera
  42351. * @param name defines camera name
  42352. * @param position defines initial position
  42353. * @param interaxialDistance defines distance between each color axis
  42354. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42355. * @param scene defines the hosting scene
  42356. */
  42357. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42358. /**
  42359. * Gets camera class name
  42360. * @returns StereoscopicFreeCamera
  42361. */
  42362. getClassName(): string;
  42363. }
  42364. }
  42365. declare module BABYLON {
  42366. /**
  42367. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42368. * @see http://doc.babylonjs.com/features/cameras
  42369. */
  42370. class StereoscopicGamepadCamera extends GamepadCamera {
  42371. /**
  42372. * Creates a new StereoscopicGamepadCamera
  42373. * @param name defines camera name
  42374. * @param position defines initial position
  42375. * @param interaxialDistance defines distance between each color axis
  42376. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42377. * @param scene defines the hosting scene
  42378. */
  42379. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42380. /**
  42381. * Gets camera class name
  42382. * @returns StereoscopicGamepadCamera
  42383. */
  42384. getClassName(): string;
  42385. }
  42386. }
  42387. declare module BABYLON {
  42388. /**
  42389. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42390. * @see http://doc.babylonjs.com/features/cameras
  42391. */
  42392. class StereoscopicUniversalCamera extends UniversalCamera {
  42393. /**
  42394. * Creates a new StereoscopicUniversalCamera
  42395. * @param name defines camera name
  42396. * @param position defines initial position
  42397. * @param interaxialDistance defines distance between each color axis
  42398. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42399. * @param scene defines the hosting scene
  42400. */
  42401. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42402. /**
  42403. * Gets camera class name
  42404. * @returns StereoscopicUniversalCamera
  42405. */
  42406. getClassName(): string;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * WebXR Camera which holds the views for the xrSession
  42412. * @see https://doc.babylonjs.com/how_to/webxr
  42413. */
  42414. class WebXRCamera extends FreeCamera {
  42415. /**
  42416. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42417. * @param name the name of the camera
  42418. * @param scene the scene to add the camera to
  42419. */
  42420. constructor(name: string, scene: BABYLON.Scene);
  42421. private _updateNumberOfRigCameras;
  42422. /** @hidden */
  42423. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42424. }
  42425. }
  42426. declare module BABYLON {
  42427. /**
  42428. * Contains an array of blocks representing the octree
  42429. */
  42430. interface IOctreeContainer<T> {
  42431. /**
  42432. * Blocks within the octree
  42433. */
  42434. blocks: Array<OctreeBlock<T>>;
  42435. }
  42436. /**
  42437. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42438. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42439. */
  42440. class Octree<T> {
  42441. /** 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.) */
  42442. maxDepth: number;
  42443. /**
  42444. * Blocks within the octree containing objects
  42445. */
  42446. blocks: Array<OctreeBlock<T>>;
  42447. /**
  42448. * Content stored in the octree
  42449. */
  42450. dynamicContent: T[];
  42451. private _maxBlockCapacity;
  42452. private _selectionContent;
  42453. private _creationFunc;
  42454. /**
  42455. * Creates a octree
  42456. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42457. * @param creationFunc function to be used to instatiate the octree
  42458. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42459. * @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.)
  42460. */
  42461. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42462. /** 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.) */
  42463. maxDepth?: number);
  42464. /**
  42465. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42466. * @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);
  42467. * @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);
  42468. * @param entries meshes to be added to the octree blocks
  42469. */
  42470. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42471. /**
  42472. * Adds a mesh to the octree
  42473. * @param entry Mesh to add to the octree
  42474. */
  42475. addMesh(entry: T): void;
  42476. /**
  42477. * Selects an array of meshes within the frustum
  42478. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42479. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42480. * @returns array of meshes within the frustum
  42481. */
  42482. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42483. /**
  42484. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42485. * @param sphereCenter defines the bounding sphere center
  42486. * @param sphereRadius defines the bounding sphere radius
  42487. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42488. * @returns an array of objects that intersect the sphere
  42489. */
  42490. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42491. /**
  42492. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42493. * @param ray defines the ray to test with
  42494. * @returns array of intersected objects
  42495. */
  42496. intersectsRay(ray: Ray): SmartArray<T>;
  42497. /**
  42498. * @hidden
  42499. */
  42500. 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;
  42501. /**
  42502. * Adds a mesh into the octree block if it intersects the block
  42503. */
  42504. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42505. /**
  42506. * Adds a submesh into the octree block if it intersects the block
  42507. */
  42508. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42509. }
  42510. }
  42511. declare module BABYLON {
  42512. /**
  42513. * Class used to store a cell in an octree
  42514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42515. */
  42516. class OctreeBlock<T> {
  42517. /**
  42518. * Gets the content of the current block
  42519. */
  42520. entries: T[];
  42521. /**
  42522. * Gets the list of block children
  42523. */
  42524. blocks: Array<OctreeBlock<T>>;
  42525. private _depth;
  42526. private _maxDepth;
  42527. private _capacity;
  42528. private _minPoint;
  42529. private _maxPoint;
  42530. private _boundingVectors;
  42531. private _creationFunc;
  42532. /**
  42533. * Creates a new block
  42534. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42535. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42536. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42537. * @param depth defines the current depth of this block in the octree
  42538. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42539. * @param creationFunc defines a callback to call when an element is added to the block
  42540. */
  42541. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42542. /**
  42543. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42544. */
  42545. readonly capacity: number;
  42546. /**
  42547. * Gets the minimum vector (in world space) of the block's bounding box
  42548. */
  42549. readonly minPoint: Vector3;
  42550. /**
  42551. * Gets the maximum vector (in world space) of the block's bounding box
  42552. */
  42553. readonly maxPoint: Vector3;
  42554. /**
  42555. * Add a new element to this block
  42556. * @param entry defines the element to add
  42557. */
  42558. addEntry(entry: T): void;
  42559. /**
  42560. * Add an array of elements to this block
  42561. * @param entries defines the array of elements to add
  42562. */
  42563. addEntries(entries: T[]): void;
  42564. /**
  42565. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42566. * @param frustumPlanes defines the frustum planes to test
  42567. * @param selection defines the array to store current content if selection is positive
  42568. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42569. */
  42570. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42571. /**
  42572. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42573. * @param sphereCenter defines the bounding sphere center
  42574. * @param sphereRadius defines the bounding sphere radius
  42575. * @param selection defines the array to store current content if selection is positive
  42576. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42577. */
  42578. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42579. /**
  42580. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42581. * @param ray defines the ray to test with
  42582. * @param selection defines the array to store current content if selection is positive
  42583. */
  42584. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42585. /**
  42586. * Subdivide the content into child blocks (this block will then be empty)
  42587. */
  42588. createInnerBlocks(): void;
  42589. }
  42590. }
  42591. declare module BABYLON {
  42592. interface Scene {
  42593. /**
  42594. * @hidden
  42595. * Backing Filed
  42596. */
  42597. _selectionOctree: Octree<AbstractMesh>;
  42598. /**
  42599. * Gets the octree used to boost mesh selection (picking)
  42600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42601. */
  42602. selectionOctree: Octree<AbstractMesh>;
  42603. /**
  42604. * Creates or updates the octree used to boost selection (picking)
  42605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42606. * @param maxCapacity defines the maximum capacity per leaf
  42607. * @param maxDepth defines the maximum depth of the octree
  42608. * @returns an octree of AbstractMesh
  42609. */
  42610. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42611. }
  42612. interface AbstractMesh {
  42613. /**
  42614. * @hidden
  42615. * Backing Field
  42616. */
  42617. _submeshesOctree: Octree<SubMesh>;
  42618. /**
  42619. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42620. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42621. * @param maxCapacity defines the maximum size of each block (64 by default)
  42622. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42623. * @returns the new octree
  42624. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42626. */
  42627. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42628. }
  42629. /**
  42630. * Defines the octree scene component responsible to manage any octrees
  42631. * in a given scene.
  42632. */
  42633. class OctreeSceneComponent {
  42634. /**
  42635. * The component name helpfull to identify the component in the list of scene components.
  42636. */
  42637. readonly name: string;
  42638. /**
  42639. * The scene the component belongs to.
  42640. */
  42641. scene: Scene;
  42642. /**
  42643. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42644. */
  42645. readonly checksIsEnabled: boolean;
  42646. /**
  42647. * Creates a new instance of the component for the given scene
  42648. * @param scene Defines the scene to register the component in
  42649. */
  42650. constructor(scene: Scene);
  42651. /**
  42652. * Registers the component in a given scene
  42653. */
  42654. register(): void;
  42655. /**
  42656. * Return the list of active meshes
  42657. * @returns the list of active meshes
  42658. */
  42659. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42660. /**
  42661. * Return the list of active sub meshes
  42662. * @param mesh The mesh to get the candidates sub meshes from
  42663. * @returns the list of active sub meshes
  42664. */
  42665. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42666. private _tempRay;
  42667. /**
  42668. * Return the list of sub meshes intersecting with a given local ray
  42669. * @param mesh defines the mesh to find the submesh for
  42670. * @param localRay defines the ray in local space
  42671. * @returns the list of intersecting sub meshes
  42672. */
  42673. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42674. /**
  42675. * Return the list of sub meshes colliding with a collider
  42676. * @param mesh defines the mesh to find the submesh for
  42677. * @param collider defines the collider to evaluate the collision against
  42678. * @returns the list of colliding sub meshes
  42679. */
  42680. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42681. /**
  42682. * Rebuilds the elements related to this component in case of
  42683. * context lost for instance.
  42684. */
  42685. rebuild(): void;
  42686. /**
  42687. * Disposes the component and the associated ressources.
  42688. */
  42689. dispose(): void;
  42690. }
  42691. }
  42692. declare module BABYLON {
  42693. /** @hidden */
  42694. class _OcclusionDataStorage {
  42695. /** @hidden */
  42696. occlusionInternalRetryCounter: number;
  42697. /** @hidden */
  42698. isOcclusionQueryInProgress: boolean;
  42699. /** @hidden */
  42700. isOccluded: boolean;
  42701. /** @hidden */
  42702. occlusionRetryCount: number;
  42703. /** @hidden */
  42704. occlusionType: number;
  42705. /** @hidden */
  42706. occlusionQueryAlgorithmType: number;
  42707. }
  42708. interface Engine {
  42709. /**
  42710. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42711. * @return the new query
  42712. */
  42713. createQuery(): WebGLQuery;
  42714. /**
  42715. * Delete and release a webGL query
  42716. * @param query defines the query to delete
  42717. * @return the current engine
  42718. */
  42719. deleteQuery(query: WebGLQuery): Engine;
  42720. /**
  42721. * Check if a given query has resolved and got its value
  42722. * @param query defines the query to check
  42723. * @returns true if the query got its value
  42724. */
  42725. isQueryResultAvailable(query: WebGLQuery): boolean;
  42726. /**
  42727. * Gets the value of a given query
  42728. * @param query defines the query to check
  42729. * @returns the value of the query
  42730. */
  42731. getQueryResult(query: WebGLQuery): number;
  42732. /**
  42733. * Initiates an occlusion query
  42734. * @param algorithmType defines the algorithm to use
  42735. * @param query defines the query to use
  42736. * @returns the current engine
  42737. * @see http://doc.babylonjs.com/features/occlusionquery
  42738. */
  42739. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42740. /**
  42741. * Ends an occlusion query
  42742. * @see http://doc.babylonjs.com/features/occlusionquery
  42743. * @param algorithmType defines the algorithm to use
  42744. * @returns the current engine
  42745. */
  42746. endOcclusionQuery(algorithmType: number): Engine;
  42747. /**
  42748. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42749. * Please note that only one query can be issued at a time
  42750. * @returns a time token used to track the time span
  42751. */
  42752. startTimeQuery(): Nullable<_TimeToken>;
  42753. /**
  42754. * Ends a time query
  42755. * @param token defines the token used to measure the time span
  42756. * @returns the time spent (in ns)
  42757. */
  42758. endTimeQuery(token: _TimeToken): int;
  42759. /** @hidden */
  42760. _currentNonTimestampToken: Nullable<_TimeToken>;
  42761. /** @hidden */
  42762. _createTimeQuery(): WebGLQuery;
  42763. /** @hidden */
  42764. _deleteTimeQuery(query: WebGLQuery): void;
  42765. /** @hidden */
  42766. _getGlAlgorithmType(algorithmType: number): number;
  42767. /** @hidden */
  42768. _getTimeQueryResult(query: WebGLQuery): any;
  42769. /** @hidden */
  42770. _getTimeQueryAvailability(query: WebGLQuery): any;
  42771. }
  42772. interface AbstractMesh {
  42773. /**
  42774. * Backing filed
  42775. * @hidden
  42776. */
  42777. __occlusionDataStorage: _OcclusionDataStorage;
  42778. /**
  42779. * Access property
  42780. * @hidden
  42781. */
  42782. _occlusionDataStorage: _OcclusionDataStorage;
  42783. /**
  42784. * 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.
  42785. * The default value is -1 which means don't break the query and wait till the result
  42786. * @see http://doc.babylonjs.com/features/occlusionquery
  42787. */
  42788. occlusionRetryCount: number;
  42789. /**
  42790. * 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:
  42791. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42792. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42793. * * 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.
  42794. * @see http://doc.babylonjs.com/features/occlusionquery
  42795. */
  42796. occlusionType: number;
  42797. /**
  42798. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42799. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42800. * * 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.
  42801. * @see http://doc.babylonjs.com/features/occlusionquery
  42802. */
  42803. occlusionQueryAlgorithmType: number;
  42804. /**
  42805. * 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
  42806. * @see http://doc.babylonjs.com/features/occlusionquery
  42807. */
  42808. isOccluded: boolean;
  42809. /**
  42810. * Flag to check the progress status of the query
  42811. * @see http://doc.babylonjs.com/features/occlusionquery
  42812. */
  42813. isOcclusionQueryInProgress: boolean;
  42814. }
  42815. }
  42816. declare module BABYLON {
  42817. interface Engine {
  42818. /**
  42819. * Creates a webGL transform feedback object
  42820. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42821. * @returns the webGL transform feedback object
  42822. */
  42823. createTransformFeedback(): WebGLTransformFeedback;
  42824. /**
  42825. * Delete a webGL transform feedback object
  42826. * @param value defines the webGL transform feedback object to delete
  42827. */
  42828. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42829. /**
  42830. * Bind a webGL transform feedback object to the webgl context
  42831. * @param value defines the webGL transform feedback object to bind
  42832. */
  42833. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42834. /**
  42835. * Begins a transform feedback operation
  42836. * @param usePoints defines if points or triangles must be used
  42837. */
  42838. beginTransformFeedback(usePoints: boolean): void;
  42839. /**
  42840. * Ends a transform feedback operation
  42841. */
  42842. endTransformFeedback(): void;
  42843. /**
  42844. * Specify the varyings to use with transform feedback
  42845. * @param program defines the associated webGL program
  42846. * @param value defines the list of strings representing the varying names
  42847. */
  42848. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42849. /**
  42850. * Bind a webGL buffer for a transform feedback operation
  42851. * @param value defines the webGL buffer to bind
  42852. */
  42853. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42854. }
  42855. }
  42856. declare module BABYLON {
  42857. /**
  42858. * Google Daydream controller
  42859. */
  42860. class DaydreamController extends WebVRController {
  42861. /**
  42862. * Base Url for the controller model.
  42863. */
  42864. static MODEL_BASE_URL: string;
  42865. /**
  42866. * File name for the controller model.
  42867. */
  42868. static MODEL_FILENAME: string;
  42869. /**
  42870. * Gamepad Id prefix used to identify Daydream Controller.
  42871. */
  42872. static readonly GAMEPAD_ID_PREFIX: string;
  42873. /**
  42874. * Creates a new DaydreamController from a gamepad
  42875. * @param vrGamepad the gamepad that the controller should be created from
  42876. */
  42877. constructor(vrGamepad: any);
  42878. /**
  42879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42880. * @param scene scene in which to add meshes
  42881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42882. */
  42883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42884. /**
  42885. * Called once for each button that changed state since the last frame
  42886. * @param buttonIdx Which button index changed
  42887. * @param state New state of the button
  42888. * @param changes Which properties on the state changed since last frame
  42889. */
  42890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42891. }
  42892. }
  42893. declare module BABYLON {
  42894. /**
  42895. * Gear VR Controller
  42896. */
  42897. class GearVRController extends WebVRController {
  42898. /**
  42899. * Base Url for the controller model.
  42900. */
  42901. static MODEL_BASE_URL: string;
  42902. /**
  42903. * File name for the controller model.
  42904. */
  42905. static MODEL_FILENAME: string;
  42906. /**
  42907. * Gamepad Id prefix used to identify this controller.
  42908. */
  42909. static readonly GAMEPAD_ID_PREFIX: string;
  42910. private readonly _buttonIndexToObservableNameMap;
  42911. /**
  42912. * Creates a new GearVRController from a gamepad
  42913. * @param vrGamepad the gamepad that the controller should be created from
  42914. */
  42915. constructor(vrGamepad: any);
  42916. /**
  42917. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42918. * @param scene scene in which to add meshes
  42919. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42920. */
  42921. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42922. /**
  42923. * Called once for each button that changed state since the last frame
  42924. * @param buttonIdx Which button index changed
  42925. * @param state New state of the button
  42926. * @param changes Which properties on the state changed since last frame
  42927. */
  42928. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42929. }
  42930. }
  42931. declare module BABYLON {
  42932. /**
  42933. * Generic Controller
  42934. */
  42935. class GenericController extends WebVRController {
  42936. /**
  42937. * Base Url for the controller model.
  42938. */
  42939. static readonly MODEL_BASE_URL: string;
  42940. /**
  42941. * File name for the controller model.
  42942. */
  42943. static readonly MODEL_FILENAME: string;
  42944. /**
  42945. * Creates a new GenericController from a gamepad
  42946. * @param vrGamepad the gamepad that the controller should be created from
  42947. */
  42948. constructor(vrGamepad: any);
  42949. /**
  42950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42951. * @param scene scene in which to add meshes
  42952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42953. */
  42954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42955. /**
  42956. * Called once for each button that changed state since the last frame
  42957. * @param buttonIdx Which button index changed
  42958. * @param state New state of the button
  42959. * @param changes Which properties on the state changed since last frame
  42960. */
  42961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42962. }
  42963. }
  42964. declare module BABYLON {
  42965. /**
  42966. * Oculus Touch Controller
  42967. */
  42968. class OculusTouchController extends WebVRController {
  42969. /**
  42970. * Base Url for the controller model.
  42971. */
  42972. static MODEL_BASE_URL: string;
  42973. /**
  42974. * File name for the left controller model.
  42975. */
  42976. static MODEL_LEFT_FILENAME: string;
  42977. /**
  42978. * File name for the right controller model.
  42979. */
  42980. static MODEL_RIGHT_FILENAME: string;
  42981. /**
  42982. * Fired when the secondary trigger on this controller is modified
  42983. */
  42984. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42985. /**
  42986. * Fired when the thumb rest on this controller is modified
  42987. */
  42988. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42989. /**
  42990. * Creates a new OculusTouchController from a gamepad
  42991. * @param vrGamepad the gamepad that the controller should be created from
  42992. */
  42993. constructor(vrGamepad: any);
  42994. /**
  42995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42996. * @param scene scene in which to add meshes
  42997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42998. */
  42999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43000. /**
  43001. * Fired when the A button on this controller is modified
  43002. */
  43003. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43004. /**
  43005. * Fired when the B button on this controller is modified
  43006. */
  43007. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43008. /**
  43009. * Fired when the X button on this controller is modified
  43010. */
  43011. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43012. /**
  43013. * Fired when the Y button on this controller is modified
  43014. */
  43015. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43016. /**
  43017. * Called once for each button that changed state since the last frame
  43018. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43019. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43020. * 2) secondary trigger (same)
  43021. * 3) A (right) X (left), touch, pressed = value
  43022. * 4) B / Y
  43023. * 5) thumb rest
  43024. * @param buttonIdx Which button index changed
  43025. * @param state New state of the button
  43026. * @param changes Which properties on the state changed since last frame
  43027. */
  43028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43029. }
  43030. }
  43031. declare module BABYLON {
  43032. /**
  43033. * Defines the types of pose enabled controllers that are supported
  43034. */
  43035. enum PoseEnabledControllerType {
  43036. /**
  43037. * HTC Vive
  43038. */
  43039. VIVE = 0,
  43040. /**
  43041. * Oculus Rift
  43042. */
  43043. OCULUS = 1,
  43044. /**
  43045. * Windows mixed reality
  43046. */
  43047. WINDOWS = 2,
  43048. /**
  43049. * Samsung gear VR
  43050. */
  43051. GEAR_VR = 3,
  43052. /**
  43053. * Google Daydream
  43054. */
  43055. DAYDREAM = 4,
  43056. /**
  43057. * Generic
  43058. */
  43059. GENERIC = 5
  43060. }
  43061. /**
  43062. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43063. */
  43064. interface MutableGamepadButton {
  43065. /**
  43066. * Value of the button/trigger
  43067. */
  43068. value: number;
  43069. /**
  43070. * If the button/trigger is currently touched
  43071. */
  43072. touched: boolean;
  43073. /**
  43074. * If the button/trigger is currently pressed
  43075. */
  43076. pressed: boolean;
  43077. }
  43078. /**
  43079. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43080. * @hidden
  43081. */
  43082. interface ExtendedGamepadButton extends GamepadButton {
  43083. /**
  43084. * If the button/trigger is currently pressed
  43085. */
  43086. readonly pressed: boolean;
  43087. /**
  43088. * If the button/trigger is currently touched
  43089. */
  43090. readonly touched: boolean;
  43091. /**
  43092. * Value of the button/trigger
  43093. */
  43094. readonly value: number;
  43095. }
  43096. /**
  43097. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43098. */
  43099. class PoseEnabledControllerHelper {
  43100. /**
  43101. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43102. * @param vrGamepad the gamepad to initialized
  43103. * @returns a vr controller of the type the gamepad identified as
  43104. */
  43105. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43106. }
  43107. /**
  43108. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43109. */
  43110. class PoseEnabledController extends Gamepad implements PoseControlled {
  43111. private _deviceRoomPosition;
  43112. private _deviceRoomRotationQuaternion;
  43113. /**
  43114. * The device position in babylon space
  43115. */
  43116. devicePosition: Vector3;
  43117. /**
  43118. * The device rotation in babylon space
  43119. */
  43120. deviceRotationQuaternion: Quaternion;
  43121. /**
  43122. * The scale factor of the device in babylon space
  43123. */
  43124. deviceScaleFactor: number;
  43125. /**
  43126. * (Likely devicePosition should be used instead) The device position in its room space
  43127. */
  43128. position: Vector3;
  43129. /**
  43130. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43131. */
  43132. rotationQuaternion: Quaternion;
  43133. /**
  43134. * The type of controller (Eg. Windows mixed reality)
  43135. */
  43136. controllerType: PoseEnabledControllerType;
  43137. protected _calculatedPosition: Vector3;
  43138. private _calculatedRotation;
  43139. /**
  43140. * The raw pose from the device
  43141. */
  43142. rawPose: DevicePose;
  43143. private _trackPosition;
  43144. private _maxRotationDistFromHeadset;
  43145. private _draggedRoomRotation;
  43146. /**
  43147. * @hidden
  43148. */
  43149. _disableTrackPosition(fixedPosition: Vector3): void;
  43150. /**
  43151. * Internal, the mesh attached to the controller
  43152. * @hidden
  43153. */
  43154. _mesh: Nullable<AbstractMesh>;
  43155. private _poseControlledCamera;
  43156. private _leftHandSystemQuaternion;
  43157. /**
  43158. * Internal, matrix used to convert room space to babylon space
  43159. * @hidden
  43160. */
  43161. _deviceToWorld: Matrix;
  43162. /**
  43163. * Node to be used when casting a ray from the controller
  43164. * @hidden
  43165. */
  43166. _pointingPoseNode: Nullable<AbstractMesh>;
  43167. /**
  43168. * Name of the child mesh that can be used to cast a ray from the controller
  43169. */
  43170. static readonly POINTING_POSE: string;
  43171. /**
  43172. * Creates a new PoseEnabledController from a gamepad
  43173. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43174. */
  43175. constructor(browserGamepad: any);
  43176. private _workingMatrix;
  43177. /**
  43178. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43179. */
  43180. update(): void;
  43181. /**
  43182. * Updates only the pose device and mesh without doing any button event checking
  43183. */
  43184. protected _updatePoseAndMesh(): void;
  43185. /**
  43186. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43187. * @param poseData raw pose fromthe device
  43188. */
  43189. updateFromDevice(poseData: DevicePose): void;
  43190. /**
  43191. * @hidden
  43192. */
  43193. _meshAttachedObservable: Observable<AbstractMesh>;
  43194. /**
  43195. * Attaches a mesh to the controller
  43196. * @param mesh the mesh to be attached
  43197. */
  43198. attachToMesh(mesh: AbstractMesh): void;
  43199. /**
  43200. * Attaches the controllers mesh to a camera
  43201. * @param camera the camera the mesh should be attached to
  43202. */
  43203. attachToPoseControlledCamera(camera: TargetCamera): void;
  43204. /**
  43205. * Disposes of the controller
  43206. */
  43207. dispose(): void;
  43208. /**
  43209. * The mesh that is attached to the controller
  43210. */
  43211. readonly mesh: Nullable<AbstractMesh>;
  43212. /**
  43213. * Gets the ray of the controller in the direction the controller is pointing
  43214. * @param length the length the resulting ray should be
  43215. * @returns a ray in the direction the controller is pointing
  43216. */
  43217. getForwardRay(length?: number): Ray;
  43218. }
  43219. }
  43220. declare module BABYLON {
  43221. /**
  43222. * Vive Controller
  43223. */
  43224. class ViveController extends WebVRController {
  43225. /**
  43226. * Base Url for the controller model.
  43227. */
  43228. static MODEL_BASE_URL: string;
  43229. /**
  43230. * File name for the controller model.
  43231. */
  43232. static MODEL_FILENAME: string;
  43233. /**
  43234. * Creates a new ViveController from a gamepad
  43235. * @param vrGamepad the gamepad that the controller should be created from
  43236. */
  43237. constructor(vrGamepad: any);
  43238. /**
  43239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43240. * @param scene scene in which to add meshes
  43241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43242. */
  43243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43244. /**
  43245. * Fired when the left button on this controller is modified
  43246. */
  43247. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43248. /**
  43249. * Fired when the right button on this controller is modified
  43250. */
  43251. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43252. /**
  43253. * Fired when the menu button on this controller is modified
  43254. */
  43255. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43256. /**
  43257. * Called once for each button that changed state since the last frame
  43258. * Vive mapping:
  43259. * 0: touchpad
  43260. * 1: trigger
  43261. * 2: left AND right buttons
  43262. * 3: menu button
  43263. * @param buttonIdx Which button index changed
  43264. * @param state New state of the button
  43265. * @param changes Which properties on the state changed since last frame
  43266. */
  43267. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43268. }
  43269. }
  43270. declare module BABYLON {
  43271. /**
  43272. * Defines the WebVRController object that represents controllers tracked in 3D space
  43273. */
  43274. abstract class WebVRController extends PoseEnabledController {
  43275. /**
  43276. * Internal, the default controller model for the controller
  43277. */
  43278. protected _defaultModel: AbstractMesh;
  43279. /**
  43280. * Fired when the trigger state has changed
  43281. */
  43282. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Fired when the main button state has changed
  43285. */
  43286. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the secondary button state has changed
  43289. */
  43290. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43291. /**
  43292. * Fired when the pad state has changed
  43293. */
  43294. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  43295. /**
  43296. * Fired when controllers stick values have changed
  43297. */
  43298. onPadValuesChangedObservable: Observable<StickValues>;
  43299. /**
  43300. * Array of button availible on the controller
  43301. */
  43302. protected _buttons: Array<MutableGamepadButton>;
  43303. private _onButtonStateChange;
  43304. /**
  43305. * Fired when a controller button's state has changed
  43306. * @param callback the callback containing the button that was modified
  43307. */
  43308. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  43309. /**
  43310. * X and Y axis corrisponding to the controllers joystick
  43311. */
  43312. pad: StickValues;
  43313. /**
  43314. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  43315. */
  43316. hand: string;
  43317. /**
  43318. * The default controller model for the controller
  43319. */
  43320. readonly defaultModel: AbstractMesh;
  43321. /**
  43322. * Creates a new WebVRController from a gamepad
  43323. * @param vrGamepad the gamepad that the WebVRController should be created from
  43324. */
  43325. constructor(vrGamepad: any);
  43326. /**
  43327. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  43328. */
  43329. update(): void;
  43330. /**
  43331. * Function to be called when a button is modified
  43332. */
  43333. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43334. /**
  43335. * Loads a mesh and attaches it to the controller
  43336. * @param scene the scene the mesh should be added to
  43337. * @param meshLoaded callback for when the mesh has been loaded
  43338. */
  43339. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43340. private _setButtonValue;
  43341. private _changes;
  43342. private _checkChanges;
  43343. /**
  43344. * Disposes of th webVRCOntroller
  43345. */
  43346. dispose(): void;
  43347. }
  43348. }
  43349. declare module BABYLON {
  43350. /**
  43351. * Defines the WindowsMotionController object that the state of the windows motion controller
  43352. */
  43353. class WindowsMotionController extends WebVRController {
  43354. /**
  43355. * The base url used to load the left and right controller models
  43356. */
  43357. static MODEL_BASE_URL: string;
  43358. /**
  43359. * The name of the left controller model file
  43360. */
  43361. static MODEL_LEFT_FILENAME: string;
  43362. /**
  43363. * The name of the right controller model file
  43364. */
  43365. static MODEL_RIGHT_FILENAME: string;
  43366. /**
  43367. * The controller name prefix for this controller type
  43368. */
  43369. static readonly GAMEPAD_ID_PREFIX: string;
  43370. /**
  43371. * The controller id pattern for this controller type
  43372. */
  43373. private static readonly GAMEPAD_ID_PATTERN;
  43374. private _loadedMeshInfo;
  43375. private readonly _mapping;
  43376. /**
  43377. * Fired when the trackpad on this controller is clicked
  43378. */
  43379. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43380. /**
  43381. * Fired when the trackpad on this controller is modified
  43382. */
  43383. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43384. /**
  43385. * The current x and y values of this controller's trackpad
  43386. */
  43387. trackpad: StickValues;
  43388. /**
  43389. * Creates a new WindowsMotionController from a gamepad
  43390. * @param vrGamepad the gamepad that the controller should be created from
  43391. */
  43392. constructor(vrGamepad: any);
  43393. /**
  43394. * Fired when the trigger on this controller is modified
  43395. */
  43396. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43397. /**
  43398. * Fired when the menu button on this controller is modified
  43399. */
  43400. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43401. /**
  43402. * Fired when the grip button on this controller is modified
  43403. */
  43404. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43405. /**
  43406. * Fired when the thumbstick button on this controller is modified
  43407. */
  43408. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43409. /**
  43410. * Fired when the touchpad button on this controller is modified
  43411. */
  43412. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43413. /**
  43414. * Fired when the touchpad values on this controller are modified
  43415. */
  43416. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43417. private _updateTrackpad;
  43418. /**
  43419. * Called once per frame by the engine.
  43420. */
  43421. update(): void;
  43422. /**
  43423. * Called once for each button that changed state since the last frame
  43424. * @param buttonIdx Which button index changed
  43425. * @param state New state of the button
  43426. * @param changes Which properties on the state changed since last frame
  43427. */
  43428. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43429. /**
  43430. * Moves the buttons on the controller mesh based on their current state
  43431. * @param buttonName the name of the button to move
  43432. * @param buttonValue the value of the button which determines the buttons new position
  43433. */
  43434. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43435. /**
  43436. * Moves the axis on the controller mesh based on its current state
  43437. * @param axis the index of the axis
  43438. * @param axisValue the value of the axis which determines the meshes new position
  43439. * @hidden
  43440. */
  43441. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43442. /**
  43443. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43444. * @param scene scene in which to add meshes
  43445. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43446. */
  43447. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43448. /**
  43449. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43450. * can be transformed by button presses and axes values, based on this._mapping.
  43451. *
  43452. * @param scene scene in which the meshes exist
  43453. * @param meshes list of meshes that make up the controller model to process
  43454. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43455. */
  43456. private processModel;
  43457. private createMeshInfo;
  43458. /**
  43459. * Gets the ray of the controller in the direction the controller is pointing
  43460. * @param length the length the resulting ray should be
  43461. * @returns a ray in the direction the controller is pointing
  43462. */
  43463. getForwardRay(length?: number): Ray;
  43464. /**
  43465. * Disposes of the controller
  43466. */
  43467. dispose(): void;
  43468. }
  43469. }
  43470. declare module BABYLON {
  43471. /**
  43472. * Interface to implement to create a shadow generator compatible with BJS.
  43473. */
  43474. interface IShadowGenerator {
  43475. /**
  43476. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43477. * @returns The render target texture if present otherwise, null
  43478. */
  43479. getShadowMap(): Nullable<RenderTargetTexture>;
  43480. /**
  43481. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43482. * @returns The render target texture if the shadow map is present otherwise, null
  43483. */
  43484. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43485. /**
  43486. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43487. * @param subMesh The submesh we want to render in the shadow map
  43488. * @param useInstances Defines wether will draw in the map using instances
  43489. * @returns true if ready otherwise, false
  43490. */
  43491. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43492. /**
  43493. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43494. * @param defines Defines of the material we want to update
  43495. * @param lightIndex Index of the light in the enabled light list of the material
  43496. */
  43497. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  43498. /**
  43499. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43500. * defined in the generator but impacting the effect).
  43501. * It implies the unifroms available on the materials are the standard BJS ones.
  43502. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43503. * @param effect The effect we are binfing the information for
  43504. */
  43505. bindShadowLight(lightIndex: string, effect: Effect): void;
  43506. /**
  43507. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43508. * (eq to shadow prjection matrix * light transform matrix)
  43509. * @returns The transform matrix used to create the shadow map
  43510. */
  43511. getTransformMatrix(): Matrix;
  43512. /**
  43513. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43514. * Cube and 2D textures for instance.
  43515. */
  43516. recreateShadowMap(): void;
  43517. /**
  43518. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43519. * @param onCompiled Callback triggered at the and of the effects compilation
  43520. * @param options Sets of optional options forcing the compilation with different modes
  43521. */
  43522. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43523. useInstances: boolean;
  43524. }>): void;
  43525. /**
  43526. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43527. * @param options Sets of optional options forcing the compilation with different modes
  43528. * @returns A promise that resolves when the compilation completes
  43529. */
  43530. forceCompilationAsync(options?: Partial<{
  43531. useInstances: boolean;
  43532. }>): Promise<void>;
  43533. /**
  43534. * Serializes the shadow generator setup to a json object.
  43535. * @returns The serialized JSON object
  43536. */
  43537. serialize(): any;
  43538. /**
  43539. * Disposes the Shadow map and related Textures and effects.
  43540. */
  43541. dispose(): void;
  43542. }
  43543. /**
  43544. * Default implementation IShadowGenerator.
  43545. * This is the main object responsible of generating shadows in the framework.
  43546. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  43547. */
  43548. class ShadowGenerator implements IShadowGenerator {
  43549. /**
  43550. * Shadow generator mode None: no filtering applied.
  43551. */
  43552. static readonly FILTER_NONE: number;
  43553. /**
  43554. * Shadow generator mode ESM: Exponential Shadow Mapping.
  43555. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43556. */
  43557. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  43558. /**
  43559. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  43560. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  43561. */
  43562. static readonly FILTER_POISSONSAMPLING: number;
  43563. /**
  43564. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  43565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43566. */
  43567. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  43568. /**
  43569. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  43570. * edge artifacts on steep falloff.
  43571. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43572. */
  43573. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  43574. /**
  43575. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  43576. * edge artifacts on steep falloff.
  43577. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  43578. */
  43579. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  43580. /**
  43581. * Shadow generator mode PCF: Percentage Closer Filtering
  43582. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43583. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  43584. */
  43585. static readonly FILTER_PCF: number;
  43586. /**
  43587. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  43588. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  43589. * Contact Hardening
  43590. */
  43591. static readonly FILTER_PCSS: number;
  43592. /**
  43593. * Reserved for PCF and PCSS
  43594. * Highest Quality.
  43595. *
  43596. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  43597. *
  43598. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  43599. */
  43600. static readonly QUALITY_HIGH: number;
  43601. /**
  43602. * Reserved for PCF and PCSS
  43603. * Good tradeoff for quality/perf cross devices
  43604. *
  43605. * Execute PCF on a 3*3 kernel.
  43606. *
  43607. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  43608. */
  43609. static readonly QUALITY_MEDIUM: number;
  43610. /**
  43611. * Reserved for PCF and PCSS
  43612. * The lowest quality but the fastest.
  43613. *
  43614. * Execute PCF on a 1*1 kernel.
  43615. *
  43616. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  43617. */
  43618. static readonly QUALITY_LOW: number;
  43619. private _bias;
  43620. /**
  43621. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  43622. */
  43623. /**
  43624. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  43625. */
  43626. bias: number;
  43627. private _normalBias;
  43628. /**
  43629. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43630. */
  43631. /**
  43632. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  43633. */
  43634. normalBias: number;
  43635. private _blurBoxOffset;
  43636. /**
  43637. * Gets the blur box offset: offset applied during the blur pass.
  43638. * Only usefull if useKernelBlur = false
  43639. */
  43640. /**
  43641. * Sets the blur box offset: offset applied during the blur pass.
  43642. * Only usefull if useKernelBlur = false
  43643. */
  43644. blurBoxOffset: number;
  43645. private _blurScale;
  43646. /**
  43647. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  43648. * 2 means half of the size.
  43649. */
  43650. /**
  43651. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  43652. * 2 means half of the size.
  43653. */
  43654. blurScale: number;
  43655. private _blurKernel;
  43656. /**
  43657. * Gets the blur kernel: kernel size of the blur pass.
  43658. * Only usefull if useKernelBlur = true
  43659. */
  43660. /**
  43661. * Sets the blur kernel: kernel size of the blur pass.
  43662. * Only usefull if useKernelBlur = true
  43663. */
  43664. blurKernel: number;
  43665. private _useKernelBlur;
  43666. /**
  43667. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  43668. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43669. */
  43670. /**
  43671. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  43672. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  43673. */
  43674. useKernelBlur: boolean;
  43675. private _depthScale;
  43676. /**
  43677. * Gets the depth scale used in ESM mode.
  43678. */
  43679. /**
  43680. * Sets the depth scale used in ESM mode.
  43681. * This can override the scale stored on the light.
  43682. */
  43683. depthScale: number;
  43684. private _filter;
  43685. /**
  43686. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  43687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43688. */
  43689. /**
  43690. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  43691. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  43692. */
  43693. filter: number;
  43694. /**
  43695. * Gets if the current filter is set to Poisson Sampling.
  43696. */
  43697. /**
  43698. * Sets the current filter to Poisson Sampling.
  43699. */
  43700. usePoissonSampling: boolean;
  43701. /**
  43702. * Gets if the current filter is set to VSM.
  43703. * DEPRECATED. Should use useExponentialShadowMap instead.
  43704. */
  43705. /**
  43706. * Sets the current filter is to VSM.
  43707. * DEPRECATED. Should use useExponentialShadowMap instead.
  43708. */
  43709. useVarianceShadowMap: boolean;
  43710. /**
  43711. * Gets if the current filter is set to blurred VSM.
  43712. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43713. */
  43714. /**
  43715. * Sets the current filter is to blurred VSM.
  43716. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  43717. */
  43718. useBlurVarianceShadowMap: boolean;
  43719. /**
  43720. * Gets if the current filter is set to ESM.
  43721. */
  43722. /**
  43723. * Sets the current filter is to ESM.
  43724. */
  43725. useExponentialShadowMap: boolean;
  43726. /**
  43727. * Gets if the current filter is set to filtered ESM.
  43728. */
  43729. /**
  43730. * Gets if the current filter is set to filtered ESM.
  43731. */
  43732. useBlurExponentialShadowMap: boolean;
  43733. /**
  43734. * Gets if the current filter is set to "close ESM" (using the inverse of the
  43735. * exponential to prevent steep falloff artifacts).
  43736. */
  43737. /**
  43738. * Sets the current filter to "close ESM" (using the inverse of the
  43739. * exponential to prevent steep falloff artifacts).
  43740. */
  43741. useCloseExponentialShadowMap: boolean;
  43742. /**
  43743. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  43744. * exponential to prevent steep falloff artifacts).
  43745. */
  43746. /**
  43747. * Sets the current filter to filtered "close ESM" (using the inverse of the
  43748. * exponential to prevent steep falloff artifacts).
  43749. */
  43750. useBlurCloseExponentialShadowMap: boolean;
  43751. /**
  43752. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  43753. */
  43754. /**
  43755. * Sets the current filter to "PCF" (percentage closer filtering).
  43756. */
  43757. usePercentageCloserFiltering: boolean;
  43758. private _filteringQuality;
  43759. /**
  43760. * Gets the PCF or PCSS Quality.
  43761. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43762. */
  43763. /**
  43764. * Sets the PCF or PCSS Quality.
  43765. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  43766. */
  43767. filteringQuality: number;
  43768. /**
  43769. * Gets if the current filter is set to "PCSS" (contact hardening).
  43770. */
  43771. /**
  43772. * Sets the current filter to "PCSS" (contact hardening).
  43773. */
  43774. useContactHardeningShadow: boolean;
  43775. private _contactHardeningLightSizeUVRatio;
  43776. /**
  43777. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43778. * Using a ratio helps keeping shape stability independently of the map size.
  43779. *
  43780. * It does not account for the light projection as it was having too much
  43781. * instability during the light setup or during light position changes.
  43782. *
  43783. * Only valid if useContactHardeningShadow is true.
  43784. */
  43785. /**
  43786. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  43787. * Using a ratio helps keeping shape stability independently of the map size.
  43788. *
  43789. * It does not account for the light projection as it was having too much
  43790. * instability during the light setup or during light position changes.
  43791. *
  43792. * Only valid if useContactHardeningShadow is true.
  43793. */
  43794. contactHardeningLightSizeUVRatio: number;
  43795. private _darkness;
  43796. /**
  43797. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  43798. * 0 means strongest and 1 would means no shadow.
  43799. * @returns the darkness.
  43800. */
  43801. getDarkness(): number;
  43802. /**
  43803. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  43804. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  43805. * @returns the shadow generator allowing fluent coding.
  43806. */
  43807. setDarkness(darkness: number): ShadowGenerator;
  43808. private _transparencyShadow;
  43809. /**
  43810. * Sets the ability to have transparent shadow (boolean).
  43811. * @param transparent True if transparent else False
  43812. * @returns the shadow generator allowing fluent coding
  43813. */
  43814. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  43815. private _shadowMap;
  43816. private _shadowMap2;
  43817. /**
  43818. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  43819. * @returns The render target texture if present otherwise, null
  43820. */
  43821. getShadowMap(): Nullable<RenderTargetTexture>;
  43822. /**
  43823. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  43824. * @returns The render target texture if the shadow map is present otherwise, null
  43825. */
  43826. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  43827. /**
  43828. * Helper function to add a mesh and its descendants to the list of shadow casters.
  43829. * @param mesh Mesh to add
  43830. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  43831. * @returns the Shadow Generator itself
  43832. */
  43833. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43834. /**
  43835. * Helper function to remove a mesh and its descendants from the list of shadow casters
  43836. * @param mesh Mesh to remove
  43837. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  43838. * @returns the Shadow Generator itself
  43839. */
  43840. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  43841. /**
  43842. * Controls the extent to which the shadows fade out at the edge of the frustum
  43843. * Used only by directionals and spots
  43844. */
  43845. frustumEdgeFalloff: number;
  43846. private _light;
  43847. /**
  43848. * Returns the associated light object.
  43849. * @returns the light generating the shadow
  43850. */
  43851. getLight(): IShadowLight;
  43852. /**
  43853. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  43854. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  43855. * It might on the other hand introduce peter panning.
  43856. */
  43857. forceBackFacesOnly: boolean;
  43858. private _scene;
  43859. private _lightDirection;
  43860. private _effect;
  43861. private _viewMatrix;
  43862. private _projectionMatrix;
  43863. private _transformMatrix;
  43864. private _cachedPosition;
  43865. private _cachedDirection;
  43866. private _cachedDefines;
  43867. private _currentRenderID;
  43868. private _boxBlurPostprocess;
  43869. private _kernelBlurXPostprocess;
  43870. private _kernelBlurYPostprocess;
  43871. private _blurPostProcesses;
  43872. private _mapSize;
  43873. private _currentFaceIndex;
  43874. private _currentFaceIndexCache;
  43875. private _textureType;
  43876. private _defaultTextureMatrix;
  43877. /**
  43878. * Creates a ShadowGenerator object.
  43879. * A ShadowGenerator is the required tool to use the shadows.
  43880. * Each light casting shadows needs to use its own ShadowGenerator.
  43881. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  43882. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  43883. * @param light The light object generating the shadows.
  43884. * @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.
  43885. */
  43886. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  43887. private _initializeGenerator;
  43888. private _initializeShadowMap;
  43889. private _initializeBlurRTTAndPostProcesses;
  43890. private _renderForShadowMap;
  43891. private _renderSubMeshForShadowMap;
  43892. private _applyFilterValues;
  43893. /**
  43894. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43895. * @param onCompiled Callback triggered at the and of the effects compilation
  43896. * @param options Sets of optional options forcing the compilation with different modes
  43897. */
  43898. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  43899. useInstances: boolean;
  43900. }>): void;
  43901. /**
  43902. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  43903. * @param options Sets of optional options forcing the compilation with different modes
  43904. * @returns A promise that resolves when the compilation completes
  43905. */
  43906. forceCompilationAsync(options?: Partial<{
  43907. useInstances: boolean;
  43908. }>): Promise<void>;
  43909. /**
  43910. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  43911. * @param subMesh The submesh we want to render in the shadow map
  43912. * @param useInstances Defines wether will draw in the map using instances
  43913. * @returns true if ready otherwise, false
  43914. */
  43915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43916. /**
  43917. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  43918. * @param defines Defines of the material we want to update
  43919. * @param lightIndex Index of the light in the enabled light list of the material
  43920. */
  43921. prepareDefines(defines: any, lightIndex: number): void;
  43922. /**
  43923. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  43924. * defined in the generator but impacting the effect).
  43925. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  43926. * @param effect The effect we are binfing the information for
  43927. */
  43928. bindShadowLight(lightIndex: string, effect: Effect): void;
  43929. /**
  43930. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  43931. * (eq to shadow prjection matrix * light transform matrix)
  43932. * @returns The transform matrix used to create the shadow map
  43933. */
  43934. getTransformMatrix(): Matrix;
  43935. /**
  43936. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  43937. * Cube and 2D textures for instance.
  43938. */
  43939. recreateShadowMap(): void;
  43940. private _disposeBlurPostProcesses;
  43941. private _disposeRTTandPostProcesses;
  43942. /**
  43943. * Disposes the ShadowGenerator.
  43944. * Returns nothing.
  43945. */
  43946. dispose(): void;
  43947. /**
  43948. * Serializes the shadow generator setup to a json object.
  43949. * @returns The serialized JSON object
  43950. */
  43951. serialize(): any;
  43952. /**
  43953. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  43954. * @param parsedShadowGenerator The JSON object to parse
  43955. * @param scene The scene to create the shadow map for
  43956. * @returns The parsed shadow generator
  43957. */
  43958. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  43959. }
  43960. }
  43961. declare module BABYLON {
  43962. /**
  43963. * Defines the shadow generator component responsible to manage any shadow generators
  43964. * in a given scene.
  43965. */
  43966. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  43967. /**
  43968. * The component name helpfull to identify the component in the list of scene components.
  43969. */
  43970. readonly name: string;
  43971. /**
  43972. * The scene the component belongs to.
  43973. */
  43974. scene: Scene;
  43975. /**
  43976. * Creates a new instance of the component for the given scene
  43977. * @param scene Defines the scene to register the component in
  43978. */
  43979. constructor(scene: Scene);
  43980. /**
  43981. * Registers the component in a given scene
  43982. */
  43983. register(): void;
  43984. /**
  43985. * Rebuilds the elements related to this component in case of
  43986. * context lost for instance.
  43987. */
  43988. rebuild(): void;
  43989. /**
  43990. * Serializes the component data to the specified json object
  43991. * @param serializationObject The object to serialize to
  43992. */
  43993. serialize(serializationObject: any): void;
  43994. /**
  43995. * Adds all the element from the container to the scene
  43996. * @param container the container holding the elements
  43997. */
  43998. addFromContainer(container: AbstractScene): void;
  43999. /**
  44000. * Removes all the elements in the container from the scene
  44001. * @param container contains the elements to remove
  44002. */
  44003. removeFromContainer(container: AbstractScene): void;
  44004. /**
  44005. * Rebuilds the elements related to this component in case of
  44006. * context lost for instance.
  44007. */
  44008. dispose(): void;
  44009. private _gatherRenderTargets;
  44010. }
  44011. }
  44012. declare module BABYLON {
  44013. }
  44014. declare module BABYLON {
  44015. /**
  44016. * Background material used to create an efficient environement around your scene.
  44017. */
  44018. class BackgroundMaterial extends PushMaterial {
  44019. /**
  44020. * Standard reflectance value at parallel view angle.
  44021. */
  44022. static StandardReflectance0: number;
  44023. /**
  44024. * Standard reflectance value at grazing angle.
  44025. */
  44026. static StandardReflectance90: number;
  44027. protected _primaryColor: Color3;
  44028. /**
  44029. * Key light Color (multiply against the environement texture)
  44030. */
  44031. primaryColor: Color3;
  44032. protected __perceptualColor: Nullable<Color3>;
  44033. /**
  44034. * Experimental Internal Use Only.
  44035. *
  44036. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44037. * This acts as a helper to set the primary color to a more "human friendly" value.
  44038. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44039. * output color as close as possible from the chosen value.
  44040. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44041. * part of lighting setup.)
  44042. */
  44043. _perceptualColor: Nullable<Color3>;
  44044. protected _primaryColorShadowLevel: float;
  44045. /**
  44046. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44047. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44048. */
  44049. primaryColorShadowLevel: float;
  44050. protected _primaryColorHighlightLevel: float;
  44051. /**
  44052. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44053. * The primary color is used at the level chosen to define what the white area would look.
  44054. */
  44055. primaryColorHighlightLevel: float;
  44056. protected _reflectionTexture: Nullable<BaseTexture>;
  44057. /**
  44058. * Reflection Texture used in the material.
  44059. * Should be author in a specific way for the best result (refer to the documentation).
  44060. */
  44061. reflectionTexture: Nullable<BaseTexture>;
  44062. protected _reflectionBlur: float;
  44063. /**
  44064. * Reflection Texture level of blur.
  44065. *
  44066. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44067. * texture twice.
  44068. */
  44069. reflectionBlur: float;
  44070. protected _diffuseTexture: Nullable<BaseTexture>;
  44071. /**
  44072. * Diffuse Texture used in the material.
  44073. * Should be author in a specific way for the best result (refer to the documentation).
  44074. */
  44075. diffuseTexture: Nullable<BaseTexture>;
  44076. protected _shadowLights: Nullable<IShadowLight[]>;
  44077. /**
  44078. * Specify the list of lights casting shadow on the material.
  44079. * All scene shadow lights will be included if null.
  44080. */
  44081. shadowLights: Nullable<IShadowLight[]>;
  44082. protected _shadowLevel: float;
  44083. /**
  44084. * Helps adjusting the shadow to a softer level if required.
  44085. * 0 means black shadows and 1 means no shadows.
  44086. */
  44087. shadowLevel: float;
  44088. protected _sceneCenter: Vector3;
  44089. /**
  44090. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44091. * It is usually zero but might be interesting to modify according to your setup.
  44092. */
  44093. sceneCenter: Vector3;
  44094. protected _opacityFresnel: boolean;
  44095. /**
  44096. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44097. * This helps ensuring a nice transition when the camera goes under the ground.
  44098. */
  44099. opacityFresnel: boolean;
  44100. protected _reflectionFresnel: boolean;
  44101. /**
  44102. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44103. * This helps adding a mirror texture on the ground.
  44104. */
  44105. reflectionFresnel: boolean;
  44106. protected _reflectionFalloffDistance: number;
  44107. /**
  44108. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44109. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44110. */
  44111. reflectionFalloffDistance: number;
  44112. protected _reflectionAmount: number;
  44113. /**
  44114. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44115. */
  44116. reflectionAmount: number;
  44117. protected _reflectionReflectance0: number;
  44118. /**
  44119. * This specifies the weight of the reflection at grazing angle.
  44120. */
  44121. reflectionReflectance0: number;
  44122. protected _reflectionReflectance90: number;
  44123. /**
  44124. * This specifies the weight of the reflection at a perpendicular point of view.
  44125. */
  44126. reflectionReflectance90: number;
  44127. /**
  44128. * Sets the reflection reflectance fresnel values according to the default standard
  44129. * empirically know to work well :-)
  44130. */
  44131. reflectionStandardFresnelWeight: number;
  44132. protected _useRGBColor: boolean;
  44133. /**
  44134. * Helps to directly use the maps channels instead of their level.
  44135. */
  44136. useRGBColor: boolean;
  44137. protected _enableNoise: boolean;
  44138. /**
  44139. * This helps reducing the banding effect that could occur on the background.
  44140. */
  44141. enableNoise: boolean;
  44142. /**
  44143. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44144. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44145. * Recommended to be keep at 1.0 except for special cases.
  44146. */
  44147. fovMultiplier: number;
  44148. private _fovMultiplier;
  44149. /**
  44150. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44151. */
  44152. useEquirectangularFOV: boolean;
  44153. private _maxSimultaneousLights;
  44154. /**
  44155. * Number of Simultaneous lights allowed on the material.
  44156. */
  44157. maxSimultaneousLights: int;
  44158. /**
  44159. * Default configuration related to image processing available in the Background Material.
  44160. */
  44161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44162. /**
  44163. * Keep track of the image processing observer to allow dispose and replace.
  44164. */
  44165. private _imageProcessingObserver;
  44166. /**
  44167. * Attaches a new image processing configuration to the PBR Material.
  44168. * @param configuration (if null the scene configuration will be use)
  44169. */
  44170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44171. /**
  44172. * Gets the image processing configuration used either in this material.
  44173. */
  44174. /**
  44175. * Sets the Default image processing configuration used either in the this material.
  44176. *
  44177. * If sets to null, the scene one is in use.
  44178. */
  44179. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44180. /**
  44181. * Gets wether the color curves effect is enabled.
  44182. */
  44183. /**
  44184. * Sets wether the color curves effect is enabled.
  44185. */
  44186. cameraColorCurvesEnabled: boolean;
  44187. /**
  44188. * Gets wether the color grading effect is enabled.
  44189. */
  44190. /**
  44191. * Gets wether the color grading effect is enabled.
  44192. */
  44193. cameraColorGradingEnabled: boolean;
  44194. /**
  44195. * Gets wether tonemapping is enabled or not.
  44196. */
  44197. /**
  44198. * Sets wether tonemapping is enabled or not
  44199. */
  44200. cameraToneMappingEnabled: boolean;
  44201. /**
  44202. * The camera exposure used on this material.
  44203. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44204. * This corresponds to a photographic exposure.
  44205. */
  44206. /**
  44207. * The camera exposure used on this material.
  44208. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44209. * This corresponds to a photographic exposure.
  44210. */
  44211. cameraExposure: float;
  44212. /**
  44213. * Gets The camera contrast used on this material.
  44214. */
  44215. /**
  44216. * Sets The camera contrast used on this material.
  44217. */
  44218. cameraContrast: float;
  44219. /**
  44220. * Gets the Color Grading 2D Lookup Texture.
  44221. */
  44222. /**
  44223. * Sets the Color Grading 2D Lookup Texture.
  44224. */
  44225. cameraColorGradingTexture: Nullable<BaseTexture>;
  44226. /**
  44227. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44228. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44229. * 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;
  44230. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44231. */
  44232. /**
  44233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44235. * 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;
  44236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44237. */
  44238. cameraColorCurves: Nullable<ColorCurves>;
  44239. /**
  44240. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44241. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44242. */
  44243. switchToBGR: boolean;
  44244. private _renderTargets;
  44245. private _reflectionControls;
  44246. private _white;
  44247. private _primaryShadowColor;
  44248. private _primaryHighlightColor;
  44249. /**
  44250. * Instantiates a Background Material in the given scene
  44251. * @param name The friendly name of the material
  44252. * @param scene The scene to add the material to
  44253. */
  44254. constructor(name: string, scene: Scene);
  44255. /**
  44256. * Gets a boolean indicating that current material needs to register RTT
  44257. */
  44258. readonly hasRenderTargetTextures: boolean;
  44259. /**
  44260. * The entire material has been created in order to prevent overdraw.
  44261. * @returns false
  44262. */
  44263. needAlphaTesting(): boolean;
  44264. /**
  44265. * The entire material has been created in order to prevent overdraw.
  44266. * @returns true if blending is enable
  44267. */
  44268. needAlphaBlending(): boolean;
  44269. /**
  44270. * Checks wether the material is ready to be rendered for a given mesh.
  44271. * @param mesh The mesh to render
  44272. * @param subMesh The submesh to check against
  44273. * @param useInstances Specify wether or not the material is used with instances
  44274. * @returns true if all the dependencies are ready (Textures, Effects...)
  44275. */
  44276. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44277. /**
  44278. * Compute the primary color according to the chosen perceptual color.
  44279. */
  44280. private _computePrimaryColorFromPerceptualColor;
  44281. /**
  44282. * Compute the highlights and shadow colors according to their chosen levels.
  44283. */
  44284. private _computePrimaryColors;
  44285. /**
  44286. * Build the uniform buffer used in the material.
  44287. */
  44288. buildUniformLayout(): void;
  44289. /**
  44290. * Unbind the material.
  44291. */
  44292. unbind(): void;
  44293. /**
  44294. * Bind only the world matrix to the material.
  44295. * @param world The world matrix to bind.
  44296. */
  44297. bindOnlyWorldMatrix(world: Matrix): void;
  44298. /**
  44299. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44300. * @param world The world matrix to bind.
  44301. * @param subMesh The submesh to bind for.
  44302. */
  44303. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44304. /**
  44305. * Dispose the material.
  44306. * @param forceDisposeEffect Force disposal of the associated effect.
  44307. * @param forceDisposeTextures Force disposal of the associated textures.
  44308. */
  44309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44310. /**
  44311. * Clones the material.
  44312. * @param name The cloned name.
  44313. * @returns The cloned material.
  44314. */
  44315. clone(name: string): BackgroundMaterial;
  44316. /**
  44317. * Serializes the current material to its JSON representation.
  44318. * @returns The JSON representation.
  44319. */
  44320. serialize(): any;
  44321. /**
  44322. * Gets the class name of the material
  44323. * @returns "BackgroundMaterial"
  44324. */
  44325. getClassName(): string;
  44326. /**
  44327. * Parse a JSON input to create back a background material.
  44328. * @param source The JSON data to parse
  44329. * @param scene The scene to create the parsed material in
  44330. * @param rootUrl The root url of the assets the material depends upon
  44331. * @returns the instantiated BackgroundMaterial.
  44332. */
  44333. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /**
  44338. * The Physically based material base class of BJS.
  44339. *
  44340. * This offers the main features of a standard PBR material.
  44341. * For more information, please refer to the documentation :
  44342. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44343. */
  44344. abstract class PBRBaseMaterial extends PushMaterial {
  44345. /**
  44346. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44347. */
  44348. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44349. /**
  44350. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44351. * to enhance interoperability with other engines.
  44352. */
  44353. static readonly LIGHTFALLOFF_GLTF: number;
  44354. /**
  44355. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44356. * to enhance interoperability with other materials.
  44357. */
  44358. static readonly LIGHTFALLOFF_STANDARD: number;
  44359. /**
  44360. * Intensity of the direct lights e.g. the four lights available in your scene.
  44361. * This impacts both the direct diffuse and specular highlights.
  44362. */
  44363. protected _directIntensity: number;
  44364. /**
  44365. * Intensity of the emissive part of the material.
  44366. * This helps controlling the emissive effect without modifying the emissive color.
  44367. */
  44368. protected _emissiveIntensity: number;
  44369. /**
  44370. * Intensity of the environment e.g. how much the environment will light the object
  44371. * either through harmonics for rough material or through the refelction for shiny ones.
  44372. */
  44373. protected _environmentIntensity: number;
  44374. /**
  44375. * This is a special control allowing the reduction of the specular highlights coming from the
  44376. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44377. */
  44378. protected _specularIntensity: number;
  44379. /**
  44380. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44381. */
  44382. private _lightingInfos;
  44383. /**
  44384. * Debug Control allowing disabling the bump map on this material.
  44385. */
  44386. protected _disableBumpMap: boolean;
  44387. /**
  44388. * AKA Diffuse Texture in standard nomenclature.
  44389. */
  44390. protected _albedoTexture: BaseTexture;
  44391. /**
  44392. * AKA Occlusion Texture in other nomenclature.
  44393. */
  44394. protected _ambientTexture: BaseTexture;
  44395. /**
  44396. * AKA Occlusion Texture Intensity in other nomenclature.
  44397. */
  44398. protected _ambientTextureStrength: number;
  44399. /**
  44400. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44401. * 1 means it completely occludes it
  44402. * 0 mean it has no impact
  44403. */
  44404. protected _ambientTextureImpactOnAnalyticalLights: number;
  44405. /**
  44406. * Stores the alpha values in a texture.
  44407. */
  44408. protected _opacityTexture: BaseTexture;
  44409. /**
  44410. * Stores the reflection values in a texture.
  44411. */
  44412. protected _reflectionTexture: BaseTexture;
  44413. /**
  44414. * Stores the refraction values in a texture.
  44415. */
  44416. protected _refractionTexture: BaseTexture;
  44417. /**
  44418. * Stores the emissive values in a texture.
  44419. */
  44420. protected _emissiveTexture: BaseTexture;
  44421. /**
  44422. * AKA Specular texture in other nomenclature.
  44423. */
  44424. protected _reflectivityTexture: BaseTexture;
  44425. /**
  44426. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44427. */
  44428. protected _metallicTexture: BaseTexture;
  44429. /**
  44430. * Specifies the metallic scalar of the metallic/roughness workflow.
  44431. * Can also be used to scale the metalness values of the metallic texture.
  44432. */
  44433. protected _metallic: Nullable<number>;
  44434. /**
  44435. * Specifies the roughness scalar of the metallic/roughness workflow.
  44436. * Can also be used to scale the roughness values of the metallic texture.
  44437. */
  44438. protected _roughness: Nullable<number>;
  44439. /**
  44440. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44441. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44442. */
  44443. protected _microSurfaceTexture: BaseTexture;
  44444. /**
  44445. * Stores surface normal data used to displace a mesh in a texture.
  44446. */
  44447. protected _bumpTexture: BaseTexture;
  44448. /**
  44449. * Stores the pre-calculated light information of a mesh in a texture.
  44450. */
  44451. protected _lightmapTexture: BaseTexture;
  44452. /**
  44453. * The color of a material in ambient lighting.
  44454. */
  44455. protected _ambientColor: Color3;
  44456. /**
  44457. * AKA Diffuse Color in other nomenclature.
  44458. */
  44459. protected _albedoColor: Color3;
  44460. /**
  44461. * AKA Specular Color in other nomenclature.
  44462. */
  44463. protected _reflectivityColor: Color3;
  44464. /**
  44465. * The color applied when light is reflected from a material.
  44466. */
  44467. protected _reflectionColor: Color3;
  44468. /**
  44469. * The color applied when light is emitted from a material.
  44470. */
  44471. protected _emissiveColor: Color3;
  44472. /**
  44473. * AKA Glossiness in other nomenclature.
  44474. */
  44475. protected _microSurface: number;
  44476. /**
  44477. * source material index of refraction (IOR)' / 'destination material IOR.
  44478. */
  44479. protected _indexOfRefraction: number;
  44480. /**
  44481. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  44482. */
  44483. protected _invertRefractionY: boolean;
  44484. /**
  44485. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44486. * Materials half opaque for instance using refraction could benefit from this control.
  44487. */
  44488. protected _linkRefractionWithTransparency: boolean;
  44489. /**
  44490. * Specifies that the material will use the light map as a show map.
  44491. */
  44492. protected _useLightmapAsShadowmap: boolean;
  44493. /**
  44494. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44495. * makes the reflect vector face the model (under horizon).
  44496. */
  44497. protected _useHorizonOcclusion: boolean;
  44498. /**
  44499. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44500. * too much the area relying on ambient texture to define their ambient occlusion.
  44501. */
  44502. protected _useRadianceOcclusion: boolean;
  44503. /**
  44504. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44505. */
  44506. protected _useAlphaFromAlbedoTexture: boolean;
  44507. /**
  44508. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44509. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44510. */
  44511. protected _useSpecularOverAlpha: boolean;
  44512. /**
  44513. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44514. */
  44515. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44516. /**
  44517. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44518. */
  44519. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44520. /**
  44521. * Specifies if the metallic texture contains the roughness information in its green channel.
  44522. */
  44523. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44524. /**
  44525. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44526. */
  44527. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44528. /**
  44529. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44530. */
  44531. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44532. /**
  44533. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44534. */
  44535. protected _useAmbientInGrayScale: boolean;
  44536. /**
  44537. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44538. * The material will try to infer what glossiness each pixel should be.
  44539. */
  44540. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44541. /**
  44542. * Defines the falloff type used in this material.
  44543. * It by default is Physical.
  44544. */
  44545. protected _lightFalloff: number;
  44546. /**
  44547. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44548. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44549. */
  44550. protected _useRadianceOverAlpha: boolean;
  44551. /**
  44552. * Allows using an object space normal map (instead of tangent space).
  44553. */
  44554. protected _useObjectSpaceNormalMap: boolean;
  44555. /**
  44556. * Allows using the bump map in parallax mode.
  44557. */
  44558. protected _useParallax: boolean;
  44559. /**
  44560. * Allows using the bump map in parallax occlusion mode.
  44561. */
  44562. protected _useParallaxOcclusion: boolean;
  44563. /**
  44564. * Controls the scale bias of the parallax mode.
  44565. */
  44566. protected _parallaxScaleBias: number;
  44567. /**
  44568. * If sets to true, disables all the lights affecting the material.
  44569. */
  44570. protected _disableLighting: boolean;
  44571. /**
  44572. * Number of Simultaneous lights allowed on the material.
  44573. */
  44574. protected _maxSimultaneousLights: number;
  44575. /**
  44576. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44577. */
  44578. protected _invertNormalMapX: boolean;
  44579. /**
  44580. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44581. */
  44582. protected _invertNormalMapY: boolean;
  44583. /**
  44584. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44585. */
  44586. protected _twoSidedLighting: boolean;
  44587. /**
  44588. * Defines the alpha limits in alpha test mode.
  44589. */
  44590. protected _alphaCutOff: number;
  44591. /**
  44592. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44593. */
  44594. protected _forceAlphaTest: boolean;
  44595. /**
  44596. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44597. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44598. */
  44599. protected _useAlphaFresnel: boolean;
  44600. /**
  44601. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44602. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44603. */
  44604. protected _useLinearAlphaFresnel: boolean;
  44605. /**
  44606. * The transparency mode of the material.
  44607. */
  44608. protected _transparencyMode: Nullable<number>;
  44609. /**
  44610. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44611. * from cos thetav and roughness:
  44612. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44613. */
  44614. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44615. /**
  44616. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44617. */
  44618. protected _forceIrradianceInFragment: boolean;
  44619. /**
  44620. * Force normal to face away from face.
  44621. */
  44622. protected _forceNormalForward: boolean;
  44623. /**
  44624. * Enables specular anti aliasing in the PBR shader.
  44625. * It will both interacts on the Geometry for analytical and IBL lighting.
  44626. * It also prefilter the roughness map based on the bump values.
  44627. */
  44628. protected _enableSpecularAntiAliasing: boolean;
  44629. /**
  44630. * Default configuration related to image processing available in the PBR Material.
  44631. */
  44632. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44633. /**
  44634. * Keep track of the image processing observer to allow dispose and replace.
  44635. */
  44636. private _imageProcessingObserver;
  44637. /**
  44638. * Attaches a new image processing configuration to the PBR Material.
  44639. * @param configuration
  44640. */
  44641. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44642. /**
  44643. * Stores the available render targets.
  44644. */
  44645. private _renderTargets;
  44646. /**
  44647. * Sets the global ambient color for the material used in lighting calculations.
  44648. */
  44649. private _globalAmbientColor;
  44650. /**
  44651. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44652. */
  44653. private _useLogarithmicDepth;
  44654. /**
  44655. * If set to true, no lighting calculations will be applied.
  44656. */
  44657. private _unlit;
  44658. /**
  44659. * Instantiates a new PBRMaterial instance.
  44660. *
  44661. * @param name The material name
  44662. * @param scene The scene the material will be use in.
  44663. */
  44664. constructor(name: string, scene: Scene);
  44665. /**
  44666. * Gets a boolean indicating that current material needs to register RTT
  44667. */
  44668. readonly hasRenderTargetTextures: boolean;
  44669. /**
  44670. * Gets the name of the material class.
  44671. */
  44672. getClassName(): string;
  44673. /**
  44674. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44675. */
  44676. /**
  44677. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44678. */
  44679. useLogarithmicDepth: boolean;
  44680. /**
  44681. * Gets the current transparency mode.
  44682. */
  44683. /**
  44684. * Sets the transparency mode of the material.
  44685. *
  44686. * | Value | Type | Description |
  44687. * | ----- | ----------------------------------- | ----------- |
  44688. * | 0 | OPAQUE | |
  44689. * | 1 | ALPHATEST | |
  44690. * | 2 | ALPHABLEND | |
  44691. * | 3 | ALPHATESTANDBLEND | |
  44692. *
  44693. */
  44694. transparencyMode: Nullable<number>;
  44695. /**
  44696. * Returns true if alpha blending should be disabled.
  44697. */
  44698. private readonly _disableAlphaBlending;
  44699. /**
  44700. * Specifies whether or not this material should be rendered in alpha blend mode.
  44701. */
  44702. needAlphaBlending(): boolean;
  44703. /**
  44704. * Specifies if the mesh will require alpha blending.
  44705. * @param mesh - BJS mesh.
  44706. */
  44707. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44708. /**
  44709. * Specifies whether or not this material should be rendered in alpha test mode.
  44710. */
  44711. needAlphaTesting(): boolean;
  44712. /**
  44713. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44714. */
  44715. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44716. /**
  44717. * Gets the texture used for the alpha test.
  44718. */
  44719. getAlphaTestTexture(): BaseTexture;
  44720. /**
  44721. * Stores the reflectivity values based on metallic roughness workflow.
  44722. */
  44723. private static _scaledReflectivity;
  44724. /**
  44725. * Specifies that the submesh is ready to be used.
  44726. * @param mesh - BJS mesh.
  44727. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44728. * @param useInstances - Specifies that instances should be used.
  44729. * @returns - boolean indicating that the submesh is ready or not.
  44730. */
  44731. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44732. /**
  44733. * Specifies if the material uses metallic roughness workflow.
  44734. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44735. */
  44736. isMetallicWorkflow(): boolean;
  44737. private _prepareEffect;
  44738. private _prepareDefines;
  44739. /**
  44740. * Force shader compilation
  44741. */
  44742. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44743. clipPlane: boolean;
  44744. }>): void;
  44745. /**
  44746. * Initializes the uniform buffer layout for the shader.
  44747. */
  44748. buildUniformLayout(): void;
  44749. /**
  44750. * Unbinds the textures.
  44751. */
  44752. unbind(): void;
  44753. /**
  44754. * Binds the submesh data.
  44755. * @param world - The world matrix.
  44756. * @param mesh - The BJS mesh.
  44757. * @param subMesh - A submesh of the BJS mesh.
  44758. */
  44759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44760. /**
  44761. * Returns the animatable textures.
  44762. * @returns - Array of animatable textures.
  44763. */
  44764. getAnimatables(): IAnimatable[];
  44765. /**
  44766. * Returns the texture used for reflections.
  44767. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44768. */
  44769. private _getReflectionTexture;
  44770. /**
  44771. * Returns the texture used for refraction or null if none is used.
  44772. * @returns - Refection texture if present. If no refraction texture and refraction
  44773. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44774. */
  44775. private _getRefractionTexture;
  44776. /**
  44777. * Disposes the resources of the material.
  44778. * @param forceDisposeEffect - Forces the disposal of effects.
  44779. * @param forceDisposeTextures - Forces the disposal of all textures.
  44780. */
  44781. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44782. }
  44783. }
  44784. declare module BABYLON {
  44785. /**
  44786. * The Physically based simple base material of BJS.
  44787. *
  44788. * This enables better naming and convention enforcements on top of the pbrMaterial.
  44789. * It is used as the base class for both the specGloss and metalRough conventions.
  44790. */
  44791. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  44792. /**
  44793. * Number of Simultaneous lights allowed on the material.
  44794. */
  44795. maxSimultaneousLights: number;
  44796. /**
  44797. * If sets to true, disables all the lights affecting the material.
  44798. */
  44799. disableLighting: boolean;
  44800. /**
  44801. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  44802. */
  44803. environmentTexture: BaseTexture;
  44804. /**
  44805. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44806. */
  44807. invertNormalMapX: boolean;
  44808. /**
  44809. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44810. */
  44811. invertNormalMapY: boolean;
  44812. /**
  44813. * Normal map used in the model.
  44814. */
  44815. normalTexture: BaseTexture;
  44816. /**
  44817. * Emissivie color used to self-illuminate the model.
  44818. */
  44819. emissiveColor: Color3;
  44820. /**
  44821. * Emissivie texture used to self-illuminate the model.
  44822. */
  44823. emissiveTexture: BaseTexture;
  44824. /**
  44825. * Occlusion Channel Strenght.
  44826. */
  44827. occlusionStrength: number;
  44828. /**
  44829. * Occlusion Texture of the material (adding extra occlusion effects).
  44830. */
  44831. occlusionTexture: BaseTexture;
  44832. /**
  44833. * Defines the alpha limits in alpha test mode.
  44834. */
  44835. alphaCutOff: number;
  44836. /**
  44837. * Gets the current double sided mode.
  44838. */
  44839. /**
  44840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44841. */
  44842. doubleSided: boolean;
  44843. /**
  44844. * Stores the pre-calculated light information of a mesh in a texture.
  44845. */
  44846. lightmapTexture: BaseTexture;
  44847. /**
  44848. * If true, the light map contains occlusion information instead of lighting info.
  44849. */
  44850. useLightmapAsShadowmap: boolean;
  44851. /**
  44852. * Return the active textures of the material.
  44853. */
  44854. getActiveTextures(): BaseTexture[];
  44855. hasTexture(texture: BaseTexture): boolean;
  44856. /**
  44857. * Instantiates a new PBRMaterial instance.
  44858. *
  44859. * @param name The material name
  44860. * @param scene The scene the material will be use in.
  44861. */
  44862. constructor(name: string, scene: Scene);
  44863. getClassName(): string;
  44864. }
  44865. }
  44866. declare module BABYLON {
  44867. /**
  44868. * The Physically based material of BJS.
  44869. *
  44870. * This offers the main features of a standard PBR material.
  44871. * For more information, please refer to the documentation :
  44872. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44873. */
  44874. class PBRMaterial extends PBRBaseMaterial {
  44875. /**
  44876. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44877. */
  44878. static readonly PBRMATERIAL_OPAQUE: number;
  44879. /**
  44880. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44881. */
  44882. static readonly PBRMATERIAL_ALPHATEST: number;
  44883. /**
  44884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44885. */
  44886. static readonly PBRMATERIAL_ALPHABLEND: number;
  44887. /**
  44888. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44889. * They are also discarded below the alpha cutoff threshold to improve performances.
  44890. */
  44891. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44892. /**
  44893. * Defines the default value of how much AO map is occluding the analytical lights
  44894. * (point spot...).
  44895. */
  44896. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44897. /**
  44898. * Intensity of the direct lights e.g. the four lights available in your scene.
  44899. * This impacts both the direct diffuse and specular highlights.
  44900. */
  44901. directIntensity: number;
  44902. /**
  44903. * Intensity of the emissive part of the material.
  44904. * This helps controlling the emissive effect without modifying the emissive color.
  44905. */
  44906. emissiveIntensity: number;
  44907. /**
  44908. * Intensity of the environment e.g. how much the environment will light the object
  44909. * either through harmonics for rough material or through the refelction for shiny ones.
  44910. */
  44911. environmentIntensity: number;
  44912. /**
  44913. * This is a special control allowing the reduction of the specular highlights coming from the
  44914. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44915. */
  44916. specularIntensity: number;
  44917. /**
  44918. * Debug Control allowing disabling the bump map on this material.
  44919. */
  44920. disableBumpMap: boolean;
  44921. /**
  44922. * AKA Diffuse Texture in standard nomenclature.
  44923. */
  44924. albedoTexture: BaseTexture;
  44925. /**
  44926. * AKA Occlusion Texture in other nomenclature.
  44927. */
  44928. ambientTexture: BaseTexture;
  44929. /**
  44930. * AKA Occlusion Texture Intensity in other nomenclature.
  44931. */
  44932. ambientTextureStrength: number;
  44933. /**
  44934. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44935. * 1 means it completely occludes it
  44936. * 0 mean it has no impact
  44937. */
  44938. ambientTextureImpactOnAnalyticalLights: number;
  44939. /**
  44940. * Stores the alpha values in a texture.
  44941. */
  44942. opacityTexture: BaseTexture;
  44943. /**
  44944. * Stores the reflection values in a texture.
  44945. */
  44946. reflectionTexture: Nullable<BaseTexture>;
  44947. /**
  44948. * Stores the emissive values in a texture.
  44949. */
  44950. emissiveTexture: BaseTexture;
  44951. /**
  44952. * AKA Specular texture in other nomenclature.
  44953. */
  44954. reflectivityTexture: BaseTexture;
  44955. /**
  44956. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44957. */
  44958. metallicTexture: BaseTexture;
  44959. /**
  44960. * Specifies the metallic scalar of the metallic/roughness workflow.
  44961. * Can also be used to scale the metalness values of the metallic texture.
  44962. */
  44963. metallic: Nullable<number>;
  44964. /**
  44965. * Specifies the roughness scalar of the metallic/roughness workflow.
  44966. * Can also be used to scale the roughness values of the metallic texture.
  44967. */
  44968. roughness: Nullable<number>;
  44969. /**
  44970. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44971. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44972. */
  44973. microSurfaceTexture: BaseTexture;
  44974. /**
  44975. * Stores surface normal data used to displace a mesh in a texture.
  44976. */
  44977. bumpTexture: BaseTexture;
  44978. /**
  44979. * Stores the pre-calculated light information of a mesh in a texture.
  44980. */
  44981. lightmapTexture: BaseTexture;
  44982. /**
  44983. * Stores the refracted light information in a texture.
  44984. */
  44985. refractionTexture: BaseTexture;
  44986. /**
  44987. * The color of a material in ambient lighting.
  44988. */
  44989. ambientColor: Color3;
  44990. /**
  44991. * AKA Diffuse Color in other nomenclature.
  44992. */
  44993. albedoColor: Color3;
  44994. /**
  44995. * AKA Specular Color in other nomenclature.
  44996. */
  44997. reflectivityColor: Color3;
  44998. /**
  44999. * The color reflected from the material.
  45000. */
  45001. reflectionColor: Color3;
  45002. /**
  45003. * The color emitted from the material.
  45004. */
  45005. emissiveColor: Color3;
  45006. /**
  45007. * AKA Glossiness in other nomenclature.
  45008. */
  45009. microSurface: number;
  45010. /**
  45011. * source material index of refraction (IOR)' / 'destination material IOR.
  45012. */
  45013. indexOfRefraction: number;
  45014. /**
  45015. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45016. */
  45017. invertRefractionY: boolean;
  45018. /**
  45019. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45020. * Materials half opaque for instance using refraction could benefit from this control.
  45021. */
  45022. linkRefractionWithTransparency: boolean;
  45023. /**
  45024. * If true, the light map contains occlusion information instead of lighting info.
  45025. */
  45026. useLightmapAsShadowmap: boolean;
  45027. /**
  45028. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45029. */
  45030. useAlphaFromAlbedoTexture: boolean;
  45031. /**
  45032. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45033. */
  45034. forceAlphaTest: boolean;
  45035. /**
  45036. * Defines the alpha limits in alpha test mode.
  45037. */
  45038. alphaCutOff: number;
  45039. /**
  45040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45042. */
  45043. useSpecularOverAlpha: boolean;
  45044. /**
  45045. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45046. */
  45047. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45048. /**
  45049. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45050. */
  45051. useRoughnessFromMetallicTextureAlpha: boolean;
  45052. /**
  45053. * Specifies if the metallic texture contains the roughness information in its green channel.
  45054. */
  45055. useRoughnessFromMetallicTextureGreen: boolean;
  45056. /**
  45057. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45058. */
  45059. useMetallnessFromMetallicTextureBlue: boolean;
  45060. /**
  45061. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45062. */
  45063. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45064. /**
  45065. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45066. */
  45067. useAmbientInGrayScale: boolean;
  45068. /**
  45069. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45070. * The material will try to infer what glossiness each pixel should be.
  45071. */
  45072. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45073. /**
  45074. * BJS is using an harcoded light falloff based on a manually sets up range.
  45075. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45076. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45077. */
  45078. /**
  45079. * BJS is using an harcoded light falloff based on a manually sets up range.
  45080. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45081. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45082. */
  45083. usePhysicalLightFalloff: boolean;
  45084. /**
  45085. * In order to support the falloff compatibility with gltf, a special mode has been added
  45086. * to reproduce the gltf light falloff.
  45087. */
  45088. /**
  45089. * In order to support the falloff compatibility with gltf, a special mode has been added
  45090. * to reproduce the gltf light falloff.
  45091. */
  45092. useGLTFLightFalloff: boolean;
  45093. /**
  45094. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45095. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45096. */
  45097. useRadianceOverAlpha: boolean;
  45098. /**
  45099. * Allows using an object space normal map (instead of tangent space).
  45100. */
  45101. useObjectSpaceNormalMap: boolean;
  45102. /**
  45103. * Allows using the bump map in parallax mode.
  45104. */
  45105. useParallax: boolean;
  45106. /**
  45107. * Allows using the bump map in parallax occlusion mode.
  45108. */
  45109. useParallaxOcclusion: boolean;
  45110. /**
  45111. * Controls the scale bias of the parallax mode.
  45112. */
  45113. parallaxScaleBias: number;
  45114. /**
  45115. * If sets to true, disables all the lights affecting the material.
  45116. */
  45117. disableLighting: boolean;
  45118. /**
  45119. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45120. */
  45121. forceIrradianceInFragment: boolean;
  45122. /**
  45123. * Number of Simultaneous lights allowed on the material.
  45124. */
  45125. maxSimultaneousLights: number;
  45126. /**
  45127. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45128. */
  45129. invertNormalMapX: boolean;
  45130. /**
  45131. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45132. */
  45133. invertNormalMapY: boolean;
  45134. /**
  45135. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45136. */
  45137. twoSidedLighting: boolean;
  45138. /**
  45139. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45140. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45141. */
  45142. useAlphaFresnel: boolean;
  45143. /**
  45144. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45145. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45146. */
  45147. useLinearAlphaFresnel: boolean;
  45148. /**
  45149. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45150. * And/Or occlude the blended part.
  45151. */
  45152. environmentBRDFTexture: Nullable<BaseTexture>;
  45153. /**
  45154. * Force normal to face away from face.
  45155. */
  45156. forceNormalForward: boolean;
  45157. /**
  45158. * Enables specular anti aliasing in the PBR shader.
  45159. * It will both interacts on the Geometry for analytical and IBL lighting.
  45160. * It also prefilter the roughness map based on the bump values.
  45161. */
  45162. enableSpecularAntiAliasing: boolean;
  45163. /**
  45164. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45165. * makes the reflect vector face the model (under horizon).
  45166. */
  45167. useHorizonOcclusion: boolean;
  45168. /**
  45169. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45170. * too much the area relying on ambient texture to define their ambient occlusion.
  45171. */
  45172. useRadianceOcclusion: boolean;
  45173. /**
  45174. * If set to true, no lighting calculations will be applied.
  45175. */
  45176. unlit: boolean;
  45177. /**
  45178. * Gets the image processing configuration used either in this material.
  45179. */
  45180. /**
  45181. * Sets the Default image processing configuration used either in the this material.
  45182. *
  45183. * If sets to null, the scene one is in use.
  45184. */
  45185. imageProcessingConfiguration: ImageProcessingConfiguration;
  45186. /**
  45187. * Gets wether the color curves effect is enabled.
  45188. */
  45189. /**
  45190. * Sets wether the color curves effect is enabled.
  45191. */
  45192. cameraColorCurvesEnabled: boolean;
  45193. /**
  45194. * Gets wether the color grading effect is enabled.
  45195. */
  45196. /**
  45197. * Gets wether the color grading effect is enabled.
  45198. */
  45199. cameraColorGradingEnabled: boolean;
  45200. /**
  45201. * Gets wether tonemapping is enabled or not.
  45202. */
  45203. /**
  45204. * Sets wether tonemapping is enabled or not
  45205. */
  45206. cameraToneMappingEnabled: boolean;
  45207. /**
  45208. * The camera exposure used on this material.
  45209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45210. * This corresponds to a photographic exposure.
  45211. */
  45212. /**
  45213. * The camera exposure used on this material.
  45214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45215. * This corresponds to a photographic exposure.
  45216. */
  45217. cameraExposure: number;
  45218. /**
  45219. * Gets The camera contrast used on this material.
  45220. */
  45221. /**
  45222. * Sets The camera contrast used on this material.
  45223. */
  45224. cameraContrast: number;
  45225. /**
  45226. * Gets the Color Grading 2D Lookup Texture.
  45227. */
  45228. /**
  45229. * Sets the Color Grading 2D Lookup Texture.
  45230. */
  45231. cameraColorGradingTexture: Nullable<BaseTexture>;
  45232. /**
  45233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45235. * 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;
  45236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45237. */
  45238. /**
  45239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45241. * 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;
  45242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45243. */
  45244. cameraColorCurves: Nullable<ColorCurves>;
  45245. /**
  45246. * Instantiates a new PBRMaterial instance.
  45247. *
  45248. * @param name The material name
  45249. * @param scene The scene the material will be use in.
  45250. */
  45251. constructor(name: string, scene: Scene);
  45252. /**
  45253. * Returns the name of this material class.
  45254. */
  45255. getClassName(): string;
  45256. /**
  45257. * Returns an array of the actively used textures.
  45258. * @returns - Array of BaseTextures
  45259. */
  45260. getActiveTextures(): BaseTexture[];
  45261. /**
  45262. * Checks to see if a texture is used in the material.
  45263. * @param texture - Base texture to use.
  45264. * @returns - Boolean specifying if a texture is used in the material.
  45265. */
  45266. hasTexture(texture: BaseTexture): boolean;
  45267. /**
  45268. * Makes a duplicate of the current material.
  45269. * @param name - name to use for the new material.
  45270. */
  45271. clone(name: string): PBRMaterial;
  45272. /**
  45273. * Serializes this PBR Material.
  45274. * @returns - An object with the serialized material.
  45275. */
  45276. serialize(): any;
  45277. /**
  45278. * Parses a PBR Material from a serialized object.
  45279. * @param source - Serialized object.
  45280. * @param scene - BJS scene instance.
  45281. * @param rootUrl - url for the scene object
  45282. * @returns - PBRMaterial
  45283. */
  45284. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45285. }
  45286. }
  45287. declare module BABYLON {
  45288. /**
  45289. * The PBR material of BJS following the metal roughness convention.
  45290. *
  45291. * This fits to the PBR convention in the GLTF definition:
  45292. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45293. */
  45294. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45295. /**
  45296. * The base color has two different interpretations depending on the value of metalness.
  45297. * When the material is a metal, the base color is the specific measured reflectance value
  45298. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45299. * of the material.
  45300. */
  45301. baseColor: Color3;
  45302. /**
  45303. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45304. * well as opacity information in the alpha channel.
  45305. */
  45306. baseTexture: BaseTexture;
  45307. /**
  45308. * Specifies the metallic scalar value of the material.
  45309. * Can also be used to scale the metalness values of the metallic texture.
  45310. */
  45311. metallic: number;
  45312. /**
  45313. * Specifies the roughness scalar value of the material.
  45314. * Can also be used to scale the roughness values of the metallic texture.
  45315. */
  45316. roughness: number;
  45317. /**
  45318. * Texture containing both the metallic value in the B channel and the
  45319. * roughness value in the G channel to keep better precision.
  45320. */
  45321. metallicRoughnessTexture: BaseTexture;
  45322. /**
  45323. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45324. *
  45325. * @param name The material name
  45326. * @param scene The scene the material will be use in.
  45327. */
  45328. constructor(name: string, scene: Scene);
  45329. /**
  45330. * Return the currrent class name of the material.
  45331. */
  45332. getClassName(): string;
  45333. /**
  45334. * Return the active textures of the material.
  45335. */
  45336. getActiveTextures(): BaseTexture[];
  45337. /**
  45338. * Checks to see if a texture is used in the material.
  45339. * @param texture - Base texture to use.
  45340. * @returns - Boolean specifying if a texture is used in the material.
  45341. */
  45342. hasTexture(texture: BaseTexture): boolean;
  45343. /**
  45344. * Makes a duplicate of the current material.
  45345. * @param name - name to use for the new material.
  45346. */
  45347. clone(name: string): PBRMetallicRoughnessMaterial;
  45348. /**
  45349. * Serialize the material to a parsable JSON object.
  45350. */
  45351. serialize(): any;
  45352. /**
  45353. * Parses a JSON object correponding to the serialize function.
  45354. */
  45355. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45356. }
  45357. }
  45358. declare module BABYLON {
  45359. /**
  45360. * The PBR material of BJS following the specular glossiness convention.
  45361. *
  45362. * This fits to the PBR convention in the GLTF definition:
  45363. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45364. */
  45365. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45366. /**
  45367. * Specifies the diffuse color of the material.
  45368. */
  45369. diffuseColor: Color3;
  45370. /**
  45371. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45372. * channel.
  45373. */
  45374. diffuseTexture: BaseTexture;
  45375. /**
  45376. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45377. */
  45378. specularColor: Color3;
  45379. /**
  45380. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45381. */
  45382. glossiness: number;
  45383. /**
  45384. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45385. */
  45386. specularGlossinessTexture: BaseTexture;
  45387. /**
  45388. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45389. *
  45390. * @param name The material name
  45391. * @param scene The scene the material will be use in.
  45392. */
  45393. constructor(name: string, scene: Scene);
  45394. /**
  45395. * Return the currrent class name of the material.
  45396. */
  45397. getClassName(): string;
  45398. /**
  45399. * Return the active textures of the material.
  45400. */
  45401. getActiveTextures(): BaseTexture[];
  45402. /**
  45403. * Checks to see if a texture is used in the material.
  45404. * @param texture - Base texture to use.
  45405. * @returns - Boolean specifying if a texture is used in the material.
  45406. */
  45407. hasTexture(texture: BaseTexture): boolean;
  45408. /**
  45409. * Makes a duplicate of the current material.
  45410. * @param name - name to use for the new material.
  45411. */
  45412. clone(name: string): PBRSpecularGlossinessMaterial;
  45413. /**
  45414. * Serialize the material to a parsable JSON object.
  45415. */
  45416. serialize(): any;
  45417. /**
  45418. * Parses a JSON object correponding to the serialize function.
  45419. */
  45420. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45421. }
  45422. }
  45423. declare module BABYLON {
  45424. /**
  45425. * Base class of all the textures in babylon.
  45426. * It groups all the common properties the materials, post process, lights... might need
  45427. * in order to make a correct use of the texture.
  45428. */
  45429. class BaseTexture {
  45430. /**
  45431. * Default anisotropic filtering level for the application.
  45432. * It is set to 4 as a good tradeoff between perf and quality.
  45433. */
  45434. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  45435. /**
  45436. * Define the name of the texture.
  45437. */
  45438. name: string;
  45439. private _hasAlpha;
  45440. /**
  45441. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  45442. */
  45443. hasAlpha: boolean;
  45444. /**
  45445. * Defines if the alpha value should be determined via the rgb values.
  45446. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  45447. */
  45448. getAlphaFromRGB: boolean;
  45449. /**
  45450. * Intensity or strength of the texture.
  45451. * It is commonly used by materials to fine tune the intensity of the texture
  45452. */
  45453. level: number;
  45454. /**
  45455. * Define the UV chanel to use starting from 0 and defaulting to 0.
  45456. * This is part of the texture as textures usually maps to one uv set.
  45457. */
  45458. coordinatesIndex: number;
  45459. private _coordinatesMode;
  45460. /**
  45461. * How a texture is mapped.
  45462. *
  45463. * | Value | Type | Description |
  45464. * | ----- | ----------------------------------- | ----------- |
  45465. * | 0 | EXPLICIT_MODE | |
  45466. * | 1 | SPHERICAL_MODE | |
  45467. * | 2 | PLANAR_MODE | |
  45468. * | 3 | CUBIC_MODE | |
  45469. * | 4 | PROJECTION_MODE | |
  45470. * | 5 | SKYBOX_MODE | |
  45471. * | 6 | INVCUBIC_MODE | |
  45472. * | 7 | EQUIRECTANGULAR_MODE | |
  45473. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  45474. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  45475. */
  45476. coordinatesMode: number;
  45477. /**
  45478. * | Value | Type | Description |
  45479. * | ----- | ------------------ | ----------- |
  45480. * | 0 | CLAMP_ADDRESSMODE | |
  45481. * | 1 | WRAP_ADDRESSMODE | |
  45482. * | 2 | MIRROR_ADDRESSMODE | |
  45483. */
  45484. wrapU: number;
  45485. /**
  45486. * | Value | Type | Description |
  45487. * | ----- | ------------------ | ----------- |
  45488. * | 0 | CLAMP_ADDRESSMODE | |
  45489. * | 1 | WRAP_ADDRESSMODE | |
  45490. * | 2 | MIRROR_ADDRESSMODE | |
  45491. */
  45492. wrapV: number;
  45493. /**
  45494. * | Value | Type | Description |
  45495. * | ----- | ------------------ | ----------- |
  45496. * | 0 | CLAMP_ADDRESSMODE | |
  45497. * | 1 | WRAP_ADDRESSMODE | |
  45498. * | 2 | MIRROR_ADDRESSMODE | |
  45499. */
  45500. wrapR: number;
  45501. /**
  45502. * With compliant hardware and browser (supporting anisotropic filtering)
  45503. * this defines the level of anisotropic filtering in the texture.
  45504. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  45505. */
  45506. anisotropicFilteringLevel: number;
  45507. /**
  45508. * Define if the texture is a cube texture or if false a 2d texture.
  45509. */
  45510. isCube: boolean;
  45511. /**
  45512. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  45513. */
  45514. is3D: boolean;
  45515. /**
  45516. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  45517. * HDR texture are usually stored in linear space.
  45518. * This only impacts the PBR and Background materials
  45519. */
  45520. gammaSpace: boolean;
  45521. /**
  45522. * Gets whether or not the texture contains RGBD data.
  45523. */
  45524. readonly isRGBD: boolean;
  45525. /**
  45526. * Is Z inverted in the texture (useful in a cube texture).
  45527. */
  45528. invertZ: boolean;
  45529. /**
  45530. * @hidden
  45531. */
  45532. lodLevelInAlpha: boolean;
  45533. /**
  45534. * With prefiltered texture, defined the offset used during the prefiltering steps.
  45535. */
  45536. lodGenerationOffset: number;
  45537. /**
  45538. * With prefiltered texture, defined the scale used during the prefiltering steps.
  45539. */
  45540. lodGenerationScale: number;
  45541. /**
  45542. * Define if the texture is a render target.
  45543. */
  45544. isRenderTarget: boolean;
  45545. /**
  45546. * Define the unique id of the texture in the scene.
  45547. */
  45548. readonly uid: string;
  45549. /**
  45550. * Return a string representation of the texture.
  45551. * @returns the texture as a string
  45552. */
  45553. toString(): string;
  45554. /**
  45555. * Get the class name of the texture.
  45556. * @returns "BaseTexture"
  45557. */
  45558. getClassName(): string;
  45559. /**
  45560. * Define the list of animation attached to the texture.
  45561. */
  45562. animations: Animation[];
  45563. /**
  45564. * An event triggered when the texture is disposed.
  45565. */
  45566. onDisposeObservable: Observable<BaseTexture>;
  45567. private _onDisposeObserver;
  45568. /**
  45569. * Callback triggered when the texture has been disposed.
  45570. * Kept for back compatibility, you can use the onDisposeObservable instead.
  45571. */
  45572. onDispose: () => void;
  45573. /**
  45574. * Define the current state of the loading sequence when in delayed load mode.
  45575. */
  45576. delayLoadState: number;
  45577. private _scene;
  45578. /** @hidden */
  45579. _texture: Nullable<InternalTexture>;
  45580. private _uid;
  45581. /**
  45582. * Define if the texture is preventinga material to render or not.
  45583. * If not and the texture is not ready, the engine will use a default black texture instead.
  45584. */
  45585. readonly isBlocking: boolean;
  45586. /**
  45587. * Instantiates a new BaseTexture.
  45588. * Base class of all the textures in babylon.
  45589. * It groups all the common properties the materials, post process, lights... might need
  45590. * in order to make a correct use of the texture.
  45591. * @param scene Define the scene the texture blongs to
  45592. */
  45593. constructor(scene: Nullable<Scene>);
  45594. /**
  45595. * Get the scene the texture belongs to.
  45596. * @returns the scene or null if undefined
  45597. */
  45598. getScene(): Nullable<Scene>;
  45599. /**
  45600. * Get the texture transform matrix used to offset tile the texture for istance.
  45601. * @returns the transformation matrix
  45602. */
  45603. getTextureMatrix(): Matrix;
  45604. /**
  45605. * Get the texture reflection matrix used to rotate/transform the reflection.
  45606. * @returns the reflection matrix
  45607. */
  45608. getReflectionTextureMatrix(): Matrix;
  45609. /**
  45610. * Get the underlying lower level texture from Babylon.
  45611. * @returns the insternal texture
  45612. */
  45613. getInternalTexture(): Nullable<InternalTexture>;
  45614. /**
  45615. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  45616. * @returns true if ready or not blocking
  45617. */
  45618. isReadyOrNotBlocking(): boolean;
  45619. /**
  45620. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  45621. * @returns true if fully ready
  45622. */
  45623. isReady(): boolean;
  45624. private _cachedSize;
  45625. /**
  45626. * Get the size of the texture.
  45627. * @returns the texture size.
  45628. */
  45629. getSize(): ISize;
  45630. /**
  45631. * Get the base size of the texture.
  45632. * It can be different from the size if the texture has been resized for POT for instance
  45633. * @returns the base size
  45634. */
  45635. getBaseSize(): ISize;
  45636. /**
  45637. * Scales the texture if is `canRescale()`
  45638. * @param ratio the resize factor we want to use to rescale
  45639. */
  45640. scale(ratio: number): void;
  45641. /**
  45642. * Get if the texture can rescale.
  45643. */
  45644. readonly canRescale: boolean;
  45645. /** @hidden */
  45646. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  45647. /** @hidden */
  45648. _rebuild(): void;
  45649. /**
  45650. * Triggers the load sequence in delayed load mode.
  45651. */
  45652. delayLoad(): void;
  45653. /**
  45654. * Clones the texture.
  45655. * @returns the cloned texture
  45656. */
  45657. clone(): Nullable<BaseTexture>;
  45658. /**
  45659. * Get the texture underlying type (INT, FLOAT...)
  45660. */
  45661. readonly textureType: number;
  45662. /**
  45663. * Get the texture underlying format (RGB, RGBA...)
  45664. */
  45665. readonly textureFormat: number;
  45666. /**
  45667. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  45668. * This will returns an RGBA array buffer containing either in values (0-255) or
  45669. * float values (0-1) depending of the underlying buffer type.
  45670. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  45671. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  45672. * @param buffer defines a user defined buffer to fill with data (can be null)
  45673. * @returns The Array buffer containing the pixels data.
  45674. */
  45675. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  45676. /**
  45677. * Release and destroy the underlying lower level texture aka internalTexture.
  45678. */
  45679. releaseInternalTexture(): void;
  45680. /**
  45681. * Get the polynomial representation of the texture data.
  45682. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  45683. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  45684. */
  45685. sphericalPolynomial: Nullable<SphericalPolynomial>;
  45686. /** @hidden */
  45687. readonly _lodTextureHigh: Nullable<BaseTexture>;
  45688. /** @hidden */
  45689. readonly _lodTextureMid: Nullable<BaseTexture>;
  45690. /** @hidden */
  45691. readonly _lodTextureLow: Nullable<BaseTexture>;
  45692. /**
  45693. * Dispose the texture and release its associated resources.
  45694. */
  45695. dispose(): void;
  45696. /**
  45697. * Serialize the texture into a JSON representation that can be parsed later on.
  45698. * @returns the JSON representation of the texture
  45699. */
  45700. serialize(): any;
  45701. /**
  45702. * Helper function to be called back once a list of texture contains only ready textures.
  45703. * @param textures Define the list of textures to wait for
  45704. * @param callback Define the callback triggered once the entire list will be ready
  45705. */
  45706. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  45707. }
  45708. }
  45709. declare module BABYLON {
  45710. /**
  45711. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45712. * It can help converting any input color in a desired output one. This can then be used to create effects
  45713. * from sepia, black and white to sixties or futuristic rendering...
  45714. *
  45715. * The only supported format is currently 3dl.
  45716. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45717. */
  45718. class ColorGradingTexture extends BaseTexture {
  45719. /**
  45720. * The current texture matrix. (will always be identity in color grading texture)
  45721. */
  45722. private _textureMatrix;
  45723. /**
  45724. * The texture URL.
  45725. */
  45726. url: string;
  45727. /**
  45728. * Empty line regex stored for GC.
  45729. */
  45730. private static _noneEmptyLineRegex;
  45731. private _engine;
  45732. /**
  45733. * Instantiates a ColorGradingTexture from the following parameters.
  45734. *
  45735. * @param url The location of the color gradind data (currently only supporting 3dl)
  45736. * @param scene The scene the texture will be used in
  45737. */
  45738. constructor(url: string, scene: Scene);
  45739. /**
  45740. * Returns the texture matrix used in most of the material.
  45741. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45742. */
  45743. getTextureMatrix(): Matrix;
  45744. /**
  45745. * Occurs when the file being loaded is a .3dl LUT file.
  45746. */
  45747. private load3dlTexture;
  45748. /**
  45749. * Starts the loading process of the texture.
  45750. */
  45751. private loadTexture;
  45752. /**
  45753. * Clones the color gradind texture.
  45754. */
  45755. clone(): ColorGradingTexture;
  45756. /**
  45757. * Called during delayed load for textures.
  45758. */
  45759. delayLoad(): void;
  45760. /**
  45761. * Parses a color grading texture serialized by Babylon.
  45762. * @param parsedTexture The texture information being parsedTexture
  45763. * @param scene The scene to load the texture in
  45764. * @param rootUrl The root url of the data assets to load
  45765. * @return A color gradind texture
  45766. */
  45767. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  45768. /**
  45769. * Serializes the LUT texture to json format.
  45770. */
  45771. serialize(): any;
  45772. }
  45773. }
  45774. declare module BABYLON {
  45775. /**
  45776. * Class for creating a cube texture
  45777. */
  45778. class CubeTexture extends BaseTexture {
  45779. /**
  45780. * The url of the texture
  45781. */
  45782. url: string;
  45783. /**
  45784. * Gets or sets the center of the bounding box associated with the cube texture.
  45785. * It must define where the camera used to render the texture was set
  45786. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45787. */
  45788. boundingBoxPosition: Vector3;
  45789. private _boundingBoxSize;
  45790. /**
  45791. * Gets or sets the size of the bounding box associated with the cube texture
  45792. * When defined, the cubemap will switch to local mode
  45793. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45794. * @example https://www.babylonjs-playground.com/#RNASML
  45795. */
  45796. /**
  45797. * Returns the bounding box size
  45798. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  45799. */
  45800. boundingBoxSize: Vector3;
  45801. protected _rotationY: number;
  45802. /**
  45803. * Sets texture matrix rotation angle around Y axis in radians.
  45804. */
  45805. /**
  45806. * Gets texture matrix rotation angle around Y axis radians.
  45807. */
  45808. rotationY: number;
  45809. private _noMipmap;
  45810. private _files;
  45811. private _extensions;
  45812. private _textureMatrix;
  45813. private _format;
  45814. private _createPolynomials;
  45815. /** @hidden */
  45816. readonly _prefiltered: boolean;
  45817. /**
  45818. * Creates a cube texture from an array of image urls
  45819. * @param files defines an array of image urls
  45820. * @param scene defines the hosting scene
  45821. * @param noMipmap specifies if mip maps are not used
  45822. * @returns a cube texture
  45823. */
  45824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  45825. /**
  45826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  45827. * @param url defines the url of the prefiltered texture
  45828. * @param scene defines the scene the texture is attached to
  45829. * @param forcedExtension defines the extension of the file if different from the url
  45830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45831. * @return the prefiltered texture
  45832. */
  45833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  45834. /**
  45835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  45836. * as prefiltered data.
  45837. * @param rootUrl defines the url of the texture or the root name of the six images
  45838. * @param scene defines the scene the texture is attached to
  45839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  45840. * @param noMipmap defines if mipmaps should be created or not
  45841. * @param files defines the six files to load for the different faces
  45842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  45843. * @param onError defines a callback triggered in case of error during load
  45844. * @param format defines the internal format to use for the texture once loaded
  45845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  45846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  45847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  45848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45850. * @return the cube texture
  45851. */
  45852. 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);
  45853. /**
  45854. * Delays loading of the cube texture
  45855. */
  45856. delayLoad(): void;
  45857. /**
  45858. * Returns the reflection texture matrix
  45859. * @returns the reflection texture matrix
  45860. */
  45861. getReflectionTextureMatrix(): Matrix;
  45862. /**
  45863. * Sets the reflection texture matrix
  45864. * @param value Reflection texture matrix
  45865. */
  45866. setReflectionTextureMatrix(value: Matrix): void;
  45867. /**
  45868. * Parses text to create a cube texture
  45869. * @param parsedTexture define the serialized text to read from
  45870. * @param scene defines the hosting scene
  45871. * @param rootUrl defines the root url of the cube texture
  45872. * @returns a cube texture
  45873. */
  45874. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  45875. /**
  45876. * Makes a clone, or deep copy, of the cube texture
  45877. * @returns a new cube texture
  45878. */
  45879. clone(): CubeTexture;
  45880. }
  45881. }
  45882. declare module BABYLON {
  45883. /**
  45884. * A class extending Texture allowing drawing on a texture
  45885. * @see http://doc.babylonjs.com/how_to/dynamictexture
  45886. */
  45887. class DynamicTexture extends Texture {
  45888. private _generateMipMaps;
  45889. private _canvas;
  45890. private _context;
  45891. private _engine;
  45892. /**
  45893. * Creates a DynamicTexture
  45894. * @param name defines the name of the texture
  45895. * @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
  45896. * @param scene defines the scene where you want the texture
  45897. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45898. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45899. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  45900. */
  45901. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45902. /**
  45903. * Gets the current state of canRescale
  45904. */
  45905. readonly canRescale: boolean;
  45906. private _recreate;
  45907. /**
  45908. * Scales the texture
  45909. * @param ratio the scale factor to apply to both width and height
  45910. */
  45911. scale(ratio: number): void;
  45912. /**
  45913. * Resizes the texture
  45914. * @param width the new width
  45915. * @param height the new height
  45916. */
  45917. scaleTo(width: number, height: number): void;
  45918. /**
  45919. * Gets the context of the canvas used by the texture
  45920. * @returns the canvas context of the dynamic texture
  45921. */
  45922. getContext(): CanvasRenderingContext2D;
  45923. /**
  45924. * Clears the texture
  45925. */
  45926. clear(): void;
  45927. /**
  45928. * Updates the texture
  45929. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45930. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45931. */
  45932. update(invertY?: boolean, premulAlpha?: boolean): void;
  45933. /**
  45934. * Draws text onto the texture
  45935. * @param text defines the text to be drawn
  45936. * @param x defines the placement of the text from the left
  45937. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45938. * @param font defines the font to be used with font-style, font-size, font-name
  45939. * @param color defines the color used for the text
  45940. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45941. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45942. * @param update defines whether texture is immediately update (default is true)
  45943. */
  45944. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  45945. /**
  45946. * Clones the texture
  45947. * @returns the clone of the texture.
  45948. */
  45949. clone(): DynamicTexture;
  45950. /**
  45951. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45952. * @returns a serialized dynamic texture object
  45953. */
  45954. serialize(): any;
  45955. /** @hidden */
  45956. _rebuild(): void;
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * This represents a texture coming from an HDR input.
  45962. *
  45963. * The only supported format is currently panorama picture stored in RGBE format.
  45964. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45965. */
  45966. class HDRCubeTexture extends BaseTexture {
  45967. private static _facesMapping;
  45968. private _generateHarmonics;
  45969. private _noMipmap;
  45970. private _textureMatrix;
  45971. private _size;
  45972. private _onLoad;
  45973. private _onError;
  45974. /**
  45975. * The texture URL.
  45976. */
  45977. url: string;
  45978. /**
  45979. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45980. */
  45981. coordinatesMode: number;
  45982. protected _isBlocking: boolean;
  45983. /**
  45984. * Sets wether or not the texture is blocking during loading.
  45985. */
  45986. /**
  45987. * Gets wether or not the texture is blocking during loading.
  45988. */
  45989. isBlocking: boolean;
  45990. protected _rotationY: number;
  45991. /**
  45992. * Sets texture matrix rotation angle around Y axis in radians.
  45993. */
  45994. /**
  45995. * Gets texture matrix rotation angle around Y axis radians.
  45996. */
  45997. rotationY: number;
  45998. /**
  45999. * Gets or sets the center of the bounding box associated with the cube texture
  46000. * It must define where the camera used to render the texture was set
  46001. */
  46002. boundingBoxPosition: Vector3;
  46003. private _boundingBoxSize;
  46004. /**
  46005. * Gets or sets the size of the bounding box associated with the cube texture
  46006. * When defined, the cubemap will switch to local mode
  46007. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46008. * @example https://www.babylonjs-playground.com/#RNASML
  46009. */
  46010. boundingBoxSize: Vector3;
  46011. /**
  46012. * Instantiates an HDRTexture from the following parameters.
  46013. *
  46014. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46015. * @param scene The scene the texture will be used in
  46016. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46017. * @param noMipmap Forces to not generate the mipmap if true
  46018. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46019. * @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)
  46020. * @param reserved Reserved flag for internal use.
  46021. */
  46022. 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>);
  46023. /**
  46024. * Occurs when the file is raw .hdr file.
  46025. */
  46026. private loadTexture;
  46027. clone(): HDRCubeTexture;
  46028. delayLoad(): void;
  46029. /**
  46030. * Get the texture reflection matrix used to rotate/transform the reflection.
  46031. * @returns the reflection matrix
  46032. */
  46033. getReflectionTextureMatrix(): Matrix;
  46034. /**
  46035. * Set the texture reflection matrix used to rotate/transform the reflection.
  46036. * @param value Define the reflection matrix to set
  46037. */
  46038. setReflectionTextureMatrix(value: Matrix): void;
  46039. /**
  46040. * Parses a JSON representation of an HDR Texture in order to create the texture
  46041. * @param parsedTexture Define the JSON representation
  46042. * @param scene Define the scene the texture should be created in
  46043. * @param rootUrl Define the root url in case we need to load relative dependencies
  46044. * @returns the newly created texture after parsing
  46045. */
  46046. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46047. serialize(): any;
  46048. }
  46049. }
  46050. declare module BABYLON {
  46051. /**
  46052. * Class used to store data associated with WebGL texture data for the engine
  46053. * This class should not be used directly
  46054. */
  46055. class InternalTexture implements IInternalTextureTracker {
  46056. /**
  46057. * The source of the texture data is unknown
  46058. */
  46059. static DATASOURCE_UNKNOWN: number;
  46060. /**
  46061. * Texture data comes from an URL
  46062. */
  46063. static DATASOURCE_URL: number;
  46064. /**
  46065. * Texture data is only used for temporary storage
  46066. */
  46067. static DATASOURCE_TEMP: number;
  46068. /**
  46069. * Texture data comes from raw data (ArrayBuffer)
  46070. */
  46071. static DATASOURCE_RAW: number;
  46072. /**
  46073. * Texture content is dynamic (video or dynamic texture)
  46074. */
  46075. static DATASOURCE_DYNAMIC: number;
  46076. /**
  46077. * Texture content is generated by rendering to it
  46078. */
  46079. static DATASOURCE_RENDERTARGET: number;
  46080. /**
  46081. * Texture content is part of a multi render target process
  46082. */
  46083. static DATASOURCE_MULTIRENDERTARGET: number;
  46084. /**
  46085. * Texture data comes from a cube data file
  46086. */
  46087. static DATASOURCE_CUBE: number;
  46088. /**
  46089. * Texture data comes from a raw cube data
  46090. */
  46091. static DATASOURCE_CUBERAW: number;
  46092. /**
  46093. * Texture data come from a prefiltered cube data file
  46094. */
  46095. static DATASOURCE_CUBEPREFILTERED: number;
  46096. /**
  46097. * Texture content is raw 3D data
  46098. */
  46099. static DATASOURCE_RAW3D: number;
  46100. /**
  46101. * Texture content is a depth texture
  46102. */
  46103. static DATASOURCE_DEPTHTEXTURE: number;
  46104. /**
  46105. * Texture data comes from a raw cube data encoded with RGBD
  46106. */
  46107. static DATASOURCE_CUBERAW_RGBD: number;
  46108. /**
  46109. * Defines if the texture is ready
  46110. */
  46111. isReady: boolean;
  46112. /**
  46113. * Defines if the texture is a cube texture
  46114. */
  46115. isCube: boolean;
  46116. /**
  46117. * Defines if the texture contains 3D data
  46118. */
  46119. is3D: boolean;
  46120. /**
  46121. * Gets the URL used to load this texture
  46122. */
  46123. url: string;
  46124. /**
  46125. * Gets the sampling mode of the texture
  46126. */
  46127. samplingMode: number;
  46128. /**
  46129. * Gets a boolean indicating if the texture needs mipmaps generation
  46130. */
  46131. generateMipMaps: boolean;
  46132. /**
  46133. * Gets the number of samples used by the texture (WebGL2+ only)
  46134. */
  46135. samples: number;
  46136. /**
  46137. * Gets the type of the texture (int, float...)
  46138. */
  46139. type: number;
  46140. /**
  46141. * Gets the format of the texture (RGB, RGBA...)
  46142. */
  46143. format: number;
  46144. /**
  46145. * Observable called when the texture is loaded
  46146. */
  46147. onLoadedObservable: Observable<InternalTexture>;
  46148. /**
  46149. * Gets the width of the texture
  46150. */
  46151. width: number;
  46152. /**
  46153. * Gets the height of the texture
  46154. */
  46155. height: number;
  46156. /**
  46157. * Gets the depth of the texture
  46158. */
  46159. depth: number;
  46160. /**
  46161. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46162. */
  46163. baseWidth: number;
  46164. /**
  46165. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46166. */
  46167. baseHeight: number;
  46168. /**
  46169. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46170. */
  46171. baseDepth: number;
  46172. /**
  46173. * Gets a boolean indicating if the texture is inverted on Y axis
  46174. */
  46175. invertY: boolean;
  46176. /**
  46177. * Gets or set the previous tracker in the list
  46178. */
  46179. previous: Nullable<IInternalTextureTracker>;
  46180. /**
  46181. * Gets or set the next tracker in the list
  46182. */
  46183. next: Nullable<IInternalTextureTracker>;
  46184. /** @hidden */
  46185. _initialSlot: number;
  46186. /** @hidden */
  46187. _designatedSlot: number;
  46188. /** @hidden */
  46189. _dataSource: number;
  46190. /** @hidden */
  46191. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46192. /** @hidden */
  46193. _bufferView: Nullable<ArrayBufferView>;
  46194. /** @hidden */
  46195. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46196. /** @hidden */
  46197. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46198. /** @hidden */
  46199. _size: number;
  46200. /** @hidden */
  46201. _extension: string;
  46202. /** @hidden */
  46203. _files: Nullable<string[]>;
  46204. /** @hidden */
  46205. _workingCanvas: HTMLCanvasElement;
  46206. /** @hidden */
  46207. _workingContext: CanvasRenderingContext2D;
  46208. /** @hidden */
  46209. _framebuffer: Nullable<WebGLFramebuffer>;
  46210. /** @hidden */
  46211. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46212. /** @hidden */
  46213. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46214. /** @hidden */
  46215. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46216. /** @hidden */
  46217. _attachments: Nullable<number[]>;
  46218. /** @hidden */
  46219. _cachedCoordinatesMode: Nullable<number>;
  46220. /** @hidden */
  46221. _cachedWrapU: Nullable<number>;
  46222. /** @hidden */
  46223. _cachedWrapV: Nullable<number>;
  46224. /** @hidden */
  46225. _cachedWrapR: Nullable<number>;
  46226. /** @hidden */
  46227. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46228. /** @hidden */
  46229. _isDisabled: boolean;
  46230. /** @hidden */
  46231. _compression: Nullable<string>;
  46232. /** @hidden */
  46233. _generateStencilBuffer: boolean;
  46234. /** @hidden */
  46235. _generateDepthBuffer: boolean;
  46236. /** @hidden */
  46237. _comparisonFunction: number;
  46238. /** @hidden */
  46239. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46240. /** @hidden */
  46241. _lodGenerationScale: number;
  46242. /** @hidden */
  46243. _lodGenerationOffset: number;
  46244. /** @hidden */
  46245. _lodTextureHigh: BaseTexture;
  46246. /** @hidden */
  46247. _lodTextureMid: BaseTexture;
  46248. /** @hidden */
  46249. _lodTextureLow: BaseTexture;
  46250. /** @hidden */
  46251. _isRGBD: boolean;
  46252. /** @hidden */
  46253. _webGLTexture: Nullable<WebGLTexture>;
  46254. /** @hidden */
  46255. _references: number;
  46256. private _engine;
  46257. /**
  46258. * Gets the Engine the texture belongs to.
  46259. * @returns The babylon engine
  46260. */
  46261. getEngine(): Engine;
  46262. /**
  46263. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46264. */
  46265. readonly dataSource: number;
  46266. /**
  46267. * Creates a new InternalTexture
  46268. * @param engine defines the engine to use
  46269. * @param dataSource defines the type of data that will be used
  46270. */
  46271. constructor(engine: Engine, dataSource: number);
  46272. /**
  46273. * Increments the number of references (ie. the number of Texture that point to it)
  46274. */
  46275. incrementReferences(): void;
  46276. /**
  46277. * Change the size of the texture (not the size of the content)
  46278. * @param width defines the new width
  46279. * @param height defines the new height
  46280. * @param depth defines the new depth (1 by default)
  46281. */
  46282. updateSize(width: int, height: int, depth?: int): void;
  46283. /** @hidden */
  46284. _rebuild(): void;
  46285. /** @hidden */
  46286. _swapAndDie(target: InternalTexture): void;
  46287. /**
  46288. * Dispose the current allocated resources
  46289. */
  46290. dispose(): void;
  46291. }
  46292. }
  46293. declare module BABYLON {
  46294. /**
  46295. * This represents the required contract to create a new type of texture loader.
  46296. */
  46297. interface IInternalTextureLoader {
  46298. /**
  46299. * Defines wether the loader supports cascade loading the different faces.
  46300. */
  46301. supportCascades: boolean;
  46302. /**
  46303. * This returns if the loader support the current file information.
  46304. * @param extension defines the file extension of the file being loaded
  46305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46306. * @param fallback defines the fallback internal texture if any
  46307. * @param isBase64 defines whether the texture is encoded as a base64
  46308. * @param isBuffer defines whether the texture data are stored as a buffer
  46309. * @returns true if the loader can load the specified file
  46310. */
  46311. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46312. /**
  46313. * Transform the url before loading if required.
  46314. * @param rootUrl the url of the texture
  46315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46316. * @returns the transformed texture
  46317. */
  46318. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46319. /**
  46320. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46321. * @param rootUrl the url of the texture
  46322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46323. * @returns the fallback texture
  46324. */
  46325. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46326. /**
  46327. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46328. * @param data contains the texture data
  46329. * @param texture defines the BabylonJS internal texture
  46330. * @param createPolynomials will be true if polynomials have been requested
  46331. * @param onLoad defines the callback to trigger once the texture is ready
  46332. * @param onError defines the callback to trigger in case of error
  46333. */
  46334. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46335. /**
  46336. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46337. * @param data contains the texture data
  46338. * @param texture defines the BabylonJS internal texture
  46339. * @param callback defines the method to call once ready to upload
  46340. */
  46341. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46342. }
  46343. }
  46344. declare module BABYLON {
  46345. /**
  46346. * Internal interface used to track InternalTexture already bound to the GL context
  46347. */
  46348. interface IInternalTextureTracker {
  46349. /**
  46350. * Gets or set the previous tracker in the list
  46351. */
  46352. previous: Nullable<IInternalTextureTracker>;
  46353. /**
  46354. * Gets or set the next tracker in the list
  46355. */
  46356. next: Nullable<IInternalTextureTracker>;
  46357. }
  46358. /**
  46359. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  46360. */
  46361. class DummyInternalTextureTracker {
  46362. /**
  46363. * Gets or set the previous tracker in the list
  46364. */
  46365. previous: Nullable<IInternalTextureTracker>;
  46366. /**
  46367. * Gets or set the next tracker in the list
  46368. */
  46369. next: Nullable<IInternalTextureTracker>;
  46370. }
  46371. }
  46372. declare module BABYLON {
  46373. /**
  46374. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46375. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46376. * You can then easily use it as a reflectionTexture on a flat surface.
  46377. * In case the surface is not a plane, please consider relying on reflection probes.
  46378. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46379. */
  46380. class MirrorTexture extends RenderTargetTexture {
  46381. private scene;
  46382. /**
  46383. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  46384. * 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.
  46385. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46386. */
  46387. mirrorPlane: Plane;
  46388. /**
  46389. * Define the blur ratio used to blur the reflection if needed.
  46390. */
  46391. blurRatio: number;
  46392. /**
  46393. * Define the adaptive blur kernel used to blur the reflection if needed.
  46394. * This will autocompute the closest best match for the `blurKernel`
  46395. */
  46396. adaptiveBlurKernel: number;
  46397. /**
  46398. * Define the blur kernel used to blur the reflection if needed.
  46399. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46400. */
  46401. blurKernel: number;
  46402. /**
  46403. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  46404. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46405. */
  46406. blurKernelX: number;
  46407. /**
  46408. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  46409. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  46410. */
  46411. blurKernelY: number;
  46412. private _autoComputeBlurKernel;
  46413. protected _onRatioRescale(): void;
  46414. private _updateGammaSpace;
  46415. private _imageProcessingConfigChangeObserver;
  46416. private _transformMatrix;
  46417. private _mirrorMatrix;
  46418. private _savedViewMatrix;
  46419. private _blurX;
  46420. private _blurY;
  46421. private _adaptiveBlurKernel;
  46422. private _blurKernelX;
  46423. private _blurKernelY;
  46424. private _blurRatio;
  46425. /**
  46426. * Instantiates a Mirror Texture.
  46427. * Mirror texture can be used to simulate the view from a mirror in a scene.
  46428. * It will dynamically be rendered every frame to adapt to the camera point of view.
  46429. * You can then easily use it as a reflectionTexture on a flat surface.
  46430. * In case the surface is not a plane, please consider relying on reflection probes.
  46431. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  46432. * @param name
  46433. * @param size
  46434. * @param scene
  46435. * @param generateMipMaps
  46436. * @param type
  46437. * @param samplingMode
  46438. * @param generateDepthBuffer
  46439. */
  46440. constructor(name: string, size: number | {
  46441. width: number;
  46442. height: number;
  46443. } | {
  46444. ratio: number;
  46445. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  46446. private _preparePostProcesses;
  46447. /**
  46448. * Clone the mirror texture.
  46449. * @returns the cloned texture
  46450. */
  46451. clone(): MirrorTexture;
  46452. /**
  46453. * Serialize the texture to a JSON representation you could use in Parse later on
  46454. * @returns the serialized JSON representation
  46455. */
  46456. serialize(): any;
  46457. /**
  46458. * Dispose the texture and release its associated resources.
  46459. */
  46460. dispose(): void;
  46461. }
  46462. }
  46463. declare module BABYLON {
  46464. /**
  46465. * Creation options of the multi render target texture.
  46466. */
  46467. interface IMultiRenderTargetOptions {
  46468. /**
  46469. * Define if the texture needs to create mip maps after render.
  46470. */
  46471. generateMipMaps?: boolean;
  46472. /**
  46473. * Define the types of all the draw buffers we want to create
  46474. */
  46475. types?: number[];
  46476. /**
  46477. * Define the sampling modes of all the draw buffers we want to create
  46478. */
  46479. samplingModes?: number[];
  46480. /**
  46481. * Define if a depth buffer is required
  46482. */
  46483. generateDepthBuffer?: boolean;
  46484. /**
  46485. * Define if a stencil buffer is required
  46486. */
  46487. generateStencilBuffer?: boolean;
  46488. /**
  46489. * Define if a depth texture is required instead of a depth buffer
  46490. */
  46491. generateDepthTexture?: boolean;
  46492. /**
  46493. * Define the number of desired draw buffers
  46494. */
  46495. textureCount?: number;
  46496. /**
  46497. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46498. */
  46499. doNotChangeAspectRatio?: boolean;
  46500. /**
  46501. * Define the default type of the buffers we are creating
  46502. */
  46503. defaultType?: number;
  46504. }
  46505. /**
  46506. * A multi render target, like a render target provides the ability to render to a texture.
  46507. * Unlike the render target, it can render to several draw buffers in one draw.
  46508. * This is specially interesting in deferred rendering or for any effects requiring more than
  46509. * just one color from a single pass.
  46510. */
  46511. class MultiRenderTarget extends RenderTargetTexture {
  46512. private _internalTextures;
  46513. private _textures;
  46514. private _multiRenderTargetOptions;
  46515. /**
  46516. * Get if draw buffers are currently supported by the used hardware and browser.
  46517. */
  46518. readonly isSupported: boolean;
  46519. /**
  46520. * Get the list of textures generated by the multi render target.
  46521. */
  46522. readonly textures: Texture[];
  46523. /**
  46524. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46525. */
  46526. readonly depthTexture: Texture;
  46527. /**
  46528. * Set the wrapping mode on U of all the textures we are rendering to.
  46529. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46530. */
  46531. wrapU: number;
  46532. /**
  46533. * Set the wrapping mode on V of all the textures we are rendering to.
  46534. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46535. */
  46536. wrapV: number;
  46537. /**
  46538. * Instantiate a new multi render target texture.
  46539. * A multi render target, like a render target provides the ability to render to a texture.
  46540. * Unlike the render target, it can render to several draw buffers in one draw.
  46541. * This is specially interesting in deferred rendering or for any effects requiring more than
  46542. * just one color from a single pass.
  46543. * @param name Define the name of the texture
  46544. * @param size Define the size of the buffers to render to
  46545. * @param count Define the number of target we are rendering into
  46546. * @param scene Define the scene the texture belongs to
  46547. * @param options Define the options used to create the multi render target
  46548. */
  46549. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46550. /** @hidden */
  46551. _rebuild(): void;
  46552. private _createInternalTextures;
  46553. private _createTextures;
  46554. /**
  46555. * Define the number of samples used if MSAA is enabled.
  46556. */
  46557. samples: number;
  46558. /**
  46559. * Resize all the textures in the multi render target.
  46560. * Be carrefull as it will recreate all the data in the new texture.
  46561. * @param size Define the new size
  46562. */
  46563. resize(size: any): void;
  46564. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46565. /**
  46566. * Dispose the render targets and their associated resources
  46567. */
  46568. dispose(): void;
  46569. /**
  46570. * Release all the underlying texture used as draw buffers.
  46571. */
  46572. releaseInternalTextures(): void;
  46573. }
  46574. }
  46575. declare module BABYLON {
  46576. /**
  46577. * Raw cube texture where the raw buffers are passed in
  46578. */
  46579. class RawCubeTexture extends CubeTexture {
  46580. /**
  46581. * Creates a cube texture where the raw buffers are passed in.
  46582. * @param scene defines the scene the texture is attached to
  46583. * @param data defines the array of data to use to create each face
  46584. * @param size defines the size of the textures
  46585. * @param format defines the format of the data
  46586. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  46587. * @param generateMipMaps defines if the engine should generate the mip levels
  46588. * @param invertY defines if data must be stored with Y axis inverted
  46589. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  46590. * @param compression defines the compression used (null by default)
  46591. */
  46592. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46593. /**
  46594. * Updates the raw cube texture.
  46595. * @param data defines the data to store
  46596. * @param format defines the data format
  46597. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46598. * @param invertY defines if data must be stored with Y axis inverted
  46599. * @param compression defines the compression used (null by default)
  46600. * @param level defines which level of the texture to update
  46601. */
  46602. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  46603. /**
  46604. * Updates a raw cube texture with RGBD encoded data.
  46605. * @param data defines the array of data [mipmap][face] to use to create each face
  46606. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46607. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46608. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46609. * @returns a promsie that resolves when the operation is complete
  46610. */
  46611. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46612. /**
  46613. * Clones the raw cube texture.
  46614. * @return a new cube texture
  46615. */
  46616. clone(): CubeTexture;
  46617. /** @hidden */
  46618. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46619. }
  46620. }
  46621. declare module BABYLON {
  46622. /**
  46623. * Raw texture can help creating a texture directly from an array of data.
  46624. * This can be super useful if you either get the data from an uncompressed source or
  46625. * if you wish to create your texture pixel by pixel.
  46626. */
  46627. class RawTexture extends Texture {
  46628. /**
  46629. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46630. */
  46631. format: number;
  46632. private _engine;
  46633. /**
  46634. * Instantiates a new RawTexture.
  46635. * Raw texture can help creating a texture directly from an array of data.
  46636. * This can be super useful if you either get the data from an uncompressed source or
  46637. * if you wish to create your texture pixel by pixel.
  46638. * @param data define the array of data to use to create the texture
  46639. * @param width define the width of the texture
  46640. * @param height define the height of the texture
  46641. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46642. * @param scene define the scene the texture belongs to
  46643. * @param generateMipMaps define whether mip maps should be generated or not
  46644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46647. */
  46648. constructor(data: ArrayBufferView, width: number, height: number,
  46649. /**
  46650. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  46651. */
  46652. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  46653. /**
  46654. * Updates the texture underlying data.
  46655. * @param data Define the new data of the texture
  46656. */
  46657. update(data: ArrayBufferView): void;
  46658. /**
  46659. * Creates a luminance texture from some data.
  46660. * @param data Define the texture data
  46661. * @param width Define the width of the texture
  46662. * @param height Define the height of the texture
  46663. * @param scene Define the scene the texture belongs to
  46664. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46665. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46666. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46667. * @returns the luminance texture
  46668. */
  46669. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46670. /**
  46671. * Creates a luminance alpha texture from some data.
  46672. * @param data Define the texture data
  46673. * @param width Define the width of the texture
  46674. * @param height Define the height of the texture
  46675. * @param scene Define the scene the texture belongs to
  46676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46679. * @returns the luminance alpha texture
  46680. */
  46681. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46682. /**
  46683. * Creates an alpha texture from some data.
  46684. * @param data Define the texture data
  46685. * @param width Define the width of the texture
  46686. * @param height Define the height of the texture
  46687. * @param scene Define the scene the texture belongs to
  46688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46691. * @returns the alpha texture
  46692. */
  46693. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  46694. /**
  46695. * Creates a RGB texture from some data.
  46696. * @param data Define the texture data
  46697. * @param width Define the width of the texture
  46698. * @param height Define the height of the texture
  46699. * @param scene Define the scene the texture belongs to
  46700. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46701. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46702. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46703. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46704. * @returns the RGB alpha texture
  46705. */
  46706. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46707. /**
  46708. * Creates a RGBA texture from some data.
  46709. * @param data Define the texture data
  46710. * @param width Define the width of the texture
  46711. * @param height Define the height of the texture
  46712. * @param scene Define the scene the texture belongs to
  46713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46716. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46717. * @returns the RGBA texture
  46718. */
  46719. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46720. /**
  46721. * Creates a R texture from some data.
  46722. * @param data Define the texture data
  46723. * @param width Define the width of the texture
  46724. * @param height Define the height of the texture
  46725. * @param scene Define the scene the texture belongs to
  46726. * @param generateMipMaps Define whether or not to create mip maps for the texture
  46727. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  46728. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  46729. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  46730. * @returns the R texture
  46731. */
  46732. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  46733. }
  46734. }
  46735. declare module BABYLON {
  46736. /**
  46737. * Class used to store 3D textures containing user data
  46738. */
  46739. class RawTexture3D extends Texture {
  46740. /** Gets or sets the texture format to use */
  46741. format: number;
  46742. private _engine;
  46743. /**
  46744. * Create a new RawTexture3D
  46745. * @param data defines the data of the texture
  46746. * @param width defines the width of the texture
  46747. * @param height defines the height of the texture
  46748. * @param depth defines the depth of the texture
  46749. * @param format defines the texture format to use
  46750. * @param scene defines the hosting scene
  46751. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46752. * @param invertY defines if texture must be stored with Y axis inverted
  46753. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  46754. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46755. */
  46756. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46757. /** Gets or sets the texture format to use */
  46758. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46759. /**
  46760. * Update the texture with new data
  46761. * @param data defines the data to store in the texture
  46762. */
  46763. update(data: ArrayBufferView): void;
  46764. }
  46765. }
  46766. declare module BABYLON {
  46767. /**
  46768. * Creates a refraction texture used by refraction channel of the standard material.
  46769. * It is like a mirror but to see through a material.
  46770. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46771. */
  46772. class RefractionTexture extends RenderTargetTexture {
  46773. /**
  46774. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46775. * 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.
  46776. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46777. */
  46778. refractionPlane: Plane;
  46779. /**
  46780. * Define how deep under the surface we should see.
  46781. */
  46782. depth: number;
  46783. /**
  46784. * Creates a refraction texture used by refraction channel of the standard material.
  46785. * It is like a mirror but to see through a material.
  46786. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46787. * @param name Define the texture name
  46788. * @param size Define the size of the underlying texture
  46789. * @param scene Define the scene the refraction belongs to
  46790. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46791. */
  46792. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46793. /**
  46794. * Clone the refraction texture.
  46795. * @returns the cloned texture
  46796. */
  46797. clone(): RefractionTexture;
  46798. /**
  46799. * Serialize the texture to a JSON representation you could use in Parse later on
  46800. * @returns the serialized JSON representation
  46801. */
  46802. serialize(): any;
  46803. }
  46804. }
  46805. declare module BABYLON {
  46806. /**
  46807. * This Helps creating a texture that will be created from a camera in your scene.
  46808. * It is basically a dynamic texture that could be used to create special effects for instance.
  46809. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  46810. */
  46811. class RenderTargetTexture extends Texture {
  46812. isCube: boolean;
  46813. /**
  46814. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  46815. */
  46816. static readonly REFRESHRATE_RENDER_ONCE: number;
  46817. /**
  46818. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  46819. */
  46820. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  46821. /**
  46822. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  46823. * the central point of your effect and can save a lot of performances.
  46824. */
  46825. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  46826. /**
  46827. * Use this predicate to dynamically define the list of mesh you want to render.
  46828. * If set, the renderList property will be overwritten.
  46829. */
  46830. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  46831. private _renderList;
  46832. /**
  46833. * Use this list to define the list of mesh you want to render.
  46834. */
  46835. renderList: Nullable<Array<AbstractMesh>>;
  46836. private _hookArray;
  46837. /**
  46838. * Define if particles should be rendered in your texture.
  46839. */
  46840. renderParticles: boolean;
  46841. /**
  46842. * Define if sprites should be rendered in your texture.
  46843. */
  46844. renderSprites: boolean;
  46845. /**
  46846. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  46847. */
  46848. coordinatesMode: number;
  46849. /**
  46850. * Define the camera used to render the texture.
  46851. */
  46852. activeCamera: Nullable<Camera>;
  46853. /**
  46854. * Override the render function of the texture with your own one.
  46855. */
  46856. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  46857. /**
  46858. * Define if camera post processes should be use while rendering the texture.
  46859. */
  46860. useCameraPostProcesses: boolean;
  46861. /**
  46862. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  46863. */
  46864. ignoreCameraViewport: boolean;
  46865. private _postProcessManager;
  46866. private _postProcesses;
  46867. private _resizeObserver;
  46868. /**
  46869. * An event triggered when the texture is unbind.
  46870. */
  46871. onBeforeBindObservable: Observable<RenderTargetTexture>;
  46872. /**
  46873. * An event triggered when the texture is unbind.
  46874. */
  46875. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  46876. private _onAfterUnbindObserver;
  46877. /**
  46878. * Set a after unbind callback in the texture.
  46879. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  46880. */
  46881. onAfterUnbind: () => void;
  46882. /**
  46883. * An event triggered before rendering the texture
  46884. */
  46885. onBeforeRenderObservable: Observable<number>;
  46886. private _onBeforeRenderObserver;
  46887. /**
  46888. * Set a before render callback in the texture.
  46889. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  46890. */
  46891. onBeforeRender: (faceIndex: number) => void;
  46892. /**
  46893. * An event triggered after rendering the texture
  46894. */
  46895. onAfterRenderObservable: Observable<number>;
  46896. private _onAfterRenderObserver;
  46897. /**
  46898. * Set a after render callback in the texture.
  46899. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  46900. */
  46901. onAfterRender: (faceIndex: number) => void;
  46902. /**
  46903. * An event triggered after the texture clear
  46904. */
  46905. onClearObservable: Observable<Engine>;
  46906. private _onClearObserver;
  46907. /**
  46908. * Set a clear callback in the texture.
  46909. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  46910. */
  46911. onClear: (Engine: Engine) => void;
  46912. /**
  46913. * Define the clear color of the Render Target if it should be different from the scene.
  46914. */
  46915. clearColor: Color4;
  46916. protected _size: number | {
  46917. width: number;
  46918. height: number;
  46919. };
  46920. protected _initialSizeParameter: number | {
  46921. width: number;
  46922. height: number;
  46923. } | {
  46924. ratio: number;
  46925. };
  46926. protected _sizeRatio: Nullable<number>;
  46927. /** @hidden */
  46928. _generateMipMaps: boolean;
  46929. protected _renderingManager: RenderingManager;
  46930. /** @hidden */
  46931. _waitingRenderList: string[];
  46932. protected _doNotChangeAspectRatio: boolean;
  46933. protected _currentRefreshId: number;
  46934. protected _refreshRate: number;
  46935. protected _textureMatrix: Matrix;
  46936. protected _samples: number;
  46937. protected _renderTargetOptions: RenderTargetCreationOptions;
  46938. /**
  46939. * Gets render target creation options that were used.
  46940. */
  46941. readonly renderTargetOptions: RenderTargetCreationOptions;
  46942. protected _engine: Engine;
  46943. protected _onRatioRescale(): void;
  46944. /**
  46945. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  46946. * It must define where the camera used to render the texture is set
  46947. */
  46948. boundingBoxPosition: Vector3;
  46949. private _boundingBoxSize;
  46950. /**
  46951. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  46952. * When defined, the cubemap will switch to local mode
  46953. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46954. * @example https://www.babylonjs-playground.com/#RNASML
  46955. */
  46956. boundingBoxSize: Vector3;
  46957. /**
  46958. * In case the RTT has been created with a depth texture, get the associated
  46959. * depth texture.
  46960. * Otherwise, return null.
  46961. */
  46962. depthStencilTexture: Nullable<InternalTexture>;
  46963. /**
  46964. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  46965. * or used a shadow, depth texture...
  46966. * @param name The friendly name of the texture
  46967. * @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)
  46968. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  46969. * @param generateMipMaps True if mip maps need to be generated after render.
  46970. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  46971. * @param type The type of the buffer in the RTT (int, half float, float...)
  46972. * @param isCube True if a cube texture needs to be created
  46973. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  46974. * @param generateDepthBuffer True to generate a depth buffer
  46975. * @param generateStencilBuffer True to generate a stencil buffer
  46976. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  46977. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  46978. */
  46979. constructor(name: string, size: number | {
  46980. width: number;
  46981. height: number;
  46982. } | {
  46983. ratio: number;
  46984. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number);
  46985. /**
  46986. * Creates a depth stencil texture.
  46987. * This is only available in WebGL 2 or with the depth texture extension available.
  46988. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  46989. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  46990. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  46991. */
  46992. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  46993. private _processSizeParameter;
  46994. /**
  46995. * Define the number of samples to use in case of MSAA.
  46996. * It defaults to one meaning no MSAA has been enabled.
  46997. */
  46998. samples: number;
  46999. /**
  47000. * Resets the refresh counter of the texture and start bak from scratch.
  47001. * Could be usefull to regenerate the texture if it is setup to render only once.
  47002. */
  47003. resetRefreshCounter(): void;
  47004. /**
  47005. * Define the refresh rate of the texture or the rendering frequency.
  47006. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47007. */
  47008. refreshRate: number;
  47009. /**
  47010. * Adds a post process to the render target rendering passes.
  47011. * @param postProcess define the post process to add
  47012. */
  47013. addPostProcess(postProcess: PostProcess): void;
  47014. /**
  47015. * Clear all the post processes attached to the render target
  47016. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47017. */
  47018. clearPostProcesses(dispose?: boolean): void;
  47019. /**
  47020. * Remove one of the post process from the list of attached post processes to the texture
  47021. * @param postProcess define the post process to remove from the list
  47022. */
  47023. removePostProcess(postProcess: PostProcess): void;
  47024. /** @hidden */
  47025. _shouldRender(): boolean;
  47026. /**
  47027. * Gets the actual render size of the texture.
  47028. * @returns the width of the render size
  47029. */
  47030. getRenderSize(): number;
  47031. /**
  47032. * Gets the actual render width of the texture.
  47033. * @returns the width of the render size
  47034. */
  47035. getRenderWidth(): number;
  47036. /**
  47037. * Gets the actual render height of the texture.
  47038. * @returns the height of the render size
  47039. */
  47040. getRenderHeight(): number;
  47041. /**
  47042. * Get if the texture can be rescaled or not.
  47043. */
  47044. readonly canRescale: boolean;
  47045. /**
  47046. * Resize the texture using a ratio.
  47047. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47048. */
  47049. scale(ratio: number): void;
  47050. /**
  47051. * Get the texture reflection matrix used to rotate/transform the reflection.
  47052. * @returns the reflection matrix
  47053. */
  47054. getReflectionTextureMatrix(): Matrix;
  47055. /**
  47056. * Resize the texture to a new desired size.
  47057. * Be carrefull as it will recreate all the data in the new texture.
  47058. * @param size Define the new size. It can be:
  47059. * - a number for squared texture,
  47060. * - an object containing { width: number, height: number }
  47061. * - or an object containing a ratio { ratio: number }
  47062. */
  47063. resize(size: number | {
  47064. width: number;
  47065. height: number;
  47066. } | {
  47067. ratio: number;
  47068. }): void;
  47069. /**
  47070. * Renders all the objects from the render list into the texture.
  47071. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47072. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47073. */
  47074. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47075. private _bestReflectionRenderTargetDimension;
  47076. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47077. private renderToTarget;
  47078. /**
  47079. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47080. * This allowed control for front to back rendering or reversly depending of the special needs.
  47081. *
  47082. * @param renderingGroupId The rendering group id corresponding to its index
  47083. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47084. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47085. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47086. */
  47087. 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;
  47088. /**
  47089. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47090. *
  47091. * @param renderingGroupId The rendering group id corresponding to its index
  47092. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47093. */
  47094. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47095. /**
  47096. * Clones the texture.
  47097. * @returns the cloned texture
  47098. */
  47099. clone(): RenderTargetTexture;
  47100. /**
  47101. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47102. * @returns The JSON representation of the texture
  47103. */
  47104. serialize(): any;
  47105. /**
  47106. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47107. */
  47108. disposeFramebufferObjects(): void;
  47109. /**
  47110. * Dispose the texture and release its associated resources.
  47111. */
  47112. dispose(): void;
  47113. /** @hidden */
  47114. _rebuild(): void;
  47115. /**
  47116. * Clear the info related to rendering groups preventing retention point in material dispose.
  47117. */
  47118. freeRenderingGroups(): void;
  47119. }
  47120. }
  47121. declare module BABYLON {
  47122. /**
  47123. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47124. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47125. */
  47126. class Texture extends BaseTexture {
  47127. /** nearest is mag = nearest and min = nearest and mip = linear */
  47128. static readonly NEAREST_SAMPLINGMODE: number;
  47129. /** nearest is mag = nearest and min = nearest and mip = linear */
  47130. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47131. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47132. static readonly BILINEAR_SAMPLINGMODE: number;
  47133. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47134. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47135. /** Trilinear is mag = linear and min = linear and mip = linear */
  47136. static readonly TRILINEAR_SAMPLINGMODE: number;
  47137. /** Trilinear is mag = linear and min = linear and mip = linear */
  47138. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47139. /** mag = nearest and min = nearest and mip = nearest */
  47140. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47141. /** mag = nearest and min = linear and mip = nearest */
  47142. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47143. /** mag = nearest and min = linear and mip = linear */
  47144. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47145. /** mag = nearest and min = linear and mip = none */
  47146. static readonly NEAREST_LINEAR: number;
  47147. /** mag = nearest and min = nearest and mip = none */
  47148. static readonly NEAREST_NEAREST: number;
  47149. /** mag = linear and min = nearest and mip = nearest */
  47150. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47151. /** mag = linear and min = nearest and mip = linear */
  47152. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47153. /** mag = linear and min = linear and mip = none */
  47154. static readonly LINEAR_LINEAR: number;
  47155. /** mag = linear and min = nearest and mip = none */
  47156. static readonly LINEAR_NEAREST: number;
  47157. /** Explicit coordinates mode */
  47158. static readonly EXPLICIT_MODE: number;
  47159. /** Spherical coordinates mode */
  47160. static readonly SPHERICAL_MODE: number;
  47161. /** Planar coordinates mode */
  47162. static readonly PLANAR_MODE: number;
  47163. /** Cubic coordinates mode */
  47164. static readonly CUBIC_MODE: number;
  47165. /** Projection coordinates mode */
  47166. static readonly PROJECTION_MODE: number;
  47167. /** Inverse Cubic coordinates mode */
  47168. static readonly SKYBOX_MODE: number;
  47169. /** Inverse Cubic coordinates mode */
  47170. static readonly INVCUBIC_MODE: number;
  47171. /** Equirectangular coordinates mode */
  47172. static readonly EQUIRECTANGULAR_MODE: number;
  47173. /** Equirectangular Fixed coordinates mode */
  47174. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47175. /** Equirectangular Fixed Mirrored coordinates mode */
  47176. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47177. /** Texture is not repeating outside of 0..1 UVs */
  47178. static readonly CLAMP_ADDRESSMODE: number;
  47179. /** Texture is repeating outside of 0..1 UVs */
  47180. static readonly WRAP_ADDRESSMODE: number;
  47181. /** Texture is repeating and mirrored */
  47182. static readonly MIRROR_ADDRESSMODE: number;
  47183. /**
  47184. * 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
  47185. */
  47186. static UseSerializedUrlIfAny: boolean;
  47187. /**
  47188. * Define the url of the texture.
  47189. */
  47190. url: Nullable<string>;
  47191. /**
  47192. * Define an offset on the texture to offset the u coordinates of the UVs
  47193. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47194. */
  47195. uOffset: number;
  47196. /**
  47197. * Define an offset on the texture to offset the v coordinates of the UVs
  47198. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47199. */
  47200. vOffset: number;
  47201. /**
  47202. * Define an offset on the texture to scale the u coordinates of the UVs
  47203. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47204. */
  47205. uScale: number;
  47206. /**
  47207. * Define an offset on the texture to scale the v coordinates of the UVs
  47208. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47209. */
  47210. vScale: number;
  47211. /**
  47212. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47213. * @see http://doc.babylonjs.com/how_to/more_materials
  47214. */
  47215. uAng: number;
  47216. /**
  47217. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47218. * @see http://doc.babylonjs.com/how_to/more_materials
  47219. */
  47220. vAng: number;
  47221. /**
  47222. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47223. * @see http://doc.babylonjs.com/how_to/more_materials
  47224. */
  47225. wAng: number;
  47226. /**
  47227. * Defines the center of rotation (U)
  47228. */
  47229. uRotationCenter: number;
  47230. /**
  47231. * Defines the center of rotation (V)
  47232. */
  47233. vRotationCenter: number;
  47234. /**
  47235. * Defines the center of rotation (W)
  47236. */
  47237. wRotationCenter: number;
  47238. /**
  47239. * Are mip maps generated for this texture or not.
  47240. */
  47241. readonly noMipmap: boolean;
  47242. private _noMipmap;
  47243. /** @hidden */
  47244. _invertY: boolean;
  47245. private _rowGenerationMatrix;
  47246. private _cachedTextureMatrix;
  47247. private _projectionModeMatrix;
  47248. private _t0;
  47249. private _t1;
  47250. private _t2;
  47251. private _cachedUOffset;
  47252. private _cachedVOffset;
  47253. private _cachedUScale;
  47254. private _cachedVScale;
  47255. private _cachedUAng;
  47256. private _cachedVAng;
  47257. private _cachedWAng;
  47258. private _cachedProjectionMatrixId;
  47259. private _cachedCoordinatesMode;
  47260. /** @hidden */
  47261. _samplingMode: number;
  47262. /** @hidden */
  47263. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47264. private _deleteBuffer;
  47265. protected _format: Nullable<number>;
  47266. private _delayedOnLoad;
  47267. private _delayedOnError;
  47268. /**
  47269. * Observable triggered once the texture has been loaded.
  47270. */
  47271. onLoadObservable: Observable<Texture>;
  47272. protected _isBlocking: boolean;
  47273. /**
  47274. * Is the texture preventing material to render while loading.
  47275. * If false, a default texture will be used instead of the loading one during the preparation step.
  47276. */
  47277. isBlocking: boolean;
  47278. /**
  47279. * Get the current sampling mode associated with the texture.
  47280. */
  47281. readonly samplingMode: number;
  47282. /**
  47283. * Instantiates a new texture.
  47284. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47285. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47286. * @param url define the url of the picture to load as a texture
  47287. * @param scene define the scene the texture will belong to
  47288. * @param noMipmap define if the texture will require mip maps or not
  47289. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47290. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47291. * @param onLoad define a callback triggered when the texture has been loaded
  47292. * @param onError define a callback triggered when an error occurred during the loading session
  47293. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47294. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47295. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47296. */
  47297. 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);
  47298. /**
  47299. * Update the url (and optional buffer) of this texture if url was null during construction.
  47300. * @param url the url of the texture
  47301. * @param buffer the buffer of the texture (defaults to null)
  47302. */
  47303. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  47304. /**
  47305. * Finish the loading sequence of a texture flagged as delayed load.
  47306. * @hidden
  47307. */
  47308. delayLoad(): void;
  47309. /**
  47310. * Update the sampling mode of the texture.
  47311. * Default is Trilinear mode.
  47312. *
  47313. * | Value | Type | Description |
  47314. * | ----- | ------------------ | ----------- |
  47315. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  47316. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  47317. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  47318. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  47319. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  47320. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  47321. * | 7 | NEAREST_LINEAR | |
  47322. * | 8 | NEAREST_NEAREST | |
  47323. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  47324. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  47325. * | 11 | LINEAR_LINEAR | |
  47326. * | 12 | LINEAR_NEAREST | |
  47327. *
  47328. * > _mag_: magnification filter (close to the viewer)
  47329. * > _min_: minification filter (far from the viewer)
  47330. * > _mip_: filter used between mip map levels
  47331. *@param samplingMode Define the new sampling mode of the texture
  47332. */
  47333. updateSamplingMode(samplingMode: number): void;
  47334. private _prepareRowForTextureGeneration;
  47335. /**
  47336. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  47337. * @returns the transform matrix of the texture.
  47338. */
  47339. getTextureMatrix(): Matrix;
  47340. /**
  47341. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  47342. * @returns The reflection texture transform
  47343. */
  47344. getReflectionTextureMatrix(): Matrix;
  47345. /**
  47346. * Clones the texture.
  47347. * @returns the cloned texture
  47348. */
  47349. clone(): Texture;
  47350. /**
  47351. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47352. * @returns The JSON representation of the texture
  47353. */
  47354. serialize(): any;
  47355. /**
  47356. * Get the current class name of the texture usefull for serialization or dynamic coding.
  47357. * @returns "Texture"
  47358. */
  47359. getClassName(): string;
  47360. /**
  47361. * Dispose the texture and release its associated resources.
  47362. */
  47363. dispose(): void;
  47364. /**
  47365. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  47366. * @param parsedTexture Define the JSON representation of the texture
  47367. * @param scene Define the scene the parsed texture should be instantiated in
  47368. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47369. * @returns The parsed texture if successful
  47370. */
  47371. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  47372. /**
  47373. * Creates a texture from its base 64 representation.
  47374. * @param data Define the base64 payload without the data: prefix
  47375. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47376. * @param scene Define the scene the texture should belong to
  47377. * @param noMipmap Forces the texture to not create mip map information if true
  47378. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47379. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47380. * @param onLoad define a callback triggered when the texture has been loaded
  47381. * @param onError define a callback triggered when an error occurred during the loading session
  47382. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47383. * @returns the created texture
  47384. */
  47385. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  47386. /**
  47387. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  47388. * @param data Define the base64 payload without the data: prefix
  47389. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  47390. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  47391. * @param scene Define the scene the texture should belong to
  47392. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  47393. * @param noMipmap Forces the texture to not create mip map information if true
  47394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  47395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  47396. * @param onLoad define a callback triggered when the texture has been loaded
  47397. * @param onError define a callback triggered when an error occurred during the loading session
  47398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  47399. * @returns the created texture
  47400. */
  47401. 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;
  47402. }
  47403. }
  47404. declare module BABYLON {
  47405. /**
  47406. * Settings for finer control over video usage
  47407. */
  47408. interface VideoTextureSettings {
  47409. /**
  47410. * Applies `autoplay` to video, if specified
  47411. */
  47412. autoPlay?: boolean;
  47413. /**
  47414. * Applies `loop` to video, if specified
  47415. */
  47416. loop?: boolean;
  47417. /**
  47418. * Automatically updates internal texture from video at every frame in the render loop
  47419. */
  47420. autoUpdateTexture: boolean;
  47421. /**
  47422. * Image src displayed during the video loading or until the user interacts with the video.
  47423. */
  47424. poster?: string;
  47425. }
  47426. /**
  47427. * If you want to display a video in your scene, this is the special texture for that.
  47428. * This special texture works similar to other textures, with the exception of a few parameters.
  47429. * @see https://doc.babylonjs.com/how_to/video_texture
  47430. */
  47431. class VideoTexture extends Texture {
  47432. /**
  47433. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  47434. */
  47435. readonly autoUpdateTexture: boolean;
  47436. /**
  47437. * The video instance used by the texture internally
  47438. */
  47439. readonly video: HTMLVideoElement;
  47440. private _onUserActionRequestedObservable;
  47441. /**
  47442. * Event triggerd when a dom action is required by the user to play the video.
  47443. * This happens due to recent changes in browser policies preventing video to auto start.
  47444. */
  47445. readonly onUserActionRequestedObservable: Observable<Texture>;
  47446. private _generateMipMaps;
  47447. private _engine;
  47448. private _stillImageCaptured;
  47449. private _poster;
  47450. /**
  47451. * Creates a video texture.
  47452. * If you want to display a video in your scene, this is the special texture for that.
  47453. * This special texture works similar to other textures, with the exception of a few parameters.
  47454. * @see https://doc.babylonjs.com/how_to/video_texture
  47455. * @param name optional name, will detect from video source, if not defined
  47456. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  47457. * @param scene is obviously the current scene.
  47458. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  47459. * @param invertY is false by default but can be used to invert video on Y axis
  47460. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  47461. * @param settings allows finer control over video usage
  47462. */
  47463. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  47464. private _getName;
  47465. private _getVideo;
  47466. private _createInternalTexture;
  47467. private reset;
  47468. /**
  47469. * @hidden Internal method to initiate `update`.
  47470. */
  47471. _rebuild(): void;
  47472. /**
  47473. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  47474. */
  47475. update(): void;
  47476. /**
  47477. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  47478. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  47479. */
  47480. updateTexture(isVisible: boolean): void;
  47481. protected _updateInternalTexture: (e?: Event | undefined) => void;
  47482. /**
  47483. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  47484. * @param url New url.
  47485. */
  47486. updateURL(url: string): void;
  47487. /**
  47488. * Dispose the texture and release its associated resources.
  47489. */
  47490. dispose(): void;
  47491. /**
  47492. * Creates a video texture straight from your WebCam video feed.
  47493. * @param scene Define the scene the texture should be created in
  47494. * @param onReady Define a callback to triggered once the texture will be ready
  47495. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  47496. */
  47497. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  47498. minWidth: number;
  47499. maxWidth: number;
  47500. minHeight: number;
  47501. maxHeight: number;
  47502. deviceId: string;
  47503. }): void;
  47504. }
  47505. }
  47506. declare var DracoDecoderModule: any;
  47507. declare var WebAssembly: any;
  47508. declare module BABYLON {
  47509. /**
  47510. * Configuration for Draco compression
  47511. */
  47512. interface IDracoCompressionConfiguration {
  47513. /**
  47514. * Configuration for the decoder.
  47515. */
  47516. decoder?: {
  47517. /**
  47518. * The url to the WebAssembly module.
  47519. */
  47520. wasmUrl?: string;
  47521. /**
  47522. * The url to the WebAssembly binary.
  47523. */
  47524. wasmBinaryUrl?: string;
  47525. /**
  47526. * The url to the fallback JavaScript module.
  47527. */
  47528. fallbackUrl?: string;
  47529. };
  47530. }
  47531. /**
  47532. * Draco compression (https://google.github.io/draco/)
  47533. *
  47534. * This class wraps the Draco module.
  47535. *
  47536. * **Encoder**
  47537. *
  47538. * The encoder is not currently implemented.
  47539. *
  47540. * **Decoder**
  47541. *
  47542. * 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.
  47543. *
  47544. * To update the configuration, use the following code:
  47545. * ```javascript
  47546. * BABYLON.DracoCompression.Configuration = {
  47547. * decoder: {
  47548. * wasmUrl: "<url to the WebAssembly library>",
  47549. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  47550. * fallbackUrl: "<url to the fallback JavaScript library>",
  47551. * }
  47552. * };
  47553. * ```
  47554. *
  47555. * 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.
  47556. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  47557. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  47558. *
  47559. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  47560. * ```javascript
  47561. * var dracoCompression = new BABYLON.DracoCompression();
  47562. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  47563. * [BABYLON.VertexBuffer.PositionKind]: 0
  47564. * });
  47565. * ```
  47566. *
  47567. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  47568. */
  47569. class DracoCompression implements IDisposable {
  47570. private static _DecoderModulePromise;
  47571. /**
  47572. * The configuration. Defaults to the following urls:
  47573. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  47574. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  47575. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  47576. */
  47577. static Configuration: IDracoCompressionConfiguration;
  47578. /**
  47579. * Returns true if the decoder is available.
  47580. */
  47581. static readonly DecoderAvailable: boolean;
  47582. /**
  47583. * Constructor
  47584. */
  47585. constructor();
  47586. /**
  47587. * Stop all async operations and release resources.
  47588. */
  47589. dispose(): void;
  47590. /**
  47591. * Decode Draco compressed mesh data to vertex data.
  47592. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  47593. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  47594. * @returns A promise that resolves with the decoded vertex data
  47595. */
  47596. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  47597. [kind: string]: number;
  47598. }): Promise<VertexData>;
  47599. private static _GetDecoderModule;
  47600. private static _LoadScriptAsync;
  47601. private static _LoadFileAsync;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. /**
  47606. * Particle emitter emitting particles from the inside of a box.
  47607. * It emits the particles randomly between 2 given directions.
  47608. */
  47609. class BoxParticleEmitter implements IParticleEmitterType {
  47610. /**
  47611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47612. */
  47613. direction1: Vector3;
  47614. /**
  47615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  47616. */
  47617. direction2: Vector3;
  47618. /**
  47619. * 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.
  47620. */
  47621. minEmitBox: Vector3;
  47622. /**
  47623. * 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.
  47624. */
  47625. maxEmitBox: Vector3;
  47626. /**
  47627. * Creates a new instance BoxParticleEmitter
  47628. */
  47629. constructor();
  47630. /**
  47631. * Called by the particle System when the direction is computed for the created particle.
  47632. * @param worldMatrix is the world matrix of the particle system
  47633. * @param directionToUpdate is the direction vector to update with the result
  47634. * @param particle is the particle we are computed the direction for
  47635. */
  47636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47637. /**
  47638. * Called by the particle System when the position is computed for the created particle.
  47639. * @param worldMatrix is the world matrix of the particle system
  47640. * @param positionToUpdate is the position vector to update with the result
  47641. * @param particle is the particle we are computed the position for
  47642. */
  47643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47644. /**
  47645. * Clones the current emitter and returns a copy of it
  47646. * @returns the new emitter
  47647. */
  47648. clone(): BoxParticleEmitter;
  47649. /**
  47650. * Called by the GPUParticleSystem to setup the update shader
  47651. * @param effect defines the update shader
  47652. */
  47653. applyToShader(effect: Effect): void;
  47654. /**
  47655. * Returns a string to use to update the GPU particles update shader
  47656. * @returns a string containng the defines string
  47657. */
  47658. getEffectDefines(): string;
  47659. /**
  47660. * Returns the string "BoxParticleEmitter"
  47661. * @returns a string containing the class name
  47662. */
  47663. getClassName(): string;
  47664. /**
  47665. * Serializes the particle system to a JSON object.
  47666. * @returns the JSON object
  47667. */
  47668. serialize(): any;
  47669. /**
  47670. * Parse properties from a JSON object
  47671. * @param serializationObject defines the JSON object
  47672. */
  47673. parse(serializationObject: any): void;
  47674. }
  47675. }
  47676. declare module BABYLON {
  47677. /**
  47678. * Particle emitter emitting particles from the inside of a cone.
  47679. * It emits the particles alongside the cone volume from the base to the particle.
  47680. * The emission direction might be randomized.
  47681. */
  47682. class ConeParticleEmitter implements IParticleEmitterType {
  47683. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47684. directionRandomizer: number;
  47685. private _radius;
  47686. private _angle;
  47687. private _height;
  47688. /**
  47689. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  47690. */
  47691. radiusRange: number;
  47692. /**
  47693. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  47694. */
  47695. heightRange: number;
  47696. /**
  47697. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  47698. */
  47699. emitFromSpawnPointOnly: boolean;
  47700. /**
  47701. * Gets or sets the radius of the emission cone
  47702. */
  47703. radius: number;
  47704. /**
  47705. * Gets or sets the angle of the emission cone
  47706. */
  47707. angle: number;
  47708. private _buildHeight;
  47709. /**
  47710. * Creates a new instance ConeParticleEmitter
  47711. * @param radius the radius of the emission cone (1 by default)
  47712. * @param angles the cone base angle (PI by default)
  47713. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  47714. */
  47715. constructor(radius?: number, angle?: number,
  47716. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  47717. directionRandomizer?: number);
  47718. /**
  47719. * Called by the particle System when the direction is computed for the created particle.
  47720. * @param worldMatrix is the world matrix of the particle system
  47721. * @param directionToUpdate is the direction vector to update with the result
  47722. * @param particle is the particle we are computed the direction for
  47723. */
  47724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47725. /**
  47726. * Called by the particle System when the position is computed for the created particle.
  47727. * @param worldMatrix is the world matrix of the particle system
  47728. * @param positionToUpdate is the position vector to update with the result
  47729. * @param particle is the particle we are computed the position for
  47730. */
  47731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47732. /**
  47733. * Clones the current emitter and returns a copy of it
  47734. * @returns the new emitter
  47735. */
  47736. clone(): ConeParticleEmitter;
  47737. /**
  47738. * Called by the GPUParticleSystem to setup the update shader
  47739. * @param effect defines the update shader
  47740. */
  47741. applyToShader(effect: Effect): void;
  47742. /**
  47743. * Returns a string to use to update the GPU particles update shader
  47744. * @returns a string containng the defines string
  47745. */
  47746. getEffectDefines(): string;
  47747. /**
  47748. * Returns the string "ConeParticleEmitter"
  47749. * @returns a string containing the class name
  47750. */
  47751. getClassName(): string;
  47752. /**
  47753. * Serializes the particle system to a JSON object.
  47754. * @returns the JSON object
  47755. */
  47756. serialize(): any;
  47757. /**
  47758. * Parse properties from a JSON object
  47759. * @param serializationObject defines the JSON object
  47760. */
  47761. parse(serializationObject: any): void;
  47762. }
  47763. }
  47764. declare module BABYLON {
  47765. /**
  47766. * Particle emitter emitting particles from the inside of a cylinder.
  47767. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  47768. */
  47769. class CylinderParticleEmitter implements IParticleEmitterType {
  47770. /**
  47771. * The radius of the emission cylinder.
  47772. */
  47773. radius: number;
  47774. /**
  47775. * The height of the emission cylinder.
  47776. */
  47777. height: number;
  47778. /**
  47779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47780. */
  47781. radiusRange: number;
  47782. /**
  47783. * How much to randomize the particle direction [0-1].
  47784. */
  47785. directionRandomizer: number;
  47786. /**
  47787. * Creates a new instance CylinderParticleEmitter
  47788. * @param radius the radius of the emission cylinder (1 by default)
  47789. * @param height the height of the emission cylinder (1 by default)
  47790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47791. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47792. */
  47793. constructor(
  47794. /**
  47795. * The radius of the emission cylinder.
  47796. */
  47797. radius?: number,
  47798. /**
  47799. * The height of the emission cylinder.
  47800. */
  47801. height?: number,
  47802. /**
  47803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47804. */
  47805. radiusRange?: number,
  47806. /**
  47807. * How much to randomize the particle direction [0-1].
  47808. */
  47809. directionRandomizer?: number);
  47810. /**
  47811. * Called by the particle System when the direction is computed for the created particle.
  47812. * @param worldMatrix is the world matrix of the particle system
  47813. * @param directionToUpdate is the direction vector to update with the result
  47814. * @param particle is the particle we are computed the direction for
  47815. */
  47816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47817. /**
  47818. * Called by the particle System when the position is computed for the created particle.
  47819. * @param worldMatrix is the world matrix of the particle system
  47820. * @param positionToUpdate is the position vector to update with the result
  47821. * @param particle is the particle we are computed the position for
  47822. */
  47823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47824. /**
  47825. * Clones the current emitter and returns a copy of it
  47826. * @returns the new emitter
  47827. */
  47828. clone(): CylinderParticleEmitter;
  47829. /**
  47830. * Called by the GPUParticleSystem to setup the update shader
  47831. * @param effect defines the update shader
  47832. */
  47833. applyToShader(effect: Effect): void;
  47834. /**
  47835. * Returns a string to use to update the GPU particles update shader
  47836. * @returns a string containng the defines string
  47837. */
  47838. getEffectDefines(): string;
  47839. /**
  47840. * Returns the string "CylinderParticleEmitter"
  47841. * @returns a string containing the class name
  47842. */
  47843. getClassName(): string;
  47844. /**
  47845. * Serializes the particle system to a JSON object.
  47846. * @returns the JSON object
  47847. */
  47848. serialize(): any;
  47849. /**
  47850. * Parse properties from a JSON object
  47851. * @param serializationObject defines the JSON object
  47852. */
  47853. parse(serializationObject: any): void;
  47854. }
  47855. /**
  47856. * Particle emitter emitting particles from the inside of a cylinder.
  47857. * It emits the particles randomly between two vectors.
  47858. */
  47859. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  47860. /**
  47861. * The min limit of the emission direction.
  47862. */
  47863. direction1: Vector3;
  47864. /**
  47865. * The max limit of the emission direction.
  47866. */
  47867. direction2: Vector3;
  47868. /**
  47869. * Creates a new instance CylinderDirectedParticleEmitter
  47870. * @param radius the radius of the emission cylinder (1 by default)
  47871. * @param height the height of the emission cylinder (1 by default)
  47872. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47873. * @param direction1 the min limit of the emission direction (up vector by default)
  47874. * @param direction2 the max limit of the emission direction (up vector by default)
  47875. */
  47876. constructor(radius?: number, height?: number, radiusRange?: number,
  47877. /**
  47878. * The min limit of the emission direction.
  47879. */
  47880. direction1?: Vector3,
  47881. /**
  47882. * The max limit of the emission direction.
  47883. */
  47884. direction2?: Vector3);
  47885. /**
  47886. * Called by the particle System when the direction is computed for the created particle.
  47887. * @param worldMatrix is the world matrix of the particle system
  47888. * @param directionToUpdate is the direction vector to update with the result
  47889. * @param particle is the particle we are computed the direction for
  47890. */
  47891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47892. /**
  47893. * Clones the current emitter and returns a copy of it
  47894. * @returns the new emitter
  47895. */
  47896. clone(): CylinderDirectedParticleEmitter;
  47897. /**
  47898. * Called by the GPUParticleSystem to setup the update shader
  47899. * @param effect defines the update shader
  47900. */
  47901. applyToShader(effect: Effect): void;
  47902. /**
  47903. * Returns a string to use to update the GPU particles update shader
  47904. * @returns a string containng the defines string
  47905. */
  47906. getEffectDefines(): string;
  47907. /**
  47908. * Returns the string "CylinderDirectedParticleEmitter"
  47909. * @returns a string containing the class name
  47910. */
  47911. getClassName(): string;
  47912. /**
  47913. * Serializes the particle system to a JSON object.
  47914. * @returns the JSON object
  47915. */
  47916. serialize(): any;
  47917. /**
  47918. * Parse properties from a JSON object
  47919. * @param serializationObject defines the JSON object
  47920. */
  47921. parse(serializationObject: any): void;
  47922. }
  47923. }
  47924. declare module BABYLON {
  47925. /**
  47926. * Particle emitter emitting particles from the inside of a hemisphere.
  47927. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  47928. */
  47929. class HemisphericParticleEmitter implements IParticleEmitterType {
  47930. /**
  47931. * The radius of the emission hemisphere.
  47932. */
  47933. radius: number;
  47934. /**
  47935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47936. */
  47937. radiusRange: number;
  47938. /**
  47939. * How much to randomize the particle direction [0-1].
  47940. */
  47941. directionRandomizer: number;
  47942. /**
  47943. * Creates a new instance HemisphericParticleEmitter
  47944. * @param radius the radius of the emission hemisphere (1 by default)
  47945. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  47946. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  47947. */
  47948. constructor(
  47949. /**
  47950. * The radius of the emission hemisphere.
  47951. */
  47952. radius?: number,
  47953. /**
  47954. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  47955. */
  47956. radiusRange?: number,
  47957. /**
  47958. * How much to randomize the particle direction [0-1].
  47959. */
  47960. directionRandomizer?: number);
  47961. /**
  47962. * Called by the particle System when the direction is computed for the created particle.
  47963. * @param worldMatrix is the world matrix of the particle system
  47964. * @param directionToUpdate is the direction vector to update with the result
  47965. * @param particle is the particle we are computed the direction for
  47966. */
  47967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  47968. /**
  47969. * Called by the particle System when the position is computed for the created particle.
  47970. * @param worldMatrix is the world matrix of the particle system
  47971. * @param positionToUpdate is the position vector to update with the result
  47972. * @param particle is the particle we are computed the position for
  47973. */
  47974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  47975. /**
  47976. * Clones the current emitter and returns a copy of it
  47977. * @returns the new emitter
  47978. */
  47979. clone(): HemisphericParticleEmitter;
  47980. /**
  47981. * Called by the GPUParticleSystem to setup the update shader
  47982. * @param effect defines the update shader
  47983. */
  47984. applyToShader(effect: Effect): void;
  47985. /**
  47986. * Returns a string to use to update the GPU particles update shader
  47987. * @returns a string containng the defines string
  47988. */
  47989. getEffectDefines(): string;
  47990. /**
  47991. * Returns the string "HemisphericParticleEmitter"
  47992. * @returns a string containing the class name
  47993. */
  47994. getClassName(): string;
  47995. /**
  47996. * Serializes the particle system to a JSON object.
  47997. * @returns the JSON object
  47998. */
  47999. serialize(): any;
  48000. /**
  48001. * Parse properties from a JSON object
  48002. * @param serializationObject defines the JSON object
  48003. */
  48004. parse(serializationObject: any): void;
  48005. }
  48006. }
  48007. declare module BABYLON {
  48008. /**
  48009. * Particle emitter represents a volume emitting particles.
  48010. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48011. */
  48012. interface IParticleEmitterType {
  48013. /**
  48014. * Called by the particle System when the direction is computed for the created particle.
  48015. * @param worldMatrix is the world matrix of the particle system
  48016. * @param directionToUpdate is the direction vector to update with the result
  48017. * @param particle is the particle we are computed the direction for
  48018. */
  48019. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48020. /**
  48021. * Called by the particle System when the position is computed for the created particle.
  48022. * @param worldMatrix is the world matrix of the particle system
  48023. * @param positionToUpdate is the position vector to update with the result
  48024. * @param particle is the particle we are computed the position for
  48025. */
  48026. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48027. /**
  48028. * Clones the current emitter and returns a copy of it
  48029. * @returns the new emitter
  48030. */
  48031. clone(): IParticleEmitterType;
  48032. /**
  48033. * Called by the GPUParticleSystem to setup the update shader
  48034. * @param effect defines the update shader
  48035. */
  48036. applyToShader(effect: Effect): void;
  48037. /**
  48038. * Returns a string to use to update the GPU particles update shader
  48039. * @returns the effect defines string
  48040. */
  48041. getEffectDefines(): string;
  48042. /**
  48043. * Returns a string representing the class name
  48044. * @returns a string containing the class name
  48045. */
  48046. getClassName(): string;
  48047. /**
  48048. * Serializes the particle system to a JSON object.
  48049. * @returns the JSON object
  48050. */
  48051. serialize(): any;
  48052. /**
  48053. * Parse properties from a JSON object
  48054. * @param serializationObject defines the JSON object
  48055. */
  48056. parse(serializationObject: any): void;
  48057. }
  48058. }
  48059. declare module BABYLON {
  48060. /**
  48061. * Particle emitter emitting particles from a point.
  48062. * It emits the particles randomly between 2 given directions.
  48063. */
  48064. class PointParticleEmitter implements IParticleEmitterType {
  48065. /**
  48066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48067. */
  48068. direction1: Vector3;
  48069. /**
  48070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48071. */
  48072. direction2: Vector3;
  48073. /**
  48074. * Creates a new instance PointParticleEmitter
  48075. */
  48076. constructor();
  48077. /**
  48078. * Called by the particle System when the direction is computed for the created particle.
  48079. * @param worldMatrix is the world matrix of the particle system
  48080. * @param directionToUpdate is the direction vector to update with the result
  48081. * @param particle is the particle we are computed the direction for
  48082. */
  48083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48084. /**
  48085. * Called by the particle System when the position is computed for the created particle.
  48086. * @param worldMatrix is the world matrix of the particle system
  48087. * @param positionToUpdate is the position vector to update with the result
  48088. * @param particle is the particle we are computed the position for
  48089. */
  48090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48091. /**
  48092. * Clones the current emitter and returns a copy of it
  48093. * @returns the new emitter
  48094. */
  48095. clone(): PointParticleEmitter;
  48096. /**
  48097. * Called by the GPUParticleSystem to setup the update shader
  48098. * @param effect defines the update shader
  48099. */
  48100. applyToShader(effect: Effect): void;
  48101. /**
  48102. * Returns a string to use to update the GPU particles update shader
  48103. * @returns a string containng the defines string
  48104. */
  48105. getEffectDefines(): string;
  48106. /**
  48107. * Returns the string "PointParticleEmitter"
  48108. * @returns a string containing the class name
  48109. */
  48110. getClassName(): string;
  48111. /**
  48112. * Serializes the particle system to a JSON object.
  48113. * @returns the JSON object
  48114. */
  48115. serialize(): any;
  48116. /**
  48117. * Parse properties from a JSON object
  48118. * @param serializationObject defines the JSON object
  48119. */
  48120. parse(serializationObject: any): void;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Particle emitter emitting particles from the inside of a sphere.
  48126. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48127. */
  48128. class SphereParticleEmitter implements IParticleEmitterType {
  48129. /**
  48130. * The radius of the emission sphere.
  48131. */
  48132. radius: number;
  48133. /**
  48134. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48135. */
  48136. radiusRange: number;
  48137. /**
  48138. * How much to randomize the particle direction [0-1].
  48139. */
  48140. directionRandomizer: number;
  48141. /**
  48142. * Creates a new instance SphereParticleEmitter
  48143. * @param radius the radius of the emission sphere (1 by default)
  48144. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48145. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48146. */
  48147. constructor(
  48148. /**
  48149. * The radius of the emission sphere.
  48150. */
  48151. radius?: number,
  48152. /**
  48153. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48154. */
  48155. radiusRange?: number,
  48156. /**
  48157. * How much to randomize the particle direction [0-1].
  48158. */
  48159. directionRandomizer?: number);
  48160. /**
  48161. * Called by the particle System when the direction is computed for the created particle.
  48162. * @param worldMatrix is the world matrix of the particle system
  48163. * @param directionToUpdate is the direction vector to update with the result
  48164. * @param particle is the particle we are computed the direction for
  48165. */
  48166. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48167. /**
  48168. * Called by the particle System when the position is computed for the created particle.
  48169. * @param worldMatrix is the world matrix of the particle system
  48170. * @param positionToUpdate is the position vector to update with the result
  48171. * @param particle is the particle we are computed the position for
  48172. */
  48173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48174. /**
  48175. * Clones the current emitter and returns a copy of it
  48176. * @returns the new emitter
  48177. */
  48178. clone(): SphereParticleEmitter;
  48179. /**
  48180. * Called by the GPUParticleSystem to setup the update shader
  48181. * @param effect defines the update shader
  48182. */
  48183. applyToShader(effect: Effect): void;
  48184. /**
  48185. * Returns a string to use to update the GPU particles update shader
  48186. * @returns a string containng the defines string
  48187. */
  48188. getEffectDefines(): string;
  48189. /**
  48190. * Returns the string "SphereParticleEmitter"
  48191. * @returns a string containing the class name
  48192. */
  48193. getClassName(): string;
  48194. /**
  48195. * Serializes the particle system to a JSON object.
  48196. * @returns the JSON object
  48197. */
  48198. serialize(): any;
  48199. /**
  48200. * Parse properties from a JSON object
  48201. * @param serializationObject defines the JSON object
  48202. */
  48203. parse(serializationObject: any): void;
  48204. }
  48205. /**
  48206. * Particle emitter emitting particles from the inside of a sphere.
  48207. * It emits the particles randomly between two vectors.
  48208. */
  48209. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48210. /**
  48211. * The min limit of the emission direction.
  48212. */
  48213. direction1: Vector3;
  48214. /**
  48215. * The max limit of the emission direction.
  48216. */
  48217. direction2: Vector3;
  48218. /**
  48219. * Creates a new instance SphereDirectedParticleEmitter
  48220. * @param radius the radius of the emission sphere (1 by default)
  48221. * @param direction1 the min limit of the emission direction (up vector by default)
  48222. * @param direction2 the max limit of the emission direction (up vector by default)
  48223. */
  48224. constructor(radius?: number,
  48225. /**
  48226. * The min limit of the emission direction.
  48227. */
  48228. direction1?: Vector3,
  48229. /**
  48230. * The max limit of the emission direction.
  48231. */
  48232. direction2?: Vector3);
  48233. /**
  48234. * Called by the particle System when the direction is computed for the created particle.
  48235. * @param worldMatrix is the world matrix of the particle system
  48236. * @param directionToUpdate is the direction vector to update with the result
  48237. * @param particle is the particle we are computed the direction for
  48238. */
  48239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48240. /**
  48241. * Clones the current emitter and returns a copy of it
  48242. * @returns the new emitter
  48243. */
  48244. clone(): SphereDirectedParticleEmitter;
  48245. /**
  48246. * Called by the GPUParticleSystem to setup the update shader
  48247. * @param effect defines the update shader
  48248. */
  48249. applyToShader(effect: Effect): void;
  48250. /**
  48251. * Returns a string to use to update the GPU particles update shader
  48252. * @returns a string containng the defines string
  48253. */
  48254. getEffectDefines(): string;
  48255. /**
  48256. * Returns the string "SphereDirectedParticleEmitter"
  48257. * @returns a string containing the class name
  48258. */
  48259. getClassName(): string;
  48260. /**
  48261. * Serializes the particle system to a JSON object.
  48262. * @returns the JSON object
  48263. */
  48264. serialize(): any;
  48265. /**
  48266. * Parse properties from a JSON object
  48267. * @param serializationObject defines the JSON object
  48268. */
  48269. parse(serializationObject: any): void;
  48270. }
  48271. }
  48272. declare module BABYLON {
  48273. /** @hidden */
  48274. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48275. private _useDeltaForWorldStep;
  48276. world: any;
  48277. name: string;
  48278. private _physicsMaterials;
  48279. private _fixedTimeStep;
  48280. BJSCANNON: any;
  48281. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  48282. setGravity(gravity: Vector3): void;
  48283. setTimeStep(timeStep: number): void;
  48284. getTimeStep(): number;
  48285. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48286. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48287. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48289. private _processChildMeshes;
  48290. removePhysicsBody(impostor: PhysicsImpostor): void;
  48291. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48292. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48293. private _addMaterial;
  48294. private _checkWithEpsilon;
  48295. private _createShape;
  48296. private _createHeightmap;
  48297. private _minus90X;
  48298. private _plus90X;
  48299. private _tmpPosition;
  48300. private _tmpDeltaPosition;
  48301. private _tmpUnityRotation;
  48302. private _updatePhysicsBodyTransformation;
  48303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48305. isSupported(): boolean;
  48306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48308. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48309. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48310. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48311. getBodyMass(impostor: PhysicsImpostor): number;
  48312. getBodyFriction(impostor: PhysicsImpostor): number;
  48313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48314. getBodyRestitution(impostor: PhysicsImpostor): number;
  48315. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48316. sleepBody(impostor: PhysicsImpostor): void;
  48317. wakeUpBody(impostor: PhysicsImpostor): void;
  48318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48319. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48322. getRadius(impostor: PhysicsImpostor): number;
  48323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48324. dispose(): void;
  48325. private _extendNamespace;
  48326. }
  48327. }
  48328. declare module BABYLON {
  48329. /** @hidden */
  48330. class OimoJSPlugin implements IPhysicsEnginePlugin {
  48331. world: any;
  48332. name: string;
  48333. BJSOIMO: any;
  48334. constructor(iterations?: number);
  48335. setGravity(gravity: Vector3): void;
  48336. setTimeStep(timeStep: number): void;
  48337. getTimeStep(): number;
  48338. private _tmpImpostorsArray;
  48339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48343. private _tmpPositionVector;
  48344. removePhysicsBody(impostor: PhysicsImpostor): void;
  48345. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48346. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48347. isSupported(): boolean;
  48348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48350. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48352. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48353. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48354. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48355. getBodyMass(impostor: PhysicsImpostor): number;
  48356. getBodyFriction(impostor: PhysicsImpostor): number;
  48357. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48358. getBodyRestitution(impostor: PhysicsImpostor): number;
  48359. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48360. sleepBody(impostor: PhysicsImpostor): void;
  48361. wakeUpBody(impostor: PhysicsImpostor): void;
  48362. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48363. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  48364. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48365. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48366. getRadius(impostor: PhysicsImpostor): number;
  48367. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48368. dispose(): void;
  48369. }
  48370. }
  48371. declare module BABYLON {
  48372. /**
  48373. * This represents a set of one or more post processes in Babylon.
  48374. * A post process can be used to apply a shader to a texture after it is rendered.
  48375. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48376. */
  48377. class PostProcessRenderEffect {
  48378. private _postProcesses;
  48379. private _getPostProcesses;
  48380. private _singleInstance;
  48381. private _cameras;
  48382. private _indicesForCamera;
  48383. /**
  48384. * Name of the effect
  48385. * @hidden
  48386. */
  48387. _name: string;
  48388. /**
  48389. * Instantiates a post process render effect.
  48390. * A post process can be used to apply a shader to a texture after it is rendered.
  48391. * @param engine The engine the effect is tied to
  48392. * @param name The name of the effect
  48393. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  48394. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  48395. */
  48396. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  48397. /**
  48398. * Checks if all the post processes in the effect are supported.
  48399. */
  48400. readonly isSupported: boolean;
  48401. /**
  48402. * Updates the current state of the effect
  48403. * @hidden
  48404. */
  48405. _update(): void;
  48406. /**
  48407. * Attaches the effect on cameras
  48408. * @param cameras The camera to attach to.
  48409. * @hidden
  48410. */
  48411. _attachCameras(cameras: Camera): void;
  48412. /**
  48413. * Attaches the effect on cameras
  48414. * @param cameras The camera to attach to.
  48415. * @hidden
  48416. */
  48417. _attachCameras(cameras: Camera[]): void;
  48418. /**
  48419. * Detatches the effect on cameras
  48420. * @param cameras The camera to detatch from.
  48421. * @hidden
  48422. */
  48423. _detachCameras(cameras: Camera): void;
  48424. /**
  48425. * Detatches the effect on cameras
  48426. * @param cameras The camera to detatch from.
  48427. * @hidden
  48428. */
  48429. _detachCameras(cameras: Camera[]): void;
  48430. /**
  48431. * Enables the effect on given cameras
  48432. * @param cameras The camera to enable.
  48433. * @hidden
  48434. */
  48435. _enable(cameras: Camera): void;
  48436. /**
  48437. * Enables the effect on given cameras
  48438. * @param cameras The camera to enable.
  48439. * @hidden
  48440. */
  48441. _enable(cameras: Nullable<Camera[]>): void;
  48442. /**
  48443. * Disables the effect on the given cameras
  48444. * @param cameras The camera to disable.
  48445. * @hidden
  48446. */
  48447. _disable(cameras: Camera): void;
  48448. /**
  48449. * Disables the effect on the given cameras
  48450. * @param cameras The camera to disable.
  48451. * @hidden
  48452. */
  48453. _disable(cameras: Nullable<Camera[]>): void;
  48454. /**
  48455. * Gets a list of the post processes contained in the effect.
  48456. * @param camera The camera to get the post processes on.
  48457. * @returns The list of the post processes in the effect.
  48458. */
  48459. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  48460. }
  48461. }
  48462. declare module BABYLON {
  48463. /**
  48464. * PostProcessRenderPipeline
  48465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48466. */
  48467. class PostProcessRenderPipeline {
  48468. private engine;
  48469. private _renderEffects;
  48470. private _renderEffectsForIsolatedPass;
  48471. /**
  48472. * @hidden
  48473. */
  48474. protected _cameras: Camera[];
  48475. /** @hidden */
  48476. _name: string;
  48477. /**
  48478. * Initializes a PostProcessRenderPipeline
  48479. * @param engine engine to add the pipeline to
  48480. * @param name name of the pipeline
  48481. */
  48482. constructor(engine: Engine, name: string);
  48483. /**
  48484. * "PostProcessRenderPipeline"
  48485. * @returns "PostProcessRenderPipeline"
  48486. */
  48487. getClassName(): string;
  48488. /**
  48489. * If all the render effects in the pipeline are support
  48490. */
  48491. readonly isSupported: boolean;
  48492. /**
  48493. * Adds an effect to the pipeline
  48494. * @param renderEffect the effect to add
  48495. */
  48496. addEffect(renderEffect: PostProcessRenderEffect): void;
  48497. /** @hidden */
  48498. _rebuild(): void;
  48499. /** @hidden */
  48500. _enableEffect(renderEffectName: string, cameras: Camera): void;
  48501. /** @hidden */
  48502. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  48503. /** @hidden */
  48504. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48505. /** @hidden */
  48506. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  48507. /** @hidden */
  48508. _attachCameras(cameras: Camera, unique: boolean): void;
  48509. /** @hidden */
  48510. _attachCameras(cameras: Camera[], unique: boolean): void;
  48511. /** @hidden */
  48512. _detachCameras(cameras: Camera): void;
  48513. /** @hidden */
  48514. _detachCameras(cameras: Nullable<Camera[]>): void;
  48515. /** @hidden */
  48516. _update(): void;
  48517. /** @hidden */
  48518. _reset(): void;
  48519. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  48520. /**
  48521. * Disposes of the pipeline
  48522. */
  48523. dispose(): void;
  48524. }
  48525. }
  48526. declare module BABYLON {
  48527. /**
  48528. * PostProcessRenderPipelineManager class
  48529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48530. */
  48531. class PostProcessRenderPipelineManager {
  48532. private _renderPipelines;
  48533. /**
  48534. * Initializes a PostProcessRenderPipelineManager
  48535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48536. */
  48537. constructor();
  48538. /**
  48539. * Adds a pipeline to the manager
  48540. * @param renderPipeline The pipeline to add
  48541. */
  48542. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  48543. /**
  48544. * Attaches a camera to the pipeline
  48545. * @param renderPipelineName The name of the pipeline to attach to
  48546. * @param cameras the camera to attach
  48547. * @param unique if the camera can be attached multiple times to the pipeline
  48548. */
  48549. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  48550. /**
  48551. * Detaches a camera from the pipeline
  48552. * @param renderPipelineName The name of the pipeline to detach from
  48553. * @param cameras the camera to detach
  48554. */
  48555. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  48556. /**
  48557. * Enables an effect by name on a pipeline
  48558. * @param renderPipelineName the name of the pipeline to enable the effect in
  48559. * @param renderEffectName the name of the effect to enable
  48560. * @param cameras the cameras that the effect should be enabled on
  48561. */
  48562. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48563. /**
  48564. * Disables an effect by name on a pipeline
  48565. * @param renderPipelineName the name of the pipeline to disable the effect in
  48566. * @param renderEffectName the name of the effect to disable
  48567. * @param cameras the cameras that the effect should be disabled on
  48568. */
  48569. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  48570. /**
  48571. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  48572. */
  48573. update(): void;
  48574. /** @hidden */
  48575. _rebuild(): void;
  48576. /**
  48577. * Disposes of the manager and pipelines
  48578. */
  48579. dispose(): void;
  48580. }
  48581. }
  48582. declare module BABYLON {
  48583. interface Scene {
  48584. /** @hidden (Backing field) */
  48585. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48586. /**
  48587. * Gets the postprocess render pipeline manager
  48588. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  48589. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  48590. */
  48591. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  48592. }
  48593. /**
  48594. * Defines the Render Pipeline scene component responsible to rendering pipelines
  48595. */
  48596. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  48597. /**
  48598. * The component name helpfull to identify the component in the list of scene components.
  48599. */
  48600. readonly name: string;
  48601. /**
  48602. * The scene the component belongs to.
  48603. */
  48604. scene: Scene;
  48605. /**
  48606. * Creates a new instance of the component for the given scene
  48607. * @param scene Defines the scene to register the component in
  48608. */
  48609. constructor(scene: Scene);
  48610. /**
  48611. * Registers the component in a given scene
  48612. */
  48613. register(): void;
  48614. /**
  48615. * Rebuilds the elements related to this component in case of
  48616. * context lost for instance.
  48617. */
  48618. rebuild(): void;
  48619. /**
  48620. * Disposes the component and the associated ressources
  48621. */
  48622. dispose(): void;
  48623. private _gatherRenderTargets;
  48624. }
  48625. }
  48626. declare module BABYLON {
  48627. /**
  48628. * Helper class dealing with the extraction of spherical polynomial dataArray
  48629. * from a cube map.
  48630. */
  48631. class CubeMapToSphericalPolynomialTools {
  48632. private static FileFaces;
  48633. /**
  48634. * Converts a texture to the according Spherical Polynomial data.
  48635. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48636. *
  48637. * @param texture The texture to extract the information from.
  48638. * @return The Spherical Polynomial data.
  48639. */
  48640. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48641. /**
  48642. * Converts a cubemap to the according Spherical Polynomial data.
  48643. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48644. *
  48645. * @param cubeInfo The Cube map to extract the information from.
  48646. * @return The Spherical Polynomial data.
  48647. */
  48648. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48649. }
  48650. }
  48651. declare module BABYLON {
  48652. /**
  48653. * Header information of HDR texture files.
  48654. */
  48655. interface HDRInfo {
  48656. /**
  48657. * The height of the texture in pixels.
  48658. */
  48659. height: number;
  48660. /**
  48661. * The width of the texture in pixels.
  48662. */
  48663. width: number;
  48664. /**
  48665. * The index of the beginning of the data in the binary file.
  48666. */
  48667. dataPosition: number;
  48668. }
  48669. /**
  48670. * This groups tools to convert HDR texture to native colors array.
  48671. */
  48672. class HDRTools {
  48673. private static Ldexp;
  48674. private static Rgbe2float;
  48675. private static readStringLine;
  48676. /**
  48677. * Reads header information from an RGBE texture stored in a native array.
  48678. * More information on this format are available here:
  48679. * https://en.wikipedia.org/wiki/RGBE_image_format
  48680. *
  48681. * @param uint8array The binary file stored in native array.
  48682. * @return The header information.
  48683. */
  48684. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48685. /**
  48686. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48687. * This RGBE texture needs to store the information as a panorama.
  48688. *
  48689. * More information on this format are available here:
  48690. * https://en.wikipedia.org/wiki/RGBE_image_format
  48691. *
  48692. * @param buffer The binary file stored in an array buffer.
  48693. * @param size The expected size of the extracted cubemap.
  48694. * @return The Cube Map information.
  48695. */
  48696. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48697. /**
  48698. * Returns the pixels data extracted from an RGBE texture.
  48699. * This pixels will be stored left to right up to down in the R G B order in one array.
  48700. *
  48701. * More information on this format are available here:
  48702. * https://en.wikipedia.org/wiki/RGBE_image_format
  48703. *
  48704. * @param uint8array The binary file stored in an array buffer.
  48705. * @param hdrInfo The header information of the file.
  48706. * @return The pixels data in RGB right to left up to down order.
  48707. */
  48708. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48709. private static RGBE_ReadPixels_RLE;
  48710. }
  48711. }
  48712. declare module BABYLON {
  48713. /**
  48714. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48715. */
  48716. interface CubeMapInfo {
  48717. /**
  48718. * The pixel array for the front face.
  48719. * This is stored in format, left to right, up to down format.
  48720. */
  48721. front: Nullable<ArrayBufferView>;
  48722. /**
  48723. * The pixel array for the back face.
  48724. * This is stored in format, left to right, up to down format.
  48725. */
  48726. back: Nullable<ArrayBufferView>;
  48727. /**
  48728. * The pixel array for the left face.
  48729. * This is stored in format, left to right, up to down format.
  48730. */
  48731. left: Nullable<ArrayBufferView>;
  48732. /**
  48733. * The pixel array for the right face.
  48734. * This is stored in format, left to right, up to down format.
  48735. */
  48736. right: Nullable<ArrayBufferView>;
  48737. /**
  48738. * The pixel array for the up face.
  48739. * This is stored in format, left to right, up to down format.
  48740. */
  48741. up: Nullable<ArrayBufferView>;
  48742. /**
  48743. * The pixel array for the down face.
  48744. * This is stored in format, left to right, up to down format.
  48745. */
  48746. down: Nullable<ArrayBufferView>;
  48747. /**
  48748. * The size of the cubemap stored.
  48749. *
  48750. * Each faces will be size * size pixels.
  48751. */
  48752. size: number;
  48753. /**
  48754. * The format of the texture.
  48755. *
  48756. * RGBA, RGB.
  48757. */
  48758. format: number;
  48759. /**
  48760. * The type of the texture data.
  48761. *
  48762. * UNSIGNED_INT, FLOAT.
  48763. */
  48764. type: number;
  48765. /**
  48766. * Specifies whether the texture is in gamma space.
  48767. */
  48768. gammaSpace: boolean;
  48769. }
  48770. /**
  48771. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  48772. */
  48773. class PanoramaToCubeMapTools {
  48774. private static FACE_FRONT;
  48775. private static FACE_BACK;
  48776. private static FACE_RIGHT;
  48777. private static FACE_LEFT;
  48778. private static FACE_DOWN;
  48779. private static FACE_UP;
  48780. /**
  48781. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48782. *
  48783. * @param float32Array The source data.
  48784. * @param inputWidth The width of the input panorama.
  48785. * @param inputHeight The height of the input panorama.
  48786. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48787. * @return The cubemap data
  48788. */
  48789. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48790. private static CreateCubemapTexture;
  48791. private static CalcProjectionSpherical;
  48792. }
  48793. }
  48794. declare module BABYLON {
  48795. }
  48796. declare module BABYLON {
  48797. }
  48798. declare module BABYLON {
  48799. }
  48800. declare module BABYLON {
  48801. }
  48802. declare module BABYLON {
  48803. /**
  48804. * 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.
  48805. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48806. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48807. */
  48808. class CustomProceduralTexture extends ProceduralTexture {
  48809. private _animate;
  48810. private _time;
  48811. private _config;
  48812. private _texturePath;
  48813. /**
  48814. * Instantiates a new Custom Procedural Texture.
  48815. * 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.
  48816. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48818. * @param name Define the name of the texture
  48819. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48820. * @param size Define the size of the texture to create
  48821. * @param scene Define the scene the texture belongs to
  48822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48823. * @param generateMipMaps Define if the texture should creates mip maps or not
  48824. */
  48825. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48826. private _loadJson;
  48827. /**
  48828. * Is the texture ready to be used ? (rendered at least once)
  48829. * @returns true if ready, otherwise, false.
  48830. */
  48831. isReady(): boolean;
  48832. /**
  48833. * Render the texture to its associated render target.
  48834. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48835. */
  48836. render(useCameraPostProcess?: boolean): void;
  48837. /**
  48838. * Update the list of dependant textures samplers in the shader.
  48839. */
  48840. updateTextures(): void;
  48841. /**
  48842. * Update the uniform values of the procedural texture in the shader.
  48843. */
  48844. updateShaderUniforms(): void;
  48845. /**
  48846. * Define if the texture animates or not.
  48847. */
  48848. animate: boolean;
  48849. }
  48850. }
  48851. declare module BABYLON {
  48852. /**
  48853. * Class used to generate noise procedural textures
  48854. */
  48855. class NoiseProceduralTexture extends ProceduralTexture {
  48856. private _time;
  48857. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48858. brightness: number;
  48859. /** Defines the number of octaves to process */
  48860. octaves: number;
  48861. /** Defines the level of persistence (0.8 by default) */
  48862. persistence: number;
  48863. /** Gets or sets animation speed factor (default is 1) */
  48864. animationSpeedFactor: number;
  48865. /**
  48866. * Creates a new NoiseProceduralTexture
  48867. * @param name defines the name fo the texture
  48868. * @param size defines the size of the texture (default is 256)
  48869. * @param scene defines the hosting scene
  48870. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48871. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48872. */
  48873. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48874. private _updateShaderUniforms;
  48875. protected _getDefines(): string;
  48876. /** Generate the current state of the procedural texture */
  48877. render(useCameraPostProcess?: boolean): void;
  48878. /**
  48879. * Serializes this noise procedural texture
  48880. * @returns a serialized noise procedural texture object
  48881. */
  48882. serialize(): any;
  48883. /**
  48884. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48885. * @param parsedTexture defines parsed texture data
  48886. * @param scene defines the current scene
  48887. * @param rootUrl defines the root URL containing noise procedural texture information
  48888. * @returns a parsed NoiseProceduralTexture
  48889. */
  48890. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  48891. }
  48892. }
  48893. declare module BABYLON {
  48894. /**
  48895. * 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.
  48896. * This is the base class of any Procedural texture and contains most of the shareable code.
  48897. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48898. */
  48899. class ProceduralTexture extends Texture {
  48900. isCube: boolean;
  48901. /**
  48902. * Define if the texture is enabled or not (disabled texture will not render)
  48903. */
  48904. isEnabled: boolean;
  48905. /**
  48906. * Define if the texture must be cleared before rendering (default is true)
  48907. */
  48908. autoClear: boolean;
  48909. /**
  48910. * Callback called when the texture is generated
  48911. */
  48912. onGenerated: () => void;
  48913. /**
  48914. * Event raised when the texture is generated
  48915. */
  48916. onGeneratedObservable: Observable<ProceduralTexture>;
  48917. /** @hidden */
  48918. _generateMipMaps: boolean;
  48919. /** @hidden **/
  48920. _effect: Effect;
  48921. /** @hidden */
  48922. _textures: {
  48923. [key: string]: Texture;
  48924. };
  48925. private _size;
  48926. private _currentRefreshId;
  48927. private _refreshRate;
  48928. private _vertexBuffers;
  48929. private _indexBuffer;
  48930. private _uniforms;
  48931. private _samplers;
  48932. private _fragment;
  48933. private _floats;
  48934. private _ints;
  48935. private _floatsArrays;
  48936. private _colors3;
  48937. private _colors4;
  48938. private _vectors2;
  48939. private _vectors3;
  48940. private _matrices;
  48941. private _fallbackTexture;
  48942. private _fallbackTextureUsed;
  48943. private _engine;
  48944. private _cachedDefines;
  48945. private _contentUpdateId;
  48946. private _contentData;
  48947. /**
  48948. * Instantiates a new procedural texture.
  48949. * 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.
  48950. * This is the base class of any Procedural texture and contains most of the shareable code.
  48951. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  48952. * @param name Define the name of the texture
  48953. * @param size Define the size of the texture to create
  48954. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  48955. * @param scene Define the scene the texture belongs to
  48956. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48957. * @param generateMipMaps Define if the texture should creates mip maps or not
  48958. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  48959. */
  48960. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  48961. /**
  48962. * The effect that is created when initializing the post process.
  48963. * @returns The created effect corrisponding the the postprocess.
  48964. */
  48965. getEffect(): Effect;
  48966. /**
  48967. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  48968. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  48969. */
  48970. getContent(): Nullable<ArrayBufferView>;
  48971. private _createIndexBuffer;
  48972. /** @hidden */
  48973. _rebuild(): void;
  48974. /**
  48975. * Resets the texture in order to recreate its associated resources.
  48976. * This can be called in case of context loss
  48977. */
  48978. reset(): void;
  48979. protected _getDefines(): string;
  48980. /**
  48981. * Is the texture ready to be used ? (rendered at least once)
  48982. * @returns true if ready, otherwise, false.
  48983. */
  48984. isReady(): boolean;
  48985. /**
  48986. * Resets the refresh counter of the texture and start bak from scratch.
  48987. * Could be usefull to regenerate the texture if it is setup to render only once.
  48988. */
  48989. resetRefreshCounter(): void;
  48990. /**
  48991. * Set the fragment shader to use in order to render the texture.
  48992. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  48993. */
  48994. setFragment(fragment: any): void;
  48995. /**
  48996. * Define the refresh rate of the texture or the rendering frequency.
  48997. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48998. */
  48999. refreshRate: number;
  49000. /** @hidden */
  49001. _shouldRender(): boolean;
  49002. /**
  49003. * Get the size the texture is rendering at.
  49004. * @returns the size (texture is always squared)
  49005. */
  49006. getRenderSize(): number;
  49007. /**
  49008. * Resize the texture to new value.
  49009. * @param size Define the new size the texture should have
  49010. * @param generateMipMaps Define whether the new texture should create mip maps
  49011. */
  49012. resize(size: number, generateMipMaps: boolean): void;
  49013. private _checkUniform;
  49014. /**
  49015. * Set a texture in the shader program used to render.
  49016. * @param name Define the name of the uniform samplers as defined in the shader
  49017. * @param texture Define the texture to bind to this sampler
  49018. * @return the texture itself allowing "fluent" like uniform updates
  49019. */
  49020. setTexture(name: string, texture: Texture): ProceduralTexture;
  49021. /**
  49022. * Set a float in the shader.
  49023. * @param name Define the name of the uniform as defined in the shader
  49024. * @param value Define the value to give to the uniform
  49025. * @return the texture itself allowing "fluent" like uniform updates
  49026. */
  49027. setFloat(name: string, value: number): ProceduralTexture;
  49028. /**
  49029. * Set a int in the shader.
  49030. * @param name Define the name of the uniform as defined in the shader
  49031. * @param value Define the value to give to the uniform
  49032. * @return the texture itself allowing "fluent" like uniform updates
  49033. */
  49034. setInt(name: string, value: number): ProceduralTexture;
  49035. /**
  49036. * Set an array of floats in the shader.
  49037. * @param name Define the name of the uniform as defined in the shader
  49038. * @param value Define the value to give to the uniform
  49039. * @return the texture itself allowing "fluent" like uniform updates
  49040. */
  49041. setFloats(name: string, value: number[]): ProceduralTexture;
  49042. /**
  49043. * Set a vec3 in the shader from a Color3.
  49044. * @param name Define the name of the uniform as defined in the shader
  49045. * @param value Define the value to give to the uniform
  49046. * @return the texture itself allowing "fluent" like uniform updates
  49047. */
  49048. setColor3(name: string, value: Color3): ProceduralTexture;
  49049. /**
  49050. * Set a vec4 in the shader from a Color4.
  49051. * @param name Define the name of the uniform as defined in the shader
  49052. * @param value Define the value to give to the uniform
  49053. * @return the texture itself allowing "fluent" like uniform updates
  49054. */
  49055. setColor4(name: string, value: Color4): ProceduralTexture;
  49056. /**
  49057. * Set a vec2 in the shader from a Vector2.
  49058. * @param name Define the name of the uniform as defined in the shader
  49059. * @param value Define the value to give to the uniform
  49060. * @return the texture itself allowing "fluent" like uniform updates
  49061. */
  49062. setVector2(name: string, value: Vector2): ProceduralTexture;
  49063. /**
  49064. * Set a vec3 in the shader from a Vector3.
  49065. * @param name Define the name of the uniform as defined in the shader
  49066. * @param value Define the value to give to the uniform
  49067. * @return the texture itself allowing "fluent" like uniform updates
  49068. */
  49069. setVector3(name: string, value: Vector3): ProceduralTexture;
  49070. /**
  49071. * Set a mat4 in the shader from a MAtrix.
  49072. * @param name Define the name of the uniform as defined in the shader
  49073. * @param value Define the value to give to the uniform
  49074. * @return the texture itself allowing "fluent" like uniform updates
  49075. */
  49076. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49077. /**
  49078. * Render the texture to its associated render target.
  49079. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49080. */
  49081. render(useCameraPostProcess?: boolean): void;
  49082. /**
  49083. * Clone the texture.
  49084. * @returns the cloned texture
  49085. */
  49086. clone(): ProceduralTexture;
  49087. /**
  49088. * Dispose the texture and release its asoociated resources.
  49089. */
  49090. dispose(): void;
  49091. }
  49092. }
  49093. declare module BABYLON {
  49094. interface AbstractScene {
  49095. /**
  49096. * The list of procedural textures added to the scene
  49097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49098. */
  49099. proceduralTextures: Array<ProceduralTexture>;
  49100. }
  49101. /**
  49102. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49103. * in a given scene.
  49104. */
  49105. class ProceduralTextureSceneComponent implements ISceneComponent {
  49106. /**
  49107. * The component name helpfull to identify the component in the list of scene components.
  49108. */
  49109. readonly name: string;
  49110. /**
  49111. * The scene the component belongs to.
  49112. */
  49113. scene: Scene;
  49114. /**
  49115. * Creates a new instance of the component for the given scene
  49116. * @param scene Defines the scene to register the component in
  49117. */
  49118. constructor(scene: Scene);
  49119. /**
  49120. * Registers the component in a given scene
  49121. */
  49122. register(): void;
  49123. /**
  49124. * Rebuilds the elements related to this component in case of
  49125. * context lost for instance.
  49126. */
  49127. rebuild(): void;
  49128. /**
  49129. * Disposes the component and the associated ressources.
  49130. */
  49131. dispose(): void;
  49132. private _beforeClear;
  49133. }
  49134. }
  49135. declare module BABYLON {
  49136. /**
  49137. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49138. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49139. */
  49140. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49141. private _scene;
  49142. private _camerasToBeAttached;
  49143. /**
  49144. * ID of the sharpen post process,
  49145. */
  49146. private readonly SharpenPostProcessId;
  49147. /**
  49148. * @ignore
  49149. * ID of the image processing post process;
  49150. */
  49151. readonly ImageProcessingPostProcessId: string;
  49152. /**
  49153. * @ignore
  49154. * ID of the Fast Approximate Anti-Aliasing post process;
  49155. */
  49156. readonly FxaaPostProcessId: string;
  49157. /**
  49158. * ID of the chromatic aberration post process,
  49159. */
  49160. private readonly ChromaticAberrationPostProcessId;
  49161. /**
  49162. * ID of the grain post process
  49163. */
  49164. private readonly GrainPostProcessId;
  49165. /**
  49166. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49167. */
  49168. sharpen: SharpenPostProcess;
  49169. private _sharpenEffect;
  49170. private bloom;
  49171. /**
  49172. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49173. */
  49174. depthOfField: DepthOfFieldEffect;
  49175. /**
  49176. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49177. */
  49178. fxaa: FxaaPostProcess;
  49179. /**
  49180. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49181. */
  49182. imageProcessing: ImageProcessingPostProcess;
  49183. /**
  49184. * Chromatic aberration post process which will shift rgb colors in the image
  49185. */
  49186. chromaticAberration: ChromaticAberrationPostProcess;
  49187. private _chromaticAberrationEffect;
  49188. /**
  49189. * Grain post process which add noise to the image
  49190. */
  49191. grain: GrainPostProcess;
  49192. private _grainEffect;
  49193. /**
  49194. * Glow post process which adds a glow to emmisive areas of the image
  49195. */
  49196. private _glowLayer;
  49197. /**
  49198. * Animations which can be used to tweak settings over a period of time
  49199. */
  49200. animations: Animation[];
  49201. private _imageProcessingConfigurationObserver;
  49202. private _sharpenEnabled;
  49203. private _bloomEnabled;
  49204. private _depthOfFieldEnabled;
  49205. private _depthOfFieldBlurLevel;
  49206. private _fxaaEnabled;
  49207. private _imageProcessingEnabled;
  49208. private _defaultPipelineTextureType;
  49209. private _bloomScale;
  49210. private _chromaticAberrationEnabled;
  49211. private _grainEnabled;
  49212. private _buildAllowed;
  49213. /**
  49214. * Enable or disable the sharpen process from the pipeline
  49215. */
  49216. sharpenEnabled: boolean;
  49217. private _resizeObserver;
  49218. private _hardwareScaleLevel;
  49219. private _bloomKernel;
  49220. /**
  49221. * Specifies the size of the bloom blur kernel, relative to the final output size
  49222. */
  49223. bloomKernel: number;
  49224. /**
  49225. * Specifies the weight of the bloom in the final rendering
  49226. */
  49227. private _bloomWeight;
  49228. /**
  49229. * Specifies the luma threshold for the area that will be blurred by the bloom
  49230. */
  49231. private _bloomThreshold;
  49232. private _hdr;
  49233. /**
  49234. * The strength of the bloom.
  49235. */
  49236. bloomWeight: number;
  49237. /**
  49238. * The strength of the bloom.
  49239. */
  49240. bloomThreshold: number;
  49241. /**
  49242. * The scale of the bloom, lower value will provide better performance.
  49243. */
  49244. bloomScale: number;
  49245. /**
  49246. * Enable or disable the bloom from the pipeline
  49247. */
  49248. bloomEnabled: boolean;
  49249. private _rebuildBloom;
  49250. /**
  49251. * If the depth of field is enabled.
  49252. */
  49253. depthOfFieldEnabled: boolean;
  49254. /**
  49255. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49256. */
  49257. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49258. /**
  49259. * If the anti aliasing is enabled.
  49260. */
  49261. fxaaEnabled: boolean;
  49262. private _samples;
  49263. /**
  49264. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49265. */
  49266. samples: number;
  49267. /**
  49268. * If image processing is enabled.
  49269. */
  49270. imageProcessingEnabled: boolean;
  49271. /**
  49272. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49273. */
  49274. glowLayerEnabled: boolean;
  49275. /**
  49276. * Enable or disable the chromaticAberration process from the pipeline
  49277. */
  49278. chromaticAberrationEnabled: boolean;
  49279. /**
  49280. * Enable or disable the grain process from the pipeline
  49281. */
  49282. grainEnabled: boolean;
  49283. /**
  49284. * @constructor
  49285. * @param name - The rendering pipeline name (default: "")
  49286. * @param hdr - If high dynamic range textures should be used (default: true)
  49287. * @param scene - The scene linked to this pipeline (default: the last created scene)
  49288. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  49289. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  49290. */
  49291. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  49292. /**
  49293. * Force the compilation of the entire pipeline.
  49294. */
  49295. prepare(): void;
  49296. private _hasCleared;
  49297. private _prevPostProcess;
  49298. private _prevPrevPostProcess;
  49299. private _setAutoClearAndTextureSharing;
  49300. private _depthOfFieldSceneObserver;
  49301. private _buildPipeline;
  49302. private _disposePostProcesses;
  49303. /**
  49304. * Adds a camera to the pipeline
  49305. * @param camera the camera to be added
  49306. */
  49307. addCamera(camera: Camera): void;
  49308. /**
  49309. * Removes a camera from the pipeline
  49310. * @param camera the camera to remove
  49311. */
  49312. removeCamera(camera: Camera): void;
  49313. /**
  49314. * Dispose of the pipeline and stop all post processes
  49315. */
  49316. dispose(): void;
  49317. /**
  49318. * Serialize the rendering pipeline (Used when exporting)
  49319. * @returns the serialized object
  49320. */
  49321. serialize(): any;
  49322. /**
  49323. * Parse the serialized pipeline
  49324. * @param source Source pipeline.
  49325. * @param scene The scene to load the pipeline to.
  49326. * @param rootUrl The URL of the serialized pipeline.
  49327. * @returns An instantiated pipeline from the serialized object.
  49328. */
  49329. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  49330. }
  49331. }
  49332. declare module BABYLON {
  49333. /**
  49334. * BABYLON.JS Chromatic Aberration GLSL Shader
  49335. * Author: Olivier Guyot
  49336. * Separates very slightly R, G and B colors on the edges of the screen
  49337. * Inspired by Francois Tarlier & Martins Upitis
  49338. */
  49339. class LensRenderingPipeline extends PostProcessRenderPipeline {
  49340. /**
  49341. * @ignore
  49342. * The chromatic aberration PostProcess id in the pipeline
  49343. */
  49344. LensChromaticAberrationEffect: string;
  49345. /**
  49346. * @ignore
  49347. * The highlights enhancing PostProcess id in the pipeline
  49348. */
  49349. HighlightsEnhancingEffect: string;
  49350. /**
  49351. * @ignore
  49352. * The depth-of-field PostProcess id in the pipeline
  49353. */
  49354. LensDepthOfFieldEffect: string;
  49355. private _scene;
  49356. private _depthTexture;
  49357. private _grainTexture;
  49358. private _chromaticAberrationPostProcess;
  49359. private _highlightsPostProcess;
  49360. private _depthOfFieldPostProcess;
  49361. private _edgeBlur;
  49362. private _grainAmount;
  49363. private _chromaticAberration;
  49364. private _distortion;
  49365. private _highlightsGain;
  49366. private _highlightsThreshold;
  49367. private _dofDistance;
  49368. private _dofAperture;
  49369. private _dofDarken;
  49370. private _dofPentagon;
  49371. private _blurNoise;
  49372. /**
  49373. * @constructor
  49374. *
  49375. * Effect parameters are as follow:
  49376. * {
  49377. * chromatic_aberration: number; // from 0 to x (1 for realism)
  49378. * edge_blur: number; // from 0 to x (1 for realism)
  49379. * distortion: number; // from 0 to x (1 for realism)
  49380. * grain_amount: number; // from 0 to 1
  49381. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  49382. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  49383. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  49384. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  49385. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  49386. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  49387. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  49388. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  49389. * }
  49390. * Note: if an effect parameter is unset, effect is disabled
  49391. *
  49392. * @param name The rendering pipeline name
  49393. * @param parameters - An object containing all parameters (see above)
  49394. * @param scene The scene linked to this pipeline
  49395. * @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)
  49396. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49397. */
  49398. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  49399. /**
  49400. * Sets the amount of blur at the edges
  49401. * @param amount blur amount
  49402. */
  49403. setEdgeBlur(amount: number): void;
  49404. /**
  49405. * Sets edge blur to 0
  49406. */
  49407. disableEdgeBlur(): void;
  49408. /**
  49409. * Sets the amout of grain
  49410. * @param amount Amount of grain
  49411. */
  49412. setGrainAmount(amount: number): void;
  49413. /**
  49414. * Set grain amount to 0
  49415. */
  49416. disableGrain(): void;
  49417. /**
  49418. * Sets the chromatic aberration amount
  49419. * @param amount amount of chromatic aberration
  49420. */
  49421. setChromaticAberration(amount: number): void;
  49422. /**
  49423. * Sets chromatic aberration amount to 0
  49424. */
  49425. disableChromaticAberration(): void;
  49426. /**
  49427. * Sets the EdgeDistortion amount
  49428. * @param amount amount of EdgeDistortion
  49429. */
  49430. setEdgeDistortion(amount: number): void;
  49431. /**
  49432. * Sets edge distortion to 0
  49433. */
  49434. disableEdgeDistortion(): void;
  49435. /**
  49436. * Sets the FocusDistance amount
  49437. * @param amount amount of FocusDistance
  49438. */
  49439. setFocusDistance(amount: number): void;
  49440. /**
  49441. * Disables depth of field
  49442. */
  49443. disableDepthOfField(): void;
  49444. /**
  49445. * Sets the Aperture amount
  49446. * @param amount amount of Aperture
  49447. */
  49448. setAperture(amount: number): void;
  49449. /**
  49450. * Sets the DarkenOutOfFocus amount
  49451. * @param amount amount of DarkenOutOfFocus
  49452. */
  49453. setDarkenOutOfFocus(amount: number): void;
  49454. /**
  49455. * Creates a pentagon bokeh effect
  49456. */
  49457. enablePentagonBokeh(): void;
  49458. /**
  49459. * Disables the pentagon bokeh effect
  49460. */
  49461. disablePentagonBokeh(): void;
  49462. /**
  49463. * Enables noise blur
  49464. */
  49465. enableNoiseBlur(): void;
  49466. /**
  49467. * Disables noise blur
  49468. */
  49469. disableNoiseBlur(): void;
  49470. /**
  49471. * Sets the HighlightsGain amount
  49472. * @param amount amount of HighlightsGain
  49473. */
  49474. setHighlightsGain(amount: number): void;
  49475. /**
  49476. * Sets the HighlightsThreshold amount
  49477. * @param amount amount of HighlightsThreshold
  49478. */
  49479. setHighlightsThreshold(amount: number): void;
  49480. /**
  49481. * Disables highlights
  49482. */
  49483. disableHighlights(): void;
  49484. /**
  49485. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  49486. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  49487. */
  49488. dispose(disableDepthRender?: boolean): void;
  49489. private _createChromaticAberrationPostProcess;
  49490. private _createHighlightsPostProcess;
  49491. private _createDepthOfFieldPostProcess;
  49492. private _createGrainTexture;
  49493. }
  49494. }
  49495. declare module BABYLON {
  49496. /**
  49497. * Render pipeline to produce ssao effect
  49498. */
  49499. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  49500. /**
  49501. * @ignore
  49502. * The PassPostProcess id in the pipeline that contains the original scene color
  49503. */
  49504. SSAOOriginalSceneColorEffect: string;
  49505. /**
  49506. * @ignore
  49507. * The SSAO PostProcess id in the pipeline
  49508. */
  49509. SSAORenderEffect: string;
  49510. /**
  49511. * @ignore
  49512. * The horizontal blur PostProcess id in the pipeline
  49513. */
  49514. SSAOBlurHRenderEffect: string;
  49515. /**
  49516. * @ignore
  49517. * The vertical blur PostProcess id in the pipeline
  49518. */
  49519. SSAOBlurVRenderEffect: string;
  49520. /**
  49521. * @ignore
  49522. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49523. */
  49524. SSAOCombineRenderEffect: string;
  49525. /**
  49526. * The output strength of the SSAO post-process. Default value is 1.0.
  49527. */
  49528. totalStrength: number;
  49529. /**
  49530. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  49531. */
  49532. maxZ: number;
  49533. /**
  49534. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  49535. */
  49536. minZAspect: number;
  49537. private _samples;
  49538. /**
  49539. * Number of samples used for the SSAO calculations. Default value is 8
  49540. */
  49541. samples: number;
  49542. private _textureSamples;
  49543. /**
  49544. * Number of samples to use for antialiasing
  49545. */
  49546. textureSamples: number;
  49547. /**
  49548. * Ratio object used for SSAO ratio and blur ratio
  49549. */
  49550. private _ratio;
  49551. /**
  49552. * Dynamically generated sphere sampler.
  49553. */
  49554. private _sampleSphere;
  49555. /**
  49556. * Blur filter offsets
  49557. */
  49558. private _samplerOffsets;
  49559. private _expensiveBlur;
  49560. /**
  49561. * If bilateral blur should be used
  49562. */
  49563. expensiveBlur: boolean;
  49564. /**
  49565. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  49566. */
  49567. radius: number;
  49568. /**
  49569. * The base color of the SSAO post-process
  49570. * The final result is "base + ssao" between [0, 1]
  49571. */
  49572. base: number;
  49573. /**
  49574. * Support test.
  49575. */
  49576. static readonly IsSupported: boolean;
  49577. private _scene;
  49578. private _depthTexture;
  49579. private _normalTexture;
  49580. private _randomTexture;
  49581. private _originalColorPostProcess;
  49582. private _ssaoPostProcess;
  49583. private _blurHPostProcess;
  49584. private _blurVPostProcess;
  49585. private _ssaoCombinePostProcess;
  49586. private _firstUpdate;
  49587. /**
  49588. * @constructor
  49589. * @param name The rendering pipeline name
  49590. * @param scene The scene linked to this pipeline
  49591. * @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 }
  49592. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49593. */
  49594. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49595. /**
  49596. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49597. */
  49598. dispose(disableGeometryBufferRenderer?: boolean): void;
  49599. private _createBlurPostProcess;
  49600. /** @hidden */
  49601. _rebuild(): void;
  49602. private _bits;
  49603. private _radicalInverse_VdC;
  49604. private _hammersley;
  49605. private _hemisphereSample_uniform;
  49606. private _generateHemisphere;
  49607. private _createSSAOPostProcess;
  49608. private _createSSAOCombinePostProcess;
  49609. private _createRandomTexture;
  49610. /**
  49611. * Serialize the rendering pipeline (Used when exporting)
  49612. * @returns the serialized object
  49613. */
  49614. serialize(): any;
  49615. /**
  49616. * Parse the serialized pipeline
  49617. * @param source Source pipeline.
  49618. * @param scene The scene to load the pipeline to.
  49619. * @param rootUrl The URL of the serialized pipeline.
  49620. * @returns An instantiated pipeline from the serialized object.
  49621. */
  49622. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  49623. }
  49624. }
  49625. declare module BABYLON {
  49626. /**
  49627. * Render pipeline to produce ssao effect
  49628. */
  49629. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  49630. /**
  49631. * @ignore
  49632. * The PassPostProcess id in the pipeline that contains the original scene color
  49633. */
  49634. SSAOOriginalSceneColorEffect: string;
  49635. /**
  49636. * @ignore
  49637. * The SSAO PostProcess id in the pipeline
  49638. */
  49639. SSAORenderEffect: string;
  49640. /**
  49641. * @ignore
  49642. * The horizontal blur PostProcess id in the pipeline
  49643. */
  49644. SSAOBlurHRenderEffect: string;
  49645. /**
  49646. * @ignore
  49647. * The vertical blur PostProcess id in the pipeline
  49648. */
  49649. SSAOBlurVRenderEffect: string;
  49650. /**
  49651. * @ignore
  49652. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  49653. */
  49654. SSAOCombineRenderEffect: string;
  49655. /**
  49656. * The output strength of the SSAO post-process. Default value is 1.0.
  49657. */
  49658. totalStrength: number;
  49659. /**
  49660. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  49661. */
  49662. radius: number;
  49663. /**
  49664. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  49665. * Must not be equal to fallOff and superior to fallOff.
  49666. * Default value is 0.975
  49667. */
  49668. area: number;
  49669. /**
  49670. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  49671. * Must not be equal to area and inferior to area.
  49672. * Default value is 0.0
  49673. */
  49674. fallOff: number;
  49675. /**
  49676. * The base color of the SSAO post-process
  49677. * The final result is "base + ssao" between [0, 1]
  49678. */
  49679. base: number;
  49680. private _scene;
  49681. private _depthTexture;
  49682. private _randomTexture;
  49683. private _originalColorPostProcess;
  49684. private _ssaoPostProcess;
  49685. private _blurHPostProcess;
  49686. private _blurVPostProcess;
  49687. private _ssaoCombinePostProcess;
  49688. private _firstUpdate;
  49689. /**
  49690. * @constructor
  49691. * @param name - The rendering pipeline name
  49692. * @param scene - The scene linked to this pipeline
  49693. * @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 }
  49694. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  49695. */
  49696. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  49697. /**
  49698. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  49699. */
  49700. dispose(disableDepthRender?: boolean): void;
  49701. private _createBlurPostProcess;
  49702. /** @hidden */
  49703. _rebuild(): void;
  49704. private _createSSAOPostProcess;
  49705. private _createSSAOCombinePostProcess;
  49706. private _createRandomTexture;
  49707. }
  49708. }
  49709. declare module BABYLON {
  49710. /**
  49711. * Standard rendering pipeline
  49712. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49713. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  49714. */
  49715. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49716. /**
  49717. * Public members
  49718. */
  49719. /**
  49720. * Post-process which contains the original scene color before the pipeline applies all the effects
  49721. */
  49722. originalPostProcess: Nullable<PostProcess>;
  49723. /**
  49724. * Post-process used to down scale an image x4
  49725. */
  49726. downSampleX4PostProcess: Nullable<PostProcess>;
  49727. /**
  49728. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  49729. */
  49730. brightPassPostProcess: Nullable<PostProcess>;
  49731. /**
  49732. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  49733. */
  49734. blurHPostProcesses: PostProcess[];
  49735. /**
  49736. * Post-process array storing all the vertical blur post-processes used by the pipeline
  49737. */
  49738. blurVPostProcesses: PostProcess[];
  49739. /**
  49740. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  49741. */
  49742. textureAdderPostProcess: Nullable<PostProcess>;
  49743. /**
  49744. * Post-process used to create volumetric lighting effect
  49745. */
  49746. volumetricLightPostProcess: Nullable<PostProcess>;
  49747. /**
  49748. * Post-process used to smooth the previous volumetric light post-process on the X axis
  49749. */
  49750. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  49751. /**
  49752. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  49753. */
  49754. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  49755. /**
  49756. * Post-process used to merge the volumetric light effect and the real scene color
  49757. */
  49758. volumetricLightMergePostProces: Nullable<PostProcess>;
  49759. /**
  49760. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  49761. */
  49762. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  49763. /**
  49764. * Base post-process used to calculate the average luminance of the final image for HDR
  49765. */
  49766. luminancePostProcess: Nullable<PostProcess>;
  49767. /**
  49768. * Post-processes used to create down sample post-processes in order to get
  49769. * the average luminance of the final image for HDR
  49770. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  49771. */
  49772. luminanceDownSamplePostProcesses: PostProcess[];
  49773. /**
  49774. * Post-process used to create a HDR effect (light adaptation)
  49775. */
  49776. hdrPostProcess: Nullable<PostProcess>;
  49777. /**
  49778. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  49779. */
  49780. textureAdderFinalPostProcess: Nullable<PostProcess>;
  49781. /**
  49782. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  49783. */
  49784. lensFlareFinalPostProcess: Nullable<PostProcess>;
  49785. /**
  49786. * Post-process used to merge the final HDR post-process and the real scene color
  49787. */
  49788. hdrFinalPostProcess: Nullable<PostProcess>;
  49789. /**
  49790. * Post-process used to create a lens flare effect
  49791. */
  49792. lensFlarePostProcess: Nullable<PostProcess>;
  49793. /**
  49794. * Post-process that merges the result of the lens flare post-process and the real scene color
  49795. */
  49796. lensFlareComposePostProcess: Nullable<PostProcess>;
  49797. /**
  49798. * Post-process used to create a motion blur effect
  49799. */
  49800. motionBlurPostProcess: Nullable<PostProcess>;
  49801. /**
  49802. * Post-process used to create a depth of field effect
  49803. */
  49804. depthOfFieldPostProcess: Nullable<PostProcess>;
  49805. /**
  49806. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49807. */
  49808. fxaaPostProcess: Nullable<FxaaPostProcess>;
  49809. /**
  49810. * Represents the brightness threshold in order to configure the illuminated surfaces
  49811. */
  49812. brightThreshold: number;
  49813. /**
  49814. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  49815. */
  49816. blurWidth: number;
  49817. /**
  49818. * Sets if the blur for highlighted surfaces must be only horizontal
  49819. */
  49820. horizontalBlur: boolean;
  49821. /**
  49822. * Sets the overall exposure used by the pipeline
  49823. */
  49824. exposure: number;
  49825. /**
  49826. * Texture used typically to simulate "dirty" on camera lens
  49827. */
  49828. lensTexture: Nullable<Texture>;
  49829. /**
  49830. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  49831. */
  49832. volumetricLightCoefficient: number;
  49833. /**
  49834. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  49835. */
  49836. volumetricLightPower: number;
  49837. /**
  49838. * Used the set the blur intensity to smooth the volumetric lights
  49839. */
  49840. volumetricLightBlurScale: number;
  49841. /**
  49842. * Light (spot or directional) used to generate the volumetric lights rays
  49843. * The source light must have a shadow generate so the pipeline can get its
  49844. * depth map
  49845. */
  49846. sourceLight: Nullable<SpotLight | DirectionalLight>;
  49847. /**
  49848. * For eye adaptation, represents the minimum luminance the eye can see
  49849. */
  49850. hdrMinimumLuminance: number;
  49851. /**
  49852. * For eye adaptation, represents the decrease luminance speed
  49853. */
  49854. hdrDecreaseRate: number;
  49855. /**
  49856. * For eye adaptation, represents the increase luminance speed
  49857. */
  49858. hdrIncreaseRate: number;
  49859. /**
  49860. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  49861. */
  49862. lensColorTexture: Nullable<Texture>;
  49863. /**
  49864. * The overall strengh for the lens flare effect
  49865. */
  49866. lensFlareStrength: number;
  49867. /**
  49868. * Dispersion coefficient for lens flare ghosts
  49869. */
  49870. lensFlareGhostDispersal: number;
  49871. /**
  49872. * Main lens flare halo width
  49873. */
  49874. lensFlareHaloWidth: number;
  49875. /**
  49876. * Based on the lens distortion effect, defines how much the lens flare result
  49877. * is distorted
  49878. */
  49879. lensFlareDistortionStrength: number;
  49880. /**
  49881. * Lens star texture must be used to simulate rays on the flares and is available
  49882. * in the documentation
  49883. */
  49884. lensStarTexture: Nullable<Texture>;
  49885. /**
  49886. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  49887. * flare effect by taking account of the dirt texture
  49888. */
  49889. lensFlareDirtTexture: Nullable<Texture>;
  49890. /**
  49891. * Represents the focal length for the depth of field effect
  49892. */
  49893. depthOfFieldDistance: number;
  49894. /**
  49895. * Represents the blur intensity for the blurred part of the depth of field effect
  49896. */
  49897. depthOfFieldBlurWidth: number;
  49898. /**
  49899. * For motion blur, defines how much the image is blurred by the movement
  49900. */
  49901. motionStrength: number;
  49902. /**
  49903. * List of animations for the pipeline (IAnimatable implementation)
  49904. */
  49905. animations: Animation[];
  49906. /**
  49907. * Private members
  49908. */
  49909. private _scene;
  49910. private _currentDepthOfFieldSource;
  49911. private _basePostProcess;
  49912. private _hdrCurrentLuminance;
  49913. private _floatTextureType;
  49914. private _ratio;
  49915. private _bloomEnabled;
  49916. private _depthOfFieldEnabled;
  49917. private _vlsEnabled;
  49918. private _lensFlareEnabled;
  49919. private _hdrEnabled;
  49920. private _motionBlurEnabled;
  49921. private _fxaaEnabled;
  49922. private _motionBlurSamples;
  49923. private _volumetricLightStepsCount;
  49924. private _samples;
  49925. /**
  49926. * @ignore
  49927. * Specifies if the bloom pipeline is enabled
  49928. */
  49929. BloomEnabled: boolean;
  49930. /**
  49931. * @ignore
  49932. * Specifies if the depth of field pipeline is enabed
  49933. */
  49934. DepthOfFieldEnabled: boolean;
  49935. /**
  49936. * @ignore
  49937. * Specifies if the lens flare pipeline is enabed
  49938. */
  49939. LensFlareEnabled: boolean;
  49940. /**
  49941. * @ignore
  49942. * Specifies if the HDR pipeline is enabled
  49943. */
  49944. HDREnabled: boolean;
  49945. /**
  49946. * @ignore
  49947. * Specifies if the volumetric lights scattering effect is enabled
  49948. */
  49949. VLSEnabled: boolean;
  49950. /**
  49951. * @ignore
  49952. * Specifies if the motion blur effect is enabled
  49953. */
  49954. MotionBlurEnabled: boolean;
  49955. /**
  49956. * Specifies if anti-aliasing is enabled
  49957. */
  49958. fxaaEnabled: boolean;
  49959. /**
  49960. * Specifies the number of steps used to calculate the volumetric lights
  49961. * Typically in interval [50, 200]
  49962. */
  49963. volumetricLightStepsCount: number;
  49964. /**
  49965. * Specifies the number of samples used for the motion blur effect
  49966. * Typically in interval [16, 64]
  49967. */
  49968. motionBlurSamples: number;
  49969. /**
  49970. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49971. */
  49972. samples: number;
  49973. /**
  49974. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  49975. * @constructor
  49976. * @param name The rendering pipeline name
  49977. * @param scene The scene linked to this pipeline
  49978. * @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)
  49979. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  49980. * @param cameras The array of cameras that the rendering pipeline will be attached to
  49981. */
  49982. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  49983. private _buildPipeline;
  49984. private _createDownSampleX4PostProcess;
  49985. private _createBrightPassPostProcess;
  49986. private _createBlurPostProcesses;
  49987. private _createTextureAdderPostProcess;
  49988. private _createVolumetricLightPostProcess;
  49989. private _createLuminancePostProcesses;
  49990. private _createHdrPostProcess;
  49991. private _createLensFlarePostProcess;
  49992. private _createDepthOfFieldPostProcess;
  49993. private _createMotionBlurPostProcess;
  49994. private _getDepthTexture;
  49995. private _disposePostProcesses;
  49996. /**
  49997. * Dispose of the pipeline and stop all post processes
  49998. */
  49999. dispose(): void;
  50000. /**
  50001. * Serialize the rendering pipeline (Used when exporting)
  50002. * @returns the serialized object
  50003. */
  50004. serialize(): any;
  50005. /**
  50006. * Parse the serialized pipeline
  50007. * @param source Source pipeline.
  50008. * @param scene The scene to load the pipeline to.
  50009. * @param rootUrl The URL of the serialized pipeline.
  50010. * @returns An instantiated pipeline from the serialized object.
  50011. */
  50012. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50013. /**
  50014. * Luminance steps
  50015. */
  50016. static LuminanceSteps: number;
  50017. }
  50018. }